diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 12 | ||||
-rw-r--r-- | src/driver/main.c | 4 | ||||
-rw-r--r-- | src/driver/utils.c | 107 | ||||
-rw-r--r-- | src/driver/utils.h | 13 | ||||
-rw-r--r-- | src/sman/sman.c | 17 |
5 files changed, 116 insertions, 37 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index be6550a2..6682c239 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,17 @@ 2009-04-13 Gabriel Dos Reis <gdr@cs.tamu.edu> + Fix SF/2760560 + * driver/utils.h (openaxiom_driver): Add openaxiom_null_driver. + Document all of them. + * driver/utils.c (print_line): New. + (print_version): Print version information. + (print_usage): Print option documentation. + (openaxiom_preprocess_arguments): Handle --help and --version. + * driver/main.c (main): Do nothing for the null driver. + * sman/sman.c (process_arguments): Accept long form of options. + +2009-04-13 Gabriel Dos Reis <gdr@cs.tamu.edu> + Fix SF/2757748 * hyper/Makefile.in (${OUTLIB}/htsearch): Insist on execution bit. (${OUTLIB}/presea): Likewise. diff --git a/src/driver/main.c b/src/driver/main.c index 6f758cfd..4d83853a 100644 --- a/src/driver/main.c +++ b/src/driver/main.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2008, Gabriel Dos Reis. + Copyright (C) 2008-2009, Gabriel Dos Reis. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -76,6 +76,8 @@ main(int argc, char* argv[]) openaxiom_preprocess_arguments(&command, argc, argv); switch (driver) { + case openaxiom_null_driver: + return 0; /* Bye. */ case openaxiom_core_driver: case openaxiom_script_driver: case openaxiom_compiler_driver: diff --git a/src/driver/utils.c b/src/driver/utils.c index a5a0b7f5..92f89eb5 100644 --- a/src/driver/utils.c +++ b/src/driver/utils.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2008, Gabriel Dos Reis. + Copyright (C) 2008-2009, Gabriel Dos Reis. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -167,6 +167,53 @@ openaxiom_build_rts_options(openaxiom_command* command, #endif +static void print_line(const char* line) { + fputs(line, stdout); + fputc('\n', stdout); +} + +/* Print OpenAxiom version information. */ +static void print_version(void) { + print_line(PACKAGE_STRING); +} + +/* Print OpenAxiom invokation syntax (e.g. options) on standard + output stream. */ + +static void print_usage(void) { + print_line("Usage: open-axiom [options] [file]"); + print_line("General options:"); + print_line(" --help Print this information and exit."); + print_line(" --version Print OpenAxiom version and exit."); + print_line(" --script Execute the file argument as a Spad script."); + print_line(" If specified, this option should be last before file argument."); + print_line(" --compile Invoke the compiler on the file argument."); + print_line(" If specified, this option should be last before file argument."); + print_line(" --server Start the Superman as master process."); + print_line(" --no-server Do not start Superman as master process."); + print_line(""); + print_line("Superman options:"); + print_line(" --no-gui Do not start the Graphics or HyperDoc components."); + print_line(" --graph Start the Graphics component. This option is meaningful"); + print_line(" only if OpenAxiom was built with graphics support."); + print_line(" --no-graph Do not start the Graphics component."); + print_line(" --hyperdoc Start the HyperDoc component. This option is meaningful"); + print_line(" only if OpenAxiom was built with graphics support."); + print_line(" --no-hyperdoc Do not start the HyperDoc component."); + + print_line(""); + print_line("Compiler options:"); + print_line(" --optimize=<n> Set compiler optimization level to <n>, a natural number."); + print_line(""); + print_line("If invoked without options and without an input file " + "OpenAxiom will start as an interative program with Superman" + " as the master process, the majority of uses. If invoked " + "with a file as single argument, OpenAxiom assumes the file is a Spad " + "script and will attempt to execute it as such."); + print_line(""); + print_line("Submit bug report to " PACKAGE_BUGREPORT); +} + /* Determine driver to be used for executing `command'. */ openaxiom_driver openaxiom_preprocess_arguments(openaxiom_command* command, @@ -188,6 +235,16 @@ openaxiom_preprocess_arguments(openaxiom_command* command, driver = openaxiom_script_driver; else if(strcmp(argv[i], "--compile") == 0) driver = openaxiom_compiler_driver; + else if (strcmp(argv[i], "--help") == 0) { + print_usage(); + driver = openaxiom_null_driver; + break; + } + else if (strcmp(argv[i], "--version") == 0) { + print_version(); + driver = openaxiom_null_driver; + break; + } else { if (argv[i][0] == '-') /* Maybe option for the driver. */ @@ -205,30 +262,32 @@ openaxiom_preprocess_arguments(openaxiom_command* command, command->core_argc = other; command->core_argv = argv; - /* If we have a file but not instructed to compiler, assume - we are asked to interpret a script. */ - if (files > 0) - switch (driver) { - case openaxiom_unknown_driver: - case openaxiom_sman_driver: - command->core_argc += 1; - command->core_argv = - (char**) malloc((other + 2) * sizeof(char*)); - command->core_argv[0] = argv[0]; - command->core_argv[1] = "--script"; - for (i = 0; i < other; ++i) - command->core_argv[2 + i] = argv[1 + i]; - driver = openaxiom_script_driver; - break; - default: - /* Driver specified by user. */ - break; + if (driver != openaxiom_null_driver) { + /* If we have a file but not instructed to compiler, assume + we are asked to interpret a script. */ + if (files > 0) + switch (driver) { + case openaxiom_unknown_driver: + case openaxiom_sman_driver: + command->core_argc += 1; + command->core_argv = + (char**) malloc((other + 2) * sizeof(char*)); + command->core_argv[0] = argv[0]; + command->core_argv[1] = "--script"; + for (i = 0; i < other; ++i) + command->core_argv[2 + i] = argv[1 + i]; + driver = openaxiom_script_driver; + break; + default: + /* Driver specified by user. */ + break; + } + else if (driver == openaxiom_unknown_driver) + driver = OPENAXIOM_DEFAULT_DRIVER; + command->core_argv[command->core_argc] = NULL; + + openaxiom_build_rts_options(command, driver); } - else if (driver == openaxiom_unknown_driver) - driver = OPENAXIOM_DEFAULT_DRIVER; - command->core_argv[command->core_argc] = NULL; - - openaxiom_build_rts_options(command, driver); return driver; } diff --git a/src/driver/utils.h b/src/driver/utils.h index fd41434a..30f94912 100644 --- a/src/driver/utils.h +++ b/src/driver/utils.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2008, Gabriel Dos Reis. + Copyright (C) 2008-2009, Gabriel Dos Reis. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -44,11 +44,12 @@ /* A list of drivers for OpenAxiom. */ typedef enum openaxiom_driver { - openaxiom_unknown_driver, - openaxiom_sman_driver, - openaxiom_core_driver, - openaxiom_script_driver, - openaxiom_compiler_driver + openaxiom_unknown_driver, /* unknown driver */ + openaxiom_null_driver, /* do nothing */ + openaxiom_sman_driver, /* start Superman as master process */ + openaxiom_core_driver, /* start the core system as master process */ + openaxiom_script_driver, /* start the core system in script mode. */ + openaxiom_compiler_driver /* start the core system in compiler mode. */ } openaxiom_driver; /* A list of runtime support systems for OpenAxiom. */ diff --git a/src/sman/sman.c b/src/sman/sman.c index 3ef2e346..252778eb 100644 --- a/src/sman/sman.c +++ b/src/sman/sman.c @@ -1,7 +1,7 @@ /* Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd. All rights reserved. - Copyright (C) 2007-2008, Gabriel Dos Reis. + Copyright (C) 2007-2009, Gabriel Dos Reis. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -157,21 +157,25 @@ process_arguments(openaxiom_command* command, int argc,char ** argv) start_clef = 0; else if (strcmp(argv[arg], "-clef") == 0) start_clef = 1; - else if (strcmp(argv[arg], "-gr") == 0) { + else if (strcmp(argv[arg], "-gr") == 0 + || strcmp(argv[arg], "--graph") == 0 ) { if (!OPENAXIOM_HAVE_GRAPHICS) fprintf(stderr, "OpenAxiom was not build with Graphics support.\n"); else start_graphics = 1; } - else if (strcmp(argv[arg], "-nogr") == 0) + else if (strcmp(argv[arg], "-nogr") == 0 + || strcmp(argv[arg], "--no-graph") == 0) start_graphics = 0; - else if (strcmp(argv[arg], "-ht") == 0) { + else if (strcmp(argv[arg], "-ht") == 0 + || strcmp(argv[arg], "--hyperdoc") == 0) { if (!OPENAXIOM_HAVE_GRAPHICS) fprintf(stderr, "OpenAxiom was not build with HyperDoc support.\n"); else start_ht = 1; } - else if (strcmp(argv[arg], "-noht") == 0) + else if (strcmp(argv[arg], "-noht") == 0 + || strcmp(argv[arg], "--no-hyperdoc") == 0) start_ht = 0; else if (strcmp(argv[arg], "-iw") == 0) start_spadclient = 1; @@ -183,7 +187,8 @@ process_arguments(openaxiom_command* command, int argc,char ** argv) start_spadclient = 0; else if (strcmp(argv[arg], "-comp") == 0) ws_path = "$AXIOM/etc/images/comp"; - else if (strcmp(argv[arg], "-nox") == 0) { + else if (strcmp(argv[arg], "-nox") == 0 + || strcmp(argv[arg], "--no-gui") == 0) { use_X = 0; start_local_spadclient = 1; start_spadclient = 0; |