date and time created 81/02/18 21:57:32 by dlw
authorDavid Wasley <dlw@ucbvax.Berkeley.EDU>
Thu, 19 Feb 1981 13:57:32 +0000 (05:57 -0800)
committerDavid Wasley <dlw@ucbvax.Berkeley.EDU>
Thu, 19 Feb 1981 13:57:32 +0000 (05:57 -0800)
SCCS-vsn: usr.bin/f77/libU77/perror_.c 1.1

usr/src/usr.bin/f77/libU77/perror_.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/f77/libU77/perror_.c b/usr/src/usr.bin/f77/libU77/perror_.c
new file mode 100644 (file)
index 0000000..3276484
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+char id_perror[] = "@(#)perror_.c      1.1";
+ *
+ * write a standard error message to the standard error output
+ *
+ * calling sequence:
+ *     call perror(string)
+ * where:
+ *     string will be written preceeding the standard error message
+ */
+
+#include       <stdio.h>
+#include       "../libI77/fiodefs.h"
+#include       "../libI77/f_errno.h"
+
+extern char *sys_errlist[];
+extern int sys_nerr;
+extern char *f_errlist[];
+extern int f_nerr;
+extern unit units[];
+
+perror_(s, len)
+char *s; long len;
+{
+       char buf[40];
+       char *mesg = s + len;
+
+       while (len > 0 && *--mesg == ' ')
+               len--;
+       if (errno >=0 && errno < sys_nerr)
+               mesg = sys_errlist[errno];
+       else if (errno >= F_ER && errno < (F_ER + f_nerr))
+               mesg = f_errlist[errno - F_ER];
+       else
+       {
+               sprintf(buf, "%d: unknown error number", errno);
+               mesg = buf;
+       }
+       while (len-- > 0)
+               putc(*s++, units[STDERR].ufd);
+       fprintf(units[STDERR].ufd, ": %s\n", mesg);
+}