Browse Source

Added "psignal" function

David McCullough 24 years ago
parent
commit
62b59bd5ed
2 changed files with 24 additions and 4 deletions
  1. 9 2
      libc/string/Makefile
  2. 15 2
      libc/string/strsignal.c

+ 9 - 2
libc/string/Makefile

@@ -32,11 +32,14 @@ MOBJ=strlen.o strcat.o strcpy.o strchr.o strcmp.o strncat.o strncpy.o \
 MSRC1=index.c
 MOBJ1=index.o rindex.o
 
+MSRC2=strsignal.c
+MOBJ2=strsignal.o psignal.o
+
 CSRC=strpbrk.c strsep.c strstr.c strtok.c strcspn.c config.c strspn.c \
 	strcasecmp.c strncasecmp.c strerror.c bcopy.c bzero.c bcmp.c \
-	strsignal.c sys_errlist.c
+	sys_errlist.c
 COBJS=$(patsubst %.c,%.o, $(CSRC))
-OBJS=$(MOBJ) $(MOBJ1) $(COBJS)
+OBJS=$(MOBJ) $(MOBJ1) $(MOBJ2) $(COBJS)
 
 all: $(OBJS) $(LIBC)
 
@@ -53,6 +56,10 @@ $(MOBJ1): $(MSRC1)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
+$(MOBJ2): $(MSRC2)
+	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
+
 $(COBJS): %.o : %.c
 	$(CC) $(CFLAGS) -c $< -o $@
 	$(STRIPTOOL) -x -R .note -R .comment $*.o

+ 15 - 2
libc/string/strsignal.c

@@ -37,6 +37,9 @@
 
 extern char *__ltostr(char *buf, long uval, int base, int uppercase);
 
+/********************** Function strsignal ************************************/
+#ifdef L_strsignal
+
 #if WANT_SIGLIST
 
 const char *const sys_siglist[] = {
@@ -79,8 +82,6 @@ const char *const sys_siglist[] = {
 
 #define NUM_KNOWN_SIGNALS    32
 
-/********************** Function strsignal ************************************/
-
 static char retbuf[28];			/* 28 is sufficient for 32 bit ints */
 static const char unknown_signal[] = "Unknown Signal:";
 
@@ -104,6 +105,18 @@ char *strsignal(int sig)
 	return pos;
 }
 
+#endif
+/********************** Function psignal ************************************/
+#ifdef L_psignal
+
+#include <stdio.h>
+
+void psignal(int sig, const char *s)
+{
+	fprintf(stderr, "%s: %s\n", s, strsignal(sig));
+}
+
+#endif
 /********************** THE END ********************************************/
 
 #ifdef CHECK_BUF