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