X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcmdline.c;h=b9205a14ed5a6358c5bff387e11d7a8afa4c8d6c;hb=b9799cdd10b30ea96d9178b7a0d48504d052228c;hp=fd4e6c450dc7ab82410b57a0897238f683e5a32f;hpb=def7e6026513a3ee7c2b38416b30a2e890e34311;p=pspp-builds.git diff --git a/src/cmdline.c b/src/cmdline.c index fd4e6c45..b9205a14 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -14,35 +14,40 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include "cmdline.h" -#include +#include "error.h" #include #include #include #include #include #include "alloc.h" +#include "copyleft.h" #include "error.h" #include "filename.h" -#include "getline.h" +#include "getl.h" +#include "glob.h" #include "main.h" #include "output.h" +#include "progname.h" #include "settings.h" #include "str.h" #include "var.h" #include "version.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) +#define N_(msgid) msgid + void welcome (void); static void usage (void); char *subst_vars (char *); -static int testing_mode=0; - /* Parses the command line specified by ARGC and ARGV as received by main(). */ void @@ -50,6 +55,7 @@ parse_command_line (int argc, char **argv) { static struct option long_options[] = { + {"algorithm", required_argument, NULL, 'a'}, {"command", required_argument, NULL, 'c'}, {"config-directory", required_argument, NULL, 'B'}, {"device", required_argument, NULL, 'o'}, @@ -66,7 +72,8 @@ parse_command_line (int argc, char **argv) {"pipe", no_argument, NULL, 'p'}, {"recon", no_argument, NULL, 'n'}, {"safer", no_argument, NULL, 's'}, - {"testing-mode", no_argument, &testing_mode, 1}, + {"syntax", required_argument, NULL, 'x'}, + {"testing-mode", no_argument, NULL, 'T'}, {"verbose", no_argument, NULL, 'v'}, {"version", no_argument, NULL, 'V'}, {0, 0, 0, 0}, @@ -74,18 +81,42 @@ parse_command_line (int argc, char **argv) int c, i; - int cleared_device_defaults = 0; - - int no_statrc = 0; + bool cleared_device_defaults = false; + bool no_statrc = false; for (;;) { - c = getopt_long (argc, argv, "B:c:f:hiI:lno:prsvV", long_options, NULL); + c = getopt_long (argc, argv, "a:x:B:c:f:hiI:lno:prsvV", long_options, NULL); if (c == -1) break; switch (c) { + /* Compatibility options */ + case 'a': + if ( 0 == strcmp(optarg,"compatible") ) + set_algorithm(COMPATIBLE); + else if ( 0 == strcmp(optarg,"enhanced")) + set_algorithm(ENHANCED); + else + { + usage(); + assert(0); + } + break; + + case 'x': + if ( 0 == strcmp(optarg,"compatible") ) + set_syntax(COMPATIBLE); + else if ( 0 == strcmp(optarg,"enhanced")) + set_syntax(ENHANCED); + else + { + usage(); + assert(0); + } + break; + case 'c': { static int n_cmds; @@ -111,7 +142,7 @@ parse_command_line (int argc, char **argv) config_path = optarg; break; case 'f': - printf(_("%s is not yet implemented."), "-f"); + printf (_("%s is not yet implemented."), "-f"); putchar('\n'); break; case 'h': @@ -128,7 +159,7 @@ parse_command_line (int argc, char **argv) break; case 'l': outp_list_classes (); - err_hcf (1); + terminate (true); case 'n': printf (_("%s is not yet implemented."),"-n"); putchar('\n'); @@ -137,7 +168,7 @@ parse_command_line (int argc, char **argv) if (!cleared_device_defaults) { outp_configure_clear (); - cleared_device_defaults = 1; + cleared_device_defaults = true; } outp_configure_add (optarg); break; @@ -146,24 +177,22 @@ parse_command_line (int argc, char **argv) putchar('\n'); break; case 'r': - no_statrc = 1; + no_statrc = true; break; case 's': - make_safe(); + set_safer_mode (); break; case 'v': err_verbosity++; break; case 'V': puts (version); - puts (_("\nCopyright (C) 1997-9, 2000 Free Software Foundation, " - "Inc.\n" - "This is free software; see the source for copying " - "conditions. There is NO\n" - "WARRANTY; not even for MERCHANTABILITY or FITNESS " - "FOR A PARTICULAR PURPOSE.\n\n" - "Written by Ben Pfaff .")); - err_hcf (1); + puts (legal); + terminate (true); + case 'T': + force_long_view (); + set_testing_mode (true); + break; case '?': usage (); assert (0); @@ -174,14 +203,6 @@ parse_command_line (int argc, char **argv) } } - - if (testing_mode) - { - /* FIXME: Later this option should do some other things, too. */ - force_long_view(); - } - - for (i = optind; i < argc; i++) { int separate = 1; @@ -223,6 +244,9 @@ N_("PSPP, a program for statistical analysis of sample data.\n" "\nIf a long option shows an argument as mandatory, then it is mandatory\n" "for the equivalent short option also. Similarly for optional arguments.\n" "\nConfiguration:\n" +" -a, --algorithm={compatible|enhanced}\n" +" set to `compatible' if you want output\n" +" calculated from broken algorithms\n" " -B, --config-dir=DIR set configuration directory to DIR\n" " -o, --device=DEVICE select output driver DEVICE and disable defaults\n" " -d, --define=VAR[=VALUE] set environment variable VAR to VALUE, or empty\n" @@ -238,6 +262,9 @@ N_("PSPP, a program for statistical analysis of sample data.\n" " -n, --edit just check syntax; don't actually run the code\n" " -r, --no-statrc disable execution of .pspp/rc at startup\n" " -s, --safer don't allow some unsafe operations\n" +" -x, --syntax={compatible|enhanced}\n" +" set to `compatible' if you want only to accept\n" +" spss compatible syntax\n" "\nInformative output:\n" " -h, --help print this help, then exit\n" " -l, --list print a list of known driver classes, then exit\n" @@ -256,9 +283,9 @@ static const char post_syntax_message[] = N_("\nReport bugs to <%s>.\n"); static void usage (void) { - printf (gettext (pre_syntax_message), pgmname); + printf (gettext (pre_syntax_message), program_name); outp_list_classes (); - printf (gettext (post_syntax_message),PACKAGE_BUGREPORT); + printf (gettext (post_syntax_message), PACKAGE_BUGREPORT); - err_hcf (1); + terminate (true); }