aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/read.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Pure preprocessor implementation of the roff(7) .ec and .eo requestsIngo Schwarze2017-06-041-70/+4
| | | | | | | | | | | | | | | | | (escape character control), touching nothing after the preprocessing stage and keeping even the state variable local to the preprocessor. Since the escape character is also used for line continuation, this requires pulling the implementation of line continuation from the input reader to the preprocessor, which also considerably shortens the code required for that. When the escape character is changed, simply let the preprocessor replace bare by escaped backslashes and instances of the non-standard escape character with bare backslashes - that's all we need. Oh, and if anybody dares to use these requests in OpenBSD manuals, sending a medium-sized pack of axe-murderers after them might be a worthwhile part of the punishment, but probably insuffient on its own.
* ignore blank lines in man(7) next line scope;Ingo Schwarze2017-06-031-1/+2
| | | | strange groff edge case behaviour found in multimedia/mjpegtools
* STYLE message about full stop at the end of .Nd; inspired by mdoclint(1)Ingo Schwarze2017-06-011-1/+2
|
* STYLE message about missing use of Ox/Nx/Fx/Dx; OK jmc@ wiz@Ingo Schwarze2017-05-311-1/+2
|
* STYLE message about useless macros we don't want (Bt Tn Ud);Ingo Schwarze2017-05-301-1/+4
| | | | not a WARNING because they don't endanger portability
* Introduce a new mandoc(1) message level, -W style, below -W warning.Ingo Schwarze2017-05-161-3/+4
| | | | | | | | | | | | | 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"
* Parser unification: use nice ohashes for all three request and macro tables;Ingo Schwarze2017-04-291-7/+12
| | | | no functional change, minus two source files, minus 200 lines of code.
* If a user-defined macro is aborted because it exceeds the stackIngo Schwarze2017-03-071-9/+13
| | | | | | | | | | | | | | | | | | | limit, usually due to infinite recursion, discard whatever remains in all those open stack levels. Otherwise, insane constructions like the following could generate macros of enormous size, causing mandoc(1) to die from memory exhaustion: .de m \" original macro definition .m \" recursion to blow up the stack .de m \" definition to be run during the call of .m marked (*) very long plain text (some kilobytes) .m \" expand the above a thousand times while unwinding the stack .. \" end of the original definition .m \" (*) recursively generate a ridiculously large macro .. \" end of recursively generated definition .m \" execute the giant macro, exhausting memory Very creative abuse found by tb@ with afl(1).
* Using .Nd only makes sense in the NAME section.Ingo Schwarze2017-03-061-1/+2
| | | | | Warn if that macro occurs elsewhere. Triggered by a question from Dag-Erling Smoergrav <des @ FreeBSD>.
* resolve trivial differences with OpenBSD:Ingo Schwarze2017-02-181-4/+2
| | | | | * we include <sys/types.h> for size_t, so we don't need <stdint.h> * sort declarations in read_whole_file()
* Minor cleanup, no functional change:Ingo Schwarze2017-02-031-7/+7
| | | | | | | We always have a roff parser, so mparse_free() does not need to check for existence before freeing it. Also arrange code in struct mparse, mparse_reset(), and mparse_free() in the same order for readability.
* If an application parses multiple files with mparse_readfd(3) butIngo Schwarze2017-02-031-1/+2
| | | | | | | | | without using mparse_open(3) to open the files, and if one of the files includes a gzip'ed file with .so, then the gzip flag remains set and the next main file will be expected to be gzip'ed. Fix this by clearing the gzip flag in mparse_reset(3). Bug found and patch provided by Michael <Stapelberg at debian dot org>.
* Add a warning "new sentence, new line".Ingo Schwarze2017-01-281-1/+2
| | | | | | | | | This does not attempt to pinpoint each and every offender, but instead tries very hard to avoid false positives: Currently, there are only two false positives in the whole OpenBSD base system. Only do this in mdoc(7), not in man(7), because manuals written in man(7) typically have much worse problems than this. OK jmc@ on a previous version of the patch
* Warnings and errors that occur during mdoc_validate()Ingo Schwarze2017-01-091-1/+8
| | | | | | 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.
* Stricter validation of the NAME section, in particular:Ingo Schwarze2017-01-081-3/+4
| | | | | | | - require a comma between names - reject all other text nodes - reject all empty Nm below NAME, not only in the leading position - reject Nm after Nd
* Make the second, section number argument of .Xr mandatory.Ingo Schwarze2016-12-281-1/+2
| | | | | | In fact, we have been requiring it for many years. The only reason to not warn when it was missing was excessive traditionalism - it was optional in 4.4BSD.
* When reporting "whitespace at end of input line" on lines ending withIngo Schwarze2016-12-071-2/+4
| | | | | | roff(7) comments, let the column number in the message point to the end of the line rather than to the beginning of the comment. Improvement suggested by bluhm@.
* warn about trailing whitespace at the end of comments;Ingo Schwarze2016-11-101-6/+12
| | | | missing feature noticed by jmc@
* Delete complicated code dealing with .Bl -tag without -width,Ingo Schwarze2016-10-091-2/+2
| | | | | | | | | | | | and just let it default to -width 6n, which agrees with the traditional -width Ds that is still in widespread use. I just pushed a patch upstream to GNU roff that does the same for groff_mdoc(7). Before, groff contained code that was even more complicated than mandoc, but both resulted in quite different user-visible output. Now, both agree, and output is nicer for both. Useless complication noticed by Carsten Kunze (Heirloom roff).
* Remove the dependency on SQLite without loss of functionality.Ingo Schwarze2016-07-191-7/+1
| | | | | Stop supporting systems that don't have mmap(3). Drop the obsolete names_check() now that we deleted MLINKS.
* Since the mdoc/man parser unification, the parser is always allocatedIngo Schwarze2016-07-191-25/+3
| | | | | | in mparse_alloc(), so delete all the curp->man == NULL checks. Triggered by a patch from Christos Zoulas suggesting to add yet another such check.
* Fix a nasty typo that prevented .so links to gziped manualsIngo Schwarze2016-07-101-2/+2
| | | | | from working in the absence of a mandoc.db(5) database. Found the hard way by Svyatoslav Mishyn on Crux Linux.
* Simplify the mparse_open() interface.Ingo Schwarze2016-01-081-12/+12
| | | | | | Just return the file descriptor or -1 on error; there is just one kind of error anyway. Suggested by Christos Zoulas (NetBSD).
* It was very surprising that a function called mparse_readfd()Ingo Schwarze2016-01-081-5/+2
| | | | | | | | | | | | | 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).
* Without HAVE_ERR, don't try to include <err.h>, it probably isn't there.Ingo Schwarze2015-11-071-1/+3
| | | | | In that case, the required prototypes are in "config.h". Patch from Peter Bray <pdb_ml at yahoo dot com dot au>.
* If a .Bd block has no arguments at all, drop the block and only keepIngo Schwarze2015-10-301-1/+2
| | | | | its contents. Removing a gratuitious difference to groff output found after a related bug report from krw@.
* Major character table cleanup:Ingo Schwarze2015-10-131-5/+3
| | | | | | | | | | | | | * 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.
* Finally use __progname, err(3) and warn(3).Ingo Schwarze2015-10-111-13/+9
| | | | | | | | | | That's more readable and less error-prone than fumbling around with argv[0], fprintf(3), strerror(3), perror(3), and exit(3). It's a bad idea to boycott good interfaces merely because standards committees ignore them. Instead, let's provide compatibility modules for archaic systems (like commercial Solaris) that still don't have them. The compat module has an UCB Copyright (c) 1993...
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-14/+14
|
* Remove the warning about children of .Vt blocks because actually,Ingo Schwarze2015-09-141-2/+1
| | | | | | | .Vt type global_variable No = Dv defined_constant ; is the best way to specify in the SYNOPSIS how a global variable is initialized in the rare case where that matters. Issue noticed by jmc@.
* Do not fork and exec gunzip(1), just link with libz instead.Ingo Schwarze2015-07-191-83/+33
| | | | | | | 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.
* Unify some node handling functions that use TOKEN_NONE.Ingo Schwarze2015-04-191-12/+7
| | | | | | | | * mdoc_word_alloc(), man_word_alloc() -> roff_word_alloc() * mdoc_word_append(), man_word_append() -> roff_word_append() * mdoc_addspan(), man_addspan() -> roff_addtbl() * mdoc_addeqn(), man_addeqn() -> roff_addeqn() Minus 50 lines of code, no functional change.
* Decouple the token code for "no request or macro" from the individualIngo Schwarze2015-04-191-6/+5
| | | | | | high-level parsers to allow further unification of functions that only need to recognize this code, but that don't care about different high-level macrosets beyond that.
* Unify {mdoc,man}_{alloc,reset,free}() into roff_man_{alloc,reset,free}().Ingo Schwarze2015-04-181-39/+25
| | | | | Minus 80 lines of code, no functional change. Written on the train from Koeln to Wolfsburg returning from p2k15.
* Move mdoc_hash_init() and man_hash_init() to libmandoc.hIngo Schwarze2015-04-181-3/+9
| | | | | and call them from mparse_alloc() and choose_parser(), preparing unified allocation of struct roff_man.
* Profit from the unified struct roff_man and reduce the number ofIngo Schwarze2015-04-181-52/+40
| | | | | arguments of mparse_result() by one. No functional change. Written on the ICE Bruxelles-Koeln on the way back from p2k15.
* Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze2015-04-181-7/+7
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* First step towards parser unification:Ingo Schwarze2015-04-021-5/+6
| | | | | | 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.
* When the user exits the pager before the pager has drained all inputIngo Schwarze2015-03-171-1/+3
| | | | | | | | 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@.
* Fix previous: size_t is often narrower than off_t.Ingo Schwarze2015-03-111-2/+2
| | | | Cluestick applied by joerg at NetBSD.
* The st_size member of struct stat is off_t, which is signed,Ingo Schwarze2015-03-101-2/+2
| | | | | all required by POSIX. So don't compare it against against an unsigned constant.
* If a non-gz manual is read after a gzipped manual, refrainIngo Schwarze2015-03-021-1/+2
| | | | | | from throwing a bogus error "wait: No child processes". As reported by Baptiste Daroussin <bapt at FreeBSD dot org>, clearing the state variable curp->child after use was forgotten.
* improve NAME section diagnostics;Ingo Schwarze2015-02-231-2/+5
| | | | confusing messages reported by Jan Stary <hans at stare dot cz>
* Completely delete all carriage return characters from the input.Ingo Schwarze2015-02-201-2/+3
| | | | | | | No change to messages about them (ignore them right before line feeds, report errors elsewhere). naddy@ found a manual in the wild containing lots of these (ysm(1)), and i can't imagine a situation where dropping them could be problematic.
* replace the last legacy generic message type, "argument count wrong",Ingo Schwarze2015-02-061-2/+3
| | | | by more specific messages, improving diagnostics for .cc .tr .Bl -column
* better error reporting regarding .OP .RS .UR .TH argumentsIngo Schwarze2015-02-061-1/+3
|
* Delete the legacy generic warning type MANDOCERR_ARGCWARN,Ingo Schwarze2015-02-061-2/+2
| | | | | replacing the last instances by more specific warnings. Improved functionality, minus 50 lines of code.
* better handle .Fo and .Fd without argumentIngo Schwarze2015-02-061-1/+2
| | | | better handle .Fo with more than one argument
* discard .Rs head arguments and improve .Rs diagnosticsIngo Schwarze2015-02-041-1/+2
|
* more specific .Nd diagnostics, allowing to get rid of enum check_lvlIngo Schwarze2015-02-041-1/+2
| | | | and the respective argument of check_count()