get retval(1) working again

This commit is contained in:
2023-08-19 09:25:33 -04:00
parent c8c3cbc247
commit d6909207df
4 changed files with 33 additions and 16 deletions
+2
View File
@@ -0,0 +1,2 @@
libio.o: libio.c libio.h
$(CC) -c -o libio.o libio.c
+21 -13
View File
@@ -3,19 +3,11 @@
/* Backups of standard library systems for the odd scenario where there is no
* standard library but there is the write(2) system call. */
static int _isdigit(int c);
static int _strlen(char *s);
/* Wrappers around write(2) */
static int _write(int fd, char *s, int n);
static int _write1(int fd, int c);
/* Normally in <ctype.h> */
static int
_isdigit(int c){
return c >= '0' && c <= '9';
}
#if defined USE_SYSTEM_STRING_H
# include <string.h>
# define _strlen strlen
#else
/* Normally in <string.h> */
static int
_strlen(char *s){
@@ -25,6 +17,22 @@ _strlen(char *s){
return i;
}
#endif
#if defined USE_SYSTEM_CTYPE_H
# include <ctype.h>
# define _isdigit isdigit
#else
/* Normally in <ctype.h> */
static int
_isdigit(int c){
return c >= '0' && c <= '9';
}
#endif
/* Wrappers around write(2) */
static int _write(int fd, char *s, int n);
static int _write1(int fd, int c);
/* Wrapper around write(2) - keeps re-running write(2) until the operation
* succeeds in full. Usually unnecessary but still good. */
@@ -52,7 +60,7 @@ _write1(int fd, int c){
int
fdprint(int fd, char *s){
return _write(fd, s, strlen(s));
return _write(fd, s, _strlen(s));
}
int