summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_argv.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Provide a helper function macro_or_word() and use it to prune theschwarze2014-11-291-12/+7
| | | | | | | | | | 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.
* Fold the loop around mdoc_argv() into the function itself,schwarze2014-11-281-71/+78
| | | | | | 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.
* Simplify the code by making various mdoc parser helper functions void.schwarze2014-11-281-22/+12
| | | | No functional change, minus 130 lines of code.
* Clean up messages related to plain text and to escape sequences.schwarze2014-07-061-5/+9
| | | | | * Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
* Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,schwarze2014-07-021-4/+4
| | | | | since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
* Audit malloc(3)/calloc(3)/realloc(3) usage.schwarze2014-04-231-5/+5
| | | | | | | * 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).
* KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,schwarze2014-04-201-46/+46
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Implement the roff(7) .ll (line length) request.schwarze2014-03-301-1/+2
| | | | | Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
* The files mandoc.c and mandoc.h contained both specialised low-levelschwarze2014-03-211-1/+2
| | | | | | | 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.
* s/[Nn]ull/NUL/ in comments where appropriate;schwarze2013-12-251-4/+4
| | | | suggested by Thomas Klausner <wiz @ NetBSD dot org>.
* Fix end-of-sentence spacing after the DragonFly text production macro.schwarze2013-12-221-2/+2
| | | | Patch from Franco Fichtner <franco at lastsummer dot de>.
* In quoted macro arguments, double quotes can be quoted by doubling them.schwarze2013-12-151-1/+13
| | | | | | | | | 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.
* Fix four small whitespace issues related to trailing punctuationschwarze2012-11-181-4/+4
| | | | | | | 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
* Cleanup naming of local variables to make the code easier on the eye:schwarze2012-11-171-30/+30
| | | | | | | | 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
* Two more macros (.Ap and .In) do trailing delimiter handling.schwarze2012-11-161-3/+4
| | | | | | | 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!
* Two bugfixes regarding the -width and -offset macro arguments:schwarze2012-04-151-38/+4
| | | | | | | | | | | | 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.
* Sync to bsd.lv (all coded by kristaps@):schwarze2011-07-051-235/+185
| | | | | | | | | | - 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
* Merge release 1.11.3, almost all code by kristaps@:schwarze2011-05-291-223/+186
| | | | | | | | | * 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.
* Merge version 1.11.1:schwarze2011-04-241-44/+77
| | | | | | | | | | | | | | 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.
* Merge version 1.10.10:schwarze2011-04-211-148/+126
| | | | | | | | | | 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
* Reorg by Kristaps: In libmdoc, replace the union of pointers to structsschwarze2010-12-291-3/+2
| | | | | | | 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.
* Prevent .Pp and .Lp from looping endlessly on punctuation.schwarze2010-09-131-3/+3
| | | | | Fix for .Pp from kristaps@, i applied the same to .Lp. Bug reported by espie@.
* Sync to bsd.lv; in particular, pull in lots of bug fixes.schwarze2010-07-251-4/+6
| | | | | | | | | | | | | | | | | | | | | 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
* Merge release 1.10.4 (all code by kristaps@), providing four new features:schwarze2010-07-131-3/+4
| | | | | | | | | | 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.
* merge release 1.10.2schwarze2010-06-261-3/+3
| | | | | | | | | | | | * 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
* Merge bsd.lv version 1.10.1 (to be released soon).schwarze2010-06-061-27/+22
| | | | | | | | | | | | | | | | | | | | 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.
* Unified error and warning message system for all of mandoc,schwarze2010-05-231-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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@.
* proper handling of quoted tab-separated column listsschwarze2010-05-151-19/+39
| | | | by kristaps@
* Distinguish OPEN, MIDDLE and CLOSE delimiters (using an enum).schwarze2010-05-151-3/+4
| | | | | | | | | | 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.
* Integrate kristaps@' end-of-sentence (EOS) frameworkschwarze2010-05-141-2/+1
| | | | | | | | | | | | | 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.
* Merge 1.9.25, keeping local patches;schwarze2010-05-141-7/+10
| | | | | | | | | | | | | | 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
* merge 1.9.24, keeping local patches; some changes:schwarze2010-05-141-22/+29
| | | | | | | | | * 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
* When two conflicting list types are specified for the same list,schwarze2010-04-031-15/+20
| | | | | | use the first, discard the second, and warn. No need to bail out. ok deraadt@
* merge 1.9.22, keeping local patchesschwarze2010-04-021-7/+7
| | | | | | * 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
* Proper inter-sentence spacing for mdoc(7).schwarze2010-03-021-1/+2
| | | | | | | | | 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.
* Distinguish opening and closing delimiters, and close out blockschwarze2010-03-021-3/+3
| | | | | | | | 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 "`('".
* sync to 1.9.12, mostly portability and refactoring:schwarze2009-12-221-33/+14
| | | | | | | | | | | | | | | | | | | 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/
* sync to 1.9.11: adapt printing of dates to groff conventions,schwarze2009-10-271-1/+2
| | | | | NetBSD portability fixes and some minor bugfixes and feature enhancements; also checked that my hyphenation code still works on top of this
* sync to 1.9.9, featuring:schwarze2009-10-211-2/+4
| | | | | | | * -Thtml output mode * roff scaling units * and some minor fixes for full changelogs, see http://bsd.lv/cgi-bin/cvsweb.cgi/
* sync to 1.9.7: avoid using the same identifier for a static functionschwarze2009-10-191-31/+31
| | | | | and for a local variable in another function in the same compilation unit; suggested by Ulrich Spoerlein, uqs at spoerlein dot net
* sync to 1.9.6: do not die from .Bd -literal -offset w/o arg (and similar)schwarze2009-10-191-3/+7
| | | | | Actually, our ancient groff behaves slightly differently than this fix, but not to die is already an improvement. Needs a closer look later.
* sync to 1.9.1: .Rv and .Ex accept multiple argumentsschwarze2009-08-221-2/+2
|
* sync to 1.9.1: correctly flag delimiter whitespaceschwarze2009-08-221-13/+30
|
* sync to 1.8.1: rewrite quoted literal handling correctly,schwarze2009-07-261-199/+154
| | | | | rewrite TABSEP handling in a simpler way, and retire ECOLEMPTY, ARGS_QUOTED and ARGS_ARGVLIKE
* sync to 1.8.1: removed excessively verbose EARGVPARM warningschwarze2009-07-261-9/+3
|
* sync to 1.8.1: support .br and .spschwarze2009-07-261-1/+3
|
* sync to 1.7.24: remove long-fixed FIXMEschwarze2009-07-121-2/+1
|
* sync to 1.7.23: pass warning code to mdoc_pwarn() instead of warning messageschwarze2009-07-121-51/+14
| | | | | | define additional warning macro mdoc_nwarn() remove obsolete warning functions mdoc_warn(), pwarn(), vwarn(), nwarn() remove various now unused "enum mdoc_warn" and "enum mwarn"
* sync to 1.7.23: pass error code to mdoc_perr() instead of error stringschwarze2009-07-121-29/+3
| | | | | and use the so improved mdoc_nerr() at many places; get rid of now unused static functions perr()
* sync to 1.7.23: pass error code to mdoc_nerr() instead of error stringschwarze2009-07-121-19/+19
| | | | and use the so improved mdoc_nerr() at many places