I've proposed to switch nvi from its bundled regex to tre for better
searching multibyte strings. For this purpose, I'm planning to make
tre usable from userland by installing headers etc.

This time, I've updated patch for tre (nvi parts are left untouched):

- change ABI and bump shlib_version

Currently, tre is compiled with TRE_USE_SYSTEM_REGEX_H, by which it
borrows definitions of flags etc from /usr/include/regex.h. This means
that ABI is somehow obscurely changed when libc's regex is modified.

To make things clear, I prefer not using TRE_USE_SYSTEM_REGEX_H and
defining everything necessary by its own. This brings about ABI changes
for libtre. This may not break everything, since it is used only by its
bundled utility, agrep(1), at this moment.

- Regen config.h and tm-config.h

In order to stop using TRE_USE_SYSTEM_REGEX_H, autotools stuffs are
regenerated. Also, according to external/bsd/tre/lib/Makefile, tre is
configured not to use alloca(3), but it is actually not. This change
also fixes it. (By this change some feature-test macros like
HAVE_INTTYPES_H are disabled. This seems strange, but these macros are
not actually referenced by sources.)

- Install documents and pkgconfig file

Any comments or suggestions are welcomed not only for this parts, but
also for changes for nvi.

Without any objections, I will commit them in the weekend.

rin

On 2017/11/13 13:24, Rin Okuyama wrote:
By default, nvi uses its bundled regex which handles wchar_t strings.
However, it is still buggy for wide chars. On the other hand, tre also
provides wchar_t version of regex routines, that are "much better" as
I can see. For example, bracket expressions work fine at least for
ja_JP.UTF-8 and ja_JP.eucJP locales, that do not with the nvi-bundled
regex. I therefore propose to switch nvi from the bundled regex to tre.
For this purpose,

- Install headers from tre into /usr/include/tre, that may also be
  useful for 3rd party softwares.
  (Alternatively: do not install them, and nvi uses them directly from
  external/bsd/tre/somewhere)

- Build /rescue/vi (and other crunched-binary versions of nvi in
  miniroot) with USE_WIDECHAR == "no" in order not to link the extra
  library into them. Actually, this is not a real problem; they cannot
  handle wide chars even if they are built with USE_WIDECHAR == "yes",
  because locale stuffs in libc do not work for statically-linked
  binaries.

Any comments or suggestions?

rin
diff -Naru external/bsd/tre/Makefile.orig external/bsd/tre/Makefile
--- external/bsd/tre/Makefile.orig      2011-11-06 07:39:12.000000000 +0900
+++ external/bsd/tre/Makefile   2017-11-15 01:32:08.469874617 +0900
@@ -1,3 +1,3 @@
 # $NetBSD: Makefile,v 1.1 2011/11/05 22:39:12 christos Exp $
-SUBDIR=        lib .WAIT bin
+SUBDIR=        lib .WAIT bin doc
 .include "bsd.subdir.mk"
diff -Naru external/bsd/tre/Makefile.inc.orig external/bsd/tre/Makefile.inc
--- external/bsd/tre/Makefile.inc.orig  2011-11-06 07:39:12.000000000 +0900
+++ external/bsd/tre/Makefile.inc       2017-11-14 21:49:18.685280836 +0900
@@ -6,8 +6,5 @@
 
 CPPFLAGS+=     -I${TREDIST}/lib -I${.CURDIR}/../include
 CPPFLAGS+=     -DHAVE_CONFIG_H=1
-CPPFLAGS+=     -DTRE_SYSTEM_REGEX_H_PATH=\"${NETBSDSRCDIR}/include/regex.h\"
-CPPFLAGS+=     -DTRE_USE_SYSTEM_REGEX_H=1
-
 
 WARNS= 4
diff -Naru external/bsd/tre/dist/lib/tre.h.orig external/bsd/tre/dist/lib/tre.h
--- external/bsd/tre/dist/lib/tre.h.orig        2011-11-06 07:39:13.000000000 
+0900
+++ external/bsd/tre/dist/lib/tre.h     2017-11-14 21:51:51.487785598 +0900
@@ -98,7 +98,8 @@
   REG_BADBR,           /* Invalid content of {} */
   REG_ERANGE,          /* Invalid use of range operator */
   REG_ESPACE,          /* Out of memory.  */
-  REG_BADRPT            /* Invalid use of repetition operators. */
+  REG_BADRPT,           /* Invalid use of repetition operators. */
+  REG_INVARG            /* Invalid arguments. */
 } reg_errcode_t;
 
 /* POSIX tre_regcomp() flags. */
@@ -121,6 +122,9 @@
 #define REG_APPROX_MATCHER      (REG_NOTEOL << 1)
 #define REG_BACKTRACKING_MATCHER (REG_APPROX_MATCHER << 1)
 
+/* BSD extension tre_regexec() flag. */
+#define REG_STARTEND (REG_BACKTRACKING_MATCHER << 1)
+
 #endif /* !TRE_USE_SYSTEM_REGEX_H */
 
 /* REG_NOSPEC and REG_LITERAL mean the same thing. */
diff -Naru external/bsd/tre/doc/Makefile.orig external/bsd/tre/doc/Makefile
--- external/bsd/tre/doc/Makefile.orig  1970-01-01 09:00:00.000000000 +0900
+++ external/bsd/tre/doc/Makefile       2017-11-15 01:29:51.626326196 +0900
@@ -0,0 +1,12 @@
+# $NetBSD$
+
+.include <bsd.init.mk>
+
+.PATH: ${TREDIST}/doc
+
+.if ${MKDOC} != "no"
+FILESDIR=      /usr/share/doc/reference/ref3/tre
+FILES=         default.css tre-api.html tre-syntax.html
+.endif
+
+.include <bsd.files.mk>
diff -Naru external/bsd/tre/include/config.h.orig 
external/bsd/tre/include/config.h
--- external/bsd/tre/include/config.h.orig      2011-11-06 07:39:13.000000000 
+0900
+++ external/bsd/tre/include/config.h   2017-11-14 22:08:29.299809132 +0900
@@ -14,7 +14,7 @@
 /* #undef ENABLE_NLS */
 
 /* Define to 1 if you have `alloca', as a function or macro. */
-#define HAVE_ALLOCA 1
+/* #undef HAVE_ALLOCA */
 
 /* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
    */
@@ -48,7 +48,7 @@
 #define HAVE_ICONV 1
 
 /* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
+/* #undef HAVE_INTTYPES_H */
 
 /* Define to 1 if you have the `isascii' function. */
 #define HAVE_ISASCII 1
@@ -81,34 +81,34 @@
 #define HAVE_MBSTATE_T 1
 
 /* Define to 1 if you have the `mbtowc' function or macro. */
-#define HAVE_MBTOWC 1
+/* #undef HAVE_MBTOWC */
 
 /* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
+/* #undef HAVE_MEMORY_H */
 
 /* Define to 1 if you have the <regex.h> header file. */
-#define HAVE_REGEX_H 1
+/* #undef HAVE_REGEX_H */
 
 /* Define to 1 if the system has the type `reg_errcode_t'. */
 /* #undef HAVE_REG_ERRCODE_T */
 
 /* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
+/* #undef HAVE_STDINT_H */
 
 /* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
+/* #undef HAVE_STDLIB_H */
 
 /* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
+/* #undef HAVE_STRINGS_H */
 
 /* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
+/* #undef HAVE_STRING_H */
 
 /* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
+/* #undef HAVE_SYS_STAT_H */
 
 /* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
+/* #undef HAVE_SYS_TYPES_H */
 
 /* Define to 1 if you have the `towlower' function or macro. */
 #define HAVE_TOWLOWER 1
@@ -117,7 +117,7 @@
 #define HAVE_TOWUPPER 1
 
 /* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
+/* #undef HAVE_UNISTD_H */
 
 /* Define to 1 if you have the <wchar.h> header file. */
 #define HAVE_WCHAR_H 1
@@ -141,7 +141,7 @@
 #define HAVE_WCSRTOMBS 1
 
 /* Define to 1 if you have the `wcstombs' function or macro. */
-#define HAVE_WCSTOMBS 1
+/* #undef HAVE_WCSTOMBS */
 
 /* Define to 1 if you have the `wctype' function or macro. */
 #define HAVE_WCTYPE 1
@@ -198,14 +198,14 @@
 
 /* Define to a field in the regex_t struct where TRE should store a pointer to
    the internal tre_tnfa_t structure */
-#define TRE_REGEX_T_FIELD re_g
+#define TRE_REGEX_T_FIELD value
 
 /* Define to the absolute path to the system regex.h */
 /* #undef TRE_SYSTEM_REGEX_H_PATH */
 
 /* Define if you want TRE to use alloca() instead of malloc() when allocating
    memory needed for regexec operations. */
-#define TRE_USE_ALLOCA 1
+/* #undef TRE_USE_ALLOCA */
 
 /* Define to include the system regex.h from TRE regex.h */
 /* #undef TRE_USE_SYSTEM_REGEX_H */
@@ -232,7 +232,7 @@
 /* #undef WCHAR_MAX */
 
 /* Define if wchar_t is signed */
-#define WCHAR_T_SIGNED 1
+/* #undef WCHAR_T_SIGNED */
 
 /* Define if wchar_t is unsigned */
 /* #undef WCHAR_T_UNSIGNED */
diff -Naru external/bsd/tre/include/tre-config.h.orig 
external/bsd/tre/include/tre-config.h
--- external/bsd/tre/include/tre-config.h.orig  2011-11-06 07:39:13.000000000 
+0900
+++ external/bsd/tre/include/tre-config.h       2017-11-14 22:08:36.129772619 
+0900
@@ -11,7 +11,7 @@
 /* #undef HAVE_REG_ERRCODE_T */
 
 /* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
+/* #undef HAVE_SYS_TYPES_H */
 
 /* Define to 1 if you have the <wchar.h> header file. */
 #define HAVE_WCHAR_H 1
diff -Naru external/bsd/tre/lib/Makefile.orig external/bsd/tre/lib/Makefile
--- external/bsd/tre/lib/Makefile.orig  2011-11-06 19:55:27.000000000 +0900
+++ external/bsd/tre/lib/Makefile       2017-11-15 03:12:20.065538204 +0900
@@ -5,12 +5,14 @@
 #      ./configure --prefix=/usr --without-alloca
 
 .include <bsd.own.mk>
-TREDIST=       ${.CURDIR}/../dist
+TREDIR=        ${.CURDIR}/..
 
 # external tre sources
-.PATH: ${TREDIST}/lib
+.PATH: ${TREDIR}/dist/lib
+.PATH: ${TREDIR}/include
 
 CPPFLAGS+=     -I${.CURDIR}
+CFLAGS+=       -Wno-stack-protector
 
 LIB=   tre
 
@@ -21,6 +23,23 @@
 
 WARNS= 4
 
-.include <bsd.lib.mk>
+INCS=  regex.h tre-config.h tre.h
+INCSDIR=/usr/include/tre
 
-CFLAGS+=       -Wno-stack-protector
+FILES+=                        tre.pc
+FILESOWN_tre.pc=       ${BINOWN}
+FILESGRP_tre.pc=       ${BINGRP}
+FILESMODE_tre.pc=      ${NONBINMODE}
+FILESDIR_tre.pc=       /usr/lib/pkgconfig
+CLEANFILES+=           tre.pc
+
+tre.pc:        config.h tre.pc.in
+       @(V=$$( (echo '#include "config.h"'; echo TRE_VERSION) | \
+           ${HOST_CC} -E -I${TREDIR}/include - | tail -1 | tr -d '"') && \
+           ${TOOL_SED} -e s/@VERSION@/$$V/ < ${.CURDIR}/tre.pc.in \
+           > ${.TARGET})
+
+all: tre.pc
+dependall: all
+
+.include <bsd.lib.mk>
diff -Naru external/bsd/tre/lib/shlib_version.orig 
external/bsd/tre/lib/shlib_version
--- external/bsd/tre/lib/shlib_version.orig     2011-11-06 07:39:13.000000000 
+0900
+++ external/bsd/tre/lib/shlib_version  2017-11-14 21:49:07.353647508 +0900
@@ -1,2 +1,2 @@
-major=0
-minor=8
+major=1
+minor=0
diff -Naru external/bsd/tre/lib/tre.pc.in.orig external/bsd/tre/lib/tre.pc.in
--- external/bsd/tre/lib/tre.pc.in.orig 1970-01-01 09:00:00.000000000 +0900
+++ external/bsd/tre/lib/tre.pc.in      2017-11-15 03:06:04.320924817 +0900
@@ -0,0 +1,10 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: TRE
+Description: TRE regexp matching library
+Version: @VERSION@
+Libs: -L${libdir} -ltre   
+Cflags: -I${includedir} 
Index: distrib/sets/lists/base/mi
===================================================================
RCS file: /home/netbsd/src/distrib/sets/lists/base/mi,v
retrieving revision 1.1164
diff -u -r1.1164 mi
--- distrib/sets/lists/base/mi  24 Oct 2017 02:22:09 -0000      1.1164
+++ distrib/sets/lists/base/mi  14 Nov 2017 16:55:06 -0000
@@ -1219,6 +1219,7 @@
 ./usr/include/ss                               base-obsolete           obsolete
 ./usr/include/ssp                              base-c-usr
 ./usr/include/sys                              base-c-usr
+./usr/include/tre                              base-c-usr
 ./usr/include/trousers                         base-c-usr
 ./usr/include/tss                              base-c-usr
 ./usr/include/ufs                              base-c-usr
@@ -2100,6 +2101,7 @@
 ./usr/share/doc/reference/ref3/sockets         base-psd-share
 ./usr/share/doc/reference/ref3/sockets-advanced        base-psd-share
 ./usr/share/doc/reference/ref3/sysman          base-psd-share
+./usr/share/doc/reference/ref3/tre             base-htmldoc-share
 ./usr/share/doc/reference/ref4                 base-sys-share
 ./usr/share/doc/reference/ref5                 base-sys-share
 ./usr/share/doc/reference/ref5/timed           base-smm-share
Index: distrib/sets/lists/base/shl.mi
===================================================================
RCS file: /home/netbsd/src/distrib/sets/lists/base/shl.mi,v
retrieving revision 1.824
diff -u -r1.824 shl.mi
--- distrib/sets/lists/base/shl.mi      25 Oct 2017 06:32:59 -0000      1.824
+++ distrib/sets/lists/base/shl.mi      14 Nov 2017 13:49:46 -0000
@@ -816,8 +816,8 @@
 ./usr/lib/libtpm_unseal.so.1                   base-sys-shlib          
compatfile,tpm
 ./usr/lib/libtpm_unseal.so.1.0                 base-sys-shlib          
compatfile,tpm
 ./usr/lib/libtre.so                            base-sys-shlib          
compatfile
-./usr/lib/libtre.so.0                          base-sys-shlib          
compatfile
-./usr/lib/libtre.so.0.8                                base-sys-shlib          
compatfile
+./usr/lib/libtre.so.1                          base-sys-shlib          
compatfile
+./usr/lib/libtre.so.1.0                                base-sys-shlib          
compatfile
 ./usr/lib/libtspi.so                           base-sys-shlib          
compatfile,tpm
 ./usr/lib/libtspi.so.3                         base-sys-shlib          
compatfile,tpm
 ./usr/lib/libtspi.so.3.0                       base-sys-shlib          
compatfile,tpm
Index: distrib/sets/lists/comp/mi
===================================================================
RCS file: /home/netbsd/src/distrib/sets/lists/comp/mi,v
retrieving revision 1.2159
diff -u -r1.2159 mi
--- distrib/sets/lists/comp/mi  7 Nov 2017 22:20:05 -0000       1.2159
+++ distrib/sets/lists/comp/mi  14 Nov 2017 16:34:32 -0000
@@ -3024,6 +3024,9 @@
 ./usr/include/termios.h                                comp-c-include
 ./usr/include/threadlib.h                      comp-obsolete           obsolete
 ./usr/include/time.h                           comp-c-include
+./usr/include/tre/regex.h                      comp-c-include
+./usr/include/tre/tre-config.h                 comp-c-include
+./usr/include/tre/tre.h                                comp-c-include
 ./usr/include/trousers/trousers.h              comp-c-include          tpm
 ./usr/include/trousers/tss.h                   comp-c-include          tpm
 ./usr/include/tss/compat11b.h                  comp-c-include          tpm
@@ -3689,6 +3692,7 @@
 ./usr/lib/pkgconfig/lutok.pc                   comp-crypto-lib         
kyua,share
 ./usr/lib/pkgconfig/openssl.pc                 comp-crypto-lib         share
 ./usr/lib/pkgconfig/sqlite3.pc                 comp-c-lib
+./usr/lib/pkgconfig/tre.pc                     comp-c-lib
 ./usr/lib/pkgconfig/zlib.pc                    comp-c-lib
 ./usr/libdata/ldscripts/kmodule                        comp-util-share         
binutils,kmod
 ./usr/libdata/lint/llib-larchive.ln            comp-c-lintlib          lint
Index: distrib/sets/lists/debug/shl.mi
===================================================================
RCS file: /home/netbsd/src/distrib/sets/lists/debug/shl.mi,v
retrieving revision 1.187
diff -u -r1.187 shl.mi
--- distrib/sets/lists/debug/shl.mi     4 Nov 2017 16:21:49 -0000       1.187
+++ distrib/sets/lists/debug/shl.mi     14 Nov 2017 13:52:22 -0000
@@ -275,7 +275,7 @@
 ./usr/libdata/debug/usr/lib/libstdc++.so.8.0.debug             comp-sys-debug  
debug,compatfile,gcc=53,cxx,libstdcxx
 ./usr/libdata/debug/usr/lib/libterminfo.so.1.0.debug           comp-sys-debug  
debug,compatfile
 ./usr/libdata/debug/usr/lib/libtpm_unseal.so.1.0.debug         comp-tpm-debug  
debug,compatfile,tpm
-./usr/libdata/debug/usr/lib/libtre.so.0.8.debug                        
comp-sys-debug  debug,compatfile
+./usr/libdata/debug/usr/lib/libtre.so.1.0.debug                        
comp-sys-debug  debug,compatfile
 ./usr/libdata/debug/usr/lib/libtspi.so.3.0.debug               comp-tpm-debug  
debug,compatfile,tpm
 ./usr/libdata/debug/usr/lib/libubsan.so.1.0.debug              comp-sys-debug  
debug,compatfile,gcc=53
 ./usr/libdata/debug/usr/lib/libukfs.so.1.0.debug               comp-sys-debug  
debug,compatfile,rump
Index: distrib/sets/lists/misc/mi
===================================================================
RCS file: /home/netbsd/src/distrib/sets/lists/misc/mi,v
retrieving revision 1.205
diff -u -r1.205 mi
--- distrib/sets/lists/misc/mi  21 May 2017 15:28:38 -0000      1.205
+++ distrib/sets/lists/misc/mi  14 Nov 2017 16:52:22 -0000
@@ -749,6 +749,9 @@
 ./usr/share/doc/reference/ref3/sysman/sysman7.png              misc-psd-doc    
        doc,html,groffhtmldoc
 ./usr/share/doc/reference/ref3/sysman/sysman8.png              misc-psd-doc    
        doc,html,groffhtmldoc
 ./usr/share/doc/reference/ref3/sysman/sysman9.png              misc-psd-doc    
        doc,html,groffhtmldoc
+./usr/share/doc/reference/ref3/tre/default.css                 
misc-reference-share    doc
+./usr/share/doc/reference/ref3/tre/tre-api.html                        
misc-reference-share    doc
+./usr/share/doc/reference/ref3/tre/tre-syntax.html             
misc-reference-share    doc
 ./usr/share/doc/reference/ref5/timed/timed.html                        
misc-smm-doc            doc,html,groffhtmldoc
 ./usr/share/doc/reference/ref5/timed/timed.ps.gz               misc-smm-doc    
        doc
 ./usr/share/doc/reference/ref5/timed/timed.txt                 misc-smm-doc    
        doc
Index: etc/mtree/NetBSD.dist.base
===================================================================
RCS file: /home/netbsd/src/etc/mtree/NetBSD.dist.base,v
retrieving revision 1.163
diff -u -r1.163 NetBSD.dist.base
--- etc/mtree/NetBSD.dist.base  21 Oct 2017 05:30:48 -0000      1.163
+++ etc/mtree/NetBSD.dist.base  14 Nov 2017 16:53:40 -0000
@@ -235,6 +235,7 @@
 ./usr/include/security
 ./usr/include/ssp
 ./usr/include/sys
+./usr/include/tre
 ./usr/include/trousers
 ./usr/include/tss
 ./usr/include/ufs
@@ -323,6 +324,7 @@
 ./usr/share/doc/reference/ref3/sockets
 ./usr/share/doc/reference/ref3/sockets-advanced
 ./usr/share/doc/reference/ref3/sysman
+./usr/share/doc/reference/ref3/tre
 ./usr/share/doc/reference/ref4
 ./usr/share/doc/reference/ref5
 ./usr/share/doc/reference/ref5/timed
Index: external/bsd/nvi/dist/common/multibyte.h
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/dist/common/multibyte.h,v
retrieving revision 1.4
diff -u -r1.4 multibyte.h
--- external/bsd/nvi/dist/common/multibyte.h    13 Nov 2017 01:34:59 -0000      
1.4
+++ external/bsd/nvi/dist/common/multibyte.h    13 Nov 2017 08:42:01 -0000
@@ -113,4 +113,12 @@
        ((void *)((char *)MEMCPY(p, t, len) + (len) * sizeof(*(p))))
 #define SIZE(w)                (sizeof(w)/sizeof(*w))
 
+#if defined(USE_WIDECHAR) && defined(HAVE_TRE)
+#define        REGCOMP regwcomp
+#define        REGEXEC regwexec
+#else
+#define        REGCOMP regcomp
+#define        REGEXEC regexec
+#endif
+
 #endif
Index: external/bsd/nvi/dist/common/search.c
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/dist/common/search.c,v
retrieving revision 1.3
diff -u -r1.3 search.c
--- external/bsd/nvi/dist/common/search.c       26 Jan 2014 21:43:45 -0000      
1.3
+++ external/bsd/nvi/dist/common/search.c       13 Nov 2017 08:42:02 -0000
@@ -237,7 +237,7 @@
                    lno, coff, len != 0 ? len - 1 : len);
 #endif
                /* Search the line. */
-               eval = regexec(&sp->re_c, l, 1, match,
+               eval = REGEXEC(&sp->re_c, l, 1, match,
                    (match[0].rm_so == 0 ? 0 : REG_NOTBOL) | REG_STARTEND);
                if (eval == REG_NOMATCH)
                        continue;
@@ -374,7 +374,7 @@
                    "B search: %lu from 0 to %qu\n", lno, match[0].rm_eo);
 #endif
                /* Search the line. */
-               eval = regexec(&sp->re_c, l, 1, match,
+               eval = REGEXEC(&sp->re_c, l, 1, match,
                    ((size_t)match[0].rm_eo == len ? 0 : REG_NOTEOL) | 
REG_STARTEND);
                if (eval == REG_NOMATCH)
                        continue;
@@ -409,7 +409,7 @@
                        if ((size_t)match[0].rm_so >= len)
                                break;
                        match[0].rm_eo = len;
-                       eval = regexec(&sp->re_c, l, 1, match,
+                       eval = REGEXEC(&sp->re_c, l, 1, match,
                            (match[0].rm_so == 0 ? 0 : REG_NOTBOL) |
                            REG_STARTEND);
                        if (eval == REG_NOMATCH)
Index: external/bsd/nvi/dist/ex/ex_global.c
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/dist/ex/ex_global.c,v
retrieving revision 1.5
diff -u -r1.5 ex_global.c
--- external/bsd/nvi/dist/ex/ex_global.c        26 Jan 2014 21:43:45 -0000      
1.5
+++ external/bsd/nvi/dist/ex/ex_global.c        13 Nov 2017 08:42:02 -0000
@@ -216,7 +216,7 @@
                match[0].rm_so = 0;
                match[0].rm_eo = len;
                switch (eval =
-                   regexec(&sp->re_c, dbp, 0, match, REG_STARTEND)) {
+                   REGEXEC(&sp->re_c, dbp, 0, match, REG_STARTEND)) {
                case 0:
                        if (cmd == V)
                                continue;
Index: external/bsd/nvi/dist/ex/ex_subst.c
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/dist/ex/ex_subst.c,v
retrieving revision 1.4
diff -u -r1.4 ex_subst.c
--- external/bsd/nvi/dist/ex/ex_subst.c 26 Jan 2014 21:43:45 -0000      1.4
+++ external/bsd/nvi/dist/ex/ex_subst.c 13 Nov 2017 08:42:02 -0000
@@ -557,7 +557,7 @@
                match[0].rm_eo = len;
 
                /* Get the next match. */
-               eval = regexec(re, st + offset, 10, match, eflags);
+               eval = REGEXEC(re, st + offset, 10, match, eflags);
 
                /*
                 * There wasn't a match or if there was an error, deal with
@@ -992,7 +992,7 @@
         * Regcomp isn't 8-bit clean, so we just lost if the pattern
         * contained a nul.  Bummer!
         */
-       if ((rval = regcomp(rep, ptrn, /* plen, */ reflags)) != 0) {
+       if ((rval = REGCOMP(rep, ptrn, /* plen, */ reflags)) != 0) {
                if (LF_ISSET(SEARCH_MSG))
                        re_error(sp, rval, rep); 
                return (1);
Index: external/bsd/nvi/usr.bin/nvi/Makefile
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/usr.bin/nvi/Makefile,v
retrieving revision 1.12
diff -u -r1.12 Makefile
--- external/bsd/nvi/usr.bin/nvi/Makefile       13 Nov 2017 04:09:41 -0000      
1.12
+++ external/bsd/nvi/usr.bin/nvi/Makefile       13 Nov 2017 08:42:02 -0000
@@ -2,7 +2,11 @@
 
 .include <bsd.own.mk>
 
+.ifndef SMALLPROG
 USE_WIDECHAR?=yes
+.else
+USE_WIDECHAR=no
+.endif
 
 CWARNFLAGS.clang+=     -Wno-uninitialized -Wno-format-security
 .if ${USE_WIDECHAR} != "yes"
@@ -57,8 +61,12 @@
 
 # For wide char support
 .if ${USE_WIDECHAR} == "yes"
-SRCS+= regcomp.c regerror.c regexec.c regfree.c
-CPPFLAGS+=-I${DIST}/regex -D__REGEX_PRIVATE -DUSE_WIDECHAR
+CPPFLAGS+=-DUSE_WIDECHAR
+CPPFLAGS+=-I${DESTDIR}/usr/include/tre -DHAVE_TRE
+LDADD+=        -ltre
+DPADD+=        ${LIBTRE}
+#SRCS+=        regcomp.c regerror.c regexec.c regfree.c
+#CPPFLAGS+=-I${DIST}/regex -D__REGEX_PRIVATE
 .endif
 
 # For db3 db1 emulation
Index: rescue/Makefile
===================================================================
RCS file: /home/netbsd/src/rescue/Makefile,v
retrieving revision 1.33
diff -u -r1.33 Makefile
--- rescue/Makefile     8 Oct 2017 15:02:33 -0000       1.33
+++ rescue/Makefile     12 Nov 2017 15:06:26 -0000
@@ -20,10 +20,12 @@
 CRUNCHBIN=     rescue
 CRUNCHENV=     RESCUEDIR=${RESCUEDIR}
 SMALLPROG=     0
-LISTS=         ${.CURDIR}/list
 TARGETDIR=     ${DESTDIR}/rescue
 PARSELISTENV+=  TARGETDIR=${TARGETDIR:Q}
 
+LISTS=         ${.CURDIR}/list
+CRUNCHENV+=    USE_WIDECHAR=no         # for nvi
+
 .for f in ldconfig
 PROG_${f}!=    cd ${NETBSDSRCDIR}/sbin/${f} && ${MAKE} -V PROG
 .if (${PROG_${f}} != "")

Reply via email to