aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-03-15 11:28:48 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-03-15 11:28:48 +0000
commit0ae9da150d599305f27b737214acfa3dc181d0e8 (patch)
treed1eca2e1e2134abeb46f5dc48db00c0ab8732daa
parent7d5354266f59d5acd666d59a0791abdc8dced520 (diff)
downloadsrc-0ae9da150d599305f27b737214acfa3dc181d0e8.tar.gz
src-0ae9da150d599305f27b737214acfa3dc181d0e8.zip
Import mdocml 1.13.3vendor/mandoc/1.13.3
Notes
Notes: svn path=/vendor/mdocml/dist/; revision=280023 svn path=/vendor/mdocml/1.13.3/; revision=280024; tag=vendor/mandoc/1.13.3
-rw-r--r--INSTALL117
-rw-r--r--Makefile6
-rw-r--r--Makefile.local30
-rw-r--r--NEWS117
-rw-r--r--TODO7
-rwxr-xr-xconfigure4
-rw-r--r--eqn.748
-rw-r--r--eqn.c6
-rw-r--r--main.c58
-rw-r--r--man_html.c4
-rw-r--r--man_term.c10
-rw-r--r--mandocdb.c3
-rw-r--r--mansearch.c7
-rw-r--r--mdoc_html.c4
-rw-r--r--mdoc_term.c13
-rw-r--r--preconv.c4
-rw-r--r--read.c4
-rw-r--r--tbl_term.c4
-rw-r--r--term.c3
19 files changed, 248 insertions, 201 deletions
diff --git a/INSTALL b/INSTALL
index cc30f4c8ebb2..eb8b5dd2c2b5 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,18 +1,13 @@
-$Id: INSTALL,v 1.9 2014/12/11 07:44:46 schwarze Exp $
+$Id: INSTALL,v 1.10 2015/03/09 21:00:14 schwarze Exp $
About mdocml, the portable mandoc distribution
----------------------------------------------
The mandoc manpage compiler toolset is a suite of tools compiling
mdoc(7), the roff(7) macro language of choice for BSD manual pages,
and man(7), the predominant historical language for UNIX manuals.
-Since the present version 1.13.2, it includes a man(1) manual viewer
-in addition to the apropos(1) manual page search tool.
+It includes a man(1) manual viewer and additional tools.
For general information, see <http://mdocml.bsd.lv/>.
-In this document, we describe the installation and deployment of
-mandoc(1), first as a simple, standalone formatter, and then as part of
-the man(1) system.
-
In case you have questions or want to provide feedback, read
<http://mdocml.bsd.lv/contact.html>. Consider subscribing to the
discuss@ mailing list mentioned on that page. If you intend to
@@ -21,7 +16,7 @@ tech@ mailing list, too.
Enjoy using the mandoc toolset!
-Ingo Schwarze, Karlsruhe, December 2014
+Ingo Schwarze, Karlsruhe, March 2015
Installation
@@ -32,10 +27,6 @@ or available via a binary package or a ports system. A list of the
latest bundled and ported versions of mandoc for various operating
systems is maintained at <http://mdocml.bsd.lv/ports.html>.
-If mandoc is installed, you can check the version by running "mandoc -V".
-You can find the version contained in this distribution tarball
-by running "./configure".
-
Regarding how packages and ports are maintained for your operating
system, please consult your operating system documentation.
To install mandoc manually, the following steps are needed:
@@ -66,17 +57,34 @@ 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. To set up a man.cgi(8) server, read its manual page.
+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 "_whatdb" 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
+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
+not find the new pages.
-7. To use mandoc(1) as your man(1) formatter, read the "Deployment"
-sections below.
+8. To set up a man.cgi(8) server, read its manual page.
+
+Note that some man(7) pages may contain low-level roff(7) markup
+that mandoc does not yet understand. On some BSD systems using
+mandoc, third-party software is vetted on whether it may be formatted
+with mandoc. If not, groff(1) is pulled in as a dependency and
+used to install a pre-formatted "catpage" instead of directly as
+manual page source.
Understanding mandoc dependencies
---------------------------------
-The mandoc(1) and demandoc(1) utilities have no external dependencies.
-However, makewhatis(8), apropos(1), and man(1) depend on the following
-software:
+The mandoc(1), man(1), and demandoc(1) utilities have no external
+dependencies, but makewhatis(8) and apropos(1) depend on the
+following software:
1. The SQLite database system, see <http://sqlite.org/>.
The recommended version of SQLite is 3.8.4.3 or newer. The mandoc
@@ -142,76 +150,3 @@ for unexpected failures. Those are most likely to happen if headers
or libraries are installed in unusual places or interfaces defined
in unusual headers. You can also look at the file "config.h" and
check that no "#define HAVE_*" differ from your expectations.
-
-
-Deployment using the integrated man(1) viewer
----------------------------------------------
-This mode of deployment requires database support. In case of
-doubt, look at the section "user settings related to database
-support" in the file configure.local.example.
-
-Deployment requires the following steps:
-
-1. Build and install mandoc as described above in steps 2 to 5
-below "Installation".
-
-2. If your system uses manpath(1), make sure it is configured
-correctly, in particular, it returns all directory trees where
-manual pages are installed. If your system uses man.conf(5), make
-sure it contains a "_whatdb" line for each directory tree, and the
-order of these lines meets your wishes.
-
-3. Run the command "sudo makewhatis" to build mandoc.db(5) databases
-in all the directory trees configured in step 2.
-
-At this point, your new man(1), apropos(1), and whatis(1) should work.
-Otherwise, please look at <http://mdocml.bsd.lv/contact.html>, both
-for help and to have these instructions improved.
-
-Whenever installing new manual pages, re-run makewhatis(8) to update
-the databases, or man(1) will not find the new pages.
-
-
-Deployment using your system's native man(1) viewer
----------------------------------------------------
-This mode of deployment does not require database support,
-so it works even if you don't have SQLite3.
-
-Usually, you can have your default installation and mandoc(1) work right
-alongside each other by using user-specific versions of the files
-mentioned below.
-
-0. Back up each file you want to change!
-
-1. First see whether your system has "/etc/man.conf" or "/etc/manpath.conf"
-(if it has neither, but man(1) is functional, then let us know) or,
-if running as your own user, a per-user override file. In either
-case, find where man(1) is executing nroff(1) or groff(1) to format
-manuals. Replace these calls with mandoc(1).
-
-2. Then make sure that man(1) isn't running preprocessors, so you may
-need to replace tbl(1), eqn(1), and similar references with cat(1).
-Some man(1) implementations, like that on Mac OSX, let you run "man -d"
-to see how the formatter is invoked. Use this to test your changes. On
-Mac OS X, for instance, man(1) will prepend all files with ".ll" and
-".nr" to set the terminal size, so you need to pass "tail -n+2 |
-mandoc(1)" to disregard them.
-
-3. Finally, make sure that mandoc(1) is actually being invoked instead
-of cached pages being pulled up. You can usually do this by commenting
-out NOCACHE or similar.
-
-
-mandoc(1) still has a long way to go in understanding non-trivial
-low-level roff(7) markup embedded in some man(7) pages. On the BSD
-systems using mandoc(1), third-party software is generally vetted
-on whether it may be formatted with mandoc(1). If not, groff(1)
-is pulled in as a dependency and used to install a pre-formatted
-"catpage" instead of directly as manual page source.
-
-For more background on switching operating systems to use mandoc(1)
-instead of groff(1) to format manuals, see the BSDCan and EuroBSDCon
-presentations by Ingo Schwarze:
-<http://www.openbsd.org/papers/bsdcan11-mandoc-openbsd.html>
-<http://www.openbsd.org/papers/bsdcan14-mandoc.pdf>
-<http://www.openbsd.org/papers/eurobsdcon2014-mandoc-paper.pdf>
diff --git a/Makefile b/Makefile
index d686e01455d6..d492ce70a720 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
-# $Id: Makefile,v 1.456 2015/02/16 16:23:54 schwarze Exp $
+# $Id: Makefile,v 1.457 2015/03/13 12:35:32 schwarze Exp $
#
# Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
-# Copyright (c) 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
+# Copyright (c) 2011, 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -15,7 +15,7 @@
# 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.2
+VERSION = 1.13.3
# === LIST OF FILES ====================================================
diff --git a/Makefile.local b/Makefile.local
deleted file mode 100644
index b197fdfdb2b2..000000000000
--- a/Makefile.local
+++ /dev/null
@@ -1,30 +0,0 @@
-BUILD_TARGETS = base-build
-INSTALL_TARGETS = base-install db-install
-CFLAGS = -g -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings -I/usr/local/include
-DBLIB = -L/usr/local/lib -lsqlite3
-STATIC = -static
-PREFIX = /usr/local
-BINDIR = /usr/local/bin
-SBINDIR = /usr/local/sbin
-INCLUDEDIR = /usr/local/include/mandoc
-LIBDIR = /usr/local/lib/mandoc
-MANDIR = /usr/local/man
-EXAMPLEDIR = /usr/local/share/examples/mandoc
-WWWPREFIX = /var/www
-HTDOCDIR = /var/www/htdocs
-CGIBINDIR = /var/www/cgi-bin
-BINM_APROPOS = apropos
-BINM_MAN = man
-BINM_WHATIS = whatis
-BINM_MAKEWHATIS = makewhatis
-MANM_MAN = man
-MANM_MDOC = mdoc
-MANM_ROFF = roff
-MANM_EQN = eqn
-MANM_TBL = tbl
-INSTALL = install
-INSTALL_PROGRAM = install -m 0555
-INSTALL_LIB = install -m 0444
-INSTALL_MAN = install -m 0444
-INSTALL_DATA = install -m 0444
-MAIN_OBJS = $(BASE_OBJS) $(DB_OBJS)
diff --git a/NEWS b/NEWS
index fbcdfc2ad3cf..ecbd0053946e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,122 @@
-$Id: NEWS,v 1.8 2014/12/13 13:43:47 schwarze Exp $
+$Id: NEWS,v 1.9 2015/03/13 12:35:32 schwarze Exp $
This file lists the most important changes in the mdocml.bsd.lv distribution.
+Changes in version 1.13.3, released on March 13, 2015
+
+ --- MAJOR NEW FEATURES ---
+ * When a manual is missing from an outdated database, let man(1)
+ show it anyway, using a KISS file system lookup as a fallback.
+ * Use this to always provide man(1), even without database support.
+ * Fatal errors no longer exist. If a file can be opened, mandoc
+ will produce some output; at worst, the output may be almost empty.
+ * New -Wunsupp message level.
+ --- POTENTIONALLY SECURITY RELEVANT BUGFIXES ---
+ * Fix a potential write buffer overrun on incomplete string conditionals.
+ http://mdocml.bsd.lv/cgi-bin/cvsweb/roff.c#rev1.241
+ * Fix a potential write buffer overrun on backslash at EOF in a conditional.
+ http://mdocml.bsd.lv/cgi-bin/cvsweb/roff.c#rev1.247
+ * Fix a use after free sometimes hit when validation deletes a block.
+ http://mdocml.bsd.lv/cgi-bin/cvsweb/mdoc_macro.c#rev1.180
+ --- MAJOR FUNCTIONALLY RELEVANT BUGFIXES ---
+ * Let man(1) show manuals for the current architecture by default,
+ and support the MACHINE environment variable.
+ * Fix the man(1) and apropos(1) -m option, it didn't work at all.
+ * Do not spawn a pager when there is no output.
+ * In makewhatis(8), fix detection of hardlinked manuals on platforms
+ having padding in struct inodev (typically 64bit platforms).
+ --- PORTABILITY IMPROVEMENTS ---
+ * Ignore O_CLOEXEC when the operating system doesn't provide it.
+ * Avoid forward reference to enum type which violates ISO C99.
+ * Support homebrew-style linking on Mac OS X.
+ --- MINOR NEW FEATURES ---
+ * lookup: Accept digit+letter and "n" as section names in man(1),
+ and consistently handle digit+letter in file name extensions.
+ * lookup: Speed up -s/-S by using the "mlinks" rather than the "keys" table.
+ * output: Insert horizontal lines between formatted manual pages.
+ * input: New stricter and more resilient UTF-8 parser.
+ * mdoc(7): Refactor block rewinding for simpler and more robust parsing.
+ * man(7): Use the -Ios option when .TH has less than four arguments.
+ * tbl(7): Implement the "center" option.
+ * tbl(7): New option and format parsers, improved in many respects.
+ * roff(7): Basic implementation of the \o escape sequence (overstrike),
+ and improved rendering of overstrikes in PostScript and PDF output.
+ * Message improvements, in particular for, but not restricted to,
+ eqn(7), tbl(7), and wrong numbers of arguments in mdoc(7) and man(7),
+ in various cases also improving output generated by invalid input.
+ * Delete the -V option. It serves no purpose but keeps confusing people.
+ * gmdiff: Minimal support for Heirloom roff.
+ --- RELIABILITY BUGFIXES ---
+ * tbl(7): Fix a read buffer overrun on 'f' at EOL in a layout.
+ * roff(7): Fix a read buffer overrun on incomplete numerical conditions.
+ * mdoc(7): Fix a NULL pointer access on .Nd followed by an explicit block.
+ * mdoc(7): Fix a NULL pointer access on .It Xo without .Xc.
+ * mdoc(7): Fix a NULL pointer access on .Eo without a tail.
+ * mdoc(7): Fix a NULL pointer access in the validation of empty .St macros.
+ * man(7)/tbl(7): Fix a NULL pointer access on .TS right after .TP.
+ * tbl(7): Fix a NULL pointer access on layout lines without any cells.
+ * eqn(7): Fix NULL pointer accesses in the terminal formatter.
+ * roff(7): Fix a NULL pointer access on trailing \s-/\s+ without an argument.
+ * gz: Fix a potential NULL pointer access after waitpid() failure.
+ * roff(7): Don't let the modulo operator divide by zero.
+ * input: Fix an assertion failure on certain invalid UTF-8 input.
+ * terminal output: Allow arbitrary depth of the font stack (assertion fix).
+ * mdoc(7): Fix assertion failures and endless loops on invalid block closing.
+ * mdoc(7): Fix an assertion failure on .Bl .Sm not followed by .It.
+ * mdoc(7): Fix an assertion failure on .Bl -column ... .El .Ta.
+ * tbl(7): Fix assertion failures by macros inside table data,
+ but do not throw away the macro arguments.
+ * Prevent certain kinds of unreasonable input from producing excessive
+ output, in one case caused by unsigned integer underflow.
+ * Fix a potential memory leak in makewhatis(8) on very long filenames.
+ --- MINOR BUGFIXES ---
+ * mdoc(7): Fix parsing of badly nested blocks with multiple identical blocks.
+ * mdoc(7): Support negative indentations for displays and lists.
+ * mdoc(7): Don't mistreat negative .sp arguments as large positive ones.
+ * mdoc(7): Some spacing fixes for .Eo/.Ec.
+ * man(7): Support negative horizontal widths.
+ * man(7): Do not print out invalid .IP arguments.
+ * man(7): Correctly handle scaling units after .PD.
+ * man(7): Support .RE with an argument.
+ * man(7): Fix restoring indentation after .RS with large negative arguments.
+ * tbl(7): Prevent tables from breaking the filling of preceding text.
+ * tbl(7): Fix vertical spacing at the beginning of tables.
+ * tbl(7): Parser and formatter fixes for line drawing and font modifiers.
+ * tbl(7): Correct handling of blank data lines.
+ * eqn(7): Add sometimes missing whitespace before equation output.
+ * roff(7): Fix vertical scaling, most of it was wrong.
+ * roff(7): Slightly improve \w width measurements.
+ * roff(7): Accept the historic aliases \s10 to \s39 for \s(10 to \s(39.
+ * roff(7): Correctly escape quotes when expanding macro arguments.
+ * roff(7): Correctly handle scaling units in numerical expressions,
+ and some other improvements to the parsing of numerical expressions.
+ * roff(7): Three minor fixes with respect to evaluation of conditionals.
+ * roff(7): Let .it accept numerical expressions, not just constants.
+ * mandoc_char(7): Correct some character names and renderings.
+ * If earlier files set a non-zero exit status, never reset it to zero.
+ --- THANKS TO ---
+ * Jonathan Gray (OpenBSD) for yet more testing with afl (the American
+ Fuzzy Lop security fuzzer), again resulting in many bug reports.
+ * Theo de Raadt (OpenBSD) for suggesting the main new feature (man(1) file
+ system lookup) and for reporting an important bug (pager without output).
+ * Theo Buehler for an important bug report (-s/-S slowness)
+ and for proposing a nice new feature (lines between pages).
+ * Jason McIntyre for an important bug report (hardlink detection)
+ and multiple documentation patches.
+ * Pascal Stumpf (OpenBSD) and Alessandro de Laurenzis for
+ important bug reports (architecture and man -m, respectively).
+ * Thomas Klausner (NetBSD) for proposing a new feature (man(7) -Ios),
+ a bug report, and release testing.
+ * Anthony Bentley, Daniel Dickman, Ted Unangst (OpenBSD) and
+ Kristaps Dzonsons (bsd.lv) for source code patches and bug reports.
+ * Christian Weisgerber (OpenBSD) for more than half a dozen bug reports.
+ * Carsten Kunze (Heirloom troff) for bug reports and release testing.
+ * Antoine Jacoutot (OpenBSD) for release testing.
+ * Alexis Hildebrandt (Homebrew), Baptiste Daroussin (FreeBSD),
+ Jonathan Perkin (SmartOS), Pedro Giffuni (FreeBSD), Svyatoslav
+ Mishyn (Crux Linux), Ulrich Spoerlein (FreeBSD), Jan Stary, Patrick
+ Keshishian, Sebastien Marie, and Steffen Nurpmeso for bug reports.
+
Changes in version 1.13.2, released on December 13, 2014
--- MAJOR NEW FEATURES ---
diff --git a/TODO b/TODO
index ebd488ccee6a..701cd1ddf212 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
************************************************************************
* Official mandoc TODO.
-* $Id: TODO,v 1.201 2015/02/20 13:47:28 schwarze Exp $
+* $Id: TODO,v 1.202 2015/03/11 13:11:22 schwarze Exp $
************************************************************************
Many issues are annotated for difficulty as follows:
@@ -557,6 +557,11 @@ Several areas can be cleaned up to make mandoc even faster. These are
* structural issues
************************************************************************
+- Improve -O suboption parsing. Do it in the main program such that
+ errors can be reported. Pay attention to distinguishing the
+ mandoc(1) and apropos(1) styles of both options.
+ loc ** exist * algo ** size ** imp ***
+
- Use libz directly instead of forking gunzip(1).
Suggested by bapt at FreeBSD among others.
diff --git a/configure b/configure
index 000d11ecc4cd..fb2dabc9f5d0 100755
--- a/configure
+++ b/configure
@@ -237,9 +237,7 @@ elif [ -z "${DBLIB}" ]; then
fi
# --- manpath ---
-if [ ${BUILD_DB} -eq 0 ]; then
- HAVE_MANPATH=0
-elif ismanual manpath "${HAVE_MANPATH}"; then
+if ismanual manpath "${HAVE_MANPATH}"; then
:
elif manpath 1>&3 2>&3; then
echo "manpath: yes" 1>&2
diff --git a/eqn.7 b/eqn.7
index 182fd4cfd719..73c488550a3f 100644
--- a/eqn.7
+++ b/eqn.7
@@ -1,4 +1,4 @@
-.\" $Id: eqn.7,v 1.33 2015/01/29 00:33:57 schwarze Exp $
+.\" $Id: eqn.7,v 1.34 2015/03/09 20:17:23 schwarze Exp $
.\"
.\" Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: January 29 2015 $
+.Dd $Mdocdate: March 9 2015 $
.Dt EQN 7
.Os
.Sh NAME
@@ -72,31 +72,31 @@ case-sensitive literals in the input:
.Bd -literal -offset indent
eqn : box | eqn box
box : text
- | \*q{\*q eqn \*q}\*q
- | \*qdefine\*q text text
- | \*qndefine\*q text text
- | \*qtdefine\*q text text
- | \*qgfont\*q text
- | \*qgsize\*q text
- | \*qset\*q text text
- | \*qundef\*q text
- | \*qsqrt\*q box
+ | \(dq{\(dq eqn \(dq}\(dq
+ | \(dqdefine\(dq text text
+ | \(dqndefine\(dq text text
+ | \(dqtdefine\(dq text text
+ | \(dqgfont\(dq text
+ | \(dqgsize\(dq text
+ | \(dqset\(dq text text
+ | \(dqundef\(dq text
+ | \(dqsqrt\(dq box
| box pos box
| box mark
- | \*qmatrix\*q \*q{\*q [col \*q{\*q list \*q}\*q ]*
- | pile \*q{\*q list \*q}\*q
+ | \(dqmatrix\(dq \(dq{\(dq [col \(dq{\(dq list \(dq}\(dq ]*
+ | pile \(dq{\(dq list \(dq}\(dq
| font box
- | \*qsize\*q text box
- | \*qleft\*q text eqn [\*qright\*q text]
-col : \*qlcol\*q | \*qrcol\*q | \*qccol\*q | \*qcol\*q
-text : [^space\e\*q]+ | \e\*q.*\e\*q
-pile : \*qlpile\*q | \*qcpile\*q | \*qrpile\*q | \*qpile\*q
-pos : \*qover\*q | \*qsup\*q | \*qsub\*q | \*qto\*q | \*qfrom\*q
-mark : \*qdot\*q | \*qdotdot\*q | \*qhat\*q | \*qtilde\*q | \*qvec\*q
- | \*qdyad\*q | \*qbar\*q | \*qunder\*q
-font : \*qroman\*q | \*qitalic\*q | \*qbold\*q | \*qfat\*q
+ | \(dqsize\(dq text box
+ | \(dqleft\(dq text eqn [\(dqright\(dq text]
+col : \(dqlcol\(dq | \(dqrcol\(dq | \(dqccol\(dq | \(dqcol\(dq
+text : [^space\e\(dq]+ | \e\(dq.*\e\(dq
+pile : \(dqlpile\(dq | \(dqcpile\(dq | \(dqrpile\(dq | \(dqpile\(dq
+pos : \(dqover\(dq | \(dqsup\(dq | \(dqsub\(dq | \(dqto\(dq | \(dqfrom\(dq
+mark : \(dqdot\(dq | \(dqdotdot\(dq | \(dqhat\(dq | \(dqtilde\(dq | \(dqvec\(dq
+ | \(dqdyad\(dq | \(dqbar\(dq | \(dqunder\(dq
+font : \(dqroman\(dq | \(dqitalic\(dq | \(dqbold\(dq | \(dqfat\(dq
list : eqn
- | list \*qabove\*q eqn
+ | list \(dqabove\(dq eqn
space : [\e^~ \et]
.Ed
.Pp
@@ -434,7 +434,7 @@ implementation (including GNU troff).
.Bl -dash -compact
.It
The text string
-.Sq \e\*q
+.Sq \e\(dq
is interpreted as a literal quote in troff.
In mandoc, this is interpreted as a comment.
.It
diff --git a/eqn.c b/eqn.c
index 8737c6620f15..9da57f06e278 100644
--- a/eqn.c
+++ b/eqn.c
@@ -1,4 +1,4 @@
-/* $Id: eqn.c,v 1.57 2015/01/28 21:11:53 schwarze Exp $ */
+/* $Id: eqn.c,v 1.58 2015/03/04 12:19:49 schwarze Exp $ */
/*
* Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -194,6 +194,7 @@ enum eqn_symt {
EQNSYM_equiv,
EQNSYM_lessequal,
EQNSYM_moreequal,
+ EQNSYM_minus,
EQNSYM__MAX
};
@@ -249,7 +250,7 @@ static const struct eqnsym eqnsyms[EQNSYM__MAX] = {
{ "cdot", "pc" }, /* EQNSYM_cdot */
{ "nothing", "&" }, /* EQNSYM_nothing */
{ "approx", "~~" }, /* EQNSYM_approx */
- { "prime", "aq" }, /* EQNSYM_prime */
+ { "prime", "fm" }, /* EQNSYM_prime */
{ "half", "12" }, /* EQNSYM_half */
{ "partial", "pd" }, /* EQNSYM_partial */
{ "inf", "if" }, /* EQNSYM_inf */
@@ -262,6 +263,7 @@ static const struct eqnsym eqnsyms[EQNSYM__MAX] = {
{ "==", "==" }, /* EQNSYM_equiv */
{ "<=", "<=" }, /* EQNSYM_lessequal */
{ ">=", ">=" }, /* EQNSYM_moreequal */
+ { "-", "mi" }, /* EQNSYM_minus */
};
static struct eqn_box *eqn_box_alloc(struct eqn_node *, struct eqn_box *);
diff --git a/main.c b/main.c
index 236c3c88d16a..f0cd8ca0ccc6 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.222 2015/02/27 16:02:10 schwarze Exp $ */
+/* $Id: main.c,v 1.225 2015/03/10 13:50:03 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -20,6 +20,7 @@
#include <sys/types.h>
#include <sys/param.h> /* MACHINE */
+#include <sys/wait.h>
#include <assert.h>
#include <ctype.h>
@@ -101,7 +102,7 @@ static void mmsg(enum mandocerr, enum mandoclevel,
static void parse(struct curparse *, int,
const char *, enum mandoclevel *);
static enum mandoclevel passthrough(const char *, int, int);
-static void spawn_pager(void);
+static pid_t spawn_pager(void);
static int toptions(struct curparse *, char *);
static void usage(enum argmode) __attribute__((noreturn));
static int woptions(struct curparse *, char *);
@@ -130,9 +131,9 @@ main(int argc, char *argv[])
enum outmode outmode;
int fd;
int show_usage;
- int use_pager;
int options;
int c;
+ pid_t pager_pid; /* 0: don't use; 1: not yet spawned. */
if (argc < 1)
progname = "mandoc";
@@ -174,7 +175,7 @@ main(int argc, char *argv[])
options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1;
defos = NULL;
- use_pager = 1;
+ pager_pid = 1;
show_usage = 0;
synopsis_only = 0;
outmode = OUTMODE_DEF;
@@ -189,7 +190,7 @@ main(int argc, char *argv[])
conf_file = optarg;
break;
case 'c':
- use_pager = 0;
+ pager_pid = 0;
break;
case 'f':
search.argmode = ARG_WORD;
@@ -197,7 +198,7 @@ main(int argc, char *argv[])
case 'h':
(void)strlcat(curp.outopts, "synopsis,", BUFSIZ);
synopsis_only = 1;
- use_pager = 0;
+ pager_pid = 0;
outmode = OUTMODE_ALL;
break;
case 'I':
@@ -272,7 +273,7 @@ main(int argc, char *argv[])
switch (search.argmode) {
case ARG_FILE:
outmode = OUTMODE_ALL;
- use_pager = 0;
+ pager_pid = 0;
break;
case ARG_NAME:
outmode = OUTMODE_ONE;
@@ -303,18 +304,20 @@ main(int argc, char *argv[])
argc = 1;
}
} else if (argc > 1 &&
- ((uc = argv[0]) != NULL) &&
+ ((uc = (unsigned char *)argv[0]) != NULL) &&
((isdigit(uc[0]) && (uc[1] == '\0' ||
(isalpha(uc[1]) && uc[2] == '\0'))) ||
(uc[0] == 'n' && uc[1] == '\0'))) {
- search.sec = uc;
+ search.sec = (char *)uc;
argv++;
argc--;
}
if (search.arch == NULL)
search.arch = getenv("MACHINE");
+#ifdef MACHINE
if (search.arch == NULL)
search.arch = MACHINE;
+#endif
}
rc = MANDOCLEVEL_OK;
@@ -415,8 +418,8 @@ main(int argc, char *argv[])
mparse_keep(curp.mp);
if (argc < 1) {
- if (use_pager && isatty(STDOUT_FILENO))
- spawn_pager();
+ if (pager_pid == 1 && isatty(STDOUT_FILENO))
+ pager_pid = spawn_pager();
parse(&curp, STDIN_FILENO, "<stdin>", &rc);
}
@@ -427,9 +430,8 @@ main(int argc, char *argv[])
rc = rctmp;
if (fd != -1) {
- if (use_pager && isatty(STDOUT_FILENO))
- spawn_pager();
- use_pager = 0;
+ if (pager_pid == 1 && isatty(STDOUT_FILENO))
+ pager_pid = spawn_pager();
if (resp == NULL)
parse(&curp, fd, *argv, &rc);
@@ -479,6 +481,17 @@ out:
free(defos);
+ /*
+ * If a pager is attached, flush the pipe leading to it
+ * and signal end of file such that the user can browse
+ * to the end. Then wait for the user to close the pager.
+ */
+
+ if (pager_pid != 0 && pager_pid != 1) {
+ fclose(stdout);
+ waitpid(pager_pid, NULL, 0);
+ }
+
return((int)rc);
}
@@ -927,7 +940,7 @@ mmsg(enum mandocerr t, enum mandoclevel lvl,
fputc('\n', stderr);
}
-static void
+static pid_t
spawn_pager(void)
{
#define MAX_PAGER_ARGS 16
@@ -936,31 +949,33 @@ spawn_pager(void)
char *cp;
int fildes[2];
int argc;
+ pid_t pager_pid;
if (pipe(fildes) == -1) {
fprintf(stderr, "%s: pipe: %s\n",
progname, strerror(errno));
- return;
+ return(0);
}
- switch (fork()) {
+ switch (pager_pid = fork()) {
case -1:
fprintf(stderr, "%s: fork: %s\n",
progname, strerror(errno));
exit((int)MANDOCLEVEL_SYSERR);
case 0:
+ break;
+ default:
close(fildes[0]);
if (dup2(fildes[1], STDOUT_FILENO) == -1) {
fprintf(stderr, "%s: dup output: %s\n",
progname, strerror(errno));
exit((int)MANDOCLEVEL_SYSERR);
}
- return;
- default:
- break;
+ close(fildes[1]);
+ return(pager_pid);
}
- /* The original process becomes the pager. */
+ /* The child process becomes the pager. */
close(fildes[1]);
if (dup2(fildes[0], STDIN_FILENO) == -1) {
@@ -968,6 +983,7 @@ spawn_pager(void)
progname, strerror(errno));
exit((int)MANDOCLEVEL_SYSERR);
}
+ close(fildes[0]);
pager = getenv("MANPAGER");
if (pager == NULL || *pager == '\0')
diff --git a/man_html.c b/man_html.c
index 0e0fad9e3d73..110941502587 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.111 2015/02/10 08:05:30 schwarze Exp $ */
+/* $Id: man_html.c,v 1.112 2015/03/03 21:11:34 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -223,6 +223,8 @@ print_man_node(MAN_ARGS)
print_text(h, n->string);
return;
case MAN_EQN:
+ if (n->flags & MAN_LINE)
+ putchar('\n');
print_eqn(h, n->eqn);
break;
case MAN_TBL:
diff --git a/man_term.c b/man_term.c
index ab75851f2b28..8be7927a65cd 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.168 2015/01/30 22:04:44 schwarze Exp $ */
+/* $Id: man_term.c,v 1.169 2015/03/06 15:48:52 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -945,12 +945,8 @@ print_man_node(DECL_ARGS)
p->flags |= TERMP_NOSPACE;
return;
case MAN_TBL:
- /*
- * Tables are preceded by a newline. Then process a
- * table line, which will cause line termination,
- */
- if (n->span->prev == NULL)
- term_newln(p);
+ if (p->tbl.cols == NULL)
+ term_vspace(p);
term_tbl(p, n->span);
return;
default:
diff --git a/mandocdb.c b/mandocdb.c
index 9270e5cd1afe..fed11e9f33e5 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.185 2015/02/27 16:22:09 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.186 2015/03/13 00:19:41 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -942,6 +942,7 @@ mlink_add(struct mlink *mlink, const struct stat *st)
assert(NULL == ohash_find(&mlinks, slot));
ohash_insert(&mlinks, slot, mlink);
+ memset(&inodev, 0, sizeof(inodev)); /* Clear padding. */
inodev.st_ino = st->st_ino;
inodev.st_dev = st->st_dev;
slot = ohash_lookup_memory(&mpages, (char *)&inodev,
diff --git a/mansearch.c b/mansearch.c
index 27cfa65568a1..05e2a0a2b3c6 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -1,4 +1,4 @@
-/* $Id: mansearch.c,v 1.54 2015/02/27 16:02:10 schwarze Exp $ */
+/* $Id: mansearch.c,v 1.55 2015/03/11 13:11:22 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -195,8 +195,8 @@ mansearch(const struct mansearch *search,
if (NULL == (e = exprcomp(search, argc, argv)))
goto out;
- outbit = 0;
if (NULL != search->outkey) {
+ outbit = TYPE_Nd;
for (indexbit = 0, iterbit = 1;
indexbit < mansearch_keymax;
indexbit++, iterbit <<= 1) {
@@ -206,7 +206,8 @@ mansearch(const struct mansearch *search,
break;
}
}
- }
+ } else
+ outbit = 0;
/*
* Save a descriptor to the current working directory.
diff --git a/mdoc_html.c b/mdoc_html.c
index 09104f8f142a..fba7fb6fa4ab 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.225 2015/02/12 12:24:33 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.226 2015/03/03 21:11:34 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -411,6 +411,8 @@ print_mdoc_node(MDOC_ARGS)
h->flags |= HTML_NOSPACE;
return;
case MDOC_EQN:
+ if (n->flags & MDOC_LINE)
+ putchar('\n');
print_eqn(h, n->eqn);
break;
case MDOC_TBL:
diff --git a/mdoc_term.c b/mdoc_term.c
index cc44d761248f..20c47d666893 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.311 2015/02/17 20:37:17 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.313 2015/03/06 15:48:52 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -348,6 +348,8 @@ print_mdoc_node(DECL_ARGS)
p->flags |= TERMP_NOSPACE;
break;
case MDOC_TBL:
+ if (p->tbl.cols == NULL)
+ term_newln(p);
term_tbl(p, n->span);
break;
default:
@@ -1808,7 +1810,7 @@ static int
termp_sp_pre(DECL_ARGS)
{
struct roffsu su;
- size_t i, len;
+ int i, len;
switch (n->tok) {
case MDOC_sp:
@@ -1829,8 +1831,11 @@ termp_sp_pre(DECL_ARGS)
if (0 == len)
term_newln(p);
- for (i = 0; i < len; i++)
- term_vspace(p);
+ else if (len < 0)
+ p->skipvsp -= len;
+ else
+ for (i = 0; i < len; i++)
+ term_vspace(p);
return(0);
}
diff --git a/preconv.c b/preconv.c
index a2bbe9ca6065..87e65ea0c6ef 100644
--- a/preconv.c
+++ b/preconv.c
@@ -1,4 +1,4 @@
-/* $Id: preconv.c,v 1.13 2014/12/19 04:58:35 schwarze Exp $ */
+/* $Id: preconv.c,v 1.14 2015/03/06 09:24:59 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -33,7 +33,7 @@ preconv_encode(struct buf *ib, size_t *ii, struct buf *ob, size_t *oi,
int nby;
unsigned int accum;
- cu = ib->buf + *ii;
+ cu = (unsigned char *)ib->buf + *ii;
assert(*cu & 0x80);
if ( ! (*filenc & MPARSE_UTF8))
diff --git a/read.c b/read.c
index 0b4caa05a9c0..471d415019f5 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.129 2015/03/02 14:50:17 schwarze Exp $ */
+/* $Id: read.c,v 1.131 2015/03/11 13:05:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -636,7 +636,7 @@ read_whole_file(struct mparse *curp, const char *file, int fd,
*/
if (S_ISREG(st.st_mode)) {
- if (st.st_size >= (1U << 31)) {
+ if (st.st_size > 0x7fffffff) {
mandoc_msg(MANDOCERR_TOOLARGE, curp, 0, 0, NULL);
return(0);
}
diff --git a/tbl_term.c b/tbl_term.c
index a6354b51c4ea..1276776668c9 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_term.c,v 1.38 2015/01/31 00:12:41 schwarze Exp $ */
+/* $Id: tbl_term.c,v 1.40 2015/03/06 15:48:53 schwarze Exp $ */
/*
* Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -82,8 +82,6 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
*/
if (tp->tbl.cols == NULL) {
- term_flushln(tp);
-
tp->tbl.len = term_tbl_len;
tp->tbl.slen = term_tbl_strlen;
tp->tbl.arg = tp;
diff --git a/term.c b/term.c
index 75c12f4af21e..ee2af9e6257f 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.244 2015/01/31 00:12:41 schwarze Exp $ */
+/* $Id: term.c,v 1.245 2015/03/06 13:02:43 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -413,6 +413,7 @@ term_word(struct termp *p, const char *word)
p->flags |= TERMP_NOSPACE;
p->flags &= ~(TERMP_SENTENCE | TERMP_NONEWLINE);
+ p->skipvsp = 0;
while ('\0' != *word) {
if ('\\' != *word) {