aboutsummaryrefslogtreecommitdiffstatshomepage
Commit message (Collapse)AuthorAgeFilesLines
...
* The mdoc_handler flags are unused and will never be used.Ingo Schwarze2013-06-071-127/+124
| | | | | Having a mask is sufficient to trigger putmdockey. Simplify by dropping the flags; no functional change.
* In .Xr database entries, mention the manual section again;Ingo Schwarze2013-06-071-3/+14
| | | | | the section was dropped when switching from db to sqlite. Use the customary format foo(N).
* The string hash table is only needed to combine multiple occurencesIngo Schwarze2013-06-071-110/+68
| | | | | | | | | | | | | | | | | | | | | | of the same string within the same manual, so initialize and purge it for each manual in ofmerge() instead of one single time in main(). There is no point in saving manual names and descriptions in that table because each of them occurs only once, or very few times. The is no point in saving section numbers there because they are so much shorter than the descriptions. Testing with the complete tree /usr/share/man/ on my notebook shows that this change slightly reduces memory consumption by about 20% while there is no measurable difference in execution time. As a bonus, this allows to delete the functions stradd() and stradds(), the "next" member from struct str, and the global struct str *words. While adapting the places in the code using stradd(), i noticed that parsing of the mdoc(7) .Nd macro was completely broken and that for formatted manual pages with unusable NAME section, the description was never set in the struct of. This commit fixes both bugs as well.
* Optimize stradds() and putkeys() to not call ohash_qlookupi()Ingo Schwarze2013-06-061-45/+28
| | | | | | | and ohash_find() twice. As a bonus, this allows to drop hashget(). While here, rename index to slot to match the terminology in the ohash manual; it also prevents potential clashes with index(3). Drop the slot variable altogether where it is used only once.
* Drop wordaddbuf() which is identical to putkeys().Ingo Schwarze2013-06-061-22/+9
| | | | | Also rename straddbuf() to stradds() to be more similar to putkeys(). Just cleanup, no functional change.
* In dbopen(), check success of remove("mandoc.db~").Ingo Schwarze2013-06-061-22/+15
| | | | | While here, simplify dbopen() and dbclose(): No need for strlcpy() and strlcat() when dealing with constant strings only.
* No point in inventing yet another file name for the database.Ingo Schwarze2013-06-061-2/+2
| | | | | | We are not going back to Berkeley DB and don't care about overwriting any obsolete files that may be lying around. So, go back from "mandocdb.db" to "mandoc.db".
* In parse_catpage(), the comment saying that the filename would beIngo Schwarze2013-06-061-1/+2
| | | | | | used as a default page description if no usable NAME section was found was preserved when moving from db to sqlite, but the code line actually doing that was removed without replacement. So, put it back.
* The return value from parse_man() is completely unused,Ingo Schwarze2013-06-051-14/+10
| | | | so make the function void; no functional change.
* Two sanity checks got lost in treescan()Ingo Schwarze2013-06-051-30/+37
| | | | | | | | | during the switch from db to sqlite; restore these: * Warn and skip when directory and file name mismatch. * Warn and skip when finding special files. * Warning about "mandocdb.db" is useless, it is always present. * While here, do not hardcode "mandocdb.db", use MANDOC_DB.
* Add back the realpath() checks that got lost during the change fromIngo Schwarze2013-06-051-122/+160
| | | | | | | | | | | | | | | | | | db to sqlite; they are needed to prevent corruption of the database when paths containing dot, dotdot, or symlinks are given on the command line. Also make sure the exit-code is really non-zero on system errors and use mandoc(1) exit codes. To make all this simpler, * Drop the "basedir" argument from almost every function and make it global because it is really state info used all over the place. * Move "startdir" and "fd" as local vars into set_basedir() because they are only used for this one purpose, i.e. to move out of basedir again. While here, * Clarify the name of path_arg in the main program; in the -C case, it is not a dir, and anyway there are lots of different dirs around. * Include missing <stdio.h> needed for perror().
* Some places used PATH_MAX from <limits.h>, some MAXPATHLEN from <sys/param.h>.Ingo Schwarze2013-06-056-55/+49
| | | | | | Consistently use the PATH_MAX since it is specified by POSIX, while MAXPATHLEN is not. In preparation for using this at a few more places.
* Changing existing SQLite databases was utterly broken:Ingo Schwarze2013-06-031-2/+4
| | | | | 1) SQL statements were only prepared when creating a new database. 2) We rely heavily on foreign_keys, but never enabled them.
* Starting the preparations to integrate this into OpenBSD.Ingo Schwarze2013-06-031-44/+65
| | | | | | | | | | As variadic macros are not supported on all architectures, replace them by a real function. While here, * choose a more logical order for "dir" and "file" arguments * choose a more logical order when printing; as a bonus, a simple sed 's/:.*//' will get you valid file names * in ofmerge(), skip diagnostic string comparisons when we don't want warnings anyway
* Let .Do .Dq .Ql .So .Sq generate the correct roff(7) character escapeIngo Schwarze2013-06-022-11/+11
| | | | | | | sequences such that output modes like -Tutf8 have a chance to select nice glyphs. This doesn't change anything for -Tascii, and, for now, it doesn't affect -Tps and -Tpdf either. OK matthew@ bentley@; like the idea tedu@; no opinion jmc@.
* Sync to OpenBSD, no functional change:Ingo Schwarze2013-06-023-16/+8
| | | | | | * Add the missing mparse_parse_buffer prototype. * Drop the useless MAP_FILE constant: It's not specified in POSIX, so it's not required, it's the default anyway, and it's 0 anyway.
* Note where these functions are declared and implemented.Ingo Schwarze2013-06-021-2/+86
| | | | That helps to find one's way when hacking on the code.
* This file contains too much complexity.Ingo Schwarze2013-06-011-19/+18
| | | | | | | Remove one layer of indirection by deleting mparse_readfd_r() and doing its work in the public mparse_readfd(). As a bonus, catch recursive .so. This is part of the preparations to resync to openbsd.org.
* Use a standard locale name, "UTF-8" is an ugly non-standard aliasIngo Schwarze2013-06-011-3/+2
| | | | | that doesn't work on OpenBSD. OK tedu@ naddy@
* latex2man.1 - oh boy...Ingo Schwarze2013-06-011-1/+5
|
* Some documentation of the tbl parser.Ingo Schwarze2013-06-011-0/+295
| | | | | | I needed this when working on tbl(7) bug fixes. Deliberately not linked to the build; this is developer documentation, not user documentation.
* If a table contained at least one complete lineIngo Schwarze2013-06-011-2/+2
| | | | | | | | | | | | | | | | | | | | and on its last line, the first T{ remained unclosed, roff_parseln() never returned ROFF_TBL for that last line, so {man,mdoc}_addspan() never got called for that last line, so we ended up with a table where no line associated with a node had TBL_SPAN_LAST set, so tbl_term() never free()'d the cols in struct roffcol, so tblcalc() crashed on the NULL == tbl->cols assertion when starting the *next* table in the same file. Fix this by returning ROFF_TBL as soon as we open a data cell, not only when finishing it - as explained above, it may never get properly closed but instead be interrupted by .TE. Problem reported by bentley@ in latex2man.1. I love it when bugs take half a day to debug but the fix turns out to be flipping one single bit in the source code.
* More cleanup: Consistently use the name "struct tbl_node *tbl"Ingo Schwarze2013-05-312-30/+30
| | | | | that is already used almost everywhere instead of gratuitiously inventing different names at four places. No functional change.
* The name "struct tbl" was badly misleading for two reasons:Ingo Schwarze2013-05-315-34/+34
| | | | | | | 1) This struct almost exclusively contains the table options. 2) Information about the table as a whole is actually in "struct tbl_node". Besides, "struct tbl" was almost impossible to search for. So rename it to "struct tbl_opts". No functional change.
* Reject non-printable characters found in the input stream even whenIngo Schwarze2013-05-301-9/+24
| | | | | | | | preceded by a backslash; otherwise, the escape sequence would later be identified as invalid and the non-printable character would be passed through to the output backends, sometimes triggering assertions. Reported by Mike Small <smallm at panix dot com> on the mdocml discuss list.
* Sync to OpenBSD:Ingo Schwarze2013-05-291-3/+5
| | | | | | | | * Guard <sys/param.h> inclusion by #ifdef USE_MANPATH to make it more obvious why this isn't needed on OpenBSD. Noticed by deraadt@. * Resolve gratuitious whitespace differences: Blanks before tabs and on empty lines.
* Simplify condition, avoid duplicate code; no functional change.Ingo Schwarze2013-05-291-7/+3
|
* In SYNOPSIS mode, .Ek doesn't end a keep.Ingo Schwarze2013-05-292-4/+4
| | | | Found and fixed on the plane to the OpenBSD t2k13 hackathon in Toronto.
* In keep mode, if any text is printed (even in NOSPACE mode),Ingo Schwarze2013-05-291-3/+3
| | | | | | | any text that follows must be kept on the same line. I already found the issue and wrote the patch in April 2011, but didn't come round to do proper testing and forgot about it.
* Support .Bl -offset in -mdoc -Tman.Ingo Schwarze2013-05-191-4/+22
| | | | | Issue found when Thomas Klausner <wiz at NetBSD dot org> made me look at the manuals of his http://www.nih.at/libzip library.
* Move printing of the .RS macro into print_offs() such that print_offs()Ingo Schwarze2013-05-191-5/+5
| | | | | | | takes care of printing the whole line. This reduces code duplication - in particular after the upcoming commit to repair .Bl -offset - and makes print_offs() more similar to what print_width() does. No functional change.
* Should termp_xx_pre() ever get called for a macro it cannot handle,Ingo Schwarze2013-05-181-2/+3
| | | | | | | | use abort(3), just like in the three other comparable cases in this file, instead of ignoring the problem and causing a null pointer access. Cosmetical issue reported by Ulrich Spoerlein <uqs@spoerlein.net> found by Coverity Scan CID 976115. No functional change.
* Remove the variable sz because it's invariantly == 0,Ingo Schwarze2013-05-181-8/+3
| | | | | | | | | along with the dead code testing whether it's positive. Reported by Ulrich Spoerlein <uqs@spoerlein.net>, found by Coverity Scan CID 975717. While here, remove the now unused **params array as well, which Coverity apparently missed, at least it wasn't reported...
* Even though the size of a pointer should not depend on the type of theIngo Schwarze2013-05-181-2/+2
| | | | | | | data pointed to, pass the size of the right pointer type to calloc; cosmetic issue reported by Ulrich Spoerlein <uqs@spoerlein.net> found in Coverity Scan CID 978734. No binary change - ok cmp(1).
* - (mdoc.7) fix Xr to selfIngo Schwarze2013-04-283-10/+10
| | | | | - double word fix from jmc@
* Cavium Octeon (new architecture in OpenBSD); from jmc@.Ingo Schwarze2013-03-271-1/+2
|
* legancy -> legacy; reported by Chris HettrickIngo Schwarze2013-03-061-3/+3
|
* In literal mode (.nf), each input line must be kept togetherIngo Schwarze2013-01-051-4/+4
| | | | | | | | | | on the same output line, even if it is longer than the output width. This commit fixes a bug allowing an overly long last line of an indented block (.RS) to be broken even in literal mode. The bug was found using the sudo_plugin(4) manual provided by millert@. I introduced the bug in rev. 1.84 during the g2k12 Budapest hackathon.
* Rewrite indentation handling for nested lists in a more systematic wayIngo Schwarze2012-12-311-35/+49
| | | | | | | | | | | | to fix multiple issues reported by Todd Miller; thanks! Specifically, - avoid double indentation after .Bd inside .Bl - set up correct indentation after .Bl inside .Bl - set up correct indentation after .Dl and .D1 inside .Bl While here, also - set up correct indentation *inside* .Dl and .D1 inside .Bl.
* Do not crash on stray .Ta macros found outside column lists.Ingo Schwarze2012-11-194-14/+19
| | | | Problem reported by jmc@, thanks.
* In groff, trying to redefine standard man(7) macros before .TH has no effect;Ingo Schwarze2012-11-193-8/+73
| | | | | | | | | | | | | | after .TH, it works. Trying to redefine standard mdoc(7) macros before .Dd works when calling groff with the -mdoc command line option, but does not when calling groff with -mandoc; after .Dd, it always works. Arguably, one might call that buggy behaviour in groff, but it is very unlikely that anybody will change groff in this respect (certainly, i'm not volunteering). So let's be bug-compatible. This fixes the vertical spacing in sox(1). Merging from OpenBSD libmandoc.h 1.18, read.c 1.8, roff.c 1.47, June 2, 2012.
* sync usage(), and tidy up the output a little; from jmc@Ingo Schwarze2012-11-191-4/+4
|
* In -Tman mode, support automatic word keeps in the SYNOPSISIngo Schwarze2012-11-191-22/+34
| | | | | | | | | just like in -Tascii mode; requested by millert@. While here, do not escape the blank characters terminating man(7) macros; this is becoming more important as we use more keeps now. Note that -Tman still does not support .nr nS.
* Three portability improvements by millert@:Ingo Schwarze2012-11-191-9/+10
| | | | | | | | | | | * Use "\\ " not "\\~" as the non-breaking space as historic nroff doesn't support the latter. * The '-' before the flags needs to be quoted to prevent nroff from putting a line break between the '-' and the flag character. * Disable hyphenation and, for nroff, disable justification which is consistent with how mdoc behaves (and produces more readable manuals). (OpenBSD rev. 1.39, 1.40 and 1.41)
* Make the generated man(7) code more portable by using .PDIngo Schwarze2012-11-181-6/+20
| | | | | | | instead of .sp -1v, which for example Solaris nroff handles poorly. Problem report and patch by millert@, with the print_word chunk tweaked by me.
* Correct indentation for lists and displays inside lists.Ingo Schwarze2012-11-181-7/+104
| | | | | | | Inspired by a diff from millert@, but implemented rather differently and with slightly better functionality. In particular, this one respects -offset and -width arguments found in the input file.
* Fix four small whitespace issues related to trailing punctuationIngo Schwarze2012-11-183-7/+17
| | | | | | | | | reported by Nicolas Joly <njoly at pasteur dot fr>: - add EOS spacing after trailing punctuation after .Cd, .Fc, and .Lb - suppress spacing before trailing punctuation after .Fd Add the remaining issues from the same report to the TODO file.
* Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze2012-11-1714-781/+779
| | | | | | | | Settle for "struct man *man", "struct mdoc *mdoc", "struct meta *meta" and avoid the confusing "*m" which was sometimes this, sometimes that. No functional change. ok kristaps@ some time ago
* Warn about unknown volume or arch in Dt macro arguments;Ingo Schwarze2012-11-163-4/+6
| | | | patch written by Nicolas Joly <njoly at pasteur dot fr>.
* End of sentence spacing after trailing punctuation after .In and .ApIngo Schwarze2012-11-161-9/+1
| | | | | has just been fixed. Note that my problem description was somewhat misleading, even though Nicolas Joly's problem report was fine.