There are two workarounds for a broken libc on linux, one for a missing
MAXHOSTNAMELEN and one "portable" reimplementation of strsignal (with
another name though). None of those are necessary for OpenBSD.

See diff below.

cheers,
natano


Index: common/exf.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
retrieving revision 1.28
diff -u -r1.28 exf.c
--- common/exf.c        1 Dec 2013 20:22:34 -0000       1.28
+++ common/exf.c        10 Nov 2014 17:10:05 -0000
@@ -856,21 +856,6 @@
                msgq_str(sp, M_ERR, name,
                    "252|%s: write lock was unavailable");
 
-#if __linux__
-       /*
-        * XXX
-        * In libc 4.5.x, fdopen(fd, "w") clears the O_APPEND flag (if set).
-        * This bug is fixed in libc 4.6.x.
-        *
-        * This code works around this problem for libc 4.5.x users.
-        * Note that this code is harmless if you're using libc 4.6.x.
-        */
-       if (LF_ISSET(FS_APPEND) && lseek(fd, (off_t)0, SEEK_END) < 0) {
-               msgq(sp, M_SYSERR, "%s", name);
-               return (1);
-       }
-#endif
-
        /*
         * Use stdio for buffering.
         *
Index: common/key.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/key.c,v
retrieving revision 1.11
diff -u -r1.11 key.c
--- common/key.c        28 Nov 2013 22:12:40 -0000      1.11
+++ common/key.c        10 Nov 2014 17:10:05 -0000
@@ -114,16 +114,6 @@
         * character set, as long as nul isn't a character.
         */
        (void)setlocale(LC_ALL, "");
-#if __linux__
-       /*
-        * In libc 4.5.26, setlocale(LC_ALL, ""), doesn't setup the table
-        * for ctype(3c) correctly.  This bug is fixed in libc 4.6.x.
-        *
-        * This code works around this problem for libc 4.5.x users.
-        * Note that this code is harmless if you're using libc 4.6.x.
-        */
-       (void)setlocale(LC_CTYPE, "");
-#endif
        v_key_ilookup(sp);
 
        v_keyval(sp, K_CNTRLD, KEY_VEOF);
Index: common/recover.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/recover.c,v
retrieving revision 1.15
diff -u -r1.15 recover.c
--- common/recover.c    27 Oct 2009 23:59:47 -0000      1.15
+++ common/recover.c    10 Nov 2014 17:10:05 -0000
@@ -339,15 +339,6 @@
        int fd;
        char *dp, *p, *t, buf[4096], mpath[MAXPATHLEN];
        char *t1, *t2, *t3;
-
-       /*
-        * XXX
-        * MAXHOSTNAMELEN is in various places on various systems, including
-        * <netdb.h> and <sys/socket.h>.  If not found, use a large default.
-        */
-#ifndef MAXHOSTNAMELEN
-#define        MAXHOSTNAMELEN  1024
-#endif
        char host[MAXHOSTNAMELEN];
 
        gp = sp->gp;
Index: ex/ex_shell.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_shell.c,v
retrieving revision 1.11
diff -u -r1.11 ex_shell.c
--- ex/ex_shell.c       27 Oct 2009 23:59:47 -0000      1.11
+++ ex/ex_shell.c       10 Nov 2014 17:10:05 -0000
@@ -26,8 +26,6 @@
 
 #include "../common/common.h"
 
-static const char *sigmsg(int);
-
 /*
  * ex_shell -- :sh[ell]
  *     Invoke the program named in the SHELL environment variable
@@ -179,7 +177,7 @@
                len = strlen(p);
                msgq(sp, M_ERR, "%.*s%s: received signal: %s%s",
                    MIN(len, 20), p, len > 20 ? " ..." : "",
-                   sigmsg(WTERMSIG(pstat)),
+                   strsignal(WTERMSIG(pstat)),
                    WCOREDUMP(pstat) ? "; core dumped" : "");
                if (nf)
                        FREE_SPACE(sp, p, 0);
@@ -208,169 +206,4 @@
                return (1);
        }
        return (0);
-}
-
-/*
- * XXX
- * The sys_siglist[] table in the C library has this information, but there's
- * no portable way to get to it.  (Believe me, I tried.)
- */
-typedef struct _sigs {
-       int      number;                /* signal number */
-       char    *message;               /* related message */
-} SIGS;
-
-SIGS const sigs[] = {
-#ifdef SIGABRT
-       { SIGABRT,      "Abort trap" },
-#endif
-#ifdef SIGALRM
-       { SIGALRM,      "Alarm clock" },
-#endif
-#ifdef SIGBUS
-       { SIGBUS,       "Bus error" },
-#endif
-#ifdef SIGCLD
-       { SIGCLD,       "Child exited or stopped" },
-#endif
-#ifdef SIGCHLD
-       { SIGCHLD,      "Child exited" },
-#endif
-#ifdef SIGCONT
-       { SIGCONT,      "Continued" },
-#endif
-#ifdef SIGDANGER
-       { SIGDANGER,    "System crash imminent" },
-#endif
-#ifdef SIGEMT
-       { SIGEMT,       "EMT trap" },
-#endif
-#ifdef SIGFPE
-       { SIGFPE,       "Floating point exception" },
-#endif
-#ifdef SIGGRANT
-       { SIGGRANT,     "HFT monitor mode granted" },
-#endif
-#ifdef SIGHUP
-       { SIGHUP,       "Hangup" },
-#endif
-#ifdef SIGILL
-       { SIGILL,       "Illegal instruction" },
-#endif
-#ifdef SIGINFO
-       { SIGINFO,      "Information request" },
-#endif
-#ifdef SIGINT
-       { SIGINT,       "Interrupt" },
-#endif
-#ifdef SIGIO
-       { SIGIO,        "I/O possible" },
-#endif
-#ifdef SIGIOT
-       { SIGIOT,       "IOT trap" },
-#endif
-#ifdef SIGKILL
-       { SIGKILL,      "Killed" },
-#endif
-#ifdef SIGLOST
-       { SIGLOST,      "Record lock" },
-#endif
-#ifdef SIGMIGRATE
-       { SIGMIGRATE,   "Migrate process to another CPU" },
-#endif
-#ifdef SIGMSG
-       { SIGMSG,       "HFT input data pending" },
-#endif
-#ifdef SIGPIPE
-       { SIGPIPE,      "Broken pipe" },
-#endif
-#ifdef SIGPOLL
-       { SIGPOLL,      "I/O possible" },
-#endif
-#ifdef SIGPRE
-       { SIGPRE,       "Programming error" },
-#endif
-#ifdef SIGPROF
-       { SIGPROF,      "Profiling timer expired" },
-#endif
-#ifdef SIGPWR
-       { SIGPWR,       "Power failure imminent" },
-#endif
-#ifdef SIGRETRACT
-       { SIGRETRACT,   "HFT monitor mode retracted" },
-#endif
-#ifdef SIGQUIT
-       { SIGQUIT,      "Quit" },
-#endif
-#ifdef SIGSAK
-       { SIGSAK,       "Secure Attention Key" },
-#endif
-#ifdef SIGSEGV
-       { SIGSEGV,      "Segmentation fault" },
-#endif
-#ifdef SIGSOUND
-       { SIGSOUND,     "HFT sound sequence completed" },
-#endif
-#ifdef SIGSTOP
-       { SIGSTOP,      "Suspended (signal)" },
-#endif
-#ifdef SIGSYS
-       { SIGSYS,       "Bad system call" },
-#endif
-#ifdef SIGTERM
-       { SIGTERM,      "Terminated" },
-#endif
-#ifdef SIGTRAP
-       { SIGTRAP,      "Trace/BPT trap" },
-#endif
-#ifdef SIGTSTP
-       { SIGTSTP,      "Suspended" },
-#endif
-#ifdef SIGTTIN
-       { SIGTTIN,      "Stopped (tty input)" },
-#endif
-#ifdef SIGTTOU
-       { SIGTTOU,      "Stopped (tty output)" },
-#endif
-#ifdef SIGURG
-       { SIGURG,       "Urgent I/O condition" },
-#endif
-#ifdef SIGUSR1
-       { SIGUSR1,      "User defined signal 1" },
-#endif
-#ifdef SIGUSR2
-       { SIGUSR2,      "User defined signal 2" },
-#endif
-#ifdef SIGVTALRM
-       { SIGVTALRM,    "Virtual timer expired" },
-#endif
-#ifdef SIGWINCH
-       { SIGWINCH,     "Window size changes" },
-#endif
-#ifdef SIGXCPU
-       { SIGXCPU,      "Cputime limit exceeded" },
-#endif
-#ifdef SIGXFSZ
-       { SIGXFSZ,      "Filesize limit exceeded" },
-#endif
-};
-
-/*
- * sigmsg --
- *     Return a pointer to a message describing a signal.
- */
-static const char *
-sigmsg(signo)
-       int signo;
-{
-       static char buf[40];
-       const SIGS *sigp;
-       int n;
-
-       for (n = 0,
-           sigp = &sigs[0]; n < sizeof(sigs) / sizeof(sigs[0]); ++n, ++sigp)
-               if (sigp->number == signo)
-                       return (sigp->message);
-       (void)snprintf(buf, sizeof(buf), "Unknown signal: %d", signo);
-       return (buf);
 }

Reply via email to