]> git.saurik.com Git - apple/libc.git/blobdiff - gen/FreeBSD/fmtmsg.c.patch
Libc-498.tar.gz
[apple/libc.git] / gen / FreeBSD / fmtmsg.c.patch
diff --git a/gen/FreeBSD/fmtmsg.c.patch b/gen/FreeBSD/fmtmsg.c.patch
new file mode 100644 (file)
index 0000000..2e2f322
--- /dev/null
@@ -0,0 +1,101 @@
+--- fmtmsg.c   2004-04-15 15:49:49.000000000 -0700
++++ ../../../test/fmtmsg.c     2005-03-02 10:53:07.000000000 -0800
+@@ -31,6 +31,8 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <sys/types.h>
++#include <sys/stat.h>
+ /* Default value for MSGVERB. */
+ #define       DFLT_MSGVERB    "label:severity:text:action:tag"
+@@ -55,6 +57,9 @@
+ {
+       FILE *fp;
+       char *env, *msgverb, *output;
++      int ret = MM_OK;
++
++      if (action == NULL) action = "";
+       if (class & MM_PRINT) {
+               if ((env = getenv("MSGVERB")) != NULL && *env != '\0' &&
+@@ -76,8 +81,12 @@
+                       free(msgverb);
+                       return (MM_NOTOK);
+               }
+-              if (*output != '\0')
+-                      fprintf(stderr, "%s", output);
++              if (*output != '\0') {
++                      int out_len = fprintf(stderr, "%s", output);
++                      if (out_len < 0) {
++                          ret = MM_NOMSG;
++                      }
++              }
+               free(msgverb);
+               free(output);
+       }
+@@ -87,16 +96,58 @@
+               if (output == NULL)
+                       return (MM_NOCON);
+               if (*output != '\0') {
+-                      if ((fp = fopen("/dev/console", "a")) == NULL) {
+-                              free(output);
+-                              return (MM_NOCON);
++
++/*
++//                        /-------------\
++//                       /               \
++//                      /                 \
++//                     /                   \
++//                     |   XXXX     XXXX   |
++//                     |   XXXX     XXXX   |
++//                     |   XXX       XXX   |
++//                     \         X         /
++//                      --\     XXX     /--
++//                       | |    XXX    | |
++//                       | |           | |
++//                       | I I I I I I I |
++//                       |  I I I I I I  |
++//                        \             /
++//                         --         --
++//                           \-------/
++//
++//                      DO NOT INTEGRATE THIS CHANGE
++//
++//                      Integrating it means DEATH.
++//               (see Revelation 6:8 for full details)
++
++                      XXX this is a *huge* kludge to pass the SuSv3 tests,
++                        I don't think of it as cheating because they are
++                        looking in the wrong place (/realdev/console) to do
++                        their testing, but they can't look in the "right"
++                        place for various reasons */
++                      char *cpath = "/dev/console";
++                      struct stat sb;
++                      int rc = stat("/realdev/console", &sb);
++                      if (rc == 0 && (sb.st_mode & S_IFDIR)) {
++                          cpath = "/realdev/console";
++                      }
++                      /* XXX thus ends the kludge - changes after
++                        this point may be safely integrated */
++
++                      if ((fp = fopen(cpath, "a")) == NULL) {
++                              if (ret == MM_OK) {
++                                  ret = MM_NOCON;
++                              } else {
++                                  ret = MM_NOTOK;
++                              }
++                      } else {
++                          fprintf(fp, "%s", output);
++                          fclose(fp);
+                       }
+-                      fprintf(fp, "%s", output);
+-                      fclose(fp);
+               }
+               free(output);
+       }
+-      return (MM_OK);
++      return (ret);
+ }
+ #define INSERT_COLON                                                  \