Use strcmp to check for empty arguments.

This commit is contained in:
mainzelm 2004-02-02 17:18:39 +00:00
parent 8fd66025f0
commit 0a899ac0fd
1 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define streq(a,b) (strcmp((a),(b))==0)
@ -45,7 +46,7 @@ char ** process_args(char **argv,
exit(1);}}
for (; *argv; argv++)
if (argv[0][0] == NULL)
if (streq (argv[0],""))
/* process_meta_arg inserts an empty argument for every space.
Skip it. */
continue;
@ -60,7 +61,7 @@ char ** process_args(char **argv,
case 'h': /* heapsize */
argv++;
if( !*argv ) bad_args(3); /* die */
while (argv[0][0] == NULL)argv++; /* Skip empty arguments */
while (streq (argv[0],"")) argv++; /* Skip empty arguments */
*pheap_size = atoi(*argv);
if( *pheap_size <= 0 ) bad_args(4);
break;
@ -68,7 +69,7 @@ char ** process_args(char **argv,
case 's':
argv++;
if( !*argv ) bad_args(5); /* die */
while (argv[0][0] == NULL) argv++; /* Skip empty arguments */
while (streq (argv[0],"")) argv++; /* Skip empty arguments */
*pstack_size = atoi(*argv);
if (*pstack_size <= 0) bad_args(6);
break;
@ -76,7 +77,7 @@ char ** process_args(char **argv,
case 'o': /* object file */
argv++;
if( !*argv ) bad_args(7); /* die */
while (argv[0][0] == NULL)argv++; /* Skip empty arguments */
while (streq (argv[0],"")) argv++; /* Skip empty arguments */
*pobject_file = *argv;
break;
@ -84,7 +85,7 @@ char ** process_args(char **argv,
case 'i':
argv++;
if( !*argv ) bad_args(8); /* die */
while (argv[0][0] == NULL)argv++; /* Skip empty arguments */
while (streq (argv[0],"")) argv++; /* Skip empty arguments */
*pimage_name = *argv++;
return argv;