Author: bapt
Date: Thu Oct  1 04:46:23 2020
New Revision: 366309
URL: https://svnweb.freebsd.org/changeset/base/366309

Log:
  Update nvi to 2.2.0-05ed8b9
  
  This version incorporates many fixes in particular a fix for vi -w
  Another approach was proposed to merge those fixes (see review), I find
  it easier to track changes if we keep importing snapshot on regular
  basis
  
  PR:           241985
  Reported by:  fernape
  Differential Revision:        https://reviews.freebsd.org/D26158

Modified:
  head/contrib/nvi/CMakeLists.txt
  head/contrib/nvi/catalog/dump.c
  head/contrib/nvi/cl/cl.h
  head/contrib/nvi/cl/cl_read.c
  head/contrib/nvi/cl/cl_term.c
  head/contrib/nvi/common/common.h
  head/contrib/nvi/common/cut.h
  head/contrib/nvi/common/exf.c
  head/contrib/nvi/common/key.c
  head/contrib/nvi/common/log.c
  head/contrib/nvi/common/main.c
  head/contrib/nvi/common/mark.c
  head/contrib/nvi/common/mem.h
  head/contrib/nvi/common/msg.c
  head/contrib/nvi/common/options.c
  head/contrib/nvi/common/put.c
  head/contrib/nvi/common/recover.c
  head/contrib/nvi/common/util.c
  head/contrib/nvi/ex/ex.c
  head/contrib/nvi/ex/ex.h
  head/contrib/nvi/ex/ex_argv.c
  head/contrib/nvi/ex/ex_bang.c
  head/contrib/nvi/ex/ex_cscope.c
  head/contrib/nvi/ex/ex_filter.c
  head/contrib/nvi/ex/ex_global.c
  head/contrib/nvi/ex/ex_script.c
  head/contrib/nvi/ex/ex_shell.c
  head/contrib/nvi/ex/ex_subst.c
  head/contrib/nvi/files/config.h.in
  head/contrib/nvi/files/pathnames.h.in
  head/contrib/nvi/regex/engine.c
  head/contrib/nvi/regex/regexec.c
  head/contrib/nvi/vi/v_itxt.c
  head/contrib/nvi/vi/v_paragraph.c
  head/contrib/nvi/vi/v_section.c
  head/contrib/nvi/vi/v_sentence.c
  head/contrib/nvi/vi/v_txt.c
  head/contrib/nvi/vi/vi.c
  head/contrib/nvi/vi/vs_line.c
  head/contrib/nvi/vi/vs_msg.c
  head/contrib/nvi/vi/vs_refresh.c
  head/contrib/nvi/vi/vs_relative.c
  head/contrib/nvi/vi/vs_smap.c
  head/usr.bin/vi/catalog/Makefile
  head/usr.bin/vi/pathnames.h
Directory Properties:
  head/contrib/nvi/   (props changed)

Modified: head/contrib/nvi/CMakeLists.txt
==============================================================================
--- head/contrib/nvi/CMakeLists.txt     Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/CMakeLists.txt     Thu Oct  1 04:46:23 2020        
(r366309)
@@ -13,6 +13,7 @@ project(nvi2 C)
 
 include(CheckIncludeFiles)
 include(CheckFunctionExists)
+include(CheckStructHasMember)
 include(CheckCSourceCompiles)
 
 mark_as_advanced(CMAKE_INSTALL_PREFIX)
@@ -127,6 +128,7 @@ endif()
 
 if(USE_WIDECHAR)
     find_library(CURSES_LIBRARY NAMES ncursesw cursesw curses HINTS /usr/lib)
+    find_library(TERMINFO_LIBRARY NAMES tinfow terminfo HINTS /usr/lib)
 
     # link to the wchar_t awared BSD libregex.a
     add_library(regex STATIC)
@@ -136,13 +138,14 @@ if(USE_WIDECHAR)
     target_link_libraries(nvi PRIVATE regex)
 else()
     find_library(CURSES_LIBRARY NAMES ncurses curses HINTS /usr/lib)
+    find_library(TERMINFO_LIBRARY NAMES tinfo terminfo HINTS /usr/lib)
     target_compile_options(nvi PRIVATE -Wno-pointer-sign)
 endif()
 
-target_link_libraries(nvi PRIVATE ${CURSES_LIBRARY})
+target_link_libraries(nvi PRIVATE ${CURSES_LIBRARY} ${TERMINFO_LIBRARY})
 
 if(USE_ICONV)
-    check_function_exists(__iconv ICONV_IN_LIBC)
+    check_function_exists(iconv ICONV_IN_LIBC)
     if(NOT ICONV_IN_LIBC)
         find_path(ICONV_INCLUDE_DIR iconv.h)
         find_library(ICONV_LIBRARY iconv)
@@ -173,9 +176,26 @@ if(USE_ICONV)
     target_link_libraries(nvi PRIVATE ${ICONV_LIBRARY})
 endif()
 
+check_function_exists(getprogname GETPROGNAME_IN_LIBC)
+check_function_exists(strlcpy STRLCPY_IN_LIBC)
+if(NOT GETPROGNAME_IN_LIBC OR NOT STRLCPY_IN_LIBC)
+    find_package(PkgConfig REQUIRED)
+    pkg_check_modules(LIBBSD libbsd-overlay)
+    add_definitions(${LIBBSD_CFLAGS})
+    target_link_libraries(nvi PRIVATE ${LIBBSD_LIBRARIES})
+endif()
+
+check_function_exists(dbopen DBOPEN_IN_LIBC)
+if(NOT DBOPEN_IN_LIBC)
+    target_link_libraries(nvi PRIVATE db1)
+endif()
+
 check_include_files(libutil.h HAVE_LIBUTIL_H)
 check_include_files(ncurses.h HAVE_NCURSES_H)
+check_include_files(ncursesw/ncurses.h HAVE_NCURSESW_NCURSES_H)
+check_include_files(pty.h HAVE_PTY_H)
 check_include_files(term.h HAVE_TERM_H)
+check_struct_has_member("struct dirent" d_namlen dirent.h HAVE_DIRENT_D_NAMLEN 
LANGUAGE C)
 
 configure_file(files/config.h.in config.h)
 

Modified: head/contrib/nvi/catalog/dump.c
==============================================================================
--- head/contrib/nvi/catalog/dump.c     Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/catalog/dump.c     Thu Oct  1 04:46:23 2020        
(r366309)
@@ -36,24 +36,24 @@ parse(FILE *fp)
 {
        int ch, s1, s2, s3;
 
-#define        TESTD(s) {                                                      
\
+#define        TESTD(s) do {                                                   
\
        if ((s = getc(fp)) == EOF)                                      \
                return;                                                 \
        if (!isdigit(s))                                                \
                continue;                                               \
-}
-#define        TESTP {                                                         
\
+} while (0)
+#define        TESTP do {                                                      
\
        if ((ch = getc(fp)) == EOF)                                     \
                return;                                                 \
        if (ch != '|')                                                  \
                continue;                                               \
-}
-#define        MOVEC(t) {                                                      
\
+} while (0)
+#define        MOVEC(t) do {                                                   
\
        do {                                                            \
                if ((ch = getc(fp)) == EOF)                             \
                        return;                                         \
        } while (ch != (t));                                            \
-}
+} while (0)
        for (;;) {
                MOVEC('"');
                TESTD(s1);

Modified: head/contrib/nvi/cl/cl.h
==============================================================================
--- head/contrib/nvi/cl/cl.h    Thu Oct  1 04:26:46 2020        (r366308)
+++ head/contrib/nvi/cl/cl.h    Thu Oct  1 04:46:23 2020        (r366309)
@@ -10,7 +10,9 @@
 #ifdef USE_WIDECHAR
 #define _XOPEN_SOURCE_EXTENDED
 #endif
-#ifdef HAVE_NCURSES_H
+#ifdef HAVE_NCURSESW_NCURSES_H
+#include <ncursesw/ncurses.h>
+#elif defined HAVE_NCURSES_H
 #include <ncurses.h>
 #else
 #include <curses.h>

Modified: head/contrib/nvi/cl/cl_read.c
==============================================================================
--- head/contrib/nvi/cl/cl_read.c       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/cl/cl_read.c       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/ioctl.h>
 #include <termios.h>
 #include <unistd.h>
 

Modified: head/contrib/nvi/cl/cl_term.c
==============================================================================
--- head/contrib/nvi/cl/cl_term.c       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/cl/cl_term.c       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -424,16 +424,18 @@ cl_ssize(SCR *sp, int sigwinch, size_t *rowp, size_t *
        if (row == 0 || col == 0) {
                if ((p = getenv("TERM")) == NULL)
                        goto noterm;
-               if (row == 0)
+               if (row == 0) {
                        if ((rval = tigetnum("lines")) < 0)
                                msgq(sp, M_SYSERR, "tigetnum: lines");
                        else
                                row = rval;
-               if (col == 0)
+               }
+               if (col == 0) {
                        if ((rval = tigetnum("cols")) < 0)
                                msgq(sp, M_SYSERR, "tigetnum: cols");
                        else
                                col = rval;
+               }
        }
 
        /* If nothing else, well, it's probably a VT100. */

Modified: head/contrib/nvi/common/common.h
==============================================================================
--- head/contrib/nvi/common/common.h    Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/common.h    Thu Oct  1 04:46:23 2020        
(r366309)
@@ -7,7 +7,15 @@
  * See the LICENSE file for redistribution information.
  */
 
-#include <db.h>                        /* Only include db1. */
+#ifndef TCSASOFT
+#define TCSASOFT 0
+#endif
+
+#ifdef __linux__
+#include "/usr/include/db1/db.h"       /* Only include db1. */
+#else
+#include "/usr/include/db.h"   /* Only include db1. */
+#endif
 #include <regex.h>             /* May refer to the bundled regex. */
 
 /*

Modified: head/contrib/nvi/common/cut.h
==============================================================================
--- head/contrib/nvi/common/cut.h       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/cut.h       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -63,13 +63,13 @@ struct _text {                              /* Text: a 
linked list of lines. */
  * Get named buffer 'name'.
  * Translate upper-case buffer names to lower-case buffer names.
  */
-#define        CBNAME(sp, cbp, nch) {                                          
\
+#define        CBNAME(sp, cbp, nch) do {                                       
\
        CHAR_T L__name;                                                 \
        L__name = isupper(nch) ? tolower(nch) : (nch);                  \
        SLIST_FOREACH(cbp, sp->gp->cutq, q)                             \
                if (cbp->name == L__name)                               \
                        break;                                          \
-}
+} while (0)
 
 /* Flags to the cut() routine. */
 #define        CUT_LINEMODE    0x01            /* Cut in line mode. */

Modified: head/contrib/nvi/common/exf.c
==============================================================================
--- head/contrib/nvi/common/exf.c       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/exf.c       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -199,7 +199,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flag
                if (!LF_ISSET(FS_OPENERR))
                        F_SET(frp, FR_NEWFILE);
 
-               ep->mtim = sb.st_mtimespec;
+               ep->mtim = sb.st_mtim;
        } else {
                /*
                 * XXX
@@ -218,7 +218,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flag
                ep->mdev = sb.st_dev;
                ep->minode = sb.st_ino;
 
-               ep->mtim = sb.st_mtimespec;
+               ep->mtim = sb.st_mtim;
 
                if (!S_ISREG(sb.st_mode))
                        msgq_str(sp, M_ERR, oname,
@@ -796,7 +796,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, char *name, in
                if (noname && !LF_ISSET(FS_FORCE | FS_APPEND) &&
                    ((F_ISSET(ep, F_DEVSET) &&
                    (sb.st_dev != ep->mdev || sb.st_ino != ep->minode)) ||
-                   timespeccmp(&sb.st_mtimespec, &ep->mtim, !=))) {
+                   timespeccmp(&sb.st_mtim, &ep->mtim, !=))) {
                        msgq_str(sp, M_ERR, name, LF_ISSET(FS_POSSIBLE) ?
 "250|%s: file modified more recently than this copy; use ! to override" :
 "251|%s: file modified more recently than this copy");
@@ -887,7 +887,7 @@ success_open:
         * we re-init the time.  That way the user can clean up the disk
         * and rewrite without having to force it.
         */
-       if (noname)
+       if (noname) {
                if (stat(name, &sb))
                        timepoint_system(&ep->mtim);
                else {
@@ -895,8 +895,9 @@ success_open:
                        ep->mdev = sb.st_dev;
                        ep->minode = sb.st_ino;
 
-                       ep->mtim = sb.st_mtimespec;
+                       ep->mtim = sb.st_mtim;
                }
+       }
 
        /*
         * If the write failed, complain loudly.  ex_writefp() has already
@@ -925,11 +926,12 @@ success_open:
         */
        if (LF_ISSET(FS_ALL) && !LF_ISSET(FS_APPEND)) {
                F_CLR(ep, F_MODIFIED);
-               if (F_ISSET(frp, FR_TMPFILE))
+               if (F_ISSET(frp, FR_TMPFILE)) {
                        if (noname)
                                F_SET(frp, FR_TMPEXIT);
                        else
                                F_CLR(frp, FR_TMPEXIT);
+               }
        }
 
        p = msg_print(sp, name, &nf);
@@ -1290,7 +1292,7 @@ file_m1(SCR *sp, int force, int flags)
         * unless force is also set.  Otherwise, we fail unless forced or
         * there's another open screen on this file.
         */
-       if (F_ISSET(ep, F_MODIFIED))
+       if (F_ISSET(ep, F_MODIFIED)) {
                if (O_ISSET(sp, O_AUTOWRITE)) {
                        if (!force && file_aw(sp, flags))
                                return (1);
@@ -1300,6 +1302,7 @@ file_m1(SCR *sp, int force, int flags)
 "263|File modified since last complete write; write or use :edit! to 
override");
                        return (1);
                }
+       }
 
        return (file_m3(sp, force));
 }

Modified: head/contrib/nvi/common/key.c
==============================================================================
--- head/contrib/nvi/common/key.c       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/key.c       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -424,12 +424,12 @@ v_event_append(SCR *sp, EVENT *argp)
 }
 
 /* Remove events from the queue. */
-#define        QREM(len) {                                                     
\
+#define        QREM(len) do {                                                  
\
        if ((gp->i_cnt -= len) == 0)                                    \
                gp->i_next = 0;                                         \
        else                                                            \
                gp->i_next += len;                                      \
-}
+} while (0)
 
 /*
  * v_event_get --

Modified: head/contrib/nvi/common/log.c
==============================================================================
--- head/contrib/nvi/common/log.c       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/log.c       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -69,10 +69,10 @@ static int  apply_with(int (*)(SCR *, recno_t, CHAR_T *
                                        SCR *, recno_t, u_char *, size_t);
 
 /* Try and restart the log on failure, i.e. if we run out of memory. */
-#define        LOG_ERR {                                                       
\
+#define        LOG_ERR do {                                                    
\
        log_err(sp, __FILE__, __LINE__);                                \
        return (1);                                                     \
-}
+} while (0)
 
 /* offset of CHAR_T string in log needs to be aligned on some systems
  * because it is passed to db_set as a string

Modified: head/contrib/nvi/common/main.c
==============================================================================
--- head/contrib/nvi/common/main.c      Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/main.c      Thu Oct  1 04:46:23 2020        
(r366309)
@@ -48,8 +48,8 @@ editor(GS *gp, int argc, char *argv[])
        size_t len;
        u_int flags;
        int ch, flagchk, lflag, secure, startup, readonly, rval, silent;
-       char *tag_f, *wsizearg, path[256];
-       CHAR_T *w;
+       char *tag_f, *wsizearg;
+       CHAR_T *w, path[256];
        size_t wlen;
 
        /* Initialize the busy routine, if not defined by the screen. */
@@ -242,9 +242,9 @@ editor(GS *gp, int argc, char *argv[])
        }
        if (wsizearg != NULL) {
                ARGS *av[2], a, b;
-               (void)snprintf(path, sizeof(path), "window=%s", wsizearg);
+               (void)SPRINTF(path, SIZE(path), L("window=%s"), wsizearg);
                a.bp = (CHAR_T *)path;
-               a.len = strlen(path);
+               a.len = SIZE(path);
                b.bp = NULL;
                b.len = 0;
                av[0] = &a;
@@ -533,7 +533,7 @@ v_obsolete(char *argv[])
                                argv[0][1] = 'c';
                                (void)strlcpy(argv[0] + 2, p + 1, len);
                        }
-               } else if (argv[0][0] == '-')
+               } else if (argv[0][0] == '-') {
                        if (argv[0][1] == '\0') {
                                argv[0] = strdup("-s");
                                if (argv[0] == NULL) {
@@ -545,6 +545,7 @@ nomem:                                      warn(NULL);
                                    argv[0][1] == 't' || argv[0][1] == 'w') &&
                                    argv[0][2] == '\0')
                                        ++argv;
+               }
        return (0);
 }
 

Modified: head/contrib/nvi/common/mark.c
==============================================================================
--- head/contrib/nvi/common/mark.c      Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/mark.c      Thu Oct  1 04:46:23 2020        
(r366309)
@@ -216,12 +216,13 @@ mark_insdel(SCR *sp, lnop_t op, recno_t lno)
                abort();
        case LINE_DELETE:
                SLIST_FOREACH(lmp, sp->ep->marks, q)
-                       if (lmp->lno >= lno)
+                       if (lmp->lno >= lno) {
                                if (lmp->lno == lno) {
                                        F_SET(lmp, MARK_DELETED);
                                        (void)log_mark(sp, lmp);
                                } else
                                        --lmp->lno;
+                       }
                break;
        case LINE_INSERT:
                /*

Modified: head/contrib/nvi/common/mem.h
==============================================================================
--- head/contrib/nvi/common/mem.h       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/mem.h       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -17,7 +17,7 @@
 /* Increase the size of a malloc'd buffer.  Two versions, one that
  * returns, one that jumps to an error label.
  */
-#define        BINC_GOTO(sp, type, lp, llen, nlen) {                           
\
+#define        BINC_GOTO(sp, type, lp, llen, nlen) do {                        
\
        CHECK_TYPE(type *, lp)                                          \
        void *L__bincp;                                                 \
        if ((nlen) > llen) {                                            \
@@ -29,12 +29,12 @@
                 */                                                     \
                lp = L__bincp;                                          \
        }                                                               \
-}
+} while (0)
 #define        BINC_GOTOC(sp, lp, llen, nlen)                                  
\
        BINC_GOTO(sp, char, lp, llen, nlen)
 #define        BINC_GOTOW(sp, lp, llen, nlen)                                  
\
        BINC_GOTO(sp, CHAR_T, lp, llen, (nlen) * sizeof(CHAR_T))
-#define        BINC_RET(sp, type, lp, llen, nlen) {                            
\
+#define        BINC_RET(sp, type, lp, llen, nlen) do {                         
\
        CHECK_TYPE(type *, lp)                                          \
        void *L__bincp;                                                 \
        if ((nlen) > llen) {                                            \
@@ -46,7 +46,7 @@
                 */                                                     \
                lp = L__bincp;                                          \
        }                                                               \
-}
+} while (0)
 #define        BINC_RETC(sp, lp, llen, nlen)                                   
\
        BINC_RET(sp, char, lp, llen, nlen)
 #define        BINC_RETW(sp, lp, llen, nlen)                                   
\
@@ -57,7 +57,7 @@
  * from a malloc'd buffer otherwise.  Two versions, one that returns, one
  * that jumps to an error label.
  */
-#define        GET_SPACE_GOTO(sp, type, bp, blen, nlen) {                      
\
+#define        GET_SPACE_GOTO(sp, type, bp, blen, nlen) do {                   
\
        CHECK_TYPE(type *, bp)                                          \
        GS *L__gp = (sp) == NULL ? NULL : (sp)->gp;                     \
        if (L__gp == NULL || F_ISSET(L__gp, G_TMP_INUSE)) {             \
@@ -70,12 +70,12 @@
                blen = L__gp->tmp_blen;                                 \
                F_SET(L__gp, G_TMP_INUSE);                              \
        }                                                               \
-}
+} while (0)
 #define        GET_SPACE_GOTOC(sp, bp, blen, nlen)                             
\
        GET_SPACE_GOTO(sp, char, bp, blen, nlen)
 #define        GET_SPACE_GOTOW(sp, bp, blen, nlen)                             
\
        GET_SPACE_GOTO(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T))
-#define        GET_SPACE_RET(sp, type, bp, blen, nlen) {                       
\
+#define        GET_SPACE_RET(sp, type, bp, blen, nlen) do {                    
\
        CHECK_TYPE(type *, bp)                                          \
        GS *L__gp = (sp) == NULL ? NULL : (sp)->gp;                     \
        if (L__gp == NULL || F_ISSET(L__gp, G_TMP_INUSE)) {             \
@@ -88,7 +88,7 @@
                blen = L__gp->tmp_blen;                                 \
                F_SET(L__gp, G_TMP_INUSE);                              \
        }                                                               \
-}
+} while (0)
 #define        GET_SPACE_RETC(sp, bp, blen, nlen)                              
\
        GET_SPACE_RET(sp, char, bp, blen, nlen)
 #define        GET_SPACE_RETW(sp, bp, blen, nlen)                              
\
@@ -98,7 +98,7 @@
  * Add space to a GET_SPACE returned buffer.  Two versions, one that
  * returns, one that jumps to an error label.
  */
-#define        ADD_SPACE_GOTO(sp, type, bp, blen, nlen) {                      
\
+#define        ADD_SPACE_GOTO(sp, type, bp, blen, nlen) do {                   
\
        CHECK_TYPE(type *, bp)                                          \
        GS *L__gp = (sp) == NULL ? NULL : (sp)->gp;                     \
        if (L__gp == NULL || bp == (type *)L__gp->tmp_bp) {             \
@@ -109,12 +109,12 @@
                F_SET(L__gp, G_TMP_INUSE);                              \
        } else                                                          \
                BINC_GOTO(sp, type, bp, blen, nlen);                    \
-}
+} while (0)
 #define        ADD_SPACE_GOTOC(sp, bp, blen, nlen)                             
\
        ADD_SPACE_GOTO(sp, char, bp, blen, nlen)
 #define        ADD_SPACE_GOTOW(sp, bp, blen, nlen)                             
\
        ADD_SPACE_GOTO(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T))
-#define        ADD_SPACE_RET(sp, type, bp, blen, nlen) {                       
\
+#define        ADD_SPACE_RET(sp, type, bp, blen, nlen) do {                    
\
        CHECK_TYPE(type *, bp)                                          \
        GS *L__gp = (sp) == NULL ? NULL : (sp)->gp;                     \
        if (L__gp == NULL || bp == (type *)L__gp->tmp_bp) {             \
@@ -125,70 +125,70 @@
                F_SET(L__gp, G_TMP_INUSE);                              \
        } else                                                          \
                BINC_RET(sp, type, bp, blen, nlen);                     \
-}
+} while (0)
 #define        ADD_SPACE_RETC(sp, bp, blen, nlen)                              
\
        ADD_SPACE_RET(sp, char, bp, blen, nlen)
 #define        ADD_SPACE_RETW(sp, bp, blen, nlen)                              
\
        ADD_SPACE_RET(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T))
 
 /* Free a GET_SPACE returned buffer. */
-#define        FREE_SPACE(sp, bp, blen) {                                      
\
+#define        FREE_SPACE(sp, bp, blen) do {                                   
\
        GS *L__gp = (sp) == NULL ? NULL : (sp)->gp;                     \
        if (L__gp != NULL && bp == L__gp->tmp_bp)                       \
                F_CLR(L__gp, G_TMP_INUSE);                              \
        else                                                            \
                free(bp);                                               \
-}
-#define        FREE_SPACEW(sp, bp, blen) {                                     
\
+} while (0)
+#define        FREE_SPACEW(sp, bp, blen) do {                                  
\
        CHECK_TYPE(CHAR_T *, bp)                                        \
        FREE_SPACE(sp, (char *)bp, blen);                               \
-}
+} while (0)
 
 /*
  * Malloc a buffer, casting the return pointer.  Various versions.
  */
-#define        CALLOC(sp, p, nmemb, size) {                                    
\
+#define        CALLOC(sp, p, nmemb, size) do {                                 
\
        if ((p = calloc(nmemb, size)) == NULL)                          \
                msgq(sp, M_SYSERR, NULL);                               \
-}
-#define        CALLOC_GOTO(sp, p, nmemb, size) {                               
\
+} while (0)
+#define        CALLOC_GOTO(sp, p, nmemb, size) do {                            
\
        if ((p = calloc(nmemb, size)) == NULL)                          \
                goto alloc_err;                                         \
-}
-#define        CALLOC_RET(sp, p, nmemb, size) {                                
\
+} while (0)
+#define        CALLOC_RET(sp, p, nmemb, size) do {                             
\
        if ((p = calloc(nmemb, size)) == NULL) {                        \
                msgq(sp, M_SYSERR, NULL);                               \
                return (1);                                             \
        }                                                               \
-}
+} while (0)
 
-#define        MALLOC(sp, p, size) {                                           
\
+#define        MALLOC(sp, p, size) do {                                        
\
        if ((p = malloc(size)) == NULL)                                 \
                msgq(sp, M_SYSERR, NULL);                               \
-}
-#define        MALLOC_GOTO(sp, p, size) {                                      
\
+} while (0)
+#define        MALLOC_GOTO(sp, p, size) do {                                   
\
        if ((p = malloc(size)) == NULL)                                 \
                goto alloc_err;                                         \
-}
-#define        MALLOC_RET(sp, p, size) {                                       
\
+} while (0)
+#define        MALLOC_RET(sp, p, size) do {                                    
\
        if ((p = malloc(size)) == NULL) {                               \
                msgq(sp, M_SYSERR, NULL);                               \
                return (1);                                             \
        }                                                               \
-}
+} while (0)
 
 /*
  * Resize a buffer, free any already held memory if we can't get more.
  * FreeBSD's reallocf(3) does the same thing, but it's not portable yet.
  */
-#define        REALLOC(sp, p, cast, size) {                                    
\
+#define        REALLOC(sp, p, cast, size) do {                                 
\
        cast newp;                                                      \
        if ((newp = realloc(p, size)) == NULL) {                        \
                free(p);                                                \
                msgq(sp, M_SYSERR, NULL);                               \
        }                                                               \
        p = newp;                                                       \
-}
+} while (0)
 
 /* 
  * p2roundup --

Modified: head/contrib/nvi/common/msg.c
==============================================================================
--- head/contrib/nvi/common/msg.c       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/msg.c       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -731,7 +731,11 @@ msg_open(SCR *sp, char *file)
                 * corrupt catalog file.  Errno == 0 is not rare; add
                 * EFTYPE, which is seen on FreeBSD, for a good measure.
                 */
+#ifdef EFTYPE
                if (errno == 0 || errno == EFTYPE)
+#else
+               if (errno == 0)
+#endif
                        msgq_str(sp, M_ERR, p,
                            "030|The file %s is not a message catalog");
                else

Modified: head/contrib/nvi/common/options.c
==============================================================================
--- head/contrib/nvi/common/options.c   Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/options.c   Thu Oct  1 04:46:23 2020        
(r366309)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unctrl.h>
 #include <unistd.h>
 
 #include "common.h"
@@ -312,7 +313,7 @@ opts_init(SCR *sp, int *oargs)
        argv[1] = &b;
 
        /* Set numeric and string default values. */
-#define        OI(indx, str) {                                                 
\
+#define        OI(indx, str) do {                                              
\
        a.len = STRLEN(str);                                            \
        if ((CHAR_T*)str != b2)   /* GCC puts strings in text-space. */ \
                (void)MEMCPY(b2, str, a.len+1);                         \
@@ -320,7 +321,7 @@ opts_init(SCR *sp, int *oargs)
                 optindx = indx;                                        \
                goto err;                                               \
        }                                                               \
-}
+} while (0)
        /*
         * Indirect global options to global space.  Specifically, set up
         * terminal, lines, columns first, they're used by other options.
@@ -366,7 +367,7 @@ opts_init(SCR *sp, int *oargs)
        OI(O_PARAGRAPHS, L("paragraphs=IPLPPPQPP LIpplpipbp"));
        (void)SPRINTF(b2, SIZE(b2), L("path=%s"), "");
        OI(O_PATH, b2);
-       (void)SPRINTF(b2, SIZE(b2), L("recdir=%s"), _PATH_PRESERVE);
+       (void)SPRINTF(b2, SIZE(b2), L("recdir=%s"), NVI_PATH_PRESERVE);
        OI(O_RECDIR, b2);
        OI(O_SECTIONS, L("sections=NHSHH HUnhsh"));
        (void)SPRINTF(b2, SIZE(b2),
@@ -573,13 +574,14 @@ opts_set(SCR *sp, ARGS *argv[], char *usage)
                         * functions can be expensive.
                         */
                        isset = !turnoff;
-                       if (!F_ISSET(op, OPT_ALWAYS))
+                       if (!F_ISSET(op, OPT_ALWAYS)) {
                                if (isset) {
                                        if (O_ISSET(sp, offset))
                                                break;
                                } else
                                        if (!O_ISSET(sp, offset))
                                                break;
+                       }
 
                        /* Report to subsystems. */
                        if ((op->func != NULL &&
@@ -945,6 +947,7 @@ static int
 opts_print(SCR *sp, OPTLIST const *op)
 {
        int curlen, offset;
+       const char *p;
 
        curlen = 0;
        offset = op - optlist;
@@ -958,8 +961,13 @@ opts_print(SCR *sp, OPTLIST const *op)
                curlen += ex_printf(sp, WS"=%ld", op->name, O_VAL(sp, offset));
                break;
        case OPT_STR:
-               curlen += ex_printf(sp, WS"=\"%s\"", op->name,
-                   O_STR(sp, offset) == NULL ? "" : O_STR(sp, offset));
+               curlen += ex_printf(sp, WS"=\"", op->name);
+               p = O_STR(sp, offset);
+               /* Keep correct count for unprintable character sequences */
+               if (p != NULL)
+                       for (; *p != '\0'; ++p)
+                               curlen += ex_puts(sp, unctrl(*p));
+               curlen += ex_puts(sp, "\"");
                break;
        }
        return (curlen);

Modified: head/contrib/nvi/common/put.c
==============================================================================
--- head/contrib/nvi/common/put.c       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/put.c       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -39,7 +39,7 @@ put(SCR *sp, CB *cbp, CHAR_T *namep, MARK *cp, MARK *r
        CHAR_T *bp, *t;
        CHAR_T *p;
 
-       if (cbp == NULL)
+       if (cbp == NULL) {
                if (namep == NULL) {
                        cbp = sp->gp->dcbp;
                        if (cbp == NULL) {
@@ -56,6 +56,7 @@ put(SCR *sp, CB *cbp, CHAR_T *namep, MARK *cp, MARK *r
                                return (1);
                        }
                }
+       }
        tp = TAILQ_FIRST(cbp->textq);
 
        /*

Modified: head/contrib/nvi/common/recover.c
==============================================================================
--- head/contrib/nvi/common/recover.c   Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/recover.c   Thu Oct  1 04:46:23 2020        
(r366309)
@@ -421,7 +421,7 @@ rcv_mailfile(SCR *sp, int issync, char *cp_path)
            getprogname(), " -r ", qt);
        free(qt);
        free(host);
-       if (buf == NULL) {
+       if (len == -1) {
                msgq(sp, M_SYSERR, NULL);
                goto err;
        }
@@ -701,7 +701,7 @@ rcv_read(SCR *sp, FREF *frp)
                /* If we've found more than one, take the most recent. */
                (void)fstat(fileno(fp), &sb);
                if (recp == NULL ||
-                   timespeccmp(&rec_mtim, &sb.st_mtimespec, <)) {
+                   timespeccmp(&rec_mtim, &sb.st_mtim, <)) {
                        p = recp;
                        t = pathp;
                        recp = recpath;
@@ -710,7 +710,7 @@ rcv_read(SCR *sp, FREF *frp)
                                free(p);
                                free(t);
                        }
-                       rec_mtim = sb.st_mtimespec;
+                       rec_mtim = sb.st_mtim;
                        if (sv_fd != -1)
                                (void)close(sv_fd);
                        sv_fd = dup(fileno(fp));
@@ -813,8 +813,7 @@ rcv_email(SCR *sp, char *fname)
 {
        char *buf;
 
-       (void)asprintf(&buf, _PATH_SENDMAIL " -odb -t < %s", fname);
-       if (buf == NULL) {
+       if (asprintf(&buf, _PATH_SENDMAIL " -odb -t < %s", fname) == -1) {
                msgq_str(sp, M_ERR, strerror(errno),
                    "071|not sending email: %s");
                return;

Modified: head/contrib/nvi/common/util.c
==============================================================================
--- head/contrib/nvi/common/util.c      Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/common/util.c      Thu Oct  1 04:46:23 2020        
(r366309)
@@ -111,8 +111,9 @@ join(char *path1, char *path2)
 
        if (path1[0] == '\0' || path2[0] == '/')
                return strdup(path2);
-       (void)asprintf(&p, path1[strlen(path1)-1] == '/' ?
-           "%s%s" : "%s/%s", path1, path2);
+       if (asprintf(&p, path1[strlen(path1)-1] == '/' ?
+           "%s%s" : "%s/%s", path1, path2) == -1)
+               return NULL;
        return p;
 }
 
@@ -140,8 +141,13 @@ expanduser(char *str)
                continue;
        if (t == p) {
                /* ~ */
+#ifdef __GLIBC__
+               extern char *secure_getenv(const char *);
+               if ((h = secure_getenv("HOME")) == NULL) {
+#else
                if (issetugid() != 0 ||
                    (h = getenv("HOME")) == NULL) {
+#endif
                        if (((h = getlogin()) != NULL &&
                             (pwd = getpwnam(h)) != NULL) ||
                            (pwd = getpwuid(getuid())) != NULL)

Modified: head/contrib/nvi/ex/ex.c
==============================================================================
--- head/contrib/nvi/ex/ex.c    Thu Oct  1 04:26:46 2020        (r366308)
+++ head/contrib/nvi/ex/ex.c    Thu Oct  1 04:46:23 2020        (r366309)
@@ -811,13 +811,14 @@ skip_srch:        if (ecp->cmd == &cmds[C_VISUAL_EX] && 
F_ISS
         * this isn't a particularly complex trap, and if backslashes were
         * legal in set commands, this would have to be much more complicated.
         */
-       if (ecp->cmd == &cmds[C_SET])
+       if (ecp->cmd == &cmds[C_SET]) {
                for (p = ecp->cp, len = ecp->clen; len > 0; --len, ++p)
                        if (IS_ESCAPE(sp, ecp, *p) && len > 1) {
                                --len;
                                ++p;
                        } else if (*p == '\\')
                                *p = CH_LITERAL;
+       }
 
        /*
         * Set the default addresses.  It's an error to specify an address for
@@ -1254,7 +1255,7 @@ addr_verify:
                                ex_badaddr(sp, ecp->cmd, A_ZERO, NUM_OK);
                                goto err;
                        }
-               } else if (!db_exist(sp, ecp->addr2.lno))
+               } else if (!db_exist(sp, ecp->addr2.lno)) {
                        if (FL_ISSET(ecp->iflags, E_C_COUNT)) {
                                if (db_last(sp, &lno))
                                        goto err;
@@ -1263,6 +1264,7 @@ addr_verify:
                                ex_badaddr(sp, NULL, A_EOF, NUM_OK);
                                goto err;
                        }
+               }
                /* FALLTHROUGH */
        case 1:
                if (ecp->addr1.lno == 0) {
@@ -2117,7 +2119,7 @@ ex_load(SCR *sp)
 
                        /* If it's a global/v command, fix up the last line. */
                        if (FL_ISSET(ecp->agv_flags,
-                           AGV_GLOBAL | AGV_V) && ecp->range_lno != OOBLNO)
+                           AGV_GLOBAL | AGV_V) && ecp->range_lno != OOBLNO) {
                                if (db_exist(sp, ecp->range_lno))
                                        sp->lno = ecp->range_lno;
                                else {
@@ -2126,6 +2128,7 @@ ex_load(SCR *sp)
                                        if (sp->lno == 0)
                                                sp->lno = 1;
                                }
+                       }
                        free(ecp->o_cp);
                }
 

Modified: head/contrib/nvi/ex/ex.h
==============================================================================
--- head/contrib/nvi/ex/ex.h    Thu Oct  1 04:26:46 2020        (r366308)
+++ head/contrib/nvi/ex/ex.h    Thu Oct  1 04:46:23 2020        (r366309)
@@ -55,12 +55,12 @@ extern EXCMDLIST const cmds[];              /* Table of ex 
command
  * at any time, and most of them won't work well if a file hasn't yet been read
  * in.  Historic vi generally took the easy way out and dropped core.
  */
-#define        NEEDFILE(sp, cmdp) {                                            
\
+#define        NEEDFILE(sp, cmdp) do {                                         
\
        if ((sp)->ep == NULL) {                                         \
                ex_wemsg(sp, (cmdp)->cmd->name, EXM_NOFILEYET);         \
                return (1);                                             \
        }                                                               \
-}
+} while (0)
 
 /* Range structures for global and @ commands. */
 typedef struct _range RANGE;
@@ -102,12 +102,12 @@ struct _excmd {
        u_int8_t  agv_flags;
 
        /* Clear the structure before each ex command. */
-#define        CLEAR_EX_CMD(cmdp) {                                            
\
+#define        CLEAR_EX_CMD(cmdp) do {                                         
\
        u_int32_t L__f = F_ISSET(cmdp, E_PRESERVE);                     \
        memset(&((cmdp)->buffer), 0, ((char *)&(cmdp)->flags -          \
            (char *)&((cmdp)->buffer)) + sizeof((cmdp)->flags));        \
        F_SET(cmdp, L__f);                                              \
-}
+} while (0)
 
        CHAR_T    buffer;               /* Command: named buffer. */
        recno_t   lineno;               /* Command: line number. */

Modified: head/contrib/nvi/ex/ex_argv.c
==============================================================================
--- head/contrib/nvi/ex/ex_argv.c       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/ex/ex_argv.c       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -611,9 +611,17 @@ argv_flt_path(SCR *sp, EXCMD *excp, CHAR_T *path, size
                if (nlen == 0) {
                        if (dp->d_name[0] == '.')
                                continue;
+#ifdef HAVE_DIRENT_D_NAMLEN
                        len = dp->d_namlen;
+#else
+                       len = strlen(dp->d_name);
+#endif
                } else {
+#ifdef HAVE_DIRENT_D_NAMLEN
                        len = dp->d_namlen;
+#else
+                       len = strlen(dp->d_name);
+#endif
                        if (len < nlen || memcmp(dp->d_name, name, nlen))
                                continue;
                }

Modified: head/contrib/nvi/ex/ex_bang.c
==============================================================================
--- head/contrib/nvi/ex/ex_bang.c       Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/ex/ex_bang.c       Thu Oct  1 04:46:23 2020        
(r366309)
@@ -96,7 +96,7 @@ ex_bang(SCR *sp, EXCMD *cmdp)
         */
        if (cmdp->addrcnt == 0) {
                msg = NULL;
-               if (sp->ep != NULL && F_ISSET(sp->ep, F_MODIFIED))
+               if (sp->ep != NULL && F_ISSET(sp->ep, F_MODIFIED)) {
                        if (O_ISSET(sp, O_AUTOWRITE)) {
                                if (file_aw(sp, FS_ALL))
                                        return (0);
@@ -105,6 +105,7 @@ ex_bang(SCR *sp, EXCMD *cmdp)
                                msg = msg_cat(sp,
                                    "303|File modified since last write.",
                                    NULL);
+               }
 
                /* If we're still in a vi screen, move out explicitly. */
                INT2CHAR(sp, ap->bp, ap->len+1, np, nlen);

Modified: head/contrib/nvi/ex/ex_cscope.c
==============================================================================
--- head/contrib/nvi/ex/ex_cscope.c     Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/ex/ex_cscope.c     Thu Oct  1 04:46:23 2020        
(r366309)
@@ -261,7 +261,7 @@ cscope_add(SCR *sp, EXCMD *cmdp, CHAR_T *dname)
        csc->dname = csc->buf;
        csc->dlen = len;
        memcpy(csc->dname, np, len);
-       csc->mtim = sb.st_mtimespec;
+       csc->mtim = sb.st_mtim;
 
        /* Get the search paths for the cscope. */
        if (get_paths(sp, csc))
@@ -411,7 +411,8 @@ err:                if (to_cs[0] != -1)
                        free(dn);
                        goto nomem;
                }
-               (void)asprintf(&cmd, CSCOPE_CMD_FMT, dn, dbn);
+               if (asprintf(&cmd, CSCOPE_CMD_FMT, dn, dbn) == -1)
+                       cmd = NULL;
                free(dbn);
                free(dn);
                if (cmd == NULL) {
@@ -812,7 +813,7 @@ csc_file(SCR *sp, CSC *csc, char *name, char **dirp, s
                        *dirp = *pp;
                        *dlenp = strlen(*pp);
                        *isolderp = timespeccmp(
-                           &sb.st_mtimespec, &csc->mtim, <);
+                           &sb.st_mtim, &csc->mtim, <);
                        return;
                }
                free(buf);
@@ -843,7 +844,7 @@ csc_help(SCR *sp, char *cmd)
 {
        CC const *ccp;
 
-       if (cmd != NULL && *cmd != '\0')
+       if (cmd != NULL && *cmd != '\0') {
                if ((ccp = lookup_ccmd(cmd)) == NULL) {
                        ex_printf(sp,
                            "%s doesn't match any cscope command\n", cmd);
@@ -854,6 +855,7 @@ csc_help(SCR *sp, char *cmd)
                        ex_printf(sp, "  Usage: %s\n", ccp->usage_msg);
                        return (0);
                }
+       }
 
        ex_printf(sp, "cscope commands:\n");
        for (ccp = cscope_cmds; ccp->name != NULL; ++ccp)

Modified: head/contrib/nvi/ex/ex_filter.c
==============================================================================
--- head/contrib/nvi/ex/ex_filter.c     Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/ex/ex_filter.c     Thu Oct  1 04:46:23 2020        
(r366309)
@@ -174,11 +174,12 @@ err:              if (input[0] != -1)
                if (ex_readfp(sp, "filter", ofp, fm, &nread, 1))
                        rval = 1;
                sp->rptlines[L_ADDED] += nread;
-               if (ftype == FILTER_READ)
+               if (ftype == FILTER_READ) {
                        if (fm->lno == 0)
                                rp->lno = nread;
                        else
                                rp->lno += nread;
+               }
                goto uwait;
        }
 

Modified: head/contrib/nvi/ex/ex_global.c
==============================================================================
--- head/contrib/nvi/ex/ex_global.c     Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/ex/ex_global.c     Thu Oct  1 04:46:23 2020        
(r366309)
@@ -112,11 +112,12 @@ usage:            ex_emsg(sp, cmdp->cmd->usage, 
EXM_USAGE);
                        *t = '\0';
                        break;
                }
-               if (p[0] == '\\')
+               if (p[0] == '\\') {
                        if (p[1] == delim)
                                ++p;
                        else if (p[1] == '\\')
                                *t++ = *p++;
+               }
                *t++ = *p++;
        }
 

Modified: head/contrib/nvi/ex/ex_script.c
==============================================================================
--- head/contrib/nvi/ex/ex_script.c     Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/ex/ex_script.c     Thu Oct  1 04:46:23 2020        
(r366309)
@@ -32,6 +32,8 @@
 #include <unistd.h>
 #ifdef HAVE_LIBUTIL_H
 #include <libutil.h>
+#elif defined HAVE_PTY_H
+#include <pty.h>
 #else
 #include <util.h>
 #endif

Modified: head/contrib/nvi/ex/ex_shell.c
==============================================================================
--- head/contrib/nvi/ex/ex_shell.c      Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/ex/ex_shell.c      Thu Oct  1 04:46:23 2020        
(r366309)
@@ -48,8 +48,7 @@ ex_shell(SCR *sp, EXCMD *cmdp)
         * XXX
         * Assumes all shells use -i.
         */
-       (void)asprintf(&buf, "%s -i", O_STR(sp, O_SHELL));
-       if (buf == NULL) {
+       if (asprintf(&buf, "%s -i", O_STR(sp, O_SHELL)) == -1) {
                msgq(sp, M_SYSERR, NULL);
                return (1);
        }

Modified: head/contrib/nvi/ex/ex_subst.c
==============================================================================
--- head/contrib/nvi/ex/ex_subst.c      Thu Oct  1 04:26:46 2020        
(r366308)
+++ head/contrib/nvi/ex/ex_subst.c      Thu Oct  1 04:46:23 2020        
(r366309)
@@ -115,11 +115,12 @@ subagain: return (ex_subagain(sp, cmdp));
                        *t = '\0';
                        break;
                }
-               if (p[0] == '\\')
+               if (p[0] == '\\') {
                        if (p[1] == delim)
                                ++p;
                        else if (p[1] == '\\')
                                *t++ = *p++;
+               }
                *t++ = *p++;
        }
 
@@ -296,7 +297,7 @@ ex_subtilde(SCR *sp, EXCMD *cmdp)
  * when the replacement is done.  Don't change it unless you're *damned*
  * confident.
  */
-#define        NEEDNEWLINE(sp) {                                               
\
+#define        NEEDNEWLINE(sp) do {                                            
\
        if (sp->newl_len == sp->newl_cnt) {                             \
                sp->newl_len += 25;                                     \
                REALLOC(sp, sp->newl, size_t *,                         \
@@ -306,9 +307,9 @@ ex_subtilde(SCR *sp, EXCMD *cmdp)
                        return (1);                                     \
                }                                                       \
        }                                                               \
-}
+} while (0)
 
-#define        BUILD(sp, l, len) {                                             
\
+#define        BUILD(sp, l, len) do {                                          
\
        if (lbclen + (len) > lblen) {                                   \
                lblen = p2roundup(MAX(lbclen + (len), 256));            \
                REALLOC(sp, lb, CHAR_T *, lblen * sizeof(CHAR_T));      \
@@ -319,9 +320,9 @@ ex_subtilde(SCR *sp, EXCMD *cmdp)
        }                                                               \
        MEMCPY(lb + lbclen, l, len);                                    \
        lbclen += len;                                                  \
-}
+} while (0)
 
-#define        NEEDSP(sp, len, pnt) {                                          
\
+#define        NEEDSP(sp, len, pnt) do {                                       
\
        if (lbclen + (len) > lblen) {                                   \
                lblen = p2roundup(MAX(lbclen + (len), 256));            \
                REALLOC(sp, lb, CHAR_T *, lblen * sizeof(CHAR_T));      \
@@ -331,7 +332,7 @@ ex_subtilde(SCR *sp, EXCMD *cmdp)
                }                                                       \
                pnt = lb + lbclen;                                      \
        }                                                               \
-}
+} while (0)
 
 static int
 s(SCR *sp, EXCMD *cmdp, CHAR_T *s, regex_t *re, u_int flags)
@@ -584,7 +585,7 @@ nextmatch:  match[0].rm_so = 0;
                        empty_ok = 1;
                        if (len == 0)
                                goto endmatch;
-                       BUILD(sp, s + offset, 1)
+                       BUILD(sp, s + offset, 1);
                        ++offset;
                        --len;
                        goto nextmatch;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to