OpenBSD CVS

CVS log for src/usr.bin/mandoc/main.c


[BACK] Up to [local] / src / usr.bin / mandoc

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.265 / (download) - annotate - [select for diffs], Fri Mar 29 01:16:30 2024 UTC (7 weeks, 2 days ago) by millert
Branch: MAIN
CVS Tags: HEAD
Changes since 1.264: +1 -4 lines
Diff to previous 1.264 (colored)

Back out tzset(3) change, it is not effective.

Revision 1.264 / (download) - annotate - [select for diffs], Fri Mar 29 01:01:00 2024 UTC (7 weeks, 2 days ago) by millert
Branch: MAIN
Changes since 1.263: +4 -1 lines
Diff to previous 1.263 (colored)

Call tzset() in main() so we don't need to check TZ repeatedly.
This has the greatest impact on makewhatis, which used to make
thousands of calls to issetugid(2) via localtime(3) and strftime(3).
Inspired by a different diff from miod@.  OK miod@

Revision 1.263 / (download) - annotate - [select for diffs], Mon Sep 4 13:08:11 2023 UTC (8 months, 2 weeks ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.262: +3 -2 lines
Diff to previous 1.262 (colored)

Fix a bug where the wrong digit was used for prioritizing filenames
in the standard man(1) mode that formats a single resulting page
if the respective manpath contained digits, like X11R6 does.
Fortunately, this bug did not trigger for any Xenocara manual page.

Revision 1.262 / (download) - annotate - [select for diffs], Mon Oct 4 21:28:50 2021 UTC (2 years, 7 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.261: +13 -15 lines
Diff to previous 1.261 (colored)

Clean up memory handling in spawn_pager(), free(3)ing everything
that is malloc(3)ed.  In addition to being less confusing, the new
code is also shorter by two lines.

Revision 1.261 / (download) - annotate - [select for diffs], Mon Oct 4 20:24:00 2021 UTC (2 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.260: +8 -1 lines
Diff to previous 1.260 (colored)

In man(1) mode, properly clean up the resn[] result array
after processing each name given on the command line.

Failure to do so resulted in a memory leak of about 50 kilobytes
per name given on the command line.  Since man(1) uses a few
Megabytes of memory anyway and people rarely give hundreds of names
on the command line, this leak did not cause practical problems,
but cleaning up properly is better in any case.

Revision 1.260 / (download) - annotate - [select for diffs], Sat Sep 4 22:37:26 2021 UTC (2 years, 8 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.259: +12 -7 lines
Diff to previous 1.259 (colored)

during prioritization for man(1), correctly extract the section name
from the file name extension of gzipped manual page files; bug found
on Alpine Linux by Soeren Tempel <soeren at soeren hyphen tempel dot net>,
who also tested this patch

Revision 1.259 / (download) - annotate - [select for diffs], Sat Sep 4 12:47:04 2021 UTC (2 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.258: +66 -22 lines
Diff to previous 1.258 (colored)

In the fallback code to look for manual pages without using mandoc.db(5),
accept files "man<one-digit-section>/<name>.<full-section>"
in addition the already supported "man<full-section>/name.[01-9]*".
Needed for example on Alpine Linux which puts its Perl manuals
into "man3/<name>.3pm" and the POSIX manuals into "man3/<name>.3p".

While here, allow the glob(3) at the end of fs_lookup() to add multiple
matches to the result set.  This improves man -w output and may also
help some cases of plain man(1), allowing main() to prioritize properly
rather than fs_lookup() picking a random match.

None of this really matters for standard manpaths on OpenBSD because
both base system and ports developers are highly disciplined about
putting manual pages into properly named files and directories, but
even on OpenBSD, it may help to access some raw, unported third-party
manual page trees.

Issue reported and patch tested
by Soeren Tempel <soeren at soeren hyphen tempel dot net>.

Revision 1.258 / (download) - annotate - [select for diffs], Sat Aug 14 13:51:46 2021 UTC (2 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.257: +4 -1 lines
Diff to previous 1.257 (colored)

print a BAGARG message if -T markdown is requested on man(7) input;
suggested by Michael Stapelberg at debian dot org

Revision 1.257 / (download) - annotate - [select for diffs], Wed Jun 2 18:27:36 2021 UTC (2 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.256: +23 -20 lines
Diff to previous 1.256 (colored)

In -W style mode, check .Xr links along the full manpath because
that is more useful for validating manuals of non-base software.
Nothing changes in -W all mode: by default for -T lint, we still
assume we want to check base system conventions, including usually
not wanting to link to non-base manual pages.

The use case, a partial idea how to handle it, and a preliminary
patch was originally presented by kn@, then refined by me.
Final patch tested and OK'ed by kn@.

Revision 1.256 / (download) - annotate - [select for diffs], Fri Feb 19 19:49:49 2021 UTC (3 years, 2 months ago) by kn
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.255: +2 -1 lines
Diff to previous 1.255 (colored)

Append .html suffix to temporary files enabling browsers to recognise it

Occasionally one might read a manual page in a webbrowser, e.g.
"MANPAGER=firefox man -T html jq", however temporary files created for
pagers lack file extensions and most web browsers are unable to detect a
file's content without it.

Special case mandoc(1)'s HTML output format by appending the ".html" suffix
to file names such that browsers will actually render HTML as such instead
of showing it as plain text.

Input schwarze

Revision 1.255 / (download) - annotate - [select for diffs], Tue Jul 21 15:08:48 2020 UTC (3 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.254: +27 -11 lines
Diff to previous 1.254 (colored)

undocumented options -O outfilename and -O tagfilename
to support regression testing without a tty;
no user visible change intended

Revision 1.254 / (download) - annotate - [select for diffs], Mon Jul 20 14:25:22 2020 UTC (3 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.253: +2 -2 lines
Diff to previous 1.253 (colored)

Switch the default pager from "more -s" to "less".

POSIX explicitly allows using a different default pager if that
is documented.  The pager provided in the OpenBSD base system is
less(1).  It can merely be called as more(1) for compatibility.
Our man(1) implementation uses less(1) features that traditional
more(1) did not provide, in particular tagging.  Besides, as noted
by deraadt@, the user interface of less(1) is slightly more refined
and preferable over the user inferface of more(1).
This switch was originally suggested by Ian Ropers.

As explained by jmc@ and deraadt@, the -s flag was added a very
long time ago when an antique version of groff(1) had an annoying
bug in terminal output that would randomly display blank lines in
the middle of pages.  Clearly, -s has no longer been needed for
many years, so drop it from the default pager invocation.

OK deraadt@ jmc@ martijn@ job@

Revision 1.253 / (download) - annotate - [select for diffs], Mon Jun 15 17:25:03 2020 UTC (3 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.252: +24 -17 lines
Diff to previous 1.252 (colored)

Support -T html -O tag by passing a file:// URI to the pager.
Feature suggested by and implementation based on a patch
from Abel Romero Perez <romeroperezabel at gmail dot com>.

Revision 1.252 / (download) - annotate - [select for diffs], Thu Jun 11 16:12:14 2020 UTC (3 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.251: +2 -2 lines
Diff to previous 1.251 (colored)

Fix a regression in rev. 1.238 (2019/07/26):
Pass the right object to html_reset() or it will crash
when rendering more than one manual page to HTML in a row.
Bug reported by Abel Romero Perez <romeroperezabel at gmail dot com>.
Ingo came up with the same diff and I'm borrowing his draft commit
message.  ok schwarze@

Revision 1.251 / (download) - annotate - [select for diffs], Thu Apr 2 22:10:27 2020 UTC (4 years, 1 month ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.250: +30 -26 lines
Diff to previous 1.250 (colored)

When the last file formatted yielded no tags, the tags file got
deleted before starting the pager, even when earlier input files
had written to it; thanks to weerd@ for reporting that bug.

Since we now generate tags for section headers, we almost always
generate at least some.  Consequently, while fixing the above bug,
simplify the code by never deleting the tags file before the pager
exits, not even in the rare case that the file happens to be empty.
Hence, this patch is -75 +63 LOC even though it fixes two bugs.

While deleting the output files belongs after exit from the pager,
closing them should be done before it is started.  Collect the
related code, which was scattered in various places, to where
it belongs, in a dedicated function in the term_tag.c module.
As a side benefit, never fclose(2) stdout, only dup2(2) to it.

Similarly, when the -O tag argument wasn't found in the last file
formatted, there was a complaint about "no such tag" even when the
argument did occur in earlier files.  Fix that by looking for a
matching tag after every formatted file rather than just once at
the very end.  Given that command line arguments aren't properties
of the file(s) being formatted, that check is a job for the main
program, not for the formatters, so while fixing the check, move
it from term_tag.c to main.c.

Revision 1.250 / (download) - annotate - [select for diffs], Sat Mar 28 16:16:42 2020 UTC (4 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.249: +10 -13 lines
Diff to previous 1.249 (colored)

Even though the HTML, man, markdown, PDF, PostScript, and tree formatters
never write a ctags(1) file, using a pager still requires writing the
main output file and passing the file name to the pager.
Recent regression mentioned on IRC and reported by kn@.

Revision 1.249 / (download) - annotate - [select for diffs], Thu Mar 19 12:20:45 2020 UTC (4 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.248: +3 -2 lines
Diff to previous 1.248 (colored)

The tag file always needs to be closed before starting the pager,
even when no output formatter was allocated because all pages
shown were preformatted.  Regression in previous reported
by <Andreas dot Kahari at abc dot se> on bugs@.

Revision 1.248 / (download) - annotate - [select for diffs], Fri Mar 13 00:31:04 2020 UTC (4 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.247: +19 -19 lines
Diff to previous 1.247 (colored)

Split tagging into a validation part including prioritization
in tag.{h,c} and {mdoc,man}_validate.c
and into a formatting part including command line argument checking
in term_tag.{h,c}, html.c, and {mdoc|man}_{term|html}.c.

Immediate functional benefits include:
* Improved prioritization of automatic tags for .Em and .Sy.
* Avoiding bogus automatic tags when .Em, .Fn, or .Sy are explicitly tagged.
* Explicit tagging of .Er and .Fl now works in HTML output.
* Automatic tagging of .IP and .TP now works in HTML output.
But mainly, this patch provides clean earth to build further improvements on.

Technical changes:
* Main program: Write a tag file for ASCII and UTF-8 output only.
* All formatters: There is no more need to delay writing the tags.
* mdoc(7)+man(7) formatters: No more need for elaborate syntax tree inspection.
* HTML formatter: If available, use the "string" attribute as the tag.
* HTML formatter: New function to write permalinks, to reduce code duplication.

Style cleanup in the vicinity while here:
* mdoc(7) terminal formatter: To set up bold font for children,
defer to termp_bold_pre() rather than calling term_fontpush() manually.
* mdoc(7) terminal formatter: Garbage collect some duplicate functions.
* mdoc(7) HTML formatter: Unify <code> handling, delete redundant functions.
* Where possible, use switch statements rather than if cascades.
* Get rid of some more Yoda notation.

The necessity for such changes was first discussed with kn@, but i didn't
bother him with a request to review the resulting -673/+782 line patch.

Revision 1.247 / (download) - annotate - [select for diffs], Mon Feb 24 21:15:05 2020 UTC (4 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.246: +26 -4 lines
Diff to previous 1.246 (colored)

Marc Espie reported that "man p*ipc" displayed the perlipc(1) manual.
The reason was that as a last resort when failing to find a page
name in mandoc.db(5) or at a few well well-defined fully qualified
file names, man(1) uses glob(3) to look for candidate files in
relevant directories, because some operating systems have weird
file name extensions, for example pcap.3pcap and BF_set_key.3ssl
on Linux.  But during that globbing, the metacharacters "*?[" need
to be escaped in the name, section, and path supplied by the user,
or you would get weird false positives and misleading warning
messages and would be unable to use the fallback for path or file
names that actually contain an opening bracket.
Feedback and OK espie@.

Revision 1.246 / (download) - annotate - [select for diffs], Mon Feb 10 13:49:04 2020 UTC (4 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.245: +15 -3 lines
Diff to previous 1.245 (colored)

For compatibility with the man(1) implementations of the man-1.6
and man-db packages, print the manpath if the -w option is given
without a following name argument.

This quirk has been in man-1.6 since at least man-1.5e (1998)
and in man-db since 2012.

Using this feature in portable software is a dubious idea because the
internal organization of manual page directories varies in about a
dozen respects among operating systems, so even if you get the answer,
there is no portable way to use it for looking up anything inside.
However, Matej Cepl <mcepl at suse dot cz> made me aware that some
software, for example the manual viewing functionality in the newest
editors/neovim code, unwisely relies on this feature anyway.

No objections were raised when this patch was shown on tech@.

Revision 1.245 / (download) - annotate - [select for diffs], Thu Feb 6 19:41:34 2020 UTC (4 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.244: +14 -3 lines
Diff to previous 1.244 (colored)

Make sure that -l always causes -w to be ignored, as documented
in the man(1) manual page.  This bugfix is needed to prevent
the command "man -lw" from dereferencing a NULL pointer.

Revision 1.244 / (download) - annotate - [select for diffs], Mon Jan 20 10:29:31 2020 UTC (4 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.243: +2 -1 lines
Diff to previous 1.243 (colored)

Make the code more readable by introducing
symbolic constants for tagging priorities.
This review also made me find a minor bug: do not upgrade
TAG_FALLBACK to TAG_WEAK when there is trailing whitespace.

Revision 1.243 / (download) - annotate - [select for diffs], Sun Jul 28 19:41:01 2019 UTC (4 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.242: +30 -37 lines
Diff to previous 1.242 (colored)

Simplification, no functional change:
Delete the "argc" argument from fs_search() which is now always 1,
and move error reporting to the main() program where it is more
logically placed and easier to see.

Revision 1.242 / (download) - annotate - [select for diffs], Sun Jul 28 18:35:09 2019 UTC (4 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.241: +1 -15 lines
Diff to previous 1.241 (colored)

There is no point in pledge(2)ing literally the same list twice,
so delete the second copy.  No functional change.

Revision 1.241 / (download) - annotate - [select for diffs], Sun Jul 28 18:22:35 2019 UTC (4 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.240: +81 -83 lines
Diff to previous 1.240 (colored)

In man(1) mode, do the search for each name independently, and
show the results in the order of the command line arguments.
Implemented by separating the code for man(1) and apropos(1)
in the main() program.
Surprisingly, the number of lines of code remains unchanged.
Issue reported by deraadt@, additional input from millert@.

Revision 1.240 / (download) - annotate - [select for diffs], Sun Jul 28 13:12:58 2019 UTC (4 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.239: +91 -81 lines
Diff to previous 1.239 (colored)

Improve structure, no functional change:
Unify code to process one single input file
and move it into a dedicated new function.

Revision 1.239 / (download) - annotate - [select for diffs], Sat Jul 27 13:40:42 2019 UTC (4 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.238: +22 -27 lines
Diff to previous 1.238 (colored)

Move two more output state variables into the new struct outstate.
Also, move setting of tag_files.tagname into tag_init().
No functional change.

Revision 1.238 / (download) - annotate - [select for diffs], Fri Jul 26 23:12:02 2019 UTC (4 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.237: +62 -60 lines
Diff to previous 1.237 (colored)

Cleanup, no functional change:
For clarity, stop storing the same information (in this case, -O
settings) in two structs.  Give the local struct in main.c a more
descriptive name (output state).

Revision 1.237 / (download) - annotate - [select for diffs], Fri Jul 26 21:03:16 2019 UTC (4 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.236: +44 -38 lines
Diff to previous 1.236 (colored)

Structural cleanup, no functional change:
Mixing parser and formatter state in the same struct was a bad idea,
so pull the parser state and configuration out of it.
This makes sure output options are not passed into parser functions
and parser options are not passed into output functions.
While here, add comments to the important local variables in main().

Revision 1.236 / (download) - annotate - [select for diffs], Fri Jul 26 18:01:21 2019 UTC (4 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.235: +61 -55 lines
Diff to previous 1.235 (colored)

Structural cleanup, no functional change:
Move process group management out of main() into its own function
because it has its own, self-contained logic and its own local variables.

Revision 1.235 / (download) - annotate - [select for diffs], Fri Jul 19 21:45:37 2019 UTC (4 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.234: +14 -8 lines
Diff to previous 1.234 (colored)

#define a handful of constant strings to reduce the diff to -portable;
now, the diff is about -30 +150 lines (about 0.4%)

Revision 1.234 / (download) - annotate - [select for diffs], Fri Jul 19 20:25:21 2019 UTC (4 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.233: +2 -2 lines
Diff to previous 1.233 (colored)

If no tags were generated at all, unlink(2) the empty tags file as
soon the condition can be detected and do not pass it to less(1).
This may happen for man(7) pages, for preformatted pages, and for
very simple pages like true(1).  The main benefit is that :t inside
less(1) yields the clearer diagnostic message "No tags file" rather
than the mildly confusing "No such tag in tags file": the latter
might encourage further, futile attempts to jump to other tags.

Improvement suggested by Leah Neukirchen <leah at vuxu dot org>
from The Void.

Revision 1.233 / (download) - annotate - [select for diffs], Mon Jul 15 21:40:28 2019 UTC (4 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.232: +3 -2 lines
Diff to previous 1.232 (colored)

don't print the final heads-up about message
when a search did not yield any manual pages to display;
issue found with regress/usr.bin/mandoc/db/

Revision 1.232 / (download) - annotate - [select for diffs], Sun Jul 14 18:14:27 2019 UTC (4 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.231: +4 -2 lines
Diff to previous 1.231 (colored)

If messages are shown and output is printed without a pager, display
a heads-up on stderr at the end because otherwise, users may easily
miss the messages: because messages typically occur while parsing,
they typically preceed the output.  This is most useful with flag
combinations like "-c -W all" but may also help in some unusual
error scenarios.
Inconvenient ordering of output originally pointed out by espie@
for the example situation that /tmp/ is not writeable.

Revision 1.231 / (download) - annotate - [select for diffs], Wed Jul 10 19:38:56 2019 UTC (4 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.230: +142 -156 lines
Diff to previous 1.230 (colored)

Some time ago, i simplified mandoc_msg() such that it can be used
everywhere and not only in the parsers.
For more uniform messages, use it at more places instead of err(3),
in particular in the main program.
While here, integrate a few trivial functions called at exactly one
place into the main option parser, and let a few more functions use
the normal convention of returning 0 for success and -1 for error.

Revision 1.230 / (download) - annotate - [select for diffs], Wed Jul 3 16:33:06 2019 UTC (4 years, 10 months ago) by espie
Branch: MAIN
Changes since 1.229: +5 -3 lines
Diff to previous 1.229 (colored)

prevent mandoc from segfaulting if /tmp is not writable
okay schwarze@

Revision 1.229 / (download) - annotate - [select for diffs], Fri May 3 18:38:44 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.228: +3 -6 lines
Diff to previous 1.228 (colored)

avoid duplicate "bad argument" error message, also shortening the code

Revision 1.228 / (download) - annotate - [select for diffs], Fri May 3 17:31:05 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.227: +12 -7 lines
Diff to previous 1.227 (colored)

In fs_lookup(), use stat(2) rather than access(2) to check file existence.
Some mildly broken real-world packages on some operating systems
contain dangling symlinks in manual page directories: pestering the
user to run makewhatis(8) makes no sense because that won't help.
On the other hand, missing read permissions deserve ugly error messages
and are unlikely to occur in practice anyway.

Fixing an issue reported by Lorenzo Beretta <loreb at github>
as part of https://github.com/void-linux/void-packages/issues/9868 .

Revision 1.227 / (download) - annotate - [select for diffs], Fri May 3 16:14:31 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.226: +17 -6 lines
Diff to previous 1.226 (colored)

In man(1) mode with a specific section requested,
try harder to find the best match.

Use this order of preference:
1. The section in both the directory name and the file name matches exactly.
2. The section in the file name matches exactly.
3. The section in the directory name matches exactly.
4. Neither of them matches exactly.
The latter can happen when mansearch() finds substring matches
or when the second .Dt argument mismatches the dir and file names.

Lorenzo Beretta <loreb at github> reported that this caused real
problems on Void Linux, like "man 3 readline" showing readline(3m).
See https://github.com/void-linux/void-packages/issues/9868 for details.

Revision 1.226 / (download) - annotate - [select for diffs], Fri May 3 09:39:01 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.225: +2 -2 lines
Diff to previous 1.225 (colored)

In man(1) mode, when the first argument starts with a digit,
optionally followed by a letter, and at least one more argument
follows, interpret the first argument as a section name even when
additional characters follow after the digit and letter.

This is needed because many operating systems have section names
consisting of a digit followed by more than one letter - for example
Illumos, Solaris, Linux, even NetBSD.

There is very little risk of regressions: in the whole corpus of
manual pages on man.openbsd.org, there isn't a single manual page
name starting with a digit.  And even if programs like "0ad" or
"4channels" had manual pages, "man 0ad" and "man -a cat 0ad" would
still work, only "man -a 0ad cat" will fail with "man: No entry for
cat in section 0ad of the manual."

Fixing one of the issues reported by Lorenzo Beretta <loreb at github>
as part of https://github.com/void-linux/void-packages/issues/9868 .

Revision 1.225 / (download) - annotate - [select for diffs], Tue Apr 30 18:48:26 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.224: +3 -1 lines
Diff to previous 1.224 (colored)

In man(1) mode, i.e. when asking for a single manual page by name,
prefer file name matches over .Dt/.TH matches over first NAME matches
over later NAME matches, but do not change the ordering for apropos(1)
nor for man -a.

This reverts main.c rev. 1.213 and mansearch.h rev. 1.23
and includes a partial revert of mansearch.c rev. 1.62.

Regression reported by Lorenzo Beretta <loreb at github>
as part of https://github.com/void-linux/void-packages/issues/9868 .

Revision 1.224 / (download) - annotate - [select for diffs], Mon Mar 4 18:14:27 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.223: +2 -2 lines
Diff to previous 1.223 (colored)

For TIOCGWINSZ, #include <termios.h> rather than <sys/termios.h>
like almost all other userland programs.  This also improves
portability: for example, it looks like <sys/termios.h> does not
work on FreeBSD, or at least bapt@ did the same change over there.

Revision 1.223 / (download) - annotate - [select for diffs], Mon Mar 4 13:01:52 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.222: +6 -2 lines
Diff to previous 1.222 (colored)

When the -S option is given to man(1) and the requested manual page
name is not found and the requested architecture is unknown, complain
about the architecture rather than about the manual page name:

$ man -S vax cpu
man: Unknown architecture "vax".
$ man -S sparc64 foobar
man: No entry for foobar in the manual.

Friendlier error message suggested by jmc@, who also OK'ed the patch.

Revision 1.222 / (download) - annotate - [select for diffs], Sun Mar 3 13:01:47 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.221: +3 -1 lines
Diff to previous 1.221 (colored)

Reset HTML formatter state, in particular the id_unique hash,
after processing each manual page, such that the next page
starts from a clean state and doesn't continue suffix numbering.

Issue found while looking at https://github.com/Debian/debiman/issues/48
which was brought up by Orestis Ioannou <oorestisime at github>.

Revision 1.221 / (download) - annotate - [select for diffs], Fri Jan 11 17:03:43 2019 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.220: +2 -2 lines
Diff to previous 1.220 (colored)

Improve error reporting when a file given on the command line
cannot be opened:
* Mention the filename.
* Report the errno for the file itself, not the one with .gz appended.

Revision 1.220 / (download) - annotate - [select for diffs], Thu Jan 10 06:27:23 2019 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.219: +3 -2 lines
Diff to previous 1.219 (colored)

Initializers for file-scope static variables should be compile-time
constants, and while stderr is a compile-time constant in OpenBSD,
Kelvin Sherlock <ksherlock at gmail dot com> reports that it isn't
on some other systems, for example on FreeBSD or Linux.
So do the initialization by calling mandoc_msg_setoutfile()
from main() instead.

Revision 1.219 / (download) - annotate - [select for diffs], Tue Jan 1 08:18:06 2019 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.218: +17 -8 lines
Diff to previous 1.218 (colored)

Support taking the -O tag value from apropos(1) key=value search terms;
feature improvement suggested by kn@.
While here, also make "-O value" work from standard input.
OK kn@

Revision 1.218 / (download) - annotate - [select for diffs], Sun Dec 30 00:48:47 2018 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.217: +17 -20 lines
Diff to previous 1.217 (colored)

Cleanup, no functional change:

The struct roff_man used to be a bad mixture of internal parser
state and public parsing results.  Move the public results to the
parsing result struct roff_meta, which is already public.  Move the
rest of struct roff_man to the parser-internal header roff_int.h.

Since the validators need access to the parser state, call them
from the top level parser during mparse_result() rather than from
the main programs, also reducing code duplication.

This keeps parser internal state out of thee main programs (five
in mandoc portable) and out of eight formatters.

Revision 1.217 / (download) - annotate - [select for diffs], Thu Dec 20 21:27:51 2018 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.216: +6 -4 lines
Diff to previous 1.216 (colored)

Move the full responsibility for reporting open(2) errors from
mparse_open() to the caller.  That is better because only the caller
knows its preferred reporting method and format and only the caller
has access to all the data that should be included - like the column
number in .so processing or the current manpath in makewhatis(8).
Moving the mandoc_msg() call out is possible because the caller can
call strerror(3) just as easily as mparse_open() can.

Move mandoc_msg_setinfilename() closer to the parsing of the file
contents, to avoid problems *with* the file (like non-existence,
lack of permissions, etc.) getting misreported as problems *in*
the file.

Fix the column number reported for .so failure:
let it point to the beginning of the filename.

Taken together, this prevents makewhatis(8) from spewing confusing
messages about .so failures to stderr, a bug reported by
Raf Czlonka <rczlonka at gmail dot com> on ports@.

It also prevents mandoc(1) from issuing *two* messages for every
single .so failure.

Revision 1.216 / (download) - annotate - [select for diffs], Fri Dec 14 05:17:45 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.215: +5 -6 lines
Diff to previous 1.215 (colored)

Almost mechanical diff to remove the "struct mparse *" argument
from mandoc_msg(), where it is no longer used.
While here, rename mandoc_vmsg() to mandoc_msg() and retire the
old version:  There is really no point in having another function
merely to save "%s" in a few places.
Minus 140 lines of code.

Revision 1.215 / (download) - annotate - [select for diffs], Fri Dec 14 01:17:46 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.214: +38 -74 lines
Diff to previous 1.214 (colored)

Major cleanup; may imply minor changes in edge cases of error reporting.

Finally, drop support for the run-time configurable mandocmsg()
callback.  It was over-engineered from the start, never used for
anything in a decade, and repeatedly caused maintenance headaches.

Consolidate reporting infrastructure into two files, mandoc.h and
mandoc_msg.c, mopping up the bits and pieces that were scattered
around main.c, read.c, mandoc_parse.h, libmandoc.h, the prototypes
of four parsing-related functions, and both parser structs.

Revision 1.214 / (download) - annotate - [select for diffs], Thu Dec 13 11:55:14 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.213: +2 -1 lines
Diff to previous 1.213 (colored)

Cleanup, no functional change:
Split the top level parser interface out of the utility header
mandoc.h, into a new header mandoc_parse.h, for use in the main
program and in the main parser only.
Move enum mandoc_os into roff.h because struct roff_man is the
place where it is stored.
This allows removal of mandoc.h from seven files in low-level
parsers and in formatters.

Revision 1.213 / (download) - annotate - [select for diffs], Thu Nov 22 12:01:42 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.212: +1 -3 lines
Diff to previous 1.212 (colored)

In apropos(1) output, stop sorting .Nm search results by name
priorities (bits).  The obscure feature wasn't documented and merely
confused people - for example Edward Tomasz Napierala <trasz at
FreeBSD>, see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227408.

Smaller patch provided by Yuri Pankov <yuripv at FreeBSD>, but i'm
also retiring the now unused "bits" member from struct manpage.
Simplification is good.

Revision 1.212 / (download) - annotate - [select for diffs], Thu Nov 22 11:30:15 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.211: +17 -5 lines
Diff to previous 1.211 (colored)

In -T locale (the default), -T ascii, and -T utf8 mode, provide a new
output option -O tag[=term] to move right to the definition of "term" when
opening the manual page in a pager, effectively porting the -T html
fragment name feature - https://man.openbsd.org/ksh#ulimit - to the
terminal.  Try:

$ man -O tag uvm_sysctl
$ man -O tag=ulimit ksh
$ man -O tag 3 compress

Feature development triggered by a question from kn@.  Klemens also
tested, provided feedback that resulted in improvements, and provided
an OK.

Revision 1.211 / (download) - annotate - [select for diffs], Thu Aug 23 19:32:03 2018 UTC (5 years, 8 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.210: +2 -8 lines
Diff to previous 1.210 (colored)

The upcoming .while request will have to re-execute roff(7) lines
parsed earlier, so they will have to be saved for reuse - but the
read.c preparser does not know yet whether a line contains a .while
request before passing it to the roff parser.  To cope with that,
save all parsed lines for now.  Even shortens the code by 20 lines.

Revision 1.210 / (download) - annotate - [select for diffs], Thu Aug 9 17:23:21 2018 UTC (5 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.209: +9 -3 lines
Diff to previous 1.209 (colored)

If somebody asks "man 3 chmod",
don't respond with the lie: "No entry for chmod in the manual."
Instead, say "No entry for chmod in section 3 of the manual."
Came up after a question from kn@; OK kn@.

Revision 1.209 / (download) - annotate - [select for diffs], Mon May 14 14:09:48 2018 UTC (6 years ago) by schwarze
Branch: MAIN
Changes since 1.208: +3 -2 lines
Diff to previous 1.208 (colored)

Some broken terminal emulators (e.g. sakura) do the equivalent
of "stty cols 0".  Ignore that insanity rather than setting
conf.output.width to an invalid value and embarking on infinite loops.
Issue reported by Jesper Wallin <jesper at ifconfig dot se>, thanks!

Revision 1.208 / (download) - annotate - [select for diffs], Thu Apr 19 16:25:11 2018 UTC (6 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.207: +57 -13 lines
Diff to previous 1.207 (colored)

Compatibility with man-db:
In page name mode (= man(1) default mode), also try to interpret
names containing slashes as absolute or relative file names.

Missing feature reported by Nate Bargmann on <groff at gnu dot org>,
and the man-db maintainer Colin Watson <cjwatson at debian dot org>
explained to me how this is supposed to work.

Revision 1.207 / (download) - annotate - [select for diffs], Fri Apr 13 19:55:13 2018 UTC (6 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.206: +14 -2 lines
Diff to previous 1.206 (colored)

Use TIOCGWINSZ to reduce the default -Owidth during interactive use
on terminals narrower than 79 columns and the default -Oindent on
terminals narrower than 66 columns.
Requested by and feedback from pirofti@;
mpi@ and juanfra@ also like the general direction.

Revision 1.206 / (download) - annotate - [select for diffs], Thu Feb 8 01:36:38 2018 UTC (6 years, 3 months ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.205: +2 -2 lines
Diff to previous 1.205 (colored)

Invalidate the tag_files.tfd after fclose(3)ing the stram associated with
it. In main assert that the tfd was actually invalidated. This avoids
closing an invalid fd.

ok deraadt on earlier version, tweak & ok schwarze

Revision 1.205 / (download) - annotate - [select for diffs], Mon Aug 21 15:41:26 2017 UTC (6 years, 8 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.204: +12 -1 lines
Diff to previous 1.204 (colored)

When the stdout stream gets broken, there is no point in reading
any more input files, and it would be misleading to start a parser,
because that would show randomly truncated text.
Instead, print an error message and exit the program.

Issue found by Leah Neukirchen <leah at vuxu dot org>, who was
surprised to see half a manpage when her /tmp/ overflew.

Revision 1.204 / (download) - annotate - [select for diffs], Wed Jul 26 10:21:24 2017 UTC (6 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.203: +2 -2 lines
Diff to previous 1.203 (colored)

Cast the return value of chdir(2) to void.  We already have a comment
above explaining to human auditors why no error checking is needed
here, so it's only fair to tell the compiler, too.
Worried compiler reported by Michael <Stapelberg at debian>.

Revision 1.203 / (download) - annotate - [select for diffs], Thu Jul 20 15:26:35 2017 UTC (6 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.202: +10 -7 lines
Diff to previous 1.202 (colored)

For -Tlint, put parser messages on stdout instead of stderr.

Originally, naddy@ requested this in 2011 (or maybe even earlier).
It was discussed with joerg@, kristaps@, naddy@, and espie@ in 2011,
and everybody agreed in principle, but it was postponed because
kristaps@ wanted to do some cleanup of the message system first.
Meanwhile, message infrastructure was improved about a dozen times...

This makes long, tedious commands like "mandoc -Tlint *.1 2>&1 | less"
unnecessary and allows simple ones like "man -l -Tlint *.1".

Revision 1.202 / (download) - annotate - [select for diffs], Tue Jul 4 14:40:30 2017 UTC (6 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.201: +2 -3 lines
Diff to previous 1.201 (colored)

Printing "BASE:" in messages about violations of base system conventions
is confusing, simply print "STYLE:", which is intuitive and does not
sound excessively alarming; suggested by jmc@, OK tedu@ jmc@.

Revision 1.201 / (download) - annotate - [select for diffs], Sun Jul 2 21:17:12 2017 UTC (6 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.200: +6 -2 lines
Diff to previous 1.200 (colored)

If a single page references the same non-existent manual more than
once, print "(N times)" after the message "referenced manual not
found", to lessen the risk that people fix the first instance and
miss the others; jmc@ confirmed that this is useful.

Revision 1.200 / (download) - annotate - [select for diffs], Sun Jul 2 15:31:48 2017 UTC (6 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.199: +6 -4 lines
Diff to previous 1.199 (colored)

add warning "cross reference to self"; inspired by mdoclint

Revision 1.199 / (download) - annotate - [select for diffs], Sat Jul 1 12:53:56 2017 UTC (6 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.198: +12 -3 lines
Diff to previous 1.198 (colored)

When checking cross references with -Tlint, ultimately fall back to
looking in the current working directory.  Not a security issue
because the files are never open(2)ed, only access(2)ed.
Requested by jmc@ and inspired by mdoclint(1).

This cannot be perfect because it only works for files having the
exact filename ./pagename.sec - mandoc has no way to figure out
which files might contain a manual for multiple names, or that files
in autohell might be called ./pagename.man.in instead, or which
subdirectories might contain additional source files.  Also, it may
hide messages if you have bogus stuff lying around in the directory
where you run mandoc -Tlint.  But jmc@ considers it important, and
good enough for everyday use.

Also avoid leaking the memory for the file name while here.

Revision 1.198 / (download) - annotate - [select for diffs], Sat Jul 1 12:00:12 2017 UTC (6 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.197: +13 -7 lines
Diff to previous 1.197 (colored)

When checking the validity of cross references with -Tlint,
fall back from database search to file system search
just like man(1) does when looking up manuals.

This is not too expensive because on a system having up-to-date
mandoc.db(5) files, it only prolongs the time needed to check
*invalid* references - and you are supposed to have many of those,
right?  And on a system with missing or invalid mandoc.db(5) files,
spending a bit of time and warning loudly about the real problem
is also better than quickly issuing bogus warnings about cross
references that are actually valid.

Revision 1.197 / (download) - annotate - [select for diffs], Sat Jul 1 09:47:23 2017 UTC (6 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.196: +34 -1 lines
Diff to previous 1.196 (colored)

Basic reporting of .Xrs to manual pages that don't exist
in the base system, inspired by mdoclint(1).

We are able to do this because (1) the -mdoc parser, the -Tlint validator,
and the man(1) manual page lookup code are all in the same program
and (2) the mandoc.db(5) database format allows fast lookup.

Feedback from, previous versions tested by, and OK jmc@.

A few features will be added to this in the tree, step by step.

Revision 1.196 / (download) - annotate - [select for diffs], Sat Jun 24 14:38:27 2017 UTC (6 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.195: +43 -26 lines
Diff to previous 1.195 (colored)

Split -Wstyle into -Wstyle and the even lower -Wbase, and add
-Wopenbsd and -Wnetbsd to check conventions for the base system of
a specific operating system.  Mark operating system specific messages
with "(OpenBSD)" at the end.

Please use just "-Tlint" to check base system manuals (defaulting
to -Wall, which is now -Wbase), but prefer "-Tlint -Wstyle" for the
manuals of portable software projects you maintain that are not
part of OpenBSD base, to avoid bogus recommendations about base
system conventions that do not apply.

Issue originally reported by semarie@, solution using
an idea from tedu@, discussed with jmc@ and jca@.

Revision 1.195 / (download) - annotate - [select for diffs], Sat Jun 3 12:16:19 2017 UTC (6 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.194: +2 -2 lines
Diff to previous 1.194 (colored)

enable -Wstyle by default in -Tlint; OK jmc@

Revision 1.194 / (download) - annotate - [select for diffs], Wed May 17 23:39:15 2017 UTC (7 years ago) by schwarze
Branch: MAIN
Changes since 1.193: +1 -3 lines
Diff to previous 1.193 (colored)

Delete the -T xhtml command line option.
It has been obsolete for more than two years.
Use -T html.

Revision 1.193 / (download) - annotate - [select for diffs], Tue May 16 19:05:36 2017 UTC (7 years ago) by schwarze
Branch: MAIN
Changes since 1.192: +14 -11 lines
Diff to previous 1.192 (colored)

Introduce a new mandoc(1) message level, -W style, below -W warning.
Switch -W all from meaning -W warning to meaning -W style.
The meaning of -T lint does *not* change, it still implies -W warning.
No messages on the new level yet, but they will come.

Usually, i do not lightly make the user interface larger.
But this has been planned for years, and EXIT STATUS 1
was reserved for it all the time.  The message system
is now stable enough to finally implement it.

jmc@ regarding the concept: "really good idea"

Revision 1.192 / (download) - annotate - [select for diffs], Tue Apr 18 15:59:56 2017 UTC (7 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.191: +7 -3 lines
Diff to previous 1.191 (colored)

Now that global -i is gone, pass -i through to the apropos(1)
expression parser, such that "apropos -i 'Nm~dump\>'"
finds kdump(1) and WCOREDUMP(2) and you don't need
to type the counter-intuitive "apropos -- -i 'Nm~dump\>'".

Revision 1.191 / (download) - annotate - [select for diffs], Tue Apr 18 15:26:33 2017 UTC (7 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.190: +1 -5 lines
Diff to previous 1.190 (colored)

Delete the undocumented and unimplemented man(1) -i (interactive
apropos) option.  It will not be implemented.  Featurism isn't the
plan for the future; simplicity is.

Revision 1.190 / (download) - annotate - [select for diffs], Mon Mar 27 18:51:20 2017 UTC (7 years, 1 month ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.189: +8 -10 lines
Diff to previous 1.189 (colored)

simplify the SYNOPSIS as well, just like the option lists;
suggested by and OK jmc@

Revision 1.189 / (download) - annotate - [select for diffs], Mon Mar 20 14:30:43 2017 UTC (7 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.188: +8 -16 lines
Diff to previous 1.188 (colored)

Silently ignore invalid -m input formats rather than erroring out.
As observed by Jan Stary <hans at stare dot cz>, this is useful such
that after 'alias man="man -m $HOME/man"', 'man -l foo.1' still works.
Simplify and shorten the description of -m, and use .Ic for macros.

Revision 1.188 / (download) - annotate - [select for diffs], Fri Mar 3 14:21:41 2017 UTC (7 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.187: +7 -1 lines
Diff to previous 1.187 (colored)

new -mdoc -Tmarkdown output mode; OK millert@ reyk@ tb@;
thanks to reyk@ and to Vsevolod at FreeBSD for suggesting it

Revision 1.187 / (download) - annotate - [select for diffs], Wed Feb 22 14:58:27 2017 UTC (7 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.186: +3 -3 lines
Diff to previous 1.186 (colored)

Since SQLite is gone, we no longer need the "flock" pledge.
Patch from semarie@, OK tb@.

Revision 1.186 / (download) - annotate - [select for diffs], Thu Feb 16 10:55:57 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.185: +23 -18 lines
Diff to previous 1.185 (colored)

Fix rev. 1.183: -O syntax is different in default apropos(1) output
mode and in other output modes, so do not error out prematurely.
Also sort local variables in main() while here.

Revision 1.185 / (download) - annotate - [select for diffs], Fri Feb 10 15:44:31 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.184: +5 -3 lines
Diff to previous 1.184 (colored)

In -Ttree output mode, show the BROKEN node flag and
provide a -Onoval output option to show the unvalidated tree.

Revision 1.184 / (download) - annotate - [select for diffs], Thu Feb 9 17:19:07 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.183: +2 -2 lines
Diff to previous 1.183 (colored)

Be consistent in protecting __attribute__ attributes with __;
from Christos Zoulas <christos @ NetBSD>.

Revision 1.183 / (download) - annotate - [select for diffs], Fri Jan 27 13:47:17 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.182: +10 -4 lines
Diff to previous 1.182 (colored)

warn about invalid output options
and error out if they occur on the command line;
missing feature found in the TODO file

Revision 1.182 / (download) - annotate - [select for diffs], Mon Jan 9 17:49:55 2017 UTC (7 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.181: +6 -6 lines
Diff to previous 1.181 (colored)

Use stdout rather than stdin for controlling the terminal
such that "cat foo.mdoc | man -l" works.
Issue reported by Christian Neukirchen <chneukirchen at gmail dot com>
and also tested by him on Void Linux with both glibc and musl.
The patch makes sense to millert@.

Revision 1.181 / (download) - annotate - [select for diffs], Mon Jan 9 01:36:22 2017 UTC (7 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.180: +3 -2 lines
Diff to previous 1.180 (colored)

Warnings and errors that occur during mdoc_validate()
or during man_validate() have to affect the mandoc(1) EXIT STATUS.
Many thanks to <Yuri dot Pankov at gmail dot com> (illumos developer)
for reporting this regression.

Revision 1.180 / (download) - annotate - [select for diffs], Sun Sep 18 15:45:50 2016 UTC (7 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.179: +15 -5 lines
Diff to previous 1.179 (colored)

We cannot use fputs(3) in passthrough() because the stdout stream
might be in stdio wide orientation due to prior formatting of an
unformatted manual in man -aTutf8 mode.  So for now, use fflush(3)
followed by unbuffered write(2) instead.  Fixes output corruption
on glibc discovered on Linux while testing a diff to fix a loosely
related bug reported by <jmates at ee dot washington dot edu>.

I detest the concept of stdio stream orientation.  One day, i will
rewrite term_ascii.c to always use narrow streams, even in UTF-8
output mode.  But that's too much work for today.

Revision 1.179 / (download) - annotate - [select for diffs], Sun Sep 18 15:21:00 2016 UTC (7 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.178: +35 -28 lines
Diff to previous 1.178 (colored)

Make sure an output device is allocated before calling terminal_sepline(),
fixing a NULL pointer access that happened when the first of multiple pages
shown was preformatted, as in "man -a groff troff".
Crash reported by <jmates at ee dot washington dot edu> on bugs@, thanks!

Revision 1.178 / (download) - annotate - [select for diffs], Tue Aug 9 15:08:15 2016 UTC (7 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.177: +3 -2 lines
Diff to previous 1.177 (colored)

fix printf("%s", NULL);
found while investigating an unrelated bug report from jsg@

Revision 1.177 / (download) - annotate - [select for diffs], Mon Aug 1 10:32:39 2016 UTC (7 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.176: +4 -8 lines
Diff to previous 1.176 (colored)

Remove the dependency on SQLite without loss of functionality.
Drop the obsolete names_check() now that we deleted MLINKS.
Run "doas makewhatis" after compiling and installing this.

Earlier version tested by jmc@ and jturner@;
"commit it all" deraadt@   "commit and dodge" krw@

Revision 1.176 / (download) - annotate - [select for diffs], Fri Jul 15 19:31:53 2016 UTC (7 years, 10 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.175: +2 -2 lines
Diff to previous 1.175 (colored)

To remove the const qualifier from a pointer to an object - either
because we know it is actually mutable or because we are passing
it to a function that doesn't accept a const object but won't
actually attempt to modify it - simply casting from (const type *)
to (type *) is legal C and clearly expresses the intent.
So get rid of the obfuscating UNCONST macro.
Basic idea discussed with guenther@.

Revision 1.175 / (download) - annotate - [select for diffs], Fri Jul 15 18:49:53 2016 UTC (7 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.174: +1 -2 lines
Diff to previous 1.174 (colored)

Fix previous: the mandocdb() prototype was already there, it just
hid among static functions, as noticed by tedu@ (my bad).

Revision 1.174 / (download) - annotate - [select for diffs], Fri Jul 15 18:02:32 2016 UTC (7 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.173: +4 -1 lines
Diff to previous 1.173 (colored)

add missing prototypes, no code change;
noticed by Christos Zoulas with -Wmissing-prototypes

Revision 1.173 / (download) - annotate - [select for diffs], Fri Jul 8 22:27:58 2016 UTC (7 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.172: +2 -2 lines
Diff to previous 1.172 (colored)

ISO C99 7.19.2.5 doesn't like mixing putchar(3) and putwchar(3) on
the same stream, and actually, it fails spectacularly on glibc.
Portability issue pointed out by Svyatoslav Mishyn <juef at openmailbox
dot org> after testing on Void Linux.

Revision 1.172 / (download) - annotate - [select for diffs], Thu Apr 14 20:54:15 2016 UTC (8 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.171: +9 -3 lines
Diff to previous 1.171 (colored)

Fix a process group race.

It could occasionally happen that the child process spawned less(1)
before the parent process passed the control of the terminal to the
child, and in that case, less(1) sometimes complained "Stopped (tty
output)".  Issue reported by naddy@.

Revision 1.171 / (download) - annotate - [select for diffs], Wed Apr 13 12:26:21 2016 UTC (8 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.170: +11 -9 lines
Diff to previous 1.170 (colored)

Give manuals in purely numerical sections priority over manuals of
the same name in sections with an alphabetical suffix (on OpenBSD,
mostly 3p), restoring behaviour of the traditional BSD man(1) that
got lost in the switch to the mandoc-based implementation.

Issue reported by jsg@, using an idea by mikeb@ for the solution,
and at least afresh1@ and jasper@ also seem in favour of the direction.

Revision 1.170 / (download) - annotate - [select for diffs], Sat Jan 16 21:56:32 2016 UTC (8 years, 4 months ago) by florian
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.169: +2 -2 lines
Diff to previous 1.169 (colored)

Unbreak reading from stdin after recent parse() restructuring.
OK schwarze@

Revision 1.169 / (download) - annotate - [select for diffs], Fri Jan 8 02:53:09 2016 UTC (8 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.168: +5 -9 lines
Diff to previous 1.168 (colored)

Simplify the mparse_open() interface.
Just return the file descriptor or -1 on error;
there is just one kind of error anyway.
Suggested by Christos Zoulas (NetBSD).

Revision 1.168 / (download) - annotate - [select for diffs], Fri Jan 8 02:13:35 2016 UTC (8 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.167: +4 -2 lines
Diff to previous 1.167 (colored)

It was very surprising that a function called mparse_readfd()
closed the file descriptor passed to it after completing its work,
in particular considering the fact that it required its callers
to call open(2) or mparse_open() beforehand.

Change mparse_readfd() to not call close(2) and change the callers
to call close(2) afterwards, more or less bringing open and close
to the same level of the code and making review easier.  Note that
man.cgi(8) already did that, even though it was wrong in the past.

Small restructuring suggested by Christos Zoulas (NetBSD).

Revision 1.167 / (download) - annotate - [select for diffs], Tue Dec 15 17:36:19 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.166: +11 -6 lines
Diff to previous 1.166 (colored)

pledge(2) style:
Make sure to always use the idiom 'if (pledge("'
such that it can easily be searched for.
No functional change.
Requested by deraadt@ some time ago.

Revision 1.166 / (download) - annotate - [select for diffs], Fri Nov 20 21:58:32 2015 UTC (8 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.165: +42 -19 lines
Diff to previous 1.165 (colored)

Fix multiple issues regarding process group and signal mask handling
found by tb@ and millert@; parts of the code, in particular in tag.c,
by millert@; OK millert@.

Revision 1.165 / (download) - annotate - [select for diffs], Sat Nov 14 23:56:41 2015 UTC (8 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.164: +35 -5 lines
Diff to previous 1.164 (colored)

Fix an issue reported by deraadt@:  When hitting Ctrl-Backslash (= SIGQUIT)
in the less(1) spawned by man(1), man(1) died uncleanly, leaving behind
its temp files, and killed less(1) uncleanly as well with SIGPIPE,
leaving the terminal in the wrong state.

Fix this by giving less(1) its own process group and handing it
control of the terminal, but in such a way that Ctrl-z (= SIGSTOP)
still works: In that case, let man(1) stop itself, too, and let it
continue the pager when it continues itself.

Joint work with millert@ who contributed most of the expertise
required, and also most parts of the code.
OK deraadt@ millert@

Revision 1.164 / (download) - annotate - [select for diffs], Sat Nov 7 17:58:52 2015 UTC (8 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.163: +20 -24 lines
Diff to previous 1.163 (colored)

Modernization, no functional change intended:
Use the POSIX function getline(3) rather than the slightly
dangerous BSD function fgetln(3).

Revision 1.163 / (download) - annotate - [select for diffs], Fri Nov 6 17:23:50 2015 UTC (8 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.162: +5 -5 lines
Diff to previous 1.162 (colored)

correct exit status on pledge(2) errors

Revision 1.162 / (download) - annotate - [select for diffs], Fri Nov 6 16:27:13 2015 UTC (8 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.161: +11 -11 lines
Diff to previous 1.161 (colored)

Use getprogname(3) rather than __progname.
Suggested by Joerg@ Sonnenberger (NetBSD).
Last year, deraadt@ confirmed on tech@ that this "has the potential
to be more portable", and micro-optimizing for speed is not relevant
here.  Also gets rid of one global variable.

Revision 1.161 / (download) - annotate - [select for diffs], Thu Oct 22 21:53:49 2015 UTC (8 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.160: +2 -1 lines
Diff to previous 1.160 (colored)

move man(7) validation into the dedicated validation phase, too

Revision 1.160 / (download) - annotate - [select for diffs], Thu Oct 22 21:02:55 2015 UTC (8 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.159: +18 -16 lines
Diff to previous 1.159 (colored)

If no output device was allocated because no file wanted to produce output,
refrain from dereferencing a NULL pointer during final deallocation.
Fixing a recent regression reported by czarkoff@

Revision 1.159 / (download) - annotate - [select for diffs], Tue Oct 20 02:00:49 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.158: +2 -1 lines
Diff to previous 1.158 (colored)

In order to become able to generate syntax tree nodes on the roff(7)
level, validation must be separated from parsing and rewinding.
This first big step moves calling of the mdoc(7) post_*() functions
out of the parser loop into their own mdoc_validate() pass, while
using a new mdoc_state() module to make syntax tree state handling
available to both the parser loop and the validation pass.

Revision 1.158 / (download) - annotate - [select for diffs], Mon Oct 19 19:51:06 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.157: +52 -36 lines
Diff to previous 1.157 (colored)

Simplify, no functional change:
Delete the outmdoc, outman, and outfree function pointers.

Revision 1.157 / (download) - annotate - [select for diffs], Fri Oct 16 21:35:16 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.156: +5 -1 lines
Diff to previous 1.156 (colored)

Once apropos(1) or man(1) are done with database access, or if the
program was called as mandoc(1) in the first place, remove "flock"
from our pledge(2) before entering the parsers and formatters.
OK millert@ deraadt@

Revision 1.156 / (download) - annotate - [select for diffs], Fri Oct 16 13:37:44 2015 UTC (8 years, 7 months ago) by millert
Branch: MAIN
Changes since 1.155: +3 -3 lines
Diff to previous 1.155 (colored)

Implement real "flock" request and add it to userland programs that
use pledge and file locking.  OK deraadt@

Revision 1.155 / (download) - annotate - [select for diffs], Tue Oct 13 22:57:49 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.154: +10 -18 lines
Diff to previous 1.154 (colored)

Major character table cleanup:
* Use ohash(3) rather than a hand-rolled hash table.
* Make the character table static in the chars.c module:
There is no need to pass a pointer around, we most certainly
never want to use two different character tables concurrently.
* No need to keep the characters in a separate file chars.in;
that merely encourages downstream porters to mess with them.
* Sort the characters to agree with the mandoc_chars(7) manual page.
* Specify Unicode codepoints in hex, not decimal (that's the detail
that originally triggered this patch).
No functional change, minus 100 LOC, and i don't see a performance change.

Revision 1.154 / (download) - annotate - [select for diffs], Mon Oct 12 22:41:18 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.153: +9 -1 lines
Diff to previous 1.153 (colored)

plegde(2) for apropos(1), help(1), man(1), mandoc(1), and whatis(1):
Always needed: stdio rpath (to open multiple files and for .so)
In addition after starting the pager: tmppath (to clean up the temp files)
In addition before starting the pager: proc exec
Looks good to deraadt@.

Revision 1.153 / (download) - annotate - [select for diffs], Mon Oct 12 00:07:27 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.152: +1 -6 lines
Diff to previous 1.152 (colored)

To make the code more readable, delete 283 /* FALLTHROUGH */ comments
that were right between two adjacent case statement.  Keep only
those 24 where the first case actually executes some code before
falling through to the next case.

Revision 1.152 / (download) - annotate - [select for diffs], Sun Oct 11 21:06:59 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.151: +28 -54 lines
Diff to previous 1.151 (colored)

Finally use __progname, err(3) and warn(3).
That's more readable and less error-prone than fumbling around
with argv[0], fprintf(3), strerror(3), perror(3), and exit(3).
It also shortens the code by 50 lines.

It's a bad idea to boycott good interfaces merely because standards
committees ignore them.  Instead, it's the job of the portable
distribution to provide compatibility modules for archaic systems
(like commercial Solaris) that still don't have them.  Actually,
the compat code for the portable distribution already exists and
will be committed right after this.

Revision 1.151 / (download) - annotate - [select for diffs], Sat Oct 10 13:20:25 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.150: +6 -4 lines
Diff to previous 1.150 (colored)

Decide whether to use_pager as early as possible,
in preparation for pledge(2); no functional change intended.

Revision 1.150 / (download) - annotate - [select for diffs], Tue Oct 6 18:30:43 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.149: +20 -20 lines
Diff to previous 1.149 (colored)

modernize style: "return" is not a function; ok cmp(1)

Revision 1.149 / (download) - annotate - [select for diffs], Tue Jul 28 18:38:05 2015 UTC (8 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.148: +33 -62 lines
Diff to previous 1.148 (colored)

Remove the hack of scrolling forward and backward with +G1G that
many (jmc@, millert@, espie@, deraadt@) considered revolting.
Instead, when using a pager, since we are using a temporary file
for tags anyway, use another temporary file for the formatted
page(s), as suggested by millert@ and similar to what the traditional
BSD man(1) did, except that we use only one single temporary output
file rather than one for each formatted manual page, such that
searching (both with / and :t) works across all the displayed files.

Revision 1.148 / (download) - annotate - [select for diffs], Tue Jul 21 03:26:02 2015 UTC (8 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.147: +12 -9 lines
Diff to previous 1.147 (colored)

When creation of the temporary tags file fails, call the pager
without the -T option, because otherwise the pager won't even start.
Fixing a bug reported by jca@.

While here, shorten the code by two lines
and delete one internal interface function.

Revision 1.147 / (download) - annotate - [select for diffs], Sun Jul 19 05:59:07 2015 UTC (8 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.146: +1 -5 lines
Diff to previous 1.146 (colored)

Do not fork and exec gunzip(1), just link with libz instead.
As discussed with deraadt@, that's cleaner and will help tame(2).
Something like this was also suggested earlier by bapt at FreeBSD.
Minus 50 lines of code, deleting one interface function (mparse_wait),
no functional change intended.

Revision 1.146 / (download) - annotate - [select for diffs], Sun Jul 19 00:06:33 2015 UTC (8 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.145: +6 -3 lines
Diff to previous 1.145 (colored)

If we aren't on a tty, clear the pager flag up front.
Just to clean up code structure, no functional change.

Revision 1.145 / (download) - annotate - [select for diffs], Sat Jul 18 05:46:52 2015 UTC (8 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.144: +2 -2 lines
Diff to previous 1.144 (colored)

Insist that manual page file name extensions must begin with a digit,
lest pkg.conf(5) be shown when pkg(5) is asked for;
issue reported by Michael Reed <m dot reed at mykolab dot com>.

Revision 1.144 / (download) - annotate - [select for diffs], Fri Jul 17 22:35:36 2015 UTC (8 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.143: +44 -27 lines
Diff to previous 1.143 (colored)

Initial, still somewhat experimental implementation to leverage
less(1) -T and :t ctags(1)-like functionality to jump to the
definitions of various terms inside manual pages.
To be polished in the tree, so bear with me and report issues.

Technically, if less(1) is used as a pager, information is collected
by the mdoc(7) terminal formatter, first stored using the ohash
library, then ultimately written to a temporary file which is passed
to less via -T.  No change intended for other output formatters or
when running without a pager.

Based on an idea from Kristaps using feedback from many, in particular
phessler@ nicm@ millert@ halex@ doug@ kspillner@ deraadt@.

Revision 1.143 / (download) - annotate - [select for diffs], Wed Apr 29 11:03:48 2015 UTC (9 years ago) by schwarze
Branch: MAIN
Changes since 1.142: +3 -3 lines
Diff to previous 1.142 (colored)

Improve the error message in case somebody has configured an invalid PAGER.
Suggested by Lorenzo Beretta <lory dot fulgi at infinito dot it>.

Revision 1.142 / (download) - annotate - [select for diffs], Mon Apr 20 09:54:34 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.141: +10 -6 lines
Diff to previous 1.141 (colored)

Fix previous:  Don't let man(1) warn twice about non-existant names.
Again noticed by deraadt@.

Revision 1.141 / (download) - annotate - [select for diffs], Sun Apr 19 15:10:04 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.140: +3 -1 lines
Diff to previous 1.140 (colored)

If apropos(1) finds no match, print "nothing appropriate" to stderr
similar to what the old apropos did.
Requested by and OK deraadt@.

Revision 1.140 / (download) - annotate - [select for diffs], Sat Apr 18 16:34:03 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.139: +7 -6 lines
Diff to previous 1.139 (colored)

Profit from the unified struct roff_man and reduce the number of
arguments of mparse_result() by one.  No functional change.
Written on the ICE Bruxelles-Koeln on the way back from p2k15.

Revision 1.139 / (download) - annotate - [select for diffs], Sat Apr 18 16:04:40 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.138: +5 -5 lines
Diff to previous 1.138 (colored)

Replace the structs mdoc and man by a unified struct roff_man.
Almost completely mechanical, no functional change.
Written on the train from Exeter to London returning from p2k15.

Revision 1.138 / (download) - annotate - [select for diffs], Thu Apr 16 16:35:02 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.137: +3 -5 lines
Diff to previous 1.137 (colored)

shorten "outdated mandoc.db" warning message; requested by deraadt@

Revision 1.137 / (download) - annotate - [select for diffs], Fri Apr 3 08:45:27 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.136: +2 -2 lines
Diff to previous 1.136 (colored)

No need to hardcode /usr/bin/ as the path to more(1); helps portability.
We don't hardcode the paths to gunzip(1) and cmp(1) either.
Discussed with ajacoutot@.

Revision 1.136 / (download) - annotate - [select for diffs], Thu Apr 2 21:03:18 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.135: +4 -3 lines
Diff to previous 1.135 (colored)

First step towards parser unification:
Replace enum mdoc_type and enum man_type by a unified enum roff_type.
Almost mechanical, no functional change.
Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.

Revision 1.135 / (download) - annotate - [select for diffs], Fri Mar 27 21:17:16 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.134: +10 -9 lines
Diff to previous 1.134 (colored)

Actually use the new man.conf(5) "output" directive.
Additional functionality, yet minus 45 lines of code.

Revision 1.134 / (download) - annotate - [select for diffs], Fri Mar 27 17:36:56 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.133: +13 -11 lines
Diff to previous 1.133 (colored)

Parse the new man.conf(5) "output" directive.
The next step will be to actually use the parsed data.

Revision 1.133 / (download) - annotate - [select for diffs], Fri Mar 27 16:35:57 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.132: +4 -4 lines
Diff to previous 1.132 (colored)

Modernize documentation by inserting blanks between option letters
and option arguments, except for -m because "-m an" and "-m andoc"
look just too weird.  Of course, the traditional form without the
blank will continue to work.

Revision 1.132 / (download) - annotate - [select for diffs], Tue Mar 17 13:35:04 2015 UTC (9 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.131: +20 -27 lines
Diff to previous 1.131 (colored)

Simplify: Now that rc is global anyway, no need to pass it around
as an argument.  No functional change.

Revision 1.131 / (download) - annotate - [select for diffs], Tue Mar 17 07:32:21 2015 UTC (9 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.130: +13 -2 lines
Diff to previous 1.130 (colored)

When the user exits the pager before the pager has drained all input
from man(1), man(1) dies from SIGPIPE.  Exiting man(1) is fine in this
case, generating more output would be pointless, but without handling
SIGPIPE, the exit code from man(1) was wrong and csh(1) printed an
ugly message "Broken pipe".  Fix this by handling SIGPIPE explicitly.
Issue noticed by deraadt@.

Revision 1.130 / (download) - annotate - [select for diffs], Tue Mar 10 13:48:57 2015 UTC (9 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.129: +23 -27 lines
Diff to previous 1.129 (colored)

We can keep track of the pager PID without additional complexity.
No functional change for now, but more robust in case anybody should
ever add additional child processes.

Revision 1.129 / (download) - annotate - [select for diffs], Tue Mar 10 03:00:48 2015 UTC (9 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.128: +22 -4 lines
Diff to previous 1.128 (colored)

Fix a regression caused in rev. 1.118, reported by kristaps@:

When using a pager and the first manual shown is gzip'ed,
the gunzip(1) process ended up as a child of the pager process
such that the man(1) process couldn't wait for it, preventing
proper display of the manual.

Solve this by making the pager a child of the man(1) process
(instead of the other way round), which requires being a bit
more careful about properly closing file descriptors after use
and waiting for the pager before exiting man(1).

Revision 1.128 / (download) - annotate - [select for diffs], Mon Mar 9 21:30:27 2015 UTC (9 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.127: +3 -3 lines
Diff to previous 1.127 (colored)

Explicitly cast when assigning from char * to unsigned char * and vice versa.
For example, gcc 4.7 wants this with -Wall.  Patch from kristaps@.

Revision 1.127 / (download) - annotate - [select for diffs], Fri Feb 27 16:00:54 2015 UTC (9 years, 2 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.126: +20 -9 lines
Diff to previous 1.126 (colored)

When man(1) and apropos(1) look for a file man1/foo.1 but it's unavailable,
fall back to glob(man1/foo.*), which is more like what old man(1) did.
Do this both for file names from the database and for fs_lookup().
This is relevant because some ports install files like man1/xset.1x.
Regression reported by patrick keshishian <pkeshish at gmail dot com>.

Revision 1.126 / (download) - annotate - [select for diffs], Mon Feb 16 16:18:02 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.125: +5 -17 lines
Diff to previous 1.125 (colored)

Delete the -V option.  It serves no purpose but keeps confusing people.

Revision 1.125 / (download) - annotate - [select for diffs], Tue Feb 10 08:05:07 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.124: +2 -2 lines
Diff to previous 1.124 (colored)

trim trailing white space, no code change;
from Svyatoslav Mishyn <juef at openmailboxd dot org>, Crux Linux

Revision 1.124 / (download) - annotate - [select for diffs], Sat Feb 7 06:27:53 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.123: +10 -7 lines
Diff to previous 1.123 (colored)

be more careful about argc == 0

Revision 1.123 / (download) - annotate - [select for diffs], Tue Jan 20 21:12:46 2015 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.122: +8 -4 lines
Diff to previous 1.122 (colored)

Split the -Werror message level into -Werror (broken manual, probably
using mandoc is better than using groff) and -Wunsupp (manual using
unsupported low-level roff(7) feature, probably using groff is better
than using mandoc).  Once this feature is complete, it is intended
to help porting, making the decision whether to USE_GROFF easier.

As a first step, distinguish four classes of roff(7) requests:
1. Supported (currently 24 requests)
2. Currently ignored because unimportant (120)  ->  no message
3. Ignored for good because insecure (14)  ->  -Werror
4. Currently unsupported (68)  ->  these trigger the new -Wunsupp messages

Revision 1.122 / (download) - annotate - [select for diffs], Fri Jan 16 21:12:01 2015 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.121: +6 -1 lines
Diff to previous 1.121 (colored)

Let man(1) show manuals for the current architecture by default,
and support the MACHINE environment variable as documented in man(1).
Missing feature reported by pascal@.

Revision 1.121 / (download) - annotate - [select for diffs], Thu Jan 15 04:26:06 2015 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.120: +3 -8 lines
Diff to previous 1.120 (colored)

Fatal errors no longer exist.
If a file can be opened, mandoc will produce some output;
at worst, the output may be almost empty.
Simplifies error handling and frees a message type for future use.

Revision 1.120 / (download) - annotate - [select for diffs], Wed Jan 14 21:27:01 2015 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.119: +13 -7 lines
Diff to previous 1.119 (colored)

if earlier files set a non-zero exit status,
do not allow later files to reset it to zero

Revision 1.119 / (download) - annotate - [select for diffs], Tue Jan 13 23:16:12 2015 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.118: +102 -5 lines
Diff to previous 1.118 (colored)

Be developer-friendly, 'cause OpenBSD devs like to:
cd /usr/src/share/man/man4; vi newdev.4 Makefile; make install; man newdev

When a manual is missing from an outdated database, let man(1)
show it anyway, using a KISS file system lookup as a fallback.
Requested by deraadt@.

87 new lines of code doesn't seem too much bloat to me.

Of course, keeping your mandoc.db(5) files up to date with makewhatis(8)
or weekly(8) is still required for apropos(1) to find your new pages.

Revision 1.118 / (download) - annotate - [select for diffs], Tue Jan 13 13:22:13 2015 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.117: +29 -24 lines
Diff to previous 1.117 (colored)

do not spawn a pager when there is no output; issue pointed out by deraadt@

Revision 1.117 / (download) - annotate - [select for diffs], Thu Jan 1 13:18:23 2015 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.116: +3 -2 lines
Diff to previous 1.116 (colored)

If man(1) only has one single argument, always interpret it as a name,
never as a section.  Who would have thought that people call their
manual pages 7z(1), 9c(1), 9p(1), and 9p(3)...
Patch from Sebastien Marie <semarie dash openbsd at latrappe dot fr>.

Revision 1.116 / (download) - annotate - [select for diffs], Wed Dec 31 16:50:54 2014 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.115: +6 -2 lines
Diff to previous 1.115 (colored)

When showing more than one formatted manual page, insert horizontal lines
between pages.  Suggested by Theo Buehler <theo at math dot ethz dot ch>.
Even in UTF-8 output mode, do not use fancy line drawing characters such
that you can easily use /^--- to skip to the next manual in your pager.

Revision 1.115 / (download) - annotate - [select for diffs], Sun Dec 21 14:49:00 2014 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.114: +8 -8 lines
Diff to previous 1.114 (colored)

Use -m for macro set selection in mandoc(1) mode only, not in man(1)
and apropos(1) mode.  While here, put a space character between
options and option arguments in error messages.
Both reported by Alessandro DE LAURENZIS <just22 dot adl at gmail dot com>.

Revision 1.114 / (download) - annotate - [select for diffs], Thu Dec 18 20:45:50 2014 UTC (9 years, 5 months ago) by jmc
Branch: MAIN
Changes since 1.113: +5 -3 lines
Diff to previous 1.113 (colored)

update usage() and the list of non-standard (i.e. non-posix) options;
ok schwarze

Revision 1.113 / (download) - annotate - [select for diffs], Wed Dec 17 18:45:00 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.112: +7 -6 lines
Diff to previous 1.112 (colored)

Be a bit more lenient in what to accept for section names given
as the first man(1) command line argument without -s:
Accept digits like "1", "2"; digit+letter like "3p", "1X"; and "n".
Issue reported by Svyatoslav Mishyn <juef at openmailbox dot org> (Crux Linux).

Revision 1.112 / (download) - annotate - [select for diffs], Mon Dec 15 18:04:32 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.111: +5 -4 lines
Diff to previous 1.111 (colored)

Let "man n open" do the same as "man -s n open" again, that is,
show the open(n) Tcl manual, as documented in man(1).  Issue reported
by Svyatoslav Mishyn <juef at openmailbox dot org> (Crux Linux).

Revision 1.111 / (download) - annotate - [select for diffs], Thu Dec 11 19:50:04 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.110: +6 -5 lines
Diff to previous 1.110 (colored)

slightly reshuffle some code to reduce the diff with portable;
no functional change

Revision 1.110 / (download) - annotate - [select for diffs], Fri Dec 5 21:55:02 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.109: +23 -10 lines
Diff to previous 1.109 (colored)

implement help(1)

Revision 1.109 / (download) - annotate - [select for diffs], Tue Dec 2 11:31:46 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.108: +2 -2 lines
Diff to previous 1.108 (colored)

Switch the default output mode from -Tascii to -Tlocale.
This doesn't change anything unless LC_CTYPE is set,
but it helps when running with LC_TYPE=something.UTF-8.

OK tedu@  and earlier positive feedback from:
bentley@ deraadt@ naddy@ stsp@  uqs@freebsd wiz@netbsd

Revision 1.108 / (download) - annotate - [select for diffs], Wed Nov 26 21:40:11 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.107: +4 -8 lines
Diff to previous 1.107 (colored)

Simplify the mparse_open()/mparse_wait() interface.
Don't bother the user with the PID of the child process,
store it inside the opaque mparse handle.

Revision 1.107 / (download) - annotate - [select for diffs], Tue Nov 11 19:03:10 2014 UTC (9 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.106: +5 -1 lines
Diff to previous 1.106 (colored)

In man(1) mode without -a, stop searching after the first manual tree
that contained at least one match in order to not prefer mdoc(1) from
ports over mdoc(7).  As a bonus, this results in a speedup.

Revision 1.106 / (download) - annotate - [select for diffs], Tue Nov 11 02:43:11 2014 UTC (9 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.105: +2 -1 lines
Diff to previous 1.105 (colored)

Let -h imply -c (that is, not use the pager).
Usually, -h output is short, so the pager is just a nuisance.
Also, traditional man(1) does not use a pager for -h.
Triggered by a remark of deraadt@ on ICB.

Revision 1.105 / (download) - annotate - [select for diffs], Tue Nov 11 02:08:57 2014 UTC (9 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.104: +55 -15 lines
Diff to previous 1.104 (colored)

implement -h (synopsis only) for preformatted (cat) pages;
requested by tedu@

Revision 1.104 / (download) - annotate - [select for diffs], Thu Oct 30 15:05:05 2014 UTC (9 years, 6 months ago) by jmc
Branch: MAIN
Changes since 1.103: +3 -3 lines
Diff to previous 1.103 (colored)

mandoc.1: fix a macro error in previous
main.c: add -K to usage() and wrap nicely

ok schwarze

Revision 1.103 / (download) - annotate - [select for diffs], Thu Oct 30 00:05:02 2014 UTC (9 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.102: +29 -3 lines
Diff to previous 1.102 (colored)

support UTF-8 and ISO-8859-1 input by integrating modified parts
of kristaps@' version of the preconv(1) utility into mandoc(1);
positive feedback from bentley@ and no concern raised when shown on tech@

Revision 1.102 / (download) - annotate - [select for diffs], Tue Oct 28 17:35:42 2014 UTC (9 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.101: +20 -18 lines
Diff to previous 1.101 (colored)

Make the character table available to libroff so it can check the
validity of character escape names and warn about unknown ones.
This requires mchars_spec2cp() to report unknown names again.
Fortunately, that doesn't require changing the calling code because
according to groff, invalid character escapes should not produce
output anyway, and now that we warn about them, that's fine.

Revision 1.101 / (download) - annotate - [select for diffs], Sat Oct 18 15:46:16 2014 UTC (9 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.100: +5 -4 lines
Diff to previous 1.100 (colored)

plug file descriptor leaks on read or write failure;
hinted at by Steffen Nurpmeso <sdaoden at yandex dot com>.

Revision 1.100 / (download) - annotate - [select for diffs], Wed Sep 3 23:20:33 2014 UTC (9 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.99: +23 -15 lines
Diff to previous 1.99 (colored)

Add *.gz support to apropos(1) -a, manm(1), and even mandoc(1).
Implemented by moving the zip code from makewhatis(8) to the parser lib.

Revision 1.99 / (download) - annotate - [select for diffs], Wed Sep 3 18:08:26 2014 UTC (9 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.98: +2 -2 lines
Diff to previous 1.98 (colored)

If a manual page is installed gzip(1)ed, let makewhatis(8) take
note in mandoc.db(5), such that man(1) -w and apropos(1) -w can
report the correct filename.
This is a prerequisite for letting apropos -a and man support
gzip'ed manuals in the future, which doesn't work yet.

Revision 1.98 / (download) - annotate - [select for diffs], Wed Sep 3 05:17:08 2014 UTC (9 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.97: +9 -5 lines
Diff to previous 1.97 (colored)

Implement the traditional -h option for man(1): show the SYNOPSIS only.
As usual, we get mandoc -h and apropos -h for free.
Try stuff like "apropos -h In=dirent" or "apropos -h Fa=timespec".

Only useful for terminal output, so -Tps, -Tpdf, -Thtml ignore -h for now.

Revision 1.97 / (download) - annotate - [select for diffs], Mon Sep 1 22:45:11 2014 UTC (9 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.96: +6 -4 lines
Diff to previous 1.96 (colored)

In man(1) mode, change to the right directory before starting the parser,
just like traditional man(1) does, such that .so links have a chance to
work.  After this point, we don't need the current directory for anything
else before exit, so we don't need to worry about getting back and we can
safely ignore failure.
This lets man(1) find more Xenocara manuals, but not all of them yet.
Other issues remain that need to be fixed, too.

Revision 1.96 / (download) - annotate - [select for diffs], Sat Aug 30 18:04:52 2014 UTC (9 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.95: +14 -9 lines
Diff to previous 1.95 (colored)

Introduce a man(1) -l option as an alias for mandoc -a.
Basically, this does the same as man -l in Linux man-db.
The point is that now all functionality of the combined tool
is reachable from the man(1) command name:
apropos = man -k, whatis = man -f, mandoc = man -cl.

Originally suggested by Carsten dot Kunze at arcor dot de,
current maintainer of the Heirloom Documentation Tools.

While here, add various missing information to the usage()
and to the manuals.

Revision 1.95 / (download) - annotate - [select for diffs], Wed Aug 27 00:06:08 2014 UTC (9 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.94: +364 -40 lines
Diff to previous 1.94 (colored)

Add an implementation of man(1) into the /usr/bin/mandoc binary and
provide a unified set of command line options for mandoc(1), man(1),
apropos(1), and whatis(1), each option doing the same for all four.
Not adding any completely new options, only extending exiting ones
from one tool to the others.  New options are:
* apropos & whatis -acfkw  (in the past, these were man(1) only)
* apropos & whatis -a -IOTW  (in the past, mandoc(1) only)
* mandoc -ac  (in the past, man(1) only)
* man -IOTW  (in the past, mandoc(1) only)

Before we can decide whether or not we want to replace src/usr.bin/man
with this implementation, considerable bugfixing, testing, and
performance measurements are needed, which i'd rather do in the tree
than outside.  Note that these bugs only affect the new man(1) mode,
existing mandoc(1), apropos(1), and whatis(1) is fine.

The new functionality in mandoc(1), apropos(1), and whatis(1)
is fully enabled.  To play with the new man(1), you can try:
# mv /usr/bin/man /usr/bin/oman
# ln -s /usr/bin/mandoc /usr/bin/man

Positive feedback about the general direction from sthen@ and jmc@,
and deraadt@ is not against it.

Revision 1.94 / (download) - annotate - [select for diffs], Sat Jun 21 22:23:44 2014 UTC (9 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.93: +6 -3 lines
Diff to previous 1.93 (colored)

Reduce the verbosity of error messages caused by open(2) failures.
Suggested by and ok jmc@.

Revision 1.93 / (download) - annotate - [select for diffs], Sat Jun 21 16:17:56 2014 UTC (9 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.92: +11 -7 lines
Diff to previous 1.92 (colored)

Prefix messages about bad command line options and arguments
with "mandoc: " or "makewhatis: ", respectively,
similar to what we already do for other messages.

Revision 1.92 / (download) - annotate - [select for diffs], Fri Jun 20 22:58:41 2014 UTC (9 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.91: +8 -4 lines
Diff to previous 1.91 (colored)

As suggested by jmc@, only include line and column numbers into messages
when they are meaningful, to avoid confusing stuff like this:
$ mandoc /dev/null
mandoc: /dev/null:0:1: FATAL: not a manual
Instead, just say:
mandoc: /dev/null: FATAL: not a manual

Another example this applies to is documents having a prologue,
but lacking a body.  Do not throw a FATAL error for these; instead,
issue a warning and show the empty document, in the man(7) case with
the same amount of blank lines as groff does.  Also downgrade mdoc(7)
documents having content before the first .Sh from FATAL to WARNING.

Revision 1.91 / (download) - annotate - [select for diffs], Fri Jun 20 16:11:03 2014 UTC (9 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.90: +3 -2 lines
Diff to previous 1.90 (colored)

Prefix error messages from mandoc(1) with "mandoc: "
just like almost all other utility programs do.
Suggested by nick@ who wondered where messages came from
when calling mandoc(1) from inside a Perl script.
ok jmc@ nick@

Revision 1.90 / (download) - annotate - [select for diffs], Sun Apr 20 16:44:44 2014 UTC (10 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.89: +44 -45 lines
Diff to previous 1.89 (colored)

KNF: case (FOO):  ->  case FOO, remove /* LINTED */ and /* ARGSUSED */,
remove trailing whitespace and blanks before tabs, improve some indenting;
no functional change

Revision 1.89 / (download) - annotate - [select for diffs], Fri Mar 21 22:17:01 2014 UTC (10 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.88: +2 -1 lines
Diff to previous 1.88 (colored)

The files mandoc.c and mandoc.h contained both specialised low-level
functions used for multiple languages (mdoc, man, roff), for example
mandoc_escape(), mandoc_getarg(), mandoc_eos(), and generic auxiliary
functions.  Split the auxiliaries out into their own file and header.
While here, do some #include cleanup.

Revision 1.88 / (download) - annotate - [select for diffs], Wed Mar 19 22:20:36 2014 UTC (10 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.87: +2 -2 lines
Diff to previous 1.87 (colored)

Without the MPARSE_SO option, if the file contains nothing but a
single .so request, do not read the file pointed to, but instead
let mparse_result() provide the file name pointed to as a return
value.  To be used by makewhatis(8) in the future.

Revision 1.87 / (download) - annotate - [select for diffs], Wed Mar 19 21:50:59 2014 UTC (10 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.86: +11 -11 lines
Diff to previous 1.86 (colored)

Generalize the mparse_alloc() and roff_alloc() functions by giving
them an "options" argument, replacing the existing "inttype" and
"quick" arguments, preparing for a future MPARSE_SO option.
Store this argument in struct mparse and struct roff, replacing the
existing "inttype", "parsetype", and "quick" members.
No functional change except one tiny cosmetic fix in roff_TH().

Revision 1.86 / (download) - annotate - [select for diffs], Mon Jan 6 00:53:14 2014 UTC (10 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.85: +2 -1 lines
Diff to previous 1.85 (colored)

Joerg Sonnenberger contributed copyrightable amounts of text to
some files.  To make it clear that he also put his contributions
under the ISC license, with his explicit permission, add his
Copyright notice to the relevant files.  No code change.

Revision 1.85 / (download) - annotate - [select for diffs], Sun Jan 5 20:26:27 2014 UTC (10 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.84: +2 -2 lines
Diff to previous 1.84 (colored)

Add an option -Q (quick) to mandocdb(8)
for accelerated generation of reduced-size databases.

Implement this by allowing the parsers to optionally
abort the parse sequence after the NAME section.

While here, garbage collect the unused void *arg attribute
of struct mparse and mparse_alloc().

This reduces the processing time of mandocdb(8) on /usr/share/man
by a factor of 2 and the database size by a factor of 4.
However, it still takes 5 times the time and 6 times the space
of makewhatis(8), so more work is clearly needed.

Revision 1.84 / (download) - annotate - [select for diffs], Mon Nov 19 08:46:24 2012 UTC (11 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.83: +4 -4 lines
Diff to previous 1.83 (colored)

sync usage(), and tidy up the output a little; ok schwarze

Revision 1.83 / (download) - annotate - [select for diffs], Thu May 24 23:33:23 2012 UTC (11 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.82: +20 -4 lines
Diff to previous 1.82 (colored)

Support -Ios='OpenBSD 5.1' to override uname(3) as the source of the
default value for the mdoc(7) .Os macro.
Needed for man.cgi on the OpenBSD website.

Problem with man.cgi first noticed by deraadt@;
beck@ and deraadt@ agree with the way to solve the issue.

Revision 1.82 / (download) - annotate - [select for diffs], Sun Dec 25 17:34:57 2011 UTC (12 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.81: +3 -2 lines
Diff to previous 1.81 (colored)

Accept "makewhatis" as an alias for "mandocdb".

Revision 1.81 / (download) - annotate - [select for diffs], Mon Nov 28 00:16:38 2011 UTC (12 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.80: +3 -2 lines
Diff to previous 1.80 (colored)

Implement whatis(1) as a special apropos(1) mode as a part of
the mandoc(1) binary; not yet enabled for the general public.
Intended to replace src/usr.bin/whatis at a later time.
Coded by kristaps@, with a few tweaks by me.

To test this:
 $ mandocdb  # unless you have already done so earlier
 $ sudo ln -s /usr/bin/mandoc /usr/bin/whatis.m
 $ whatis.m mandoc apropos whatis
 $ whatis.m man

Revision 1.80 / (download) - annotate - [select for diffs], Sun Oct 9 17:59:56 2011 UTC (12 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.79: +8 -1 lines
Diff to previous 1.79 (colored)

Sync to version 1.12.0; all code by kristaps@:
Implement .Rv in -Tman.
Let -man -Tman work a bit like cat(1).
Add the -Ofragment option to -T[x]html.
Minor fixes in -T[x]html.
Lots of apropos(1) and -Tman code cleanup.

Revision 1.79 / (download) - annotate - [select for diffs], Thu Oct 6 23:04:16 2011 UTC (12 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.78: +9 -1 lines
Diff to previous 1.78 (colored)

1) Import the future apropos(1) replacement written by kristaps@.
2) Link both that one and mandocdb(8) into the mandoc(1) binary.
3) Install a /usr/bin/mandocdb hardlink and the mandocdb(8) manual.

Do not replace /usr/bin/apropos by a hardlink yet because it is
not ready for production, and ports integration is still missing.
Development will be done in the tree, even the user interfaces
are still subject to change at this point.

Both jmc@ and deraadt@ agree with getting this in.

Revision 1.78 / (download) - annotate - [select for diffs], Sat Sep 17 14:45:22 2011 UTC (12 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.77: +7 -1 lines
Diff to previous 1.77 (colored)

Initial, incomplete support for -Tman
to convert mdoc(7) documents to the man(7) language.
This is work in progress and will be developed in tree.
It does already handle the cat(1) manual,
but will hardly handle all your fancy manuals yet.
go ahead  kristaps@ jmc@ millert@ deraadt@

Revision 1.77 / (download) - annotate - [select for diffs], Sun May 29 21:22:18 2011 UTC (12 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.76: +21 -2 lines
Diff to previous 1.76 (colored)

Merge release 1.11.3, almost all code by kristaps@:
* Unicode output support (no Unicode input yet, though).
* Refactoring: completely handle predefined strings in roff.c.
- New function mandoc_escape() replaces a2roffdeco() and mandoc_special().
- Start using mandoc_getarg() in mdoc_argv.c.
- Clean up parsing of delimiters in mdoc(7).
* And many minor fixes and lots of cleanup.

Revision 1.76 / (download) - annotate - [select for diffs], Sun Apr 24 16:22:02 2011 UTC (13 years ago) by schwarze
Branch: MAIN
Changes since 1.75: +66 -753 lines
Diff to previous 1.75 (colored)

Merge version 1.11.1:
Again lots of cleanup and maintenance work by kristaps@.
- simplify error reporting: less function pointers, more mandoc_[v]msg
- main: split document parsing out of main.c into read.c
- roff, mdoc, man: improved recognition of control characters
- roff: better handling of if/else stack overflows
- roff: add some predefined strings for backward compatibility
- mdoc, man: empty sections are not errors
- mdoc: move delimiter handling to libmdoc
- some header restructuring and some minor features and fixes
This merge causes two minor regressions
that i will fix in separate commits right afterwards.

Revision 1.75 / (download) - annotate - [select for diffs], Thu Apr 21 22:59:54 2011 UTC (13 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.74: +38 -45 lines
Diff to previous 1.74 (colored)

Merge version 1.10.10:
lots of cleanup and maintenance work by kristaps@.
- move some main.c globals into struct curparse
- move mandoc_*alloc to mandoc.h such that all code can use them
- make mandoc_isdelim available to formatting frontends
- dissolve mdoc_strings.c, move the code where it is used
- make all error reporting functions void, their return values were useless
- and various minor cleanups and fixes

Revision 1.74 / (download) - annotate - [select for diffs], Sun Mar 20 23:36:42 2011 UTC (13 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.73: +19 -11 lines
Diff to previous 1.73 (colored)

Import the foundation for eqn(7) support.
Written by kristaps@.

For now, i'm adding one line to each of the four frontends
to just pass the input text through to the output,
not yet interpreting any of then eqn keywords.

Revision 1.73 / (download) - annotate - [select for diffs], Mon Mar 7 01:35:33 2011 UTC (13 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.72: +3 -2 lines
Diff to previous 1.72 (colored)

Clean up date handling,
as a first step to get rid of the frequent petty warnings in this area:
 - always store dates as strings, not as seconds since the Epoch
 - for input, try the three most common formats everywhere
 - for unrecognized format, just pass the date though verbatim
 - when there is no date at all, still use the current date
Originally triggered by a one-line patch from Tim van der Molen,
<tbvdm at xs4all dot nl>, which is included here.
Feedback and OK on manual parts from jmc@.
"please check this in" kristaps@

Revision 1.72 / (download) - annotate - [select for diffs], Sun Feb 6 17:33:20 2011 UTC (13 years, 3 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.71: +2 -1 lines
Diff to previous 1.71 (colored)

If .Ns is specified on its own line, ignore it, like groff does;
from kristaps@.

Revision 1.71 / (download) - annotate - [select for diffs], Tue Jan 25 12:24:26 2011 UTC (13 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.70: +8 -6 lines
Diff to previous 1.70 (colored)

Since tbl_data() can now produce multiple spans, let parsebuf()
generate man(7) or mdoc(7) nodes for all these spans,
not only for the last one.
Restores the horizontal lines in the cpu(4/hppa) tables.
ok kristaps@

Revision 1.70 / (download) - annotate - [select for diffs], Mon Jan 24 23:40:12 2011 UTC (13 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.69: +21 -4 lines
Diff to previous 1.69 (colored)

Skip carriage return before newline, if any.
As pointed out by Joerg Sonnenberger, this is useful
because we use mmap(3) and look for '\n' by hand.
"check it in" kristaps@

Revision 1.69 / (download) - annotate - [select for diffs], Thu Jan 20 21:33:11 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.68: +2 -2 lines
Diff to previous 1.68 (colored)

When finding the roff .it request (line trap),
make it clear that you cannot use mandoc to format that page (yet).
Triggered by a report from brad@.

Revision 1.68 / (download) - annotate - [select for diffs], Sun Jan 16 19:27:25 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.67: +2 -1 lines
Diff to previous 1.67 (colored)

Some improvements to error handling from kristaps@:
* Make out-of-context .fi invocations not cause an error, but just a warning.
* Downgrade -man message about ignored empty paragraph to MANDOC_IGNPAR.
* Avoid syntax tree corruption when removing empty block macros.
Triggered by some reports from brad@.

Revision 1.67 / (download) - annotate - [select for diffs], Sun Jan 16 01:11:50 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.66: +2 -4 lines
Diff to previous 1.66 (colored)

Various tbl improvements from kristaps@:
* horizontal lines do not consume layout lines
* skip excessive data cells
* prepare rendering of spanned cells
* support vertical spans

Revision 1.66 / (download) - annotate - [select for diffs], Mon Jan 10 23:53:32 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.65: +2 -1 lines
Diff to previous 1.65 (colored)

Refactoring in preparation for .rm support:
Unify parsing of names given as roff request arguments into a new
function roff_getname(), which is rather different from the parsing
function for normal arguments, mandoc_getarg(), because names cannot
be quoted and cannot contain whitespace or escaped characters.
The new function now throws an ERROR when finding escaped characters
in a name.
"I'm fine with this." kristaps@

Revision 1.65 / (download) - annotate - [select for diffs], Sun Jan 9 13:16:48 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.64: +9 -1 lines
Diff to previous 1.64 (colored)

Make sure coding errors cannot make us miss fatal parsing errors
by assert(3)ing valid parser state in the main parsing functions;
from kristaps@.

Revision 1.64 / (download) - annotate - [select for diffs], Tue Jan 4 22:28:17 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.63: +28 -9 lines
Diff to previous 1.63 (colored)

Merge kristaps@' cleaner tbl integration, removing mine;
there are still a few bugs, but fixing these will be easier in tree.

Revision 1.63 / (download) - annotate - [select for diffs], Mon Jan 3 23:39:27 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.62: +2 -1 lines
Diff to previous 1.62 (colored)

Partial cleanup of argument count validation in mdoc(7):

* Do not segfault on empty .Db, .Rs, .Sm, and .St.
* Let check_count() really throw the requested level, not always ERROR.
* Downgrade most bad argument counts from ERROR to WARNING.
* And some related internal cleanup.

Looks fine to kristaps@.

Note that the macros using eerr_ge1() still need to be checked at a later
time; but as all the others are done, let's use what we already have.

Revision 1.62 / (download) - annotate - [select for diffs], Tue Dec 21 01:22:00 2010 UTC (13 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.61: +2 -2 lines
Diff to previous 1.61 (colored)

Sane behaviour for the growing of very small buffers:
Always grow at least to the minimum requested size.
Before this, a buffer of 1 byte was grown to 2 bytes,
which was too small and sometimes caused segfaults.
ok kristaps@

Revision 1.61 / (download) - annotate - [select for diffs], Thu Dec 9 23:01:18 2010 UTC (13 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.60: +12 -3 lines
Diff to previous 1.60 (colored)

Abort endless loops during roff macro and string expansion.
For now, use the simplest conceivable approach, like groff does:
Just a fixed, ugly input stack limit.
Kristaps@ agrees.

Revision 1.60 / (download) - annotate - [select for diffs], Thu Dec 2 20:40:43 2010 UTC (13 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.59: +19 -14 lines
Diff to previous 1.59 (colored)

Track the parser status both per file (file_status), such that
we can for example skip rendering on FATAL parsing errors,
and globally (exit_status), such that we know what to return.
Without this, following files produced no rendered output
once a single file suffered from a FATAL error.
Bug reported by kristaps@, fix by me.

Revision 1.59 / (download) - annotate - [select for diffs], Wed Dec 1 23:38:11 2010 UTC (13 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.58: +159 -87 lines
Diff to previous 1.58 (colored)

Cleanup by kristaps@:
* When autodetecting the format, don't assume all files are the same.
* Add more comments and apply some whitespace beautifications.

Revision 1.58 / (download) - annotate - [select for diffs], Wed Dec 1 22:02:29 2010 UTC (13 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.57: +1 -2 lines
Diff to previous 1.57 (colored)

Merge mdoc_action.c into mdoc_validate.c, because having two places to do
basically the same things just causes code duplication and confusion.
Work by kristaps@, including a few bugfixes he found during the merge,
and reapplying OpenBSD changes on top.

Revision 1.57 / (download) - annotate - [select for diffs], Mon Nov 29 00:12:02 2010 UTC (13 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.56: +2 -1 lines
Diff to previous 1.56 (colored)

Implement the roff .ft (change font) request for man(7).
Of course, we don't want to encourage low-level physical markup,
but pod2man(1) writes such requests, so Perl manuals contain them,
and some Xenocara and lots and lots of ports manuals use them as well.
In base and Xenocara, this will reduce mandoc -Tlint ERROR noise;
in ports, it will improve rendering of many manuals.

Revision 1.56 / (download) - annotate - [select for diffs], Sun Nov 28 19:35:33 2010 UTC (13 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.55: +4 -3 lines
Diff to previous 1.55 (colored)

To avoid FATAL errors, we have been parsing and ignoring the roff
requests .am, .ami, .am1, .dei, and .rm for a long time.
Since ignoring them can (rarely) cause information loss and serious
misformatting, throw an ERROR: NOT IMPLEMENTED when finding them.
Implementing them would not be too difficult, but they are so rare
in practice that i can find better use for my time right now.

In this context,
- Put the string "NOT IMPLEMENTED" into two other error messages
as well, to distinguish them from those caused by broken input.
- Print the string "unknown macro" once, not twice in the error message
associated with MANDOCERR_MACRO, and begin printing the buffer at the
point where the unknown macro really is, not at the start of line.

Revision 1.55 / (download) - annotate - [select for diffs], Thu Nov 25 22:23:31 2010 UTC (13 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.54: +72 -40 lines
Diff to previous 1.54 (colored)

Implement the .de (define macro) roff instruction.
This fixes various Xenocara manuals.
Do not define your own macros in new manuals, though:
this code exists purely to cope with existing and old stuff.

Like in both traditional and GNU roff, the .de and .ds (define string)
roff instructions share the same string table, so one can abuse strings
as macros and vice versa.  This implementation supports multi-line
user-defined macros and user-defined macros taking up to 9 arguments.

Project started near the end of p2k10, now mature for production,
but there is still room for future improvements in various respects.

Revision 1.54 / (download) - annotate - [select for diffs], Tue Oct 26 23:34:38 2010 UTC (13 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.53: +2 -1 lines
Diff to previous 1.53 (colored)

Warn developers that .so is fragile and suggest using ln(1) instead;
throwing a warning here was suggested by Joerg Sonnenberger.

Revision 1.53 / (download) - annotate - [select for diffs], Tue Oct 26 22:48:07 2010 UTC (13 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.52: +52 -42 lines
Diff to previous 1.52 (colored)

Downgrade nearly 20 ERRORS to WARNINGS.
All these indicate problems in the mdoc(7) or man(7) source code,
but they can't cause relevant information loss or clobbered formatting.
While here, error message improve wording and make it more uniform,
don't throw MANDOCERR_NOWIDTHARG twice when there is one single issue,
and consolidate MANDOCERR_WIDTHARG into MANDOCERR_IGNARGV.

Revision 1.52 / (download) - annotate - [select for diffs], Tue Oct 26 22:28:56 2010 UTC (13 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.51: +37 -1 lines
Diff to previous 1.51 (colored)

Support .so (low-level roff "switch source file"),
needed for Xenocara and various ports.
Accept only relative paths and no ascension to the parent directory
as suggested by Joerg Sonnenberger; code looked over by Joerg, too.
Useful discussions with various people, among others espie@.

Revision 1.51 / (download) - annotate - [select for diffs], Tue Oct 26 22:13:58 2010 UTC (13 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.50: +125 -108 lines
Diff to previous 1.50 (colored)

Refactoring, no functional change:
Seperate the code to read and parse a PART of a page (new function pdesc())
from the code to finish and output a FULL page (function fdesc());
in preparation for .so support.

Revision 1.50 / (download) - annotate - [select for diffs], Sun Oct 24 18:15:43 2010 UTC (13 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.49: +4 -5 lines
Diff to previous 1.49 (colored)

Do not throw FATAL errors when there is no need to:
 - when encountering nested displays (.Bd containing .Bd, .D1, .D1)
 - when a block end macro was forgotten
 - when ending a block that was never started
 - when the uname(3) system call failed
along with a little related cleanup

Revision 1.49 / (download) - annotate - [select for diffs], Sat Oct 16 20:49:37 2010 UTC (13 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.48: +2 -1 lines
Diff to previous 1.48 (colored)

Do not abort() on tbl errors, reduce the risk that tbl stuff kills a build,
and provide more useful tbl error messages in a non-intrusive way.

Revision 1.48 / (download) - annotate - [select for diffs], Mon Sep 27 21:25:28 2010 UTC (13 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.47: +2 -1 lines
Diff to previous 1.47 (colored)

Merge the last bits of 1.10.6 (released today), most were already in:
* ignore double-.Pp
* ignore .Pp before .Bd and .Bl (unless -compact in specified)
* avoid double blank line upon .Pp, .br and friends in literal context
* cast enums to int when passing them to exit(3) to please lint(1)
While merging, fix a regression introduced by kristaps@:
Outside literal mode, double blank lines must both be printed.
To achieve this again after kristaps@ improvements in 1.10.6,
treat such blank lines as .sp (instead of .Pp as in 1.10.5)
and drop .Pp before .sp just like dropping .Pp before .Pp.

Revision 1.47 / (download) - annotate - [select for diffs], Sun Sep 26 20:19:58 2010 UTC (13 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.46: +10 -10 lines
Diff to previous 1.46 (colored)

If an explicit scope is still open at the end of an input file,
report an ERROR:  We can still render the page by just closing
the open scope, but it is likely that information will be missing
or document structure mangled.
Before, man(7) only reported a WARNING (which is dangerous because
we cannot be sure rendering is correct) and mdoc(7) ran into FATAL
(which is too drastic, there is no reason not to show what we have).
While here, add a few explicit casts to appease lint.
"looks good" kristaps@

Revision 1.46 / (download) - annotate - [select for diffs], Fri Aug 20 08:13:03 2010 UTC (13 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.45: +9 -9 lines
Diff to previous 1.45 (colored)

fix previous: when bailing out due to -Wstop,
skip output functions, but not *_endparse;
problem reported by kristaps@

Revision 1.45 / (download) - annotate - [select for diffs], Fri Aug 20 00:53:35 2010 UTC (13 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.44: +137 -230 lines
Diff to previous 1.44 (colored)

Implement a simple, consistent user interface for error handling.
We now have sufficient practical experience to know what we want,
so this is intended to be final:
- provide -Wlevel (warning, error or fatal) to select what you care about
- provide -Wstop to stop after parsing a file with warnings you care about
- provide consistent exit status codes for those warnings you care about
- fully document what warnings, errors and fatal errors mean
- remove all other cruft from the user interface, less is more:
- remove all -f knobs along with the whole -f option
- remove the old -Werror because calling warnings "fatal" is silly
- always finish parsing each file, unless fatal errors prevent that
This commit also includes a couple of related simplifications behind
the scenes regarding error handling.
Feedback and OK  kristaps@;  Joerg Sonnenberger (NetBSD) and
Sascha Wildner (DragonFly BSD) agree with the general direction.

Revision 1.44 / (download) - annotate - [select for diffs], Wed Aug 18 01:03:22 2010 UTC (13 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.43: +4 -3 lines
Diff to previous 1.43 (colored)

Use isascii(3) to make sure we really throw away non-ASCII characters,
because isgraph(3) returns true for some eight-bit characters.
ok kristaps@

Revision 1.43 / (download) - annotate - [select for diffs], Sun Jul 25 18:05:54 2010 UTC (13 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.42: +34 -3 lines
Diff to previous 1.42 (colored)

Sync to bsd.lv; in particular, pull in lots of bug fixes.
new features:
* support the .in macro in man(7)
* support minimal PDF output
* support .Sm in mdoc(7) HTML output
* support .Vb and .nf in man(7) HTML output
* complete the mdoc(7) manual
bug fixes:
* do not let mdoc(7) .Pp produce a newline before/after .Sh; reported by jmc@
* avoid double blank lines related to man(7) .sp and .br
* let man(7) .nf and .fi flush the line; reported by jsg@ and naddy@
* let "\ " produce a non-breaking space; reported by deraadt@
* discard \m colour escape sequences; reported by J.C. Roberts
* map undefined 1-character-escapes to the literal character itself
maintenance:
* express mdoc(7) arguments in terms of an enum for additional type-safety
* simplify mandoc_special() and a2roffdeco()
* use strcspn in term_word() in place of a manual loop
* minor optimisations in the -Tps and -Thtml formatting frontends

Revision 1.42 / (download) - annotate - [select for diffs], Tue Jul 13 01:09:12 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.41: +4 -4 lines
Diff to previous 1.41 (colored)

Merge release 1.10.4 (all code by kristaps@), providing four new features:
1) Proper .Bk support: allow output line breaks at input line breaks,
but keep input lines together in the output, finally fixing
synopses like aucat(1), mail(1) and tmux(1).
2) Mostly finished -Tps (PostScript) output.
3) Implement -Thtml output for .Nm blocks and .Bk -words.
4) Allow iterative interpolation of user-defined roff(7) strings.
Also contains some minor bugfixes and some performance improvements.

Revision 1.41 / (download) - annotate - [select for diffs], Thu Jul 1 15:36:59 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.40: +4 -3 lines
Diff to previous 1.40 (colored)

Improve .Nm indentation in the SYNOPSIS;
kristaps@ will do the missing HTML part soon.
"looks nicer" jmc@
"seems perfect to me" sobrado@
"slap it in" kristaps@

Revision 1.40 / (download) - annotate - [select for diffs], Wed Jun 30 20:29:44 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.39: +43 -27 lines
Diff to previous 1.39 (colored)

improve error reporting:
* avoid error exit code after mere warnings
* add ERROR: and FATAL: to messages when appropriate
* sort the code in mmsg() to make it easier on the eye
* make the mandocerrs[] list easier to maintain
* update a few comments in mandoc.h
ok kristaps@

Revision 1.39 / (download) - annotate - [select for diffs], Tue Jun 29 15:49:52 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.38: +2 -2 lines
Diff to previous 1.38 (colored)

sync to bsd.lv version 1.10.3:
* support -Tps -Opaper=a4 and -Opaper=letter
* lots of mandoc.1 manual improvements

Revision 1.38 / (download) - annotate - [select for diffs], Sun Jun 27 21:54:41 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.37: +9 -5 lines
Diff to previous 1.37 (colored)

Full .nr nS support, unbreaking the kernel manuals.

Kristaps coded this from scratch after reading my .nr patch;
it is simpler and more powerful.

Registers live in struct regset in regs.h, struct man and struct mdoc
contain pointers to it.  The nS register is cleared when parsing .Sh.
Frontends respect the MDOC_SYNPRETTY flag set in mdoc node_alloc.

Revision 1.37 / (download) - annotate - [select for diffs], Sat Jun 26 17:56:43 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.36: +5 -3 lines
Diff to previous 1.36 (colored)

merge release 1.10.2
* bug fixes:
- interaction of ASCII_HYPH with special chars (found by Ulrich Spoerlein)
- handling of roff conditionals (found by Ulrich Spoerlein)
- .Bd -offset will no more default to 6n
* maintenance:
- more caching of .Bd and .Bl arguments for efficiency
- deconstify man(7) validation routines
- add FreeBSD library names (provided by Ulrich Spoerlein)
* start PostScript font-switching

Revision 1.36 / (download) - annotate - [select for diffs], Thu Jun 10 22:50:10 2010 UTC (13 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.35: +27 -10 lines
Diff to previous 1.35 (colored)

minimal initial -Tps support, from kristaps@ GSOC
so far, monospace without font decoration,
but it already has page headers and footers

Revision 1.35 / (download) - annotate - [select for diffs], Tue Jun 8 00:11:47 2010 UTC (13 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.34: +3 -3 lines
Diff to previous 1.34 (colored)

Merge more bits that will be going into 1.10.1:

Clean up vertical spacing in the SYNOPSIS, making the code much more
systematic; this doesn't solve all SYNOPSIS problems yet, in particular
not those related to keeps, indentation and the low-level .nr roff
instruction, but it's a nice step forward and i couldn't find relevant
regressions.  (from kristaps)

Besides,
* make the output width configurable (default: -Owidth=80) (kristaps)
* use mmap with MAP_SHARED (from Joerg Sonnenberger)

Revision 1.34 / (download) - annotate - [select for diffs], Sun Jun 6 20:30:08 2010 UTC (13 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.33: +5 -5 lines
Diff to previous 1.33 (colored)

Merge bsd.lv version 1.10.1 (to be released soon).

The main step forward is that this now has *much* better .Bl -column
support, now supporting many manuals that previously errored out
without producing any output.

Other fixes include:
* do not die from multiple list types, use the first and warn
* in .Bl without a type, default to -item
* various tweaks to .Dt
* fix .In, .Fd, .Ft, .Fn and .Fo formatting
* some documentation fixes and additions
* and fix a couple of bugs reported by Ulrich Spoerlein:
* better support for roff block-end "\}" without a preceding dot
* .In must not break the line outside SYNOPSIS
* spelling in some error messages

While merging, fix one regression in .In spacing
that needs to go to bsd.lv, too.

Revision 1.33 / (download) - annotate - [select for diffs], Sun May 23 22:45:00 2010 UTC (13 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.32: +95 -79 lines
Diff to previous 1.32 (colored)

Unified error and warning message system for all of mandoc,
featuring three message levels, as agreed during the mandoc hackathon:
* FATAL parser failure, cannot produce any output from this input file:
  eventually, we hope to convert most of these to ERRORs.
* ERROR, meaning mandoc cannot cope fully with the input syntax and will
  probably lose information or produce structurally garbled output;
  it will try to produce output anyway but exit non-zero at the end,
  which is eventually intended to make the ports infrastructure happy.
* WARNING, meaning you should clean up the input file, but output
  is probably mostly OK, so this will not cause error-exit at the end.
This commit is mostly just converting the old system to the new one; before
the classification will become really reliable, we must check all messages.

In particular,
* set up a new central message string table in main.c
* drop the old message string tables from man.c and mdoc.c
* get rid of the piece-meal merr enums in libman and libmdoc
* reduce number of error/warning functions from 16 to 6 (still a lot...)

While here, handle a few problems more gracefully:
* allow .Rv and .Ex to work without a prior .Nm
* allow .An to ignore extra arguments
* allow undeclared columns in .Bl -column

Written by kristaps@.

Revision 1.32 / (download) - annotate - [select for diffs], Thu May 20 00:58:02 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.31: +33 -10 lines
Diff to previous 1.31 (colored)

Support nested roff instructions:
* allow roff_parseln() to be re-run
* allow roff_parseln() to manipulate the line buffer offset
* support the offset in the man and mdoc libraries
* adapt .if, .ie, .el, .ig, .am* and .de* support
* interpret some instructions even in conditional-negative context
Coded by kristaps during the last day of the mandoc hackathon.

To avoid regressions in the OpenBSD tree, commit this together
with some small local additions:
* detect roff block end "\}" even on macro lines
* actually implement the ".if n" conditional
* ignore .ds, .rm and .tr in libroff

Also back my old .if/.ie/.el-handling out of libman, reverting:
man.h 1.15 man.c 1.25 man_macro.c 1.15 man_validate.c 1.19
man_action.c 1.15 man_term.c 1.28 man_html.c 1.9.

Revision 1.31 / (download) - annotate - [select for diffs], Sun May 16 01:16:25 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.30: +2 -2 lines
Diff to previous 1.30 (colored)

allow the single quote as a control character in place of the dot
at all relevant places;
from kristaps@

Revision 1.30 / (download) - annotate - [select for diffs], Sun May 16 00:54:03 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.29: +85 -18 lines
Diff to previous 1.29 (colored)

In theory, Kristaps never intended to write a roff parser,
but in practice, most real legacy man(7)uals are using so much
low level roff that we can't really get away without at least
partially handling some roff instructions.

As doing this in man(7) only has become messy and as even some
mdoc(7) pages need it, start a minimal partial roff preprocessor.
As a first step, move handling of .am[i], .de[i] and .ig there.
Do not use the roff preprocessor for new manuals!

Now that we have three main parser libraries - roff, man and mdoc -
each one having its own error handling is becoming messy, too.
Thus, start unifying message handling in one central place,
introducing a new generic function mmsg().

coded by kristaps@

Revision 1.29 / (download) - annotate - [select for diffs], Sat May 15 22:00:22 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.28: +53 -51 lines
Diff to previous 1.28 (colored)

Joerg Sonnenberger rewrote the comment stripping and line merging
to be easier to follow and slightly faster.

Revision 1.28 / (download) - annotate - [select for diffs], Sat May 15 21:09:53 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.27: +2 -2 lines
Diff to previous 1.27 (colored)

More systematic output width handling by Joerg Sonnenberger:
* save and restore the output width when switching to MANT_LITERAL
* add an argument to ascii_alloc to specify the output width
* set the default output width to 80 minus 2 characters
* OpenBSD local: set the output width to 65 characters for -man

Revision 1.27 / (download) - annotate - [select for diffs], Sat May 15 17:32:25 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.26: +211 -158 lines
Diff to previous 1.26 (colored)

Bugfxing and cleanup by Joerg Sonnenberger, edited by kristaps@:
* Flag errors and warnings in global variables.
* Exit with error code if either is not null on exit.
* Push down the buffers to the functions using them.
* Handle the stdin/file argument in one function.
* Use mmap when possible or else read the whole file into a single buffer.
* Push buffer resizing into its own function.

Revision 1.26 / (download) - annotate - [select for diffs], Sat May 15 15:58:56 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.25: +3 -3 lines
Diff to previous 1.25 (colored)

merge bsd.lv 1.63:
fix stripping of whitespace before trailing comments;
by Joerg Sonnenberger

Revision 1.25 / (download) - annotate - [select for diffs], Fri May 14 01:54:37 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.24: +7 -1 lines
Diff to previous 1.24 (colored)

merge 1.9.24, keeping local patches; some changes:
* preserve multiple consecutive space characters in input
* do not restrict .Cd and .Rv to certain sections (requested by Joerg)
* do not run lookup() on quoted words
* enum return types for mdoc_args and mdoc_argv
* fix auto-closing of LINK tag in -Txhtml (from Daniel Friesel)
* various lint and manual fixes

Revision 1.24 / (download) - annotate - [select for diffs], Thu May 13 20:34:29 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.23: +10 -20 lines
Diff to previous 1.23 (colored)

Remove the command line option -fno-ign-chars.
This option was not useful, you never want mandoc to die
just because there is an invalid character in the input file,
neither in production nor when linting: a warning is sufficient.
This was particularly annoying because it was part of -fstrict
and could not be switched off.
"less is more" kristaps@

Revision 1.23 / (download) - annotate - [select for diffs], Tue Apr 13 06:52:12 2010 UTC (14 years, 1 month ago) by jmc
Branch: MAIN
Changes since 1.22: +3 -3 lines
Diff to previous 1.22 (colored)

- sort everything
- prefer Cm to Ar for stuff like -Tascii
- fix wonky ellipsis
- standard $ prompt
- update usage()

kristaps has these diffs rolled in already
ok schwarze kristaps

Revision 1.22 / (download) - annotate - [select for diffs], Fri Mar 26 01:22:05 2010 UTC (14 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.21: +38 -32 lines
Diff to previous 1.21 (colored)

merge 1.9.17, keeping local patches

* much improved pod2man support and low-level roff robustness
* have -Tlint imply -Wall and -fstrict
* use fewer macros and more enum in libman
* and various bug fixes

Revision 1.21 / (download) - annotate - [select for diffs], Thu Feb 18 02:11:26 2010 UTC (14 years, 3 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.20: +10 -1 lines
Diff to previous 1.20 (colored)

sync to release 1.9.15:
 * corrected .Vt handling (spotted by Joerg Sonnenberger)
 * corrected .Xr argument handling (based on my patch)
 * removed \\ escape sequence (because it is for low-level roff only)
 * warn about trailing whitespace (suggested by jmc@)
 * -Txhtml support
 * and some general cleanup and doc improvements

Revision 1.20 / (download) - annotate - [select for diffs], Wed Dec 23 22:30:17 2009 UTC (14 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.19: +9 -9 lines
Diff to previous 1.19 (colored)

sync to 1.9.13: minor fixes:

correctness/functionality:
 - bugfix: properly ignore lines with only a dot in -man
 - bugfix: .Bl -ohang doesn't allow -width, warn about this
 - improve date string handling by new function mandoc_a2time
 - some HTML improvements
 - significant documentation additions in man.7 and mdoc.7

portability:
 - replace __dead by __attribute__((noreturn))
 - bugfix: correct .Dx rendering
 - some more library names for NetBSD

simplicity:
 - replace hand-rolled putchar(3)-loops by fwrite(3)
 - replace single-character printf(3) by putchar(3)

Revision 1.19 / (download) - annotate - [select for diffs], Tue Dec 22 23:58:00 2009 UTC (14 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.18: +36 -38 lines
Diff to previous 1.18 (colored)

sync to 1.9.12, mostly portability and refactoring:

correctness/functionality:
- bugfix: do not die when overstep hits the right margin
- new option: -fign-escape
- and various HTML features

portability:
- replace bzero(3) by memset(3), which is ANSI C
- replace err(3)/warn(3) by perror(3)/exit(3), which is ANSI C
- iuse argv[0] instead of __progname
- add time.h to various files for FreeBSD compilation

simplicity:
- do not allocate header/footer data dynamically in *_term.c
- provide and use malloc frontends that error out on failure

for full changelogs, see http://bsd.lv/cgi-bin/cvsweb.cgi/

Revision 1.18 / (download) - annotate - [select for diffs], Tue Oct 27 21:40:07 2009 UTC (14 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.17: +8 -7 lines
Diff to previous 1.17 (colored)

sync to 1.9.11: adapt printing of dates to groff conventions,
NetBSD portability fixes and some minor bugfixes and feature enhancements;
also checked that my hyphenation code still works on top of this

Revision 1.17 / (download) - annotate - [select for diffs], Wed Oct 21 19:13:50 2009 UTC (14 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.16: +23 -13 lines
Diff to previous 1.16 (colored)

sync to 1.9.9, featuring:
 * -Thtml output mode
 * roff scaling units
 * and some minor fixes
for full changelogs, see http://bsd.lv/cgi-bin/cvsweb.cgi/

Revision 1.16 / (download) - annotate - [select for diffs], Mon Sep 21 20:57:57 2009 UTC (14 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.15: +9 -11 lines
Diff to previous 1.15 (colored)

sync to 1.9.5: make terminal_*, tree_* and out_* functions return void,
making the code simpler

Revision 1.15 / (download) - annotate - [select for diffs], Sat Aug 22 17:21:23 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.14: +7 -7 lines
Diff to previous 1.14 (colored)

sync to 1.8.5: Error string is now file:line:col: message.
Fixed column reporting (off by one).
Use fprintf instead of warnx for parse errors (like cc).

Revision 1.14 / (download) - annotate - [select for diffs], Sat Aug 22 14:56:03 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.13: +28 -15 lines
Diff to previous 1.13 (colored)

sync to 1.8.4: add option -fign-errors to check several manual pages
without stopping at errors

Revision 1.13 / (download) - annotate - [select for diffs], Sun Jul 12 22:44:45 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.12: +6 -15 lines
Diff to previous 1.12 (colored)

sync to 1.7.23: Fewer knobs: provide -Wall -Werror but not -Wsyntax -Wcompat.
The simplification of the internal code has already been done before,
this is just the user interface adjustment.

Revision 1.12 / (download) - annotate - [select for diffs], Sun Jul 12 18:28:29 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.11: +8 -44 lines
Diff to previous 1.11 (colored)

sync to 1.7.23: first step to get rid of enum mdoc_warn:
unify manwarn() and mdocwarn() into mwarn()

Revision 1.11 / (download) - annotate - [select for diffs], Tue Jul 7 00:54:46 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.10: +4 -2 lines
Diff to previous 1.10 (colored)

sync to 1.7.21: provide WESCAPE and MAN_IGN_ESCAPE,
to be used soon in man_validate.c

Revision 1.10 / (download) - annotate - [select for diffs], Tue Jul 7 00:16:21 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.9: +11 -7 lines
Diff to previous 1.9 (colored)

sync to 1.7.21: suboptarg is not portable to Linux;
no functional change on OpenBSD

Revision 1.9 / (download) - annotate - [select for diffs], Mon Jul 6 22:12:38 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.8: +8 -8 lines
Diff to previous 1.8 (colored)

(1) exit with failure not success if options parsing fails;
(2) use warn not warnx if fstat fails;
(3) getsubopt modifies arg, so printing it on error will print
    the wrong thing: use suboptarg instead.
from nicm@
ok kristaps@   and contained in 1.7.21

Revision 1.8 / (download) - annotate - [select for diffs], Tue Jun 23 22:31:26 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.7: +4 -2 lines
Diff to previous 1.7 (colored)

sync to 1.7.20: root and text validation for -man

Revision 1.7 / (download) - annotate - [select for diffs], Sun Jun 21 20:10:31 2009 UTC (14 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.6: +6 -15 lines
Diff to previous 1.6 (colored)

sync to 1.7.19: the static function fstdin was called from exactly one place
and did so little that it was better merged into main()

Revision 1.6 / (download) - annotate - [select for diffs], Thu Jun 18 23:51:12 2009 UTC (14 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.5: +7 -43 lines
Diff to previous 1.5 (colored)

sync to 1.7.19: comment cleanup; no functional change

Revision 1.5 / (download) - annotate - [select for diffs], Thu Jun 18 23:34:53 2009 UTC (14 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.4: +40 -25 lines
Diff to previous 1.4 (colored)

sync to 1.7.19: improved comment handling

Revision 1.4 / (download) - annotate - [select for diffs], Thu Jun 18 22:16:56 2009 UTC (14 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.3: +1 -2 lines
Diff to previous 1.3 (colored)

complete sync to 1.7.17: garbage collect unused functions
mdoc_msg, mdoc_pmsg, mdoc_vmsg, and mdoc_nwarn

Revision 1.3 / (download) - annotate - [select for diffs], Sun Jun 14 23:39:43 2009 UTC (14 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.2: +16 -3 lines
Diff to previous 1.2 (colored)

sync to 1.7.16: support -V command line option

Revision 1.2 / (download) - annotate - [select for diffs], Sun Jun 14 23:00:57 2009 UTC (14 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.1: +42 -16 lines
Diff to previous 1.1 (colored)

sync to 1.7.16: comments, whitespace and spelling fixes; no functional change

Revision 1.1 / (download) - annotate - [select for diffs], Mon Apr 6 20:30:40 2009 UTC (15 years, 1 month ago) by kristaps
Branch: MAIN

Initial check-in of mandoc for formatting manuals. ok deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.