vi: remove workarounds for other systems

2014-11-10 Thread Martin Natano
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.c1 Dec 2013 20:22:34 -   1.28
+++ common/exf.c10 Nov 2014 17:10:05 -
@@ -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.c28 Nov 2013 22:12:40 -  1.11
+++ common/key.c10 Nov 2014 17:10:05 -
@@ -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.c27 Oct 2009 23:59:47 -  1.15
+++ common/recover.c10 Nov 2014 17:10:05 -
@@ -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
-#defineMAXHOSTNAMELEN  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 -  1.11
+++ ex/ex_shell.c   10 Nov 2014 17:10:05 -
@@ -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,  

Re: vi: remove workarounds for other systems

2014-11-10 Thread Anthony J. Bentley
Martin Natano writes:
 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 -  1.15
 +++ common/recover.c  10 Nov 2014 17:10:05 -
 @@ -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;

FreeBSD nvi uses sysconf for this. If that's the right thing to do, we
should probably synchronize with them...

-- 
Anthony J. Bentley



Re: vi: remove workarounds for other systems

2014-11-10 Thread Ted Unangst
On Mon, Nov 10, 2014 at 13:51, Anthony J. Bentley wrote:
 Martin Natano writes:
 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 -  1.15
 +++ common/recover.c 10 Nov 2014 17:10:05 -
 @@ -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;
 
 FreeBSD nvi uses sysconf for this. If that's the right thing to do, we
 should probably synchronize with them...

overkill in my opinion. we're not going to change it.

diff applied. thanks.