Ingo Schwarze [Sun, 27 May 2012 17:54:54 +0000 (17:54 +0000)]
Do not handle vertical lines as additional tbl(7) columns,
instead save their properties with the following column.
This simplifies layout parsing and saves a lot of code
related to column handling.
At output time, print all white space and vertical lines
separating columns before printing the following column,
and none after printing the preceding column, considerably
simplifying white space handling and width calculations.
No functional change, but it saves 150 lines of code,
and it allows the next patch to tbl_term.c, tbl_literal().
"Please check them in and I'll look into them later!" kristaps@
Ingo Schwarze [Sun, 27 May 2012 17:48:57 +0000 (17:48 +0000)]
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.
"Please check them in and I'll look into them later!" kristaps@
Ingo Schwarze [Sun, 27 May 2012 14:42:05 +0000 (14:42 +0000)]
The .\} -> .\& -> pset() bug reported by naddy has already been fixed;
i'm really sure because i both stepped through the code with gdb
and wrote an OpenBSD regression test for it.
While here, note that bentley@ reported .ti .ce .fc missing.
Discourage the use of esr's man-ext macros:
If man(7) has any advantage compared to mdoc(7), it's portability,
and using man-ext would needlessly give that advantage away.
ok kristaps@
Improve mandocdb's ability to handle NAME sections by sucking the entire
shebang into a buffer and parsing it that way. This improves on many
cruddy -man manuals in the wild.
Merge some/most of schwarze@'s OpenBSD changes into mandoc: many more
warnings about grokking manpages in their respective directories.
DO NOT, however, import his temporary-file routines (I don't plan on
staying with a recno/btree split) nor the realpath() routines, which
destroy relative path-ness.
Also pull in the lorder bits.
There are some changes I started to make then stopped relating to
reporting errors in the correct directories. I'll clean this up in
subsequent commits.
Ingo Schwarze [Thu, 5 Jan 2012 00:43:51 +0000 (00:43 +0000)]
Fix previous such that all .It HEADs are unparsed,
not just the first one in each -diag list.
While here, drop the needless if-statement
and choose a more precise wording for the comment.
ok kristaps@
When parsing catpages, read from the first section (NAME, we hope) until
the next section. Also, remove the limit of 72 characters and enforce
this, instead in the apropos frontend.
Ingo Schwarze [Sun, 25 Dec 2011 14:58:39 +0000 (14:58 +0000)]
For binary compatability of the databases across architectures,
use pointers to arrays, not pointers to structs. It is now possible
to create databases on sparc64 and use them on i386 and vice versa.
Kristaps@ can't think of anything else that might be required, either.
Put this in now such that we can move on.
Ingo Schwarze [Sun, 25 Dec 2011 13:08:12 +0000 (13:08 +0000)]
Implement test mode (makewhatis -t), required for pkg_create(8).
Always do all consistency checks; when any one fails, decide whether
to print a message, or skip the file, or both, or none.
While here, do some cleanup as well:
* Bail out on conflicting options.
* Do not crash with -a if there are plain files in the root dir.
* Collect some related variables into structs.
Support leading, trailing and double colons in MANPATH to prepend,
append or insert the man.conf(5) default path; compatible with GNU
manpath(1), implementation by kristaps@, heavily tweaked by schwarze@.
Updates to MANPATH documentation applied to whatis.1, apropos.1, and
catman.8 also.
Ingo Schwarze [Tue, 20 Dec 2011 21:41:11 +0000 (21:41 +0000)]
Do not cast void pointers to pointers requiring alignment.
This makes mandocdb(8)/apropos(1) work on strict alignment architectures.
Basic way to fix this confirmed by deraadt@ and kettenis@, thanks.
ok kristaps@
This now works on both sparc64 and i386, but note that the binary
database format is still machine-dependent.
When routing to a "result" page in the cgi, remember our input parameters
and repeat them in the search bar. This is handy. While here, make the
QUERY_STRING parser a bit simpler.
Make the stored "cat"/"mdoc"/"man" strings just be c/d/a single-character
bytes. This cuts down a little in index size and allows for cleaner
extraction of information.
Make paths in the mandocdb(8) index relative to the databases' path
prefix. This means that an index in, say, /usr/share/man will point to
man1/foo.1 instead of /usr/share/man/man1/foo.1. Not only does this
save a lot of space, it also allows manual trees to be moved around
without any side effects to the mandocdb(8) databases.
- include search bar above result page (I relent: it's annoying to
follow three links then press back three times to get a search page);
- make man.cgi.css into man-cgi.css so Apache isn't confused by two
handlers (css, cgi);
- finally consolidate example.style.css to be under the div.mandoc css
selector;
- put catman pages under div.catman;
- put search bar under div#mancgi;
- reflect this properly in the bundled CSS files.
Have manpath.c properly use manpath(1), that is, using -C and -m and so on.
This also cleans up the code a little bit. While here, make some functions
static that are only used within manpath.c.
Compatibility support fgetln() on Linux. This uses the BSD-licensed
implementation from NetBSD tnftpd, Christos Zoulas (copyright message
retained in the compat_fgetln.c file). Patch verified by schwarze@. He
notes that you'll need -pthread for -static binaries (due to libdb), so
I've noted that -static should really only be used for BSD UNIX.
While here, add some forgotten goop to the Makefile, building and
cleaning extra manpages.
When 303'ing a search directly to a page, remember to specify its manroot.
Also allow for a CSS_DIR to specify alternate CSS locations.
Finally, some clutter as I assume that "css" and "progname" are already
HTML-safe.
Finishing touches on multi-manroot man.cgi. If more than one root is
specified, write them out using a SELECT box. Else write nothing (the
manroot will still be checked if it's specified).
Switch on "manpath=" handling, which I call the "manroot" (as "manpath" is
reserved for paths within a manroot). This functionality is bare-bones:
right now, the default manroot is the first one scanned from the cache
directory. At some point this will be sexy and smooth, but it's easy to
upgrade functionality by modifying pathgen() and so forth. If a manroot
isn't parsed from the "manpath=", results are always empty.
- Deprecate kvals (key/value pairs for QUERY_STRING values). Since there's
only one place that uses this, kval_parse (now http_parse()) dumps directly
into struct query, which is more high-level.
- Put query values directly into struct req.
- The biggest difference is dynamic support for multiple "manroots". A
"manroot" is a path with an "etc/catman.conf" file. When the cgi starts,
it (prefix) recurses through its CACHE_DIR searching for "etc" directories.
When one's found, it sees if a catman.conf file exists. This is marked
as a manroot and appended to a list. The name of a manroot is the path
without slashes (e.g., OpenBSD/4.9 -> "OpenBSD 4.9").
Right now "manroot" isn't enabled. The first manroot is chosen as the
real one. I'll add the interface to it in the next checkins, but it'll be
quite simple.
Ingo Schwarze [Sat, 10 Dec 2011 16:53:39 +0000 (16:53 +0000)]
Fix selection of arch-specific manuals:
(1) Correctly compare cat vs. man paths.
(2) Compare arch (and section) names case-insensitively.
Problem noticed by kristaps@.
When specifying an architecture to whatis(1)/apropos(1)/man.cgi(7), do a
comparison only if the manual specifies an architecture, otherwise let it
through. Looked over by schwarze@. This brings us much more in line with
OpenBSD's behaviour.
Ingo Schwarze [Fri, 9 Dec 2011 11:16:34 +0000 (11:16 +0000)]
Tweak pformatted():
* If the first section is empty, use the file name as .Nd.
* No need to check (len > 0) after successful fgetln(3).
* Improve some comments and strip trailing whitespace.
ok kristaps@
Clean up grok of preformatted manual description.
(1) put fclose() at the end, as line isn't valid afterward (see fgetln())
(2) clean up loops to be more readable to my old eyes
(3) mandate trailing newline, nul-terminate, and use strrchr
If arguments are passed to mandocdb(8) in "default" mode, then use
realpath() to convert them into absolute paths before putting the
traversed subdirectory filenames into the index.