stdio.h defines BUFSIZ
[unix-history] / usr / src / usr.bin / f77 / libU77 / perror_.c
index 3276484..47292b7 100644 (file)
@@ -1,6 +1,12 @@
 /*
 /*
-char id_perror[] = "@(#)perror_.c      1.1";
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
  *
  *
+ *     @(#)perror_.c   5.2     %G%
+ */
+
+/*
  * write a standard error message to the standard error output
  *
  * calling sequence:
  * write a standard error message to the standard error output
  *
  * calling sequence:
@@ -13,7 +19,6 @@ char id_perror[] = "@(#)perror_.c     1.1";
 #include       "../libI77/fiodefs.h"
 #include       "../libI77/f_errno.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 int sys_nerr;
 extern char *f_errlist[];
 extern int f_nerr;
@@ -22,13 +27,15 @@ extern unit units[];
 perror_(s, len)
 char *s; long len;
 {
 perror_(s, len)
 char *s; long len;
 {
-       char buf[40];
-       char *mesg = s + len;
+       unit    *lu;
+       char    buf[40];
+       char    *mesg = s + len;
+       char    *strerror();
 
        while (len > 0 && *--mesg == ' ')
                len--;
        if (errno >=0 && errno < sys_nerr)
 
        while (len > 0 && *--mesg == ' ')
                len--;
        if (errno >=0 && errno < sys_nerr)
-               mesg = sys_errlist[errno];
+               mesg = strerror(errno);
        else if (errno >= F_ER && errno < (F_ER + f_nerr))
                mesg = f_errlist[errno - F_ER];
        else
        else if (errno >= F_ER && errno < (F_ER + f_nerr))
                mesg = f_errlist[errno - F_ER];
        else
@@ -36,7 +43,10 @@ char *s; long len;
                sprintf(buf, "%d: unknown error number", errno);
                mesg = buf;
        }
                sprintf(buf, "%d: unknown error number", errno);
                mesg = buf;
        }
+       lu = &units[STDERR];
+       if (!lu->uwrt)
+               nowwriting(lu);
        while (len-- > 0)
        while (len-- > 0)
-               putc(*s++, units[STDERR].ufd);
-       fprintf(units[STDERR].ufd, ": %s\n", mesg);
+               putc(*s++, lu->ufd);
+       fprintf(lu->ufd, ": %s\n", mesg);
 }
 }