Use strcmp to check for empty arguments.
This commit is contained in:
parent
8fd66025f0
commit
0a899ac0fd
|
@ -1,5 +1,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define streq(a,b) (strcmp((a),(b))==0)
|
#define streq(a,b) (strcmp((a),(b))==0)
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ char ** process_args(char **argv,
|
||||||
exit(1);}}
|
exit(1);}}
|
||||||
|
|
||||||
for (; *argv; argv++)
|
for (; *argv; argv++)
|
||||||
if (argv[0][0] == NULL)
|
if (streq (argv[0],""))
|
||||||
/* process_meta_arg inserts an empty argument for every space.
|
/* process_meta_arg inserts an empty argument for every space.
|
||||||
Skip it. */
|
Skip it. */
|
||||||
continue;
|
continue;
|
||||||
|
@ -60,7 +61,7 @@ char ** process_args(char **argv,
|
||||||
case 'h': /* heapsize */
|
case 'h': /* heapsize */
|
||||||
argv++;
|
argv++;
|
||||||
if( !*argv ) bad_args(3); /* die */
|
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);
|
*pheap_size = atoi(*argv);
|
||||||
if( *pheap_size <= 0 ) bad_args(4);
|
if( *pheap_size <= 0 ) bad_args(4);
|
||||||
break;
|
break;
|
||||||
|
@ -68,7 +69,7 @@ char ** process_args(char **argv,
|
||||||
case 's':
|
case 's':
|
||||||
argv++;
|
argv++;
|
||||||
if( !*argv ) bad_args(5); /* die */
|
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);
|
*pstack_size = atoi(*argv);
|
||||||
if (*pstack_size <= 0) bad_args(6);
|
if (*pstack_size <= 0) bad_args(6);
|
||||||
break;
|
break;
|
||||||
|
@ -76,7 +77,7 @@ char ** process_args(char **argv,
|
||||||
case 'o': /* object file */
|
case 'o': /* object file */
|
||||||
argv++;
|
argv++;
|
||||||
if( !*argv ) bad_args(7); /* die */
|
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;
|
*pobject_file = *argv;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ char ** process_args(char **argv,
|
||||||
case 'i':
|
case 'i':
|
||||||
argv++;
|
argv++;
|
||||||
if( !*argv ) bad_args(8); /* die */
|
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++;
|
*pimage_name = *argv++;
|
||||||
return argv;
|
return argv;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue