Author: bapt
Date: Sat Jan 21 13:17:25 2017
New Revision: 312593
URL: https://svnweb.freebsd.org/changeset/base/312593

Log:
  Import mandoc cvs snapshot 20170121 (pre 1.14)
  
  Note that mandoc does not use anymore sqlite3 but a home made database format
  An important improvement has been made as well in makewhatis performance:
  Tests on my laptop shows makewhatis on the entire system goes from 26s to 12s

Added:
  head/contrib/mdocml/dba.c
     - copied unchanged from r312592, vendor/mdocml/dist/dba.c
  head/contrib/mdocml/dba.h
     - copied unchanged from r312592, vendor/mdocml/dist/dba.h
  head/contrib/mdocml/dba_array.c
     - copied unchanged from r312592, vendor/mdocml/dist/dba_array.c
  head/contrib/mdocml/dba_array.h
     - copied unchanged from r312592, vendor/mdocml/dist/dba_array.h
  head/contrib/mdocml/dba_read.c
     - copied unchanged from r312592, vendor/mdocml/dist/dba_read.c
  head/contrib/mdocml/dba_write.c
     - copied unchanged from r312592, vendor/mdocml/dist/dba_write.c
  head/contrib/mdocml/dba_write.h
     - copied unchanged from r312592, vendor/mdocml/dist/dba_write.h
  head/contrib/mdocml/dbm.c
     - copied unchanged from r312592, vendor/mdocml/dist/dbm.c
  head/contrib/mdocml/dbm.h
     - copied unchanged from r312592, vendor/mdocml/dist/dbm.h
  head/contrib/mdocml/dbm_map.c
     - copied unchanged from r312592, vendor/mdocml/dist/dbm_map.c
  head/contrib/mdocml/dbm_map.h
     - copied unchanged from r312592, vendor/mdocml/dist/dbm_map.h
  head/contrib/mdocml/test-EFTYPE.c
     - copied unchanged from r312592, vendor/mdocml/dist/test-EFTYPE.c
  head/contrib/mdocml/test-PATH_MAX.c
     - copied unchanged from r312592, vendor/mdocml/dist/test-PATH_MAX.c
  head/contrib/mdocml/test-be32toh.c
     - copied unchanged from r312592, vendor/mdocml/dist/test-be32toh.c
  head/contrib/mdocml/test-nanosleep.c
     - copied unchanged from r312592, vendor/mdocml/dist/test-nanosleep.c
  head/contrib/mdocml/test-ntohl.c
     - copied unchanged from r312592, vendor/mdocml/dist/test-ntohl.c
  head/contrib/mdocml/test-sandbox_init.c
     - copied unchanged from r312592, vendor/mdocml/dist/test-sandbox_init.c
Deleted:
  head/contrib/mdocml/compat_sqlite3_errstr.c
  head/contrib/mdocml/config.log
  head/contrib/mdocml/mansearch_const.c
  head/contrib/mdocml/test-mmap.c
  head/contrib/mdocml/test-sqlite3.c
  head/contrib/mdocml/test-sqlite3_errstr.c
Modified:
  head/Makefile.inc1
  head/contrib/mdocml/INSTALL
  head/contrib/mdocml/LICENSE
  head/contrib/mdocml/Makefile
  head/contrib/mdocml/Makefile.depend
  head/contrib/mdocml/TODO
  head/contrib/mdocml/cgi.c
  head/contrib/mdocml/compat_fts.c
  head/contrib/mdocml/compat_fts.h
  head/contrib/mdocml/config.h
  head/contrib/mdocml/configure
  head/contrib/mdocml/configure.local.example
  head/contrib/mdocml/demandoc.c
  head/contrib/mdocml/eqn_html.c
  head/contrib/mdocml/html.c
  head/contrib/mdocml/html.h
  head/contrib/mdocml/lib.in
  head/contrib/mdocml/libmandoc.h
  head/contrib/mdocml/main.c
  head/contrib/mdocml/main.h
  head/contrib/mdocml/makewhatis.8
  head/contrib/mdocml/man.1
  head/contrib/mdocml/man.c
  head/contrib/mdocml/man.conf.5
  head/contrib/mdocml/man_hash.c
  head/contrib/mdocml/man_html.c
  head/contrib/mdocml/man_macro.c
  head/contrib/mdocml/man_term.c
  head/contrib/mdocml/mandoc.1
  head/contrib/mdocml/mandoc.3
  head/contrib/mdocml/mandoc.css
  head/contrib/mdocml/mandoc.db.5
  head/contrib/mdocml/mandoc.h
  head/contrib/mdocml/mandoc_aux.h
  head/contrib/mdocml/mandoc_html.3
  head/contrib/mdocml/mandocdb.c
  head/contrib/mdocml/manpath.c
  head/contrib/mdocml/mansearch.c
  head/contrib/mdocml/mansearch.h
  head/contrib/mdocml/mdoc.7
  head/contrib/mdocml/mdoc.c
  head/contrib/mdocml/mdoc_argv.c
  head/contrib/mdocml/mdoc_hash.c
  head/contrib/mdocml/mdoc_html.c
  head/contrib/mdocml/mdoc_macro.c
  head/contrib/mdocml/mdoc_man.c
  head/contrib/mdocml/mdoc_state.c
  head/contrib/mdocml/mdoc_term.c
  head/contrib/mdocml/mdoc_validate.c
  head/contrib/mdocml/read.c
  head/contrib/mdocml/roff.c
  head/contrib/mdocml/roff.h
  head/contrib/mdocml/tag.c
  head/contrib/mdocml/tbl_html.c
  head/contrib/mdocml/term.c
  head/contrib/mdocml/term_ascii.c
  head/contrib/mdocml/term_ps.c
  head/contrib/mdocml/test-fts.c
  head/contrib/mdocml/test-ohash.c
  head/contrib/mdocml/test-vasprintf.c
  head/contrib/mdocml/test-wchar.c
  head/contrib/mdocml/tree.c
  head/usr.bin/mandoc/Makefile
  head/usr.bin/mandoc/Makefile.depend
Directory Properties:
  head/contrib/mdocml/   (props changed)

Modified: head/Makefile.inc1
==============================================================================
--- head/Makefile.inc1  Sat Jan 21 13:02:53 2017        (r312592)
+++ head/Makefile.inc1  Sat Jan 21 13:17:25 2017        (r312593)
@@ -1694,11 +1694,10 @@ _kerberos5_bootstrap_tools= \
 .endif
 
 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
-.if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
+.if ${MK_MANDOCDB} != "no"
 _libopenbsd?=  lib/libopenbsd
-_makewhatis=   lib/libsqlite3 \
-               usr.bin/mandoc
-${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
+_makewhatis=   usr.bin/mandoc
+${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
 .endif
 
 bootstrap-tools: .PHONY

Modified: head/contrib/mdocml/INSTALL
==============================================================================
--- head/contrib/mdocml/INSTALL Sat Jan 21 13:02:53 2017        (r312592)
+++ head/contrib/mdocml/INSTALL Sat Jan 21 13:17:25 2017        (r312593)
@@ -1,4 +1,4 @@
-$Id: INSTALL,v 1.15 2016/07/14 11:09:06 schwarze Exp $
+$Id: INSTALL,v 1.17 2016/07/19 22:40:33 schwarze Exp $
 
 About mdocml, the portable mandoc distribution
 ----------------------------------------------
@@ -35,7 +35,11 @@ To install mandoc manually, the followin
 command "echo BUILD_CGI=1 > configure.local".  Then run "cp
 cgi.h.examples cgi.h" and edit cgi.h as desired.
 
-2. Run "./configure".
+2. Define MANPATH_DEFAULT in configure.local
+if /usr/share/man:/usr/X11R6/man:/usr/local/man is not appropriate
+for your operating system.
+
+3. Run "./configure".
 This script attempts autoconfiguration of mandoc for your system.
 Read both its standard output and the file "Makefile.local" it
 generates.  If anything looks wrong or different from what you
@@ -45,28 +49,21 @@ result seems right to you.
 On Solaris 10 and earlier, you may have to run "ksh ./configure"
 because the native /bin/sh lacks some POSIX features.
 
-3. Run "make".
+4. Run "make".
 Any POSIX-compatible make, in particular both BSD make and GNU make,
 should work.  If the build fails, look at "configure.local.example"
 and go back to step 2.
 
-4. Run "make -n install" and check whether everything will be
+5. Run "make -n install" and check whether everything will be
 installed to the intended places.  Otherwise, put some *DIR or *NM*
-variables into "configure.local" and go back to step 2.
+variables into "configure.local" and go back to step 3.
 
-5. Run "sudo make install".  If you intend to build a binary
+6. Run "sudo make install".  If you intend to build a binary
 package using some kind of fake root mechanism, you may need a
 command like "make DESTDIR=... install".  Read the *-install targets
 in the "Makefile" to understand how DESTDIR is used.
 
-6. If you want to use the integrated man(1) and your system uses
-manpath(1), make sure it is configured correctly, in particular,
-it returns all directory trees where manual pages are installed.
-Otherwise, if your system uses man.conf(5), make sure it contains
-a "manpath" line for each directory tree, and the order of these
-lines meets your wishes.
-
-7. If you compiled with database support, run the command "sudo
+7. Run the command "sudo
 makewhatis" to build mandoc.db(5) databases in all the directory
 trees configured in step 6.  Whenever installing new manual pages,
 re-run makewhatis(8) to update the databases, or apropos(1) will
@@ -84,20 +81,9 @@ manual page source.
 
 Understanding mandoc dependencies
 ---------------------------------
-The mandoc(1), man(1), and demandoc(1) utilities only depend
-on the zlib library for decompressing gzipped manual pages,
-but makewhatis(8) and apropos(1) depend on the following
-additional software:
-
-1. The SQLite database system, see <http://sqlite.org/>.
-The recommended version of SQLite is 3.8.4.3 or newer.  The mandoc
-toolset is known to work with version 3.7.5 or newer.  Versions
-older than 3.8.3 may not achieve full performance due to the
-missing SQLITE_DETERMINISTIC optimization flag.  Versions older
-than 3.8.0 may not show full error information if opening a database
-fails due to the missing sqlite3_errstr() API.  Both are very minor
-problems, apropos(1) is fully usable with SQLite 3.7.5.  Versions
-older than 3.7.5 may or may not work, they have not been tested.
+The following libraries are required:
+
+1. zlib for decompressing gzipped manual pages.
 
 2. The fts(3) directory traversion functions.
 If your system does not have them, the bundled compatibility version

Modified: head/contrib/mdocml/LICENSE
==============================================================================
--- head/contrib/mdocml/LICENSE Sat Jan 21 13:02:53 2017        (r312592)
+++ head/contrib/mdocml/LICENSE Sat Jan 21 13:17:25 2017        (r312593)
@@ -1,4 +1,4 @@
-$Id: LICENSE,v 1.12 2016/07/07 23:46:36 schwarze Exp $
+$Id: LICENSE,v 1.13 2016/10/18 14:15:33 schwarze Exp $
 
 With the exceptions noted below, all code and documentation
 contained in the mdocml toolkit is protected by the Copyright
@@ -8,7 +8,8 @@ Copyright (c) 2008-2012, 2014 Kristaps D
 Copyright (c) 2010-2016 Ingo Schwarze <schwa...@openbsd.org>
 Copyright (c) 2009, 2010, 2011, 2012 Joerg Sonnenberger <jo...@netbsd.org>
 Copyright (c) 2013 Franco Fichtner <fra...@lastsummer.de>
-Copyright (c) 2014 Baptiste Daroussin <b...@freebsd.org>
+Copyright (c) 2014 Baptiste Daroussin <b...@freebsd.org>
+Copyright (c) 2016 Ed Maste <ema...@freebsd.org>
 Copyright (c) 1999, 2004 Marc Espie <es...@openbsd.org>
 Copyright (c) 1998, 2004, 2010 Todd C. Miller <todd.mil...@courtesan.com>
 Copyright (c) 2008 Otto Moerbeek <o...@drijf.net>
@@ -41,7 +42,7 @@ other people's Copyright and are distrib
 and 3-clause BSD licenses; see these individual files for details.
 
 soelim.c, soelim.1:
-Copyright (c) 2014 Baptiste Daroussin <b...@freebsd.org>
+Copyright (c) 2014 Baptiste Daroussin <b...@freebsd.org>
 
 compat_err.c, compat_fts.c, compat_fts.h,
 compat_getsubopt.c, compat_strcasestr.c, compat_strsep.c,

Modified: head/contrib/mdocml/Makefile
==============================================================================
--- head/contrib/mdocml/Makefile        Sat Jan 21 13:02:53 2017        
(r312592)
+++ head/contrib/mdocml/Makefile        Sat Jan 21 13:17:25 2017        
(r312593)
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.488 2016/07/12 05:18:38 kristaps Exp $
+# $Id: Makefile,v 1.493 2016/11/19 15:24:51 schwarze Exp $
 #
 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <krist...@bsd.lv>
 # Copyright (c) 2011, 2013-2016 Ingo Schwarze <schwa...@openbsd.org>
@@ -15,27 +15,29 @@
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-VERSION = 1.13.4
+VERSION = 1.14.0
 
 # === LIST OF FILES ====================================================
 
-TESTSRCS        = test-dirent-namlen.c \
+TESTSRCS        = test-be32toh.c \
+                  test-dirent-namlen.c \
+                  test-EFTYPE.c \
                   test-err.c \
                   test-fts.c \
                   test-getline.c \
                   test-getsubopt.c \
                   test-isblank.c \
                   test-mkdtemp.c \
-                  test-mmap.c \
+                  test-nanosleep.c \
+                  test-ntohl.c \
                   test-ohash.c \
+                  test-PATH_MAX.c \
                   test-pledge.c \
                   test-progname.c \
                   test-reallocarray.c \
                   test-rewb-bsd.c \
                   test-rewb-sysv.c \
                   test-sandbox_init.c \
-                  test-sqlite3.c \
-                  test-sqlite3_errstr.c \
                   test-strcasestr.c \
                   test-stringlist.c \
                   test-strlcat.c \
@@ -58,7 +60,6 @@ SRCS           = att.c \
                   compat_ohash.c \
                   compat_progname.c \
                   compat_reallocarray.c \
-                  compat_sqlite3_errstr.c \
                   compat_strcasestr.c \
                   compat_stringlist.c \
                   compat_strlcat.c \
@@ -66,6 +67,12 @@ SRCS          = att.c \
                   compat_strsep.c \
                   compat_strtonum.c \
                   compat_vasprintf.c \
+                  dba.c \
+                  dba_array.c \
+                  dba_read.c \
+                  dba_write.c \
+                  dbm.c \
+                  dbm_map.c \
                   demandoc.c \
                   eqn.c \
                   eqn_html.c \
@@ -86,7 +93,6 @@ SRCS           = att.c \
                   manpage.c \
                   manpath.c \
                   mansearch.c \
-                  mansearch_const.c \
                   mdoc.c \
                   mdoc_argv.c \
                   mdoc_hash.c \
@@ -128,6 +134,11 @@ DISTFILES   = INSTALL \
                   compat_stringlist.h \
                   configure \
                   configure.local.example \
+                  dba.h \
+                  dba_array.h \
+                  dba_write.h \
+                  dbm.h \
+                  dbm_map.h \
                   demandoc.1 \
                   eqn.7 \
                   gmdiff \
@@ -220,7 +231,6 @@ COMPAT_OBJS  = compat_err.o \
                   compat_ohash.o \
                   compat_progname.o \
                   compat_reallocarray.o \
-                  compat_sqlite3_errstr.o \
                   compat_strcasestr.o \
                   compat_strlcat.o \
                   compat_strlcpy.o \
@@ -244,28 +254,35 @@ MANDOC_TERM_OBJS = eqn_term.o \
                   term_ps.o \
                   tbl_term.o
 
-BASE_OBJS       = $(MANDOC_HTML_OBJS) \
+DBM_OBJS        = dbm.o \
+                  dbm_map.o \
+                  mansearch.o
+
+DBA_OBJS        = dba.o \
+                  dba_array.o \
+                  dba_read.o \
+                  dba_write.o \
+                  mandocdb.o
+
+MAIN_OBJS       = $(MANDOC_HTML_OBJS) \
                   $(MANDOC_MAN_OBJS) \
                   $(MANDOC_TERM_OBJS) \
+                  $(DBM_OBJS) \
+                  $(DBA_OBJS) \
                   main.o \
                   manpath.o \
                   out.o \
                   tag.o \
                   tree.o
 
-MAIN_OBJS       = $(BASE_OBJS)
-
-DB_OBJS                 = mandocdb.o \
-                  mansearch.o \
-                  mansearch_const.o
-
 CGI_OBJS        = $(MANDOC_HTML_OBJS) \
+                  $(DBM_OBJS) \
                   cgi.o \
-                  mansearch.o \
-                  mansearch_const.o \
                   out.o
 
-MANPAGE_OBJS    = manpage.o mansearch.o mansearch_const.o manpath.o
+MANPAGE_OBJS    = $(DBM_OBJS) \
+                  manpage.o \
+                  manpath.o
 
 DEMANDOC_OBJS   = demandoc.o
 
@@ -329,7 +346,7 @@ www: $(WWW_OBJS) $(WWW_MANS)
 
 $(WWW_MANS): mandoc
 
-.PHONY: base-install cgi-install db-install install www-install
+.PHONY: base-install cgi-install install www-install
 .PHONY: clean distclean depend
 
 include Makefile.depend
@@ -341,7 +358,7 @@ distclean: clean
 
 clean:
        rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
-       rm -f mandoc $(BASE_OBJS) $(DB_OBJS)
+       rm -f mandoc $(MAIN_OBJS)
        rm -f man.cgi $(CGI_OBJS)
        rm -f manpage $(MANPAGE_OBJS)
        rm -f demandoc $(DEMANDOC_OBJS)
@@ -351,50 +368,45 @@ clean:
 
 base-install: base-build
        mkdir -p $(DESTDIR)$(BINDIR)
-       mkdir -p $(DESTDIR)$(LIBDIR)
-       mkdir -p $(DESTDIR)$(INCLUDEDIR)
+       mkdir -p $(DESTDIR)$(SBINDIR)
        mkdir -p $(DESTDIR)$(MANDIR)/man1
-       mkdir -p $(DESTDIR)$(MANDIR)/man3
        mkdir -p $(DESTDIR)$(MANDIR)/man5
        mkdir -p $(DESTDIR)$(MANDIR)/man7
+       mkdir -p $(DESTDIR)$(MANDIR)/man8
        $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
        $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
        ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
-       $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
-       $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
-               $(DESTDIR)$(INCLUDEDIR)
+       ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
+       ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
+       ln -f $(DESTDIR)$(BINDIR)/mandoc \
+               $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
        $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
        $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
        $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
-       $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
-               mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
+       $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
+       ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
+               $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
        $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/${MANM_MANCONF}.5
+       $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
        $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
        $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
        $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
        $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
        $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
        $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
-
-db-install: base-build
-       mkdir -p $(DESTDIR)$(BINDIR)
-       mkdir -p $(DESTDIR)$(SBINDIR)
-       mkdir -p $(DESTDIR)$(MANDIR)/man1
-       mkdir -p $(DESTDIR)$(MANDIR)/man3
-       mkdir -p $(DESTDIR)$(MANDIR)/man5
-       mkdir -p $(DESTDIR)$(MANDIR)/man8
-       ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
-       ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
-       ln -f $(DESTDIR)$(BINDIR)/mandoc \
-               $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
-       $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
-       ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
-               $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
-       $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
-       $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
        $(INSTALL_MAN) makewhatis.8 \
                $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
 
+lib-install: base-build
+       mkdir -p $(DESTDIR)$(LIBDIR)
+       mkdir -p $(DESTDIR)$(INCLUDEDIR)
+       mkdir -p $(DESTDIR)$(MANDIR)/man3
+       $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
+       $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
+               $(DESTDIR)$(INCLUDEDIR)
+       $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
+               mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
+
 cgi-install: cgi-build
        mkdir -p $(DESTDIR)$(CGIBINDIR)
        mkdir -p $(DESTDIR)$(HTDOCDIR)

Modified: head/contrib/mdocml/Makefile.depend
==============================================================================
--- head/contrib/mdocml/Makefile.depend Sat Jan 21 13:02:53 2017        
(r312592)
+++ head/contrib/mdocml/Makefile.depend Sat Jan 21 13:17:25 2017        
(r312593)
@@ -10,7 +10,6 @@ compat_mkdtemp.o: compat_mkdtemp.c confi
 compat_ohash.o: compat_ohash.c config.h compat_ohash.h
 compat_progname.o: compat_progname.c config.h
 compat_reallocarray.o: compat_reallocarray.c config.h
-compat_sqlite3_errstr.o: compat_sqlite3_errstr.c config.h
 compat_strcasestr.o: compat_strcasestr.c config.h
 compat_stringlist.o: compat_stringlist.c config.h compat_stringlist.h
 compat_strlcat.o: compat_strlcat.c config.h
@@ -18,6 +17,12 @@ compat_strlcpy.o: compat_strlcpy.c confi
 compat_strsep.o: compat_strsep.c config.h
 compat_strtonum.o: compat_strtonum.c config.h
 compat_vasprintf.o: compat_vasprintf.c config.h
+dba.o: dba.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mansearch.h 
dba_write.h dba_array.h dba.h
+dba_array.o: dba_array.c mandoc_aux.h dba_write.h dba_array.h
+dba_read.o: dba_read.c mandoc_aux.h mansearch.h dba_array.h dba.h dbm.h
+dba_write.o: dba_write.c config.h dba_write.h
+dbm.o: dbm.c config.h mansearch.h dbm_map.h dbm.h
+dbm_map.o: dbm_map.c config.h mansearch.h dbm_map.h dbm.h
 demandoc.o: demandoc.c config.h roff.h man.h mdoc.h mandoc.h
 eqn.o: eqn.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h
 eqn_html.o: eqn_html.c config.h mandoc.h out.h html.h
@@ -26,7 +31,7 @@ html.o: html.c config.h mandoc.h mandoc_
 lib.o: lib.c config.h roff.h mdoc.h libmdoc.h lib.in
 main.o: main.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h tag.h main.h 
manconf.h mansearch.h
 man.o: man.c config.h mandoc_aux.h mandoc.h roff.h man.h libmandoc.h 
roff_int.h libman.h
-man_hash.o: man_hash.c config.h roff.h man.h libman.h
+man_hash.o: man_hash.c config.h mandoc.h roff.h man.h libmandoc.h libman.h
 man_html.o: man_html.c config.h mandoc_aux.h roff.h man.h out.h html.h main.h
 man_macro.o: man_macro.c config.h mandoc.h roff.h man.h libmandoc.h roff_int.h 
libman.h
 man_term.o: man_term.c config.h mandoc_aux.h mandoc.h roff.h man.h out.h 
term.h main.h
@@ -34,14 +39,13 @@ man_validate.o: man_validate.c config.h 
 mandoc.o: mandoc.c config.h mandoc.h mandoc_aux.h libmandoc.h
 mandoc_aux.o: mandoc_aux.c config.h mandoc.h mandoc_aux.h
 mandoc_ohash.o: mandoc_ohash.c mandoc_aux.h mandoc_ohash.h compat_ohash.h
-mandocdb.o: mandocdb.c config.h compat_fts.h mandoc_aux.h mandoc_ohash.h 
compat_ohash.h mandoc.h roff.h mdoc.h man.h manconf.h mansearch.h
+mandocdb.o: mandocdb.c config.h compat_fts.h mandoc_aux.h mandoc_ohash.h 
compat_ohash.h mandoc.h roff.h mdoc.h man.h manconf.h mansearch.h dba_array.h 
dba.h
 manpage.o: manpage.c config.h manconf.h mansearch.h
 manpath.o: manpath.c config.h mandoc_aux.h manconf.h
-mansearch.o: mansearch.c config.h mandoc.h mandoc_aux.h mandoc_ohash.h 
compat_ohash.h manconf.h mansearch.h
-mansearch_const.o: mansearch_const.c config.h mansearch.h
+mansearch.o: mansearch.c config.h mandoc.h mandoc_aux.h mandoc_ohash.h 
compat_ohash.h manconf.h mansearch.h dbm.h
 mdoc.o: mdoc.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h libmandoc.h 
roff_int.h libmdoc.h
-mdoc_argv.o: mdoc_argv.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h 
libmandoc.h libmdoc.h
-mdoc_hash.o: mdoc_hash.c config.h roff.h mdoc.h libmdoc.h
+mdoc_argv.o: mdoc_argv.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h 
libmandoc.h roff_int.h libmdoc.h
+mdoc_hash.o: mdoc_hash.c config.h mandoc.h roff.h mdoc.h libmandoc.h libmdoc.h
 mdoc_html.o: mdoc_html.c config.h mandoc_aux.h roff.h mdoc.h out.h html.h 
main.h
 mdoc_macro.o: mdoc_macro.c config.h mandoc.h roff.h mdoc.h libmandoc.h 
roff_int.h libmdoc.h
 mdoc_man.o: mdoc_man.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h 
out.h main.h

Modified: head/contrib/mdocml/TODO
==============================================================================
--- head/contrib/mdocml/TODO    Sat Jan 21 13:02:53 2017        (r312592)
+++ head/contrib/mdocml/TODO    Sat Jan 21 13:17:25 2017        (r312593)
@@ -1,6 +1,6 @@
 ************************************************************************
 * Official mandoc TODO.
-* $Id: TODO,v 1.218 2016/06/05 21:06:04 schwarze Exp $
+* $Id: TODO,v 1.223 2017/01/17 15:32:43 schwarze Exp $
 ************************************************************************
 
 Many issues are annotated for difficulty as follows:
@@ -33,15 +33,6 @@ Obviously, as the issues have not been s
 are mere guesses, and some may be wrong.
 
 ************************************************************************
-* crashes
-************************************************************************
-
-- The abort() in bufcat(), html.c, can be triggered via buffmt_includes()
-  by running -Thtml -Oincludes on a file containing a long .In argument.
-  Fixing this will probably require reworking the whole bufcat() concept.
-  loc **  exist *  algo *  size **  imp **
-
-************************************************************************
 * missing features
 ************************************************************************
 
@@ -213,6 +204,13 @@ are mere guesses, and some may be wrong.
   synaptics(4) found by tedu@  Mon, 17 Aug 2015 21:17:42 -0400
   loc **  exist **  algo **  size **  imp ***
 
+- break long text into lines inside cells
+  net/lftp(1) from jirib via bentley@ Sep 13, 2016
+
+- layout l1 for a column of max text width 3 reduces the following
+  inter-column spacing for groff, but not for mandoc
+  net/lftp(1) from jirib via bentley@ Sep 13, 2016
+
 - the "w" layout option is ignored
   synaptics(4) found by tedu@  Mon, 17 Aug 2015 21:17:42 -0400
   loc *  exist *  algo *  size *  imp **
@@ -529,16 +527,6 @@ are mere guesses, and some may be wrong.
   loc **  exist **  algo **  size *  imp **
 
 ************************************************************************
-* portability
-************************************************************************
-
-- systems having UTF-8 but not en_US.UTF-8
-  call locale(1) from ./configure, select a UTF-8-locale,
-  and use that for test-wchar.c and term_ascii.c
-  to Markus Waldeck  Sat, 18 Jul 2015 01:55:37 +0200
-  loc *  exist *  algo *  size *  imp *
-
-************************************************************************
 * warning issues
 ************************************************************************
 
@@ -612,7 +600,6 @@ are mere guesses, and some may be wrong.
 ************************************************************************
 
 - Why are we using MAP_SHARED, not MAP_PRIVATE for mmap(2)?
-  How does SQLITE_CONFIG_PAGECACHE actually work?  Document it!
   from kristaps@  Sat, 09 Aug 2014 13:51:36 +0200
 
 Several areas can be cleaned up to make mandoc even faster.  These are
@@ -631,6 +618,13 @@ Several areas can be cleaned up to make 
 * structural issues
 ************************************************************************
 
+- POSIX says in the documentation of sysconf(3) that PATH_MAX
+  is allowed to be so large that it is a bad idea to use it
+  for sizing static buffers.  So use dynamic buffers throughout.
+  See the file test-PATH_MAX.c for details.
+  Found by Aaron M. Ucko in the GNU Hurd via Bdale Garbee,
+  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=829624
+
 - We use the input line number at several places to distinguish
   same-line from different-line input.  That plainly doesn't work
   with user-defined macros, leading to random breakage.
@@ -646,11 +640,6 @@ Several areas can be cleaned up to make 
 - struct mparse refactoring
   Steffen Nurpmeso  Thu, 04 Sep 2014 12:50:00 +0200
 
-- Consider creating some views that will make the database more
-  readable from the sqlite3 shell.  Consider using them to
-  abstract from the database structure, too.
-  suggested by espie@  Sat, 19 Apr 2014 14:52:57 +0200
-
 ************************************************************************
 * CGI issues
 ************************************************************************

Modified: head/contrib/mdocml/cgi.c
==============================================================================
--- head/contrib/mdocml/cgi.c   Sat Jan 21 13:02:53 2017        (r312592)
+++ head/contrib/mdocml/cgi.c   Sat Jan 21 13:17:25 2017        (r312593)
@@ -1,7 +1,7 @@
-/*     $Id: cgi.c,v 1.135 2016/07/11 22:48:37 schwarze Exp $ */
+/*     $Id: cgi.c,v 1.144 2017/01/21 01:20:31 schwarze Exp $ */
 /*
  * Copyright (c) 2011, 2012 Kristaps Dzonsons <krist...@bsd.lv>
- * Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwa...@usta.de>
+ * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwa...@usta.de>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -113,17 +113,18 @@ static    const char *const sec_names[] = {
 static const int sec_MAX = sizeof(sec_names) / sizeof(char *);
 
 static const char *const arch_names[] = {
-    "amd64",       "alpha",       "armish",      "armv7",
-    "hppa",        "hppa64",      "i386",        "landisk",
+    "amd64",       "alpha",       "armv7",
+    "hppa",        "i386",        "landisk",
     "loongson",    "luna88k",     "macppc",      "mips64",
-    "octeon",      "sgi",         "socppc",      "sparc",
-    "sparc64",     "zaurus",
-    "amiga",       "arc",         "arm32",       "atari",
-    "aviion",      "beagle",      "cats",        "hp300",       
+    "octeon",      "sgi",         "socppc",      "sparc64",
+    "amiga",       "arc",         "armish",      "arm32",
+    "atari",       "aviion",      "beagle",      "cats",
+    "hppa64",      "hp300",
     "ia64",        "mac68k",      "mvme68k",     "mvme88k",
     "mvmeppc",     "palm",        "pc532",       "pegasos",
-    "pmax",        "powerpc",     "solbourne",   "sun3",
-    "vax",         "wgrisc",      "x68k"
+    "pmax",        "powerpc",     "solbourne",   "sparc",
+    "sun3",        "vax",         "wgrisc",      "x68k",
+    "zaurus"
 };
 static const int arch_MAX = sizeof(arch_names) / sizeof(char *);
 
@@ -137,7 +138,7 @@ html_putchar(char c)
 
        switch (c) {
        case ('"'):
-               printf("&quote;");
+               printf("&quot;");
                break;
        case ('&'):
                printf("&amp;");
@@ -337,6 +338,7 @@ resp_copy(const char *filename)
                fflush(stdout);
                while ((sz = read(fd, buf, sizeof(buf))) > 0)
                        write(STDOUT_FILENO, buf, sz);
+               close(fd);
        }
 }
 
@@ -349,13 +351,12 @@ resp_begin_html(int code, const char *ms
        printf("<!DOCTYPE html>\n"
               "<html>\n"
               "<head>\n"
-              "<meta charset=\"UTF-8\"/>\n"
-              "<link rel=\"stylesheet\" href=\"%s/mandoc.css\""
+              "  <meta charset=\"UTF-8\"/>\n"
+              "  <link rel=\"stylesheet\" href=\"%s/mandoc.css\""
               " type=\"text/css\" media=\"all\">\n"
-              "<title>%s</title>\n"
+              "  <title>%s</title>\n"
               "</head>\n"
-              "<body>\n"
-              "<!-- Begin page content. //-->\n",
+              "<body>\n",
               CSS_DIR, CUSTOMIZE_TITLE);
 
        resp_copy(MAN_DIR "/header.html");
@@ -376,16 +377,14 @@ resp_searchform(const struct req *req, e
 {
        int              i;
 
-       puts("<!-- Begin search form. //-->");
-       printf("<div id=\"mancgi\">\n"
-              "<form action=\"/%s\" method=\"get\">\n"
-              "<fieldset>\n"
-              "<legend>Manual Page Search Parameters</legend>\n",
+       printf("<form action=\"/%s\" method=\"get\">\n"
+              "  <fieldset>\n"
+              "    <legend>Manual Page Search Parameters</legend>\n",
               scriptname);
 
        /* Write query input box. */
 
-       printf("<input type=\"text\" name=\"query\" value=\"");
+       printf("    <input type=\"text\" name=\"query\" value=\"");
        if (req->q.query != NULL)
                html_print(req->q.query);
        printf( "\" size=\"40\"");
@@ -395,45 +394,46 @@ resp_searchform(const struct req *req, e
 
        /* Write submission buttons. */
 
-       printf( "<button type=\"submit\" name=\"apropos\" value=\"0\">"
+       printf( "    <button type=\"submit\" name=\"apropos\" value=\"0\">"
                "man</button>\n"
-               "<button type=\"submit\" name=\"apropos\" value=\"1\">"
-               "apropos</button>\n<br/>\n");
+               "    <button type=\"submit\" name=\"apropos\" value=\"1\">"
+               "apropos</button>\n"
+               "    <br/>\n");
 
        /* Write section selector. */
 
-       puts("<select name=\"sec\">");
+       puts("    <select name=\"sec\">");
        for (i = 0; i < sec_MAX; i++) {
-               printf("<option value=\"%s\"", sec_numbers[i]);
+               printf("      <option value=\"%s\"", sec_numbers[i]);
                if (NULL != req->q.sec &&
                    0 == strcmp(sec_numbers[i], req->q.sec))
                        printf(" selected=\"selected\"");
                printf(">%s</option>\n", sec_names[i]);
        }
-       puts("</select>");
+       puts("    </select>");
 
        /* Write architecture selector. */
 
-       printf( "<select name=\"arch\">\n"
-               "<option value=\"default\"");
+       printf( "    <select name=\"arch\">\n"
+               "      <option value=\"default\"");
        if (NULL == req->q.arch)
                printf(" selected=\"selected\"");
        puts(">All Architectures</option>");
        for (i = 0; i < arch_MAX; i++) {
-               printf("<option value=\"%s\"", arch_names[i]);
+               printf("      <option value=\"%s\"", arch_names[i]);
                if (NULL != req->q.arch &&
                    0 == strcmp(arch_names[i], req->q.arch))
                        printf(" selected=\"selected\"");
                printf(">%s</option>\n", arch_names[i]);
        }
-       puts("</select>");
+       puts("    </select>");
 
        /* Write manpath selector. */
 
        if (req->psz > 1) {
-               puts("<select name=\"manpath\">");
+               puts("    <select name=\"manpath\">");
                for (i = 0; i < (int)req->psz; i++) {
-                       printf("<option ");
+                       printf("      <option ");
                        if (strcmp(req->q.manpath, req->p[i]) == 0)
                                printf("selected=\"selected\" ");
                        printf("value=\"");
@@ -442,13 +442,11 @@ resp_searchform(const struct req *req, e
                        html_print(req->p[i]);
                        puts("</option>");
                }
-               puts("</select>");
+               puts("    </select>");
        }
 
-       puts("</fieldset>\n"
-            "</form>\n"
-            "</div>");
-       puts("<!-- End search form. //-->");
+       puts("  </fieldset>\n"
+            "</form>");
 }
 
 static int
@@ -496,9 +494,9 @@ pg_index(const struct req *req)
        resp_searchform(req, FOCUS_QUERY);
        printf("<p>\n"
               "This web interface is documented in the\n"
-              "<a href=\"/%s%sman.cgi.8\">man.cgi(8)</a>\n"
+              "<a class=\"Xr\" href=\"/%s%sman.cgi.8\">man.cgi(8)</a>\n"
               "manual, and the\n"
-              "<a href=\"/%s%sapropos.1\">apropos(1)</a>\n"
+              "<a class=\"Xr\" href=\"/%s%sapropos.1\">apropos(1)</a>\n"
               "manual explains the query syntax.\n"
               "</p>\n",
               scriptname, *scriptname == '\0' ? "" : "/",
@@ -578,27 +576,21 @@ pg_searchres(const struct req *req, stru
            req->q.equal || sz == 1 ? FOCUS_NONE : FOCUS_QUERY);
 
        if (sz > 1) {
-               puts("<div class=\"results\">");
-               puts("<table>");
-
+               puts("<table class=\"results\">");
                for (i = 0; i < sz; i++) {
-                       printf("<tr>\n"
-                              "<td class=\"title\">\n"
-                              "<a href=\"/%s%s%s/%s",
+                       printf("  <tr>\n"
+                              "    <td>"
+                              "<a class=\"Xr\" href=\"/%s%s%s/%s\">",
                            scriptname, *scriptname == '\0' ? "" : "/",
                            req->q.manpath, r[i].file);
-                       printf("\">");
                        html_print(r[i].names);
-                       printf("</a>\n"
-                              "</td>\n"
-                              "<td class=\"desc\">");
+                       printf("</a></td>\n"
+                              "    <td><span class=\"Nd\">");
                        html_print(r[i].output);
-                       puts("</td>\n"
-                            "</tr>");
+                       puts("</span></td>\n"
+                            "  </tr>");
                }
-
-               puts("</table>\n"
-                    "</div>");
+               puts("</table>");
        }
 
        /*
@@ -800,7 +792,8 @@ resp_format(const struct req *req, const
        }
 
        mchars_alloc();
-       mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_BADARG, NULL, req->q.manpath);
+       mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1,
+           MANDOCLEVEL_BADARG, NULL, req->q.manpath);
        mparse_readfd(mp, fd, file);
        close(fd);
 

Modified: head/contrib/mdocml/compat_fts.c
==============================================================================
--- head/contrib/mdocml/compat_fts.c    Sat Jan 21 13:02:53 2017        
(r312592)
+++ head/contrib/mdocml/compat_fts.c    Sat Jan 21 13:17:25 2017        
(r312593)
@@ -6,8 +6,8 @@ int dummy;
 
 #else
 
-/*     $Id: compat_fts.c,v 1.9 2015/03/18 19:29:48 schwarze Exp $      */
-/*     $OpenBSD: fts.c,v 1.50 2015/01/16 16:48:51 deraadt Exp $        */
+/*     $Id: compat_fts.c,v 1.12 2016/10/18 23:58:12 schwarze Exp $     */
+/*     $OpenBSD: fts.c,v 1.56 2016/09/21 04:38:56 guenther Exp $       */
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -59,6 +59,7 @@ static void    fts_load(FTS *, FTSENT *);
 static size_t   fts_maxarglen(char * const *);
 static void     fts_padjust(FTS *, FTSENT *);
 static int      fts_palloc(FTS *, size_t);
+static FTSENT  *fts_sort(FTS *, FTSENT *, int);
 static unsigned short   fts_stat(FTS *, FTSENT *);
 
 #define        ISDOT(a)        (a[0] == '.' && (!a[1] || (a[1] == '.' && 
!a[2])))
@@ -68,19 +69,22 @@ static unsigned short        fts_stat(FTS *, F
 #ifndef        O_CLOEXEC
 #define        O_CLOEXEC       0
 #endif
+#ifndef        PATH_MAX
+#define        PATH_MAX        4096
+#endif
 
 #define        CLR(opt)        (sp->fts_options &= ~(opt))
 #define        ISSET(opt)      (sp->fts_options & (opt))
 #define        SET(opt)        (sp->fts_options |= (opt))
 
 FTS *
-fts_open(char * const *argv, int options, void *dummy)
+fts_open(char * const *argv, int options,
+    int (*compar)(const FTSENT **, const FTSENT **))
 {
        FTS *sp;
        FTSENT *p, *root;
        int nitems;
        FTSENT *parent, *tmp;
-       size_t len;
 
        /* Options check. */
        if (options & ~FTS_OPTIONMASK) {
@@ -88,9 +92,16 @@ fts_open(char * const *argv, int options
                return (NULL);
        }
 
+       /* At least one path must be specified. */
+       if (*argv == NULL) {
+               errno = EINVAL;
+               return (NULL);
+       }
+
        /* Allocate/initialize the stream */
        if ((sp = calloc(1, sizeof(FTS))) == NULL)
                return (NULL);
+       sp->fts_compar = compar;
        sp->fts_options = options;
 
        /*
@@ -107,13 +118,7 @@ fts_open(char * const *argv, int options
 
        /* Allocate/initialize root(s). */
        for (root = NULL, nitems = 0; *argv; ++argv, ++nitems) {
-               /* Don't allow zero-length paths. */
-               if ((len = strlen(*argv)) == 0) {
-                       errno = ENOENT;
-                       goto mem3;
-               }
-
-               if ((p = fts_alloc(sp, *argv, len)) == NULL)
+               if ((p = fts_alloc(sp, *argv, strlen(*argv))) == NULL)
                        goto mem3;
                p->fts_level = FTS_ROOTLEVEL;
                p->fts_parent = parent;
@@ -124,14 +129,25 @@ fts_open(char * const *argv, int options
                if (p->fts_info == FTS_DOT)
                        p->fts_info = FTS_D;
 
-               p->fts_link = NULL;
-               if (root == NULL)
-                       tmp = root = p;
-               else {
-                       tmp->fts_link = p;
-                       tmp = p;
+               /*
+                * If comparison routine supplied, traverse in sorted
+                * order; otherwise traverse in the order specified.
+                */
+               if (compar) {
+                       p->fts_link = root;
+                       root = p;
+               } else {
+                       p->fts_link = NULL;
+                       if (root == NULL)
+                               tmp = root = p;
+                       else {
+                               tmp->fts_link = p;
+                               tmp = p;
+                       }
                }
        }
+       if (compar && nitems > 1)
+               root = fts_sort(sp, root, nitems);
 
        /*
         * Allocate a dummy pointer and make fts_read think that we've just
@@ -201,6 +217,7 @@ fts_close(FTS *sp)
        /* Free up child linked list, sort array, path buffer, stream ptr.*/
        if (sp->fts_child)
                fts_lfree(sp->fts_child);
+       free(sp->fts_array);
        free(sp->fts_path);
        free(sp);
 
@@ -317,7 +334,6 @@ name:               t = sp->fts_path + NAPPEND(p->fts
  * semantics to fts using fts_set.  An error return is allowed for similar
  * reasons.
  */
-/* ARGSUSED */
 int
 fts_set(FTS *sp, FTSENT *p, int instr)
 {
@@ -416,8 +432,7 @@ fts_build(FTS *sp)
                                 * structures already allocated.
                                 */
 mem1:                          saved_errno = errno;
-                               if (p)
-                                       free(p);
+                               free(p);
                                fts_lfree(head);
                                (void)closedir(dirp);
                                cur->fts_info = FTS_ERR;
@@ -490,6 +505,10 @@ mem1:                              saved_errno = errno;
                cur->fts_info = FTS_DP;
                return (NULL);
        }
+
+       /* Sort the entries. */
+       if (sp->fts_compar && nitems > 1)
+               head = fts_sort(sp, head, nitems);
        return (head);
 }
 
@@ -547,6 +566,40 @@ fts_stat(FTS *sp, FTSENT *p)
 }
 
 static FTSENT *
+fts_sort(FTS *sp, FTSENT *head, int nitems)
+{
+       FTSENT **ap, *p;
+
+       /*
+        * Construct an array of pointers to the structures and call qsort(3).
+        * Reassemble the array in the order returned by qsort.  If unable to
+        * sort for memory reasons, return the directory entries in their
+        * current order.  Allocate enough space for the current needs plus
+        * 40 so don't realloc one entry at a time.
+        */
+       if (nitems > sp->fts_nitems) {
+               struct _ftsent **a;
+
+               sp->fts_nitems = nitems + 40;
+               if ((a = reallocarray(sp->fts_array,
+                   sp->fts_nitems, sizeof(FTSENT *))) == NULL) {
+                       free(sp->fts_array);
+                       sp->fts_array = NULL;
+                       sp->fts_nitems = 0;
+                       return (head);
+               }
+               sp->fts_array = a;
+       }
+       for (ap = sp->fts_array, p = head; p; p = p->fts_link)
+               *ap++ = p;
+       qsort(sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar);
+       for (head = *(ap = sp->fts_array); --nitems; ++ap)
+               ap[0]->fts_link = ap[1];
+       ap[0]->fts_link = NULL;
+       return (head);
+}
+
+static FTSENT *
 fts_alloc(FTS *sp, const char *name, size_t namelen)
 {
        FTSENT *p;
@@ -597,8 +650,7 @@ fts_palloc(FTS *sp, size_t more)
         */
        more += 256;
        if (sp->fts_pathlen + more < sp->fts_pathlen) {
-               if (sp->fts_path)
-                       free(sp->fts_path);
+               free(sp->fts_path);
                sp->fts_path = NULL;
                errno = ENAMETOOLONG;
                return (1);
@@ -606,8 +658,7 @@ fts_palloc(FTS *sp, size_t more)
        sp->fts_pathlen += more;
        p = realloc(sp->fts_path, sp->fts_pathlen);
        if (p == NULL) {
-               if (sp->fts_path)
-                       free(sp->fts_path);
+               free(sp->fts_path);
                sp->fts_path = NULL;
                return (1);
        }

Modified: head/contrib/mdocml/compat_fts.h
==============================================================================
--- head/contrib/mdocml/compat_fts.h    Sat Jan 21 13:02:53 2017        
(r312592)
+++ head/contrib/mdocml/compat_fts.h    Sat Jan 21 13:17:25 2017        
(r312593)
@@ -38,9 +38,12 @@
 typedef struct {
        struct _ftsent *fts_cur;        /* current node */
        struct _ftsent *fts_child;      /* linked list of children */
+       struct _ftsent **fts_array;     /* sort array */
        dev_t fts_dev;                  /* starting device # */
        char *fts_path;                 /* path for this descent */
        size_t fts_pathlen;             /* sizeof(path) */
+       int fts_nitems;                 /* elements in the sort array */
+       int (*fts_compar)();            /* compare function */
 
 #define        FTS_NOCHDIR     0x0004          /* don't change directories */
 #define        FTS_PHYSICAL    0x0010          /* physical walk */
@@ -94,7 +97,8 @@ typedef struct _ftsent {
 
 
 int     fts_close(FTS *);
-FTS    *fts_open(char * const *, int, void *);
+FTS    *fts_open(char * const *, int,
+           int (*)(const FTSENT **, const FTSENT **));
 FTSENT *fts_read(FTS *);
 int     fts_set(FTS *, FTSENT *, int);
 

Modified: head/contrib/mdocml/config.h
==============================================================================
--- head/contrib/mdocml/config.h        Sat Jan 21 13:02:53 2017        
(r312592)
+++ head/contrib/mdocml/config.h        Sat Jan 21 13:17:25 2017        
(r312593)
@@ -2,30 +2,33 @@
 #error "Do not use C++.  See the INSTALL file."
 #endif
 
-#ifndef MANDOC_CONFIG_H
-#define MANDOC_CONFIG_H
+#if !defined(__GNUC__) || (__GNUC__ < 4)
+#define __attribute__(x)
+#endif
 
 #if defined(__linux__) || defined(__MINT__)
 #define _GNU_SOURCE    /* See test-*.c what needs this. */
 #endif
 
-#include <sys/types.h>
-#include <stdio.h>
 
 #define MAN_CONF_FILE "/etc/man.conf"
+#define MANPATH_DEFAULT "/usr/share/man:/usr/local/man"
+#define UTF8_LOCALE "en_US.UTF-8"
 #define HAVE_DIRENT_NAMLEN 1
+#define HAVE_ENDIAN 0
 #define HAVE_ERR 1
 #define HAVE_FTS 1
 #define HAVE_GETLINE 1
 #define HAVE_GETSUBOPT 1
 #define HAVE_ISBLANK 1
 #define HAVE_MKDTEMP 1
-#define HAVE_MMAP 1
+#define HAVE_NTOHL 1
 #define HAVE_PLEDGE 0
 #define HAVE_PROGNAME 1
 #define HAVE_REALLOCARRAY 1
-#define HAVE_REWB_BSD 0
-#define HAVE_REWB_SYSV 0
+#define HAVE_REWB_BSD 1
+#define HAVE_REWB_SYSV 1
+#define HAVE_SANDBOX_INIT 0
 #define HAVE_STRCASESTR 1
 #define HAVE_STRINGLIST 1
 #define HAVE_STRLCAT 1
@@ -33,20 +36,14 @@
 #define HAVE_STRPTIME 1

*** 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