aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkinori MUSHA <knu@FreeBSD.org>2002-02-03 10:01:49 +0000
committerAkinori MUSHA <knu@FreeBSD.org>2002-02-03 10:01:49 +0000
commit5c08c7d35d540c885277cac0fba5ccbe79b1205d (patch)
tree046a2245ff2897913322cbf80f95768df17fc734
parent766f247a598169b6b0d8c88edeb90f612cbcfdea (diff)
Notes
-rw-r--r--bin/test/test.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/bin/test/test.c b/bin/test/test.c
index a6713a67b0d9b..bf33ac2f61d42 100644
--- a/bin/test/test.c
+++ b/bin/test/test.c
@@ -172,7 +172,6 @@ static int getn(const char *);
static long long getq(const char *);
static int intcmp(const char *, const char *);
static int isoperand(void);
-int main(int, char **);
static int newerf(const char *, const char *);
static int nexpr(enum token);
static int oexpr(enum token);
@@ -184,8 +183,23 @@ static enum token t_lex(char *);
int
main(int argc, char **argv)
{
- int res;
+ int i, res;
char *p;
+ char **nargv;
+
+ /*
+ * XXX copy the whole contents of argv to a newly allocated
+ * space with two extra cells filled with NULL's - this source
+ * code totally depends on their presence.
+ */
+ if ((nargv = (char **)malloc((argc + 2) * sizeof(char *))) == NULL)
+ error("Out of space");
+
+ for (i = 0; i < argc; i++)
+ nargv[i] = argv[i];
+
+ nargv[i] = nargv[i + 1] = NULL;
+ argv = nargv;
if ((p = rindex(argv[0], '/')) == NULL)
p = argv[0];
@@ -197,10 +211,6 @@ main(int argc, char **argv)
argv[argc] = NULL;
}
- /* no expression => false */
- if (--argc <= 0)
- return 1;
-
#ifndef SHELL
(void)setlocale(LC_CTYPE, "");
#endif