]> diplodocus.org Git - nmh/blobdiff - sbr/error.c
Add EndsWithC(char *s, int c) and call it in some initial places.
[nmh] / sbr / error.c
index 1ac4cb115922bfbd40673bf156c761a58bbf9d8d..beb4ba6d2213e77937e9ac61c116a8ccdea47987 100644 (file)
@@ -17,7 +17,7 @@
  * print out error message
  */
 void
  * print out error message
  */
 void
-advise (const char *what, char *fmt, ...)
+advise (const char *what, const char *fmt, ...)
 {
     va_list ap;
 
 {
     va_list ap;
 
@@ -31,7 +31,7 @@ advise (const char *what, char *fmt, ...)
  * print out error message and exit
  */
 void
  * print out error message and exit
  */
 void
-adios (const char *what, char *fmt, ...)
+adios (const char *what, const char *fmt, ...)
 {
     va_list ap;
 
 {
     va_list ap;
 
@@ -60,7 +60,7 @@ admonish (char *what, char *fmt, ...)
  * main routine for printing error messages.
  */
 void
  * main routine for printing error messages.
  */
 void
-advertise (const char *what, char *tail, char *fmt, va_list ap)
+advertise (const char *what, char *tail, const char *fmt, va_list ap)
 {
     int        eindex = errno;
     char buffer[BUFSIZ], err[BUFSIZ];
 {
     int        eindex = errno;
     char buffer[BUFSIZ], err[BUFSIZ];
@@ -107,6 +107,10 @@ advertise (const char *what, char *tail, char *fmt, va_list ap)
     iov->iov_len = strlen (iov->iov_base = "\n");
     iov++;
     if (writev (fileno (stderr), iob, iov - iob) < 0) {
     iov->iov_len = strlen (iov->iov_base = "\n");
     iov++;
     if (writev (fileno (stderr), iob, iov - iob) < 0) {
-       advise ("stderr", "writev");
+        snprintf(buffer, sizeof buffer, "%s: write stderr failed: %d\n",
+            invo_name && *invo_name ? invo_name : "nmh", errno);
+        if (write(2, buffer, strlen(buffer)) == -1) {
+            /* Ignore.  if-statement needed to shut up compiler. */
+        }
     }
 }
     }
 }