summaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c54
1 files changed, 8 insertions, 46 deletions
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 <ctype.h>
#include <sys/types.h>
#include <regex.h>
-#include <getopt.h>
#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. */