work without libio
This commit is contained in:
parent
4161fad929
commit
054063f2f3
@ -1,8 +1,2 @@
|
|||||||
retval: retval.o ../libio/libio.o
|
retval: retval.c
|
||||||
$(CC) -o retval ../libio/libio.o retval.o
|
$(CC) -o retval retval.c
|
||||||
|
|
||||||
retval.o: retval.c ../libio/libio.h
|
|
||||||
$(CC) -c -I../libio -o retval.o retval.c
|
|
||||||
|
|
||||||
../libio/libio.o: ../libio/libio.c ../libio/libio.h
|
|
||||||
$(MAKE) -C ../libio
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <ctype.h> /* isdigit(3) */
|
#include <errno.h> /* errno */
|
||||||
#include <stdio.h> /* fprintf(3), stderr */
|
#include <stdio.h> /* fprintf(3), stderr */
|
||||||
|
#include <stdlib.h> /* strtol(3) */
|
||||||
#include <sysexits.h> /* EX_USAGE */
|
#include <sysexits.h> /* EX_USAGE */
|
||||||
#include <unistd.h> /* write(2) */
|
|
||||||
#include "libio.h" /* fdprint(3), parse_uint(3) */
|
|
||||||
|
|
||||||
static char *program_name = "retval";
|
static char *program_name = "retval";
|
||||||
|
|
||||||
@ -14,11 +13,10 @@ usage: fprintf(stderr, "Usage: %s [status]\n", argv[0] == NULL ? program_name :
|
|||||||
return EX_USAGE;
|
return EX_USAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(s = 0; argv[1][s] != '\0'; ++s)
|
errno = 0;
|
||||||
if(!isdigit(argv[1][s]))
|
s = strtol(argv[1], &argv[1], 10);
|
||||||
goto usage;
|
if(*argv[1] != '\0' || errno != 0)
|
||||||
|
goto usage;
|
||||||
s = parse_uint(argv[1]);
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user