diff options
author | Robert de Bath <rdebath@poboxes.com> | 2004-01-24 16:27:32 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:48:49 +0200 |
commit | beba34dc223aa0dcf3e5f696966c5e8408b022c3 (patch) | |
tree | ea0523ac242bd3e877338e9a771b975d4cd3839a /libc/error | |
parent | b5dac1e3bdd01a2ce105df747a9073ff0d6a94e2 (diff) | |
download | dev86-beba34dc223aa0dcf3e5f696966c5e8408b022c3.tar.gz |
Import Dev86src-0.16.15.tar.gzv0.16.15
Diffstat (limited to 'libc/error')
-rw-r--r-- | libc/error/Makefile | 13 | ||||
-rw-r--r-- | libc/error/README | 9 | ||||
-rw-r--r-- | libc/error/error.c | 2 | ||||
-rw-r--r-- | libc/error/error2.c | 21 | ||||
-rw-r--r-- | libc/error/mktab.sh | 25 | ||||
-rw-r--r-- | libc/error/sys_errlist.c | 2 |
6 files changed, 64 insertions, 8 deletions
diff --git a/libc/error/Makefile b/libc/error/Makefile index f14e956..01a488f 100644 --- a/libc/error/Makefile +++ b/libc/error/Makefile @@ -4,14 +4,23 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) -ifeq ($(LIB_OS),ELKS) +ifeq ($(PLATFORM),i86-FAST) OBJ=error.o sys_errlist.o perror.o sys_siglist.o __assert.o else +ifeq ($(LIB_OS),ELKS) +OBJ=error2.o perror.o sys_siglist.o __assert.o +else OBJ=__assert.o endif +endif all: $(LIBC)($(OBJ)) @$(RM) $(OBJ) clean: - rm -f *.o libc.a + rm -f *.o libc.a error_list.h + +$(LIBC)(error2.o): error_list.h + +error_list.h: liberror.txt + sh mktab.sh diff --git a/libc/error/README b/libc/error/README index 02c123f..3165722 100644 --- a/libc/error/README +++ b/libc/error/README @@ -1,10 +1,11 @@ -Copyright (C) 1996 Robert de Bath <robert@debath.thenet.co.uk> +Copyright (C) 1996,2004 Robert de Bath <robert@debath.thenet.co.uk> This file is part of the Linux-8086 C library and is distributed under the GNU Library General Public License. -These routines assume the existance of a file /usr/lib/liberror.txt, -this file contains the actual error messages. One useful feature, -the language of the error messages can be easily changed. +The file "liberror.txt" is the master list of errors for ELKS only. +WARNING: + If you use the -Mf compile style this file must be in the filessystem + as "/lib/liberror.txt" unless you're using elksemu. -Robert diff --git a/libc/error/error.c b/libc/error/error.c index 3695719..4be2a56 100644 --- a/libc/error/error.c +++ b/libc/error/error.c @@ -24,7 +24,7 @@ int err; } if( err <= 0 ) goto unknown; /* NB the <= allows comments in the file */ - fd = open("/usr/lib/liberror.txt", 0); + fd = open("/lib/liberror.txt", 0); if( fd < 0 ) goto unknown; while( (cc=read(fd, inbuf, sizeof(inbuf))) > 0 ) diff --git a/libc/error/error2.c b/libc/error/error2.c new file mode 100644 index 0000000..4ad2892 --- /dev/null +++ b/libc/error/error2.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1996,2004 Robert de Bath <robert@debath.thenet.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ +#include <string.h> + +#include "error_list.h" + +char * +strerror(err) +int err; +{ + static char retbuf[20]; + + if( err > 0 && err <= sys_nerr ) + return sys_errlist[err]; + + strcpy(retbuf, "Error "); + strcpy(retbuf+6, itoa(err)); + return retbuf; +} diff --git a/libc/error/mktab.sh b/libc/error/mktab.sh new file mode 100644 index 0000000..b5afcc4 --- /dev/null +++ b/libc/error/mktab.sh @@ -0,0 +1,25 @@ +#!/bin/sh - + +awk '{ + e=$0; + sub("^[^ ]* ", "", e); + sub(" [^ ]*$", "", e); + n=0+$1; + if (!(n in errlist)) + errlist[n] = e; + if(n > maxerr) maxerr=n; +} +END{ + printf ("#define NR_ERRORS\t%d\n", maxerr+1); + printf ("int sys_nerr = NR_ERRORS;\n"); + printf ("char *sys_errlist[NR_ERRORS] = {\n"); + + for(i=0; i<=maxerr; i++) { + if (errlist[i] == "") + printf(" \"Error %d\"", i); + else + printf(" \"%s\"", errlist[i]); + if (i != maxerr) printf(",\n"); else printf("\n"); + } + printf ("};\n"); +}' < liberror.txt > error_list.h diff --git a/libc/error/sys_errlist.c b/libc/error/sys_errlist.c index 48aa6a3..8dfa3ec 100644 --- a/libc/error/sys_errlist.c +++ b/libc/error/sys_errlist.c @@ -42,7 +42,7 @@ static void init_vars() int i, cc, fd, err, len, bufoff=0; char * ptr; - fd = open("/usr/lib/liberror.txt", 0); + fd = open("/lib/liberror.txt", 0); if( fd < 0 ) return; for(i=0; i<NR_ERRORS; i++) sys_errlist[i] = "Unknown error"; |