summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mdoc_argv.c
AgeCommit message (Collapse)Author
2015-04-19Decouple the token code for "no request or macro" from the individualIngo Schwarze
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.
2015-04-18Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze
Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
2015-04-02Second step towards parser unification:Ingo Schwarze
Replace struct mdoc_node and struct man_node by a unified struct roff_node. To be able to use the tok member for both mdoc(7) and man(7) without defining all the macros in roff.h, sacrifice a tiny bit of type safety and make tok an int rather than an enum. Almost mechanical, no functional change. Written on the Eurostar from Bruxelles to London on the way to p2k15.
2015-04-02First step towards parser unification:Ingo Schwarze
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.
2015-02-04fix column numbers of macro arguments in messagesIngo Schwarze
2014-11-29Provide a helper function macro_or_word() and use it to prune theIngo Schwarze
same chunk of argument parsing code out of five of the eight callback functions. The other three have too much special handling to participate. As a bonus, let lookup() and mdoc_args() deal with line macros and retire the lookup_raw() helper and the mdoc_zargs() internal interface function. No functional change, minus 40 lines of code.
2014-11-28Fold the loop around mdoc_argv() into the function itself,Ingo Schwarze
it was the same in all four cases. As a bonus, get rid of one enum type that was used for internal communication. No functional change, minus 40 lines of code.
2014-11-28Simplify the code by making various mdoc parser helper functions void.Ingo Schwarze
No functional change, minus 130 lines of code.
2014-07-06Clean up messages related to plain text and to escape sequences.Ingo Schwarze
* Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
2014-07-02Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,Ingo Schwarze
since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
2014-04-23Audit malloc(3)/calloc(3)/realloc(3) usage.Ingo Schwarze
* Change eight reallocs to reallocarray to be safe from overflows. * Change one malloc to reallocarray to be safe from overflows. * Change one calloc to reallocarray, no zeroing needed. * Change the order of arguments of three callocs (aesthetical).
2014-04-20KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze
remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
2014-03-30Implement the roff(7) .ll (line length) request.Ingo Schwarze
Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
2014-03-21The files mandoc.c and mandoc.h contained both specialised low-levelIngo Schwarze
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.
2013-12-25s/[Nn]ull/NUL/ in comments where appropriate;Ingo Schwarze
suggested by Thomas Klausner <wiz @ NetBSD dot org>.
2013-12-22Fix end-of-sentence spacing after the DragonFly text production macro.Ingo Schwarze
Patch from Franco Fichtner <franco at lastsummer dot de>.
2013-12-15In quoted macro arguments, double quotes can be quoted by doubling them.Ingo Schwarze
For a long time, we handle this in roff(7) and man(7) macros. Now add correct handling for the mdoc(7) case, too. Closely based on a patch by Tsugutomo dot ENAMI at jp dot sony dot com, see http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=48438 received via Thomas Klausner (wiz@), slightly tweaked by me.
2012-11-18Fix four small whitespace issues related to trailing punctuationIngo Schwarze
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
2012-11-17Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze
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
2012-11-16Two more macros (.Ap and .In) do trailing delimiter handling.Ingo Schwarze
This fixes the end of sentence spacing in open(2) and in about 150 pages in the NetBSD base system. Reported by Nicolas Joly <njoly a pasteur point fr>, merci!
2012-04-15Two bugfixes regarding the -width and -offset macro arguments:Ingo Schwarze
1) They consume the next argument even if it starts with a dash. 2) When -width is the last argument on the line such that the actual width argument is missing, downgrade from a fatal to a non-fatal error, just like for -offset. The formatting still doesn't agree with groff, but at least we don't die any longer. Item 2 was observed and that part of the patch coded by kristaps@, who found lots of instances of this particular formatting error in Mac OSX manuals.
2011-07-05Sync to bsd.lv (all coded by kristaps@):Ingo Schwarze
- mdoc(7): fix an assertion if the first line after .Bd -column starts with a blank, and some simplifications in mdoc_argv.c - man(7): literal mode ends at .SH and .SS (bug reported by naddy@) - allow .RS/.RE blocks to nest (bug reported by dcoppa@ and gsoares@) - improve vertical spacing of man(7) blocks - roff(7): clear user-defined strings when starting a new file - correct ID tags in -T[x]html
2011-05-29Merge release 1.11.3, almost all code by kristaps@:Ingo Schwarze
* 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.
2011-04-24Merge version 1.11.1:Ingo Schwarze
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.
2011-04-21Merge version 1.10.10:Ingo Schwarze
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
2010-12-29Reorg by Kristaps: In libmdoc, replace the union of pointers to structsIngo Schwarze
of macro-specific data by a pointer to a union of structs, which makes the code simpler and more robust at the expense of a small memory overhead. Merging was somewhat difficult because we mustn't break tbl(1) support which the bsd.lv version does not yet have.
2010-09-13Prevent .Pp and .Lp from looping endlessly on punctuation.Ingo Schwarze
Fix for .Pp from kristaps@, i applied the same to .Lp. Bug reported by espie@.
2010-07-25Sync to bsd.lv; in particular, pull in lots of bug fixes.Ingo Schwarze
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
2010-07-13Merge release 1.10.4 (all code by kristaps@), providing four new features:Ingo Schwarze
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.
2010-06-26merge release 1.10.2Ingo Schwarze
* 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
2010-06-06Merge bsd.lv version 1.10.1 (to be released soon).Ingo Schwarze
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.
2010-05-23Unified error and warning message system for all of mandoc,Ingo Schwarze
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@.
2010-05-15proper handling of quoted tab-separated column listsIngo Schwarze
by kristaps@
2010-05-15Distinguish OPEN, MIDDLE and CLOSE delimiters (using an enum).Ingo Schwarze
Only OPEN are drawn before the beginning of a macro; this is new, before this, MIDDLE ('|') were drawn in front, too. Only CLOSE are pushed after the end of a macro (as before). ok kristaps@ This allows us to finally enable handling of leading punctuation without regressions.
2010-05-14Integrate kristaps@' end-of-sentence (EOS) frameworkIngo Schwarze
which is simpler and more powerful than mine, and remove mine. * man(7) now has EOS handling, too * put EOS detection into its own function in libmandoc * use node and termp flags to communicate the EOS condition * no more EOS pseudo-macro * no more non-printable EOS marker character on the formatter level This slightly breaks EOS detection after trailing punctuation in mdoc(7) macros, but that will be restored soon.
2010-05-14Merge 1.9.25, keeping local patches;Ingo Schwarze
this does not merge kristaps' end-of-sentences handling yet, i will check that separately. This one includes: * handle \*(Ba as a delimiter * introduce ARGS_PEND for .Bl -column .It end-of-line special casing * section ordering: expect EXIT STATUS at the right place * line break fixes in SYNOPSIS * allow literal contexts to have arbitrary line lengths * the input file column number can not be used to identify the beginning of a line because white space is allowed after the initial '.' * proper leading spaces in -man -Tascii mode * do not let Lb break lines in -mdoc -Thtml LIBRARY
2010-05-14merge 1.9.24, keeping local patches; some changes:Ingo Schwarze
* 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
2010-04-03When two conflicting list types are specified for the same list,Ingo Schwarze
use the first, discard the second, and warn. No need to bail out. ok deraadt@
2010-04-02merge 1.9.22, keeping local patchesIngo Schwarze
* convert mdoc tokens from #define to enum * fix a segfault with .Xo/.Xc in explicit blocks * Thorn is \*(Th, not \*(TH; noticed by Joerg Sonnenberger
2010-03-02Proper inter-sentence spacing for mdoc(7).Ingo Schwarze
When a text line or a non-block macro line in the source code ends in any of ".!?", consider that an end of sentence (EOS). This makes Jason's rule "new sentence, new line" even more important. Let the parser detect the EOS and insert a token into the AST. Let the -Tascii frontend render the EOS token as a double space before the next word.
2010-03-02Distinguish opening and closing delimiters, and close out blockIngo Schwarze
macros after closing delimiters only, not after opening ones. Besides, neither roff nor old nor new groff consider braces { } as delimiters. This fixes some frequent misrenderings by mandoc, for example ".Ql (" being rendered as "`'(" instead of "`('".
2009-12-22sync to 1.9.12, mostly portability and refactoring:Ingo Schwarze
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/
2009-10-27sync to 1.9.11: adapt printing of dates to groff conventions,Ingo Schwarze
NetBSD portability fixes and some minor bugfixes and feature enhancements; also checked that my hyphenation code still works on top of this
2009-10-21sync to 1.9.9, featuring:Ingo Schwarze
* -Thtml output mode * roff scaling units * and some minor fixes for full changelogs, see http://bsd.lv/cgi-bin/cvsweb.cgi/
2009-10-19sync to 1.9.7: avoid using the same identifier for a static functionIngo Schwarze
and for a local variable in another function in the same compilation unit; suggested by Ulrich Spoerlein, uqs at spoerlein dot net
2009-10-19sync to 1.9.6: do not die from .Bd -literal -offset w/o arg (and similar)Ingo Schwarze
Actually, our ancient groff behaves slightly differently than this fix, but not to die is already an improvement. Needs a closer look later.
2009-08-22sync to 1.9.1: .Rv and .Ex accept multiple argumentsIngo Schwarze
2009-08-22sync to 1.9.1: correctly flag delimiter whitespaceIngo Schwarze
2009-07-26sync to 1.8.1: rewrite quoted literal handling correctly,Ingo Schwarze
rewrite TABSEP handling in a simpler way, and retire ECOLEMPTY, ARGS_QUOTED and ARGS_ARGVLIKE
2009-07-26sync to 1.8.1: removed excessively verbose EARGVPARM warningIngo Schwarze