From 87fa23e6417d7d1938b72e872d779ae7225a5aa4 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 12 Oct 1993 01:52:24 +0000 Subject: merge with 1.8.1b --- src/expr.c | 54 ++++++++---------------------------------------------- 1 file changed, 8 insertions(+), 46 deletions(-) (limited to 'src/expr.c') diff --git a/src/expr.c b/src/expr.c index a9f376942..97f7b39d8 100644 --- a/src/expr.c +++ b/src/expr.c @@ -32,7 +32,6 @@ #include #include #include -#include #include "system.h" #include "version.h" @@ -81,6 +80,7 @@ void error (); char *xstrdup (); char *strstr (); char *xmalloc (); +void parse_long_options (); static VALUE *docolon (); static VALUE *eval (); @@ -99,13 +99,6 @@ static void tostring (); static void trace (); #endif -static struct option const long_options[] = -{ - {"help", no_argument, 0, 'h'}, - {"version", no_argument, 0, 'v'}, - {0, 0, 0, 0} -}; - static void usage () { @@ -114,39 +107,6 @@ usage () exit (1); } -/* Process long options that precede all other command line arguments. */ - -static void -parse_long_options (argc, argv) - int argc; - char **argv; -{ - int c; - - while ((c = getopt_long (argc, argv, "+", long_options, (int *) 0)) != EOF) - { - switch (c) - { - case 'h': - usage (); - - case 'v': - printf ("%s\n", version_string); - exit (0); - - default: - usage (); - } - } - - /* Restore optind in case it has advanced past a leading `--'. We can use a - simple assignment here because all brances of the above switch statement - exit. Otherwise, we'd have to be careful to decrement only when optind - is larger than 1 and the last argument processed was `--'. */ - - optind = 1; -} - void main (argc, argv) int argc; @@ -156,7 +116,7 @@ main (argc, argv) program_name = argv[0]; - parse_long_options (argc, argv); + parse_long_options (argc, argv, usage); if (argc == 1) usage (); @@ -465,7 +425,8 @@ eval7 () #endif if (nomoreargs ()) error (2, 0, "syntax error"); - else if (nextarg ("(")) + + if (nextarg ("(")) { args++; v = eval (); @@ -474,10 +435,11 @@ eval7 () args++; return v; } - else if (nextarg (")")) + + if (nextarg (")")) error (2, 0, "syntax error"); - else - return str_value (*args++); + + return str_value (*args++); } /* Handle match, substr, index, and length keywords. */ -- cgit v1.2.3-54-g00ecf