aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/read.c
Commit message (Collapse)AuthorAgeFilesLines
* Improve build system and autodetection.Ingo Schwarze2014-08-161-4/+4
| | | | | | | | | * Make ./configure standalone, that's what people expect. * Let people write a ./configure.local from scratch, not edit existing files. * Autodetect wchar, sqlite3, and manpath and act accordingly. * Autodetect the need for -L/usr/local/lib and -lutil. * Get rid of config.h.p{re,ost}, let ./configure only write what's needed. * Let ./configure write a Makefile.local snippet, that's quite flexible.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-5/+4
| | | | | | Include <sys/types.h> where needed, it does not belong in config.h. Remove <stdio.h> from config.h; if it is missing somewhere, it should be added, but i cannot find a *.c file where it is missing.
* Bring the handling of defective prologues even closer to groff,Ingo Schwarze2014-08-061-5/+8
| | | | | | | | | | | | in particular relaxing the distinction between prologue and body and further improving messages. * The last .Dd wins and the last .Os wins, even in the body. * The last .Dt before the first body macro wins. * Missing title in .Dt defaults to UNTITLED. Warn about it. * Missing section in .Dt does not default to 1. But warn about it. * Do not warn multiple times about the same mdoc(7) prologue macro. * Warn about missing .Os. * Incomplete .TH defaults to empty strings. Warn about it.
* mention requests and macros in more messagesIngo Schwarze2014-08-011-9/+9
|
* Dynamically allocate the stack of roff(7) .ie condition valuesIngo Schwarze2014-08-011-2/+1
| | | | and thus get rid of the last useless fatal error.
* Split MANDOCERR_IGNARGV into one message for .An and one for .BlIngo Schwarze2014-07-311-2/+3
| | | | and report the macro name and argument.
* In .Bl -column, if some of the column width declarations are givenIngo Schwarze2014-07-311-2/+1
| | | | | | | | | | | | | right after the -column argument and some at the very end of the argument list, after some other arguments like -compact, concatenate the column lists. This gets rid of one of the last useless FATAL errors and actually shortens the code by a few lines. This fixes an issue introduced more than five years ago, at first causing an assert() since mdoc_action.c rev. 1.14 (June 17, 2009), then later a FATAL error since mdoc_validate rev. 1.130 (Nov. 30, 2010), and marked as "TODO" ever since.
* Remove the useless FATAL error "argument count wrong, violates syntax".Ingo Schwarze2014-07-301-2/+1
| | | | | | The last remaining instance was .It in .Bl -column with more than one excessive .Ta. However, simply downgrading from FATAL to ERROR, it just works fine, almost the same way as in groff, without any other changes.
* Get rid of the useless FATAL error "child violates parent syntax".Ingo Schwarze2014-07-301-2/+2
| | | | | When finding items outside lists, simply skip them and throw an ERROR. Handle subsections before the first section instead of bailing out.
* Remove two useless FATAL errors.Ingo Schwarze2014-07-301-18/+22
| | | | | When a file contains neither text nor macros, treat it as an empty document. When the mdoc(7) document prologue is incomplete, use some default values.
* better name and wording for the last two non-generic errorsIngo Schwarze2014-07-301-4/+4
|
* Various improvements related to .Ex and .Rv:Ingo Schwarze2014-07-301-2/+3
| | | | | | | | | | * let .Nm fall back to the empty string, not to UNKNOWN * never let .Rv copy an argument from .Nm * avoid spurious \fR after empty .Nm in -Tman * correct handling of .Ex and .Rv in -Tman * correct the wording of the output for .Rv without arguments * use non-breaking spaces in .Ex and .Rv output where required * split MANDOCERR_NONAME into a warning for .Ex and an error for .Nm
* mark defos as const; nobody needs to change it,Ingo Schwarze2014-07-091-3/+3
| | | | and it is occasionally useful to be able to pass literal strings
* Clean up ERROR messages related to document structure and macros:Ingo Schwarze2014-07-071-6/+9
| | | | Hierarchical naming and mention macro names in messages.
* no need to delete any content from .Rs blocks,Ingo Schwarze2014-07-071-2/+2
| | | | and downgrade the related message from ERROR to WARNING
* no need to skip content before first section headerIngo Schwarze2014-07-071-2/+1
|
* implement .dei and .amiIngo Schwarze2014-07-071-2/+1
|
* Clean up messages related to plain text and to escape sequences.Ingo Schwarze2014-07-061-6/+7
| | | | | * Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
* Cleanup with respect to bad macro arguments.Ingo Schwarze2014-07-051-7/+6
| | | | | | | | * Fix .Sm with invalid arg: move arg out and toggle mode. * Promote "unknown standard" from WARNING to ERROR, it loses information. * Delete MANDOCERR_BADWIDTH, it would only indicate a mandoc(1) bug. * Do not report MANDOCERR_BL_LATETYPE when there is no type at all. * Mention macro names, arguments and fallbacks.
* Cleanup regarding -offset and -width:Ingo Schwarze2014-07-051-1/+2
| | | | | | | * Bugfix: Last one wins, not first one. * Fix .Bl -width without argument: it means 0n, so do not ignore it. * Report macro names, argument names and fallbacks in related messages. * Simplify: Garbage collect auxiliary variables in pre_bd() and pre_bl().
* Clean up messages regarding excess arguments:Ingo Schwarze2014-07-041-4/+5
| | | | | | * Downgrade ".Bf -emphasis Em" from FATAL to WARNING. * Mention the macros, the arguments, and the fallbacks. * Hierarchical naming.
* Clean up messages related to missing arguments.Ingo Schwarze2014-07-041-8/+8
| | | | | | | | | * Do not warn about empty -column cells, they seem valid to me. * Downgrade empty item and missing -std from ERROR to WARNING. * Hierarchical naming. * Descriptive, not imperative style. * Mention macro names, argument names, and fallbacks. * Garbage collect some unreachable code in post_it().
* Fix formatting of empty .Bl -inset item heads.Ingo Schwarze2014-07-031-2/+2
| | | | | | Downgrade empty item heads from ERROR to WARNING. Show the list type in the error message. Choose better variable names for nodes in post_it().
* MANDOCERR_NOARGS reported three completely unrelated classes of problems.Ingo Schwarze2014-07-031-1/+3
| | | | Split the roff(7) parts out of it and report the request names for these cases.
* Disentangle the MANDOCERR_CHILD message, which reported threeIngo Schwarze2014-07-021-2/+4
| | | | | completely different things, into three distinct messages. Also mention the macro names we are talking about.
* Clean up warnings related to macros and nesting.Ingo Schwarze2014-07-021-3/+3
| | | | | | | * Hierarchical naming of enum mandocerr items. * Improve the wording to make it comprehensible. * Mention the offending macro. * Garbage collect one chunk of ancient, long unreachable code.
* Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,Ingo Schwarze2014-07-021-2/+2
| | | | | since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
* Clean up the warnings related to document structure.Ingo Schwarze2014-07-011-11/+11
| | | | | | | | | * Hierarchical naming of the related enum mandocerr items. * Mention the offending macro, section title, or string. While here, improve some wordings: * Descriptive instead of imperative style. * Uniform style for "missing" and "skipping". * Where applicable, mention the fallback used.
* garbage collect two unused enum mandocerr itemsIngo Schwarze2014-06-301-5/+1
| | | | and fix a couple of comments while here
* Improve messages related to the roff(7) .so request.Ingo Schwarze2014-06-251-2/+7
| | | | | | | | | | | | | In all these messages, show the filename argument that was passed to the .so request. In case of failure, show an additional message reporting the file and the line number where the failing request was found. The existing message reporting the reason for the failure - for example, "Permission denied" - is left in place, unchanged. Inspired by a question asked by Nick@ after he saw the confusing old messages that used to be emitted in this area.
* Reduce the verbosity of error messages caused by open(2) failures.Ingo Schwarze2014-06-211-2/+2
| | | | Suggested by and ok jmc@.
* As suggested by jmc@, only include line and column numbers into messagesIngo Schwarze2014-06-201-3/+4
| | | | | | | | | | | | | | when they are meaningful, to avoid confusing stuff like this: $ mandoc /dev/null mandoc: /dev/null:0:1: FATAL: not a manual Instead, just say: mandoc: /dev/null: FATAL: not a manual Another example this applies to is documents having a prologue, but lacking a body. Do not throw a FATAL error for these; instead, issue a WARNING and show the empty document, in the man(7) case with the same amount of blank lines as groff does. Also downgrade mdoc(7) documents having content before the first .Sh from FATAL to WARNING.
* Start systematic improvements of error reporting.Ingo Schwarze2014-06-201-2/+2
| | | | | | | | | | | So far, this covers all WARNINGs related to the prologue. 1) hierarchical naming of MANDOCERR_* constants 2) mention the macro name in messages where that adds clarity 3) add one missing MANDOCERR_DATE_MISSING msg 4) fix the wording of one message related to the man(7) prologue Started on the plane back from Ottawa.
* in debug messages, truncating strings of excessive lengths is actuallyIngo Schwarze2014-04-201-2/+2
| | | | | a good thing, so cast the return value from sprintf to (void); this concludes the mandoc sprintf audit
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-50/+49
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* The files mandoc.c and mandoc.h contained both specialised low-levelIngo Schwarze2014-03-231-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.
* Without the MPARSE_SO option, if the file contains nothing but aIngo Schwarze2014-03-191-3/+20
| | | | | | single .so request, do not read the file pointed to, but instead let mparse_result() provide the file name pointed to as a return value. To be used by makewhatis(8) in the future.
* Generalize the mparse_alloc() and roff_alloc() functions by givingIngo Schwarze2014-03-191-19/+17
| | | | | | | | them an "options" argument, replacing the existing "inttype" and "quick" arguments, preparing for a future MPARSE_SO option. Store this argument in struct mparse and struct roff, replacing the existing "inttype", "parsetype", and "quick" members. No functional change except one tiny cosmetic fix in roff_TH().
* Another 25% speedup for mandocdb(8) -Q mode, found with gprof(1).Ingo Schwarze2014-01-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | For /usr/share/man, we only need 56% of the time of makewhatis(8) now. In groff, user-defined macros clashing with mdoc(7) or man(7) standard macros are cleared when parsing the .Dd or .TH macro, respectively. Of course, we continue doing that in standard mode to assure full groff bug compatibility. However, in -Q mode, full groff bug compatibility makes no sense when it's unreasonably expensive, so skip this step in -Q mode. Real-world manuals hardly ever redefine standard macros, that's terrible style, and if they do, it's pointless to do so before .Dd or .TH because it has no effect. Even if someone does, it's extremely unlikely to break mandocdb(8) -Q parsing because we abort the parse sequence after the NAME section, anyway. So if you manually redefine .Sh, .Nm, .Nd, or .SH in a way that doesn't work at all and rely on .Dd or .TH to fix it up for you, your broken manual will no longer get a perfect apropos(1) entry until you re-run mandocdb(8) without -Q. It think that consequence is acceptable in order to get a 25% speedup for everyone else.
* Joerg Sonnenberger contributed copyrightable amounts of text toIngo Schwarze2014-01-061-1/+2
| | | | | | some files. To make it clear that he also put his contributions under the ISC license, with his explicit permission, add his Copyright notice to the relevant files. No code change.
* Add an option -Q (quick) to mandocdb(8)Ingo Schwarze2014-01-051-9/+11
| | | | | | | | | | | | | | | for accelerated generation of reduced-size databases. Implement this by allowing the parsers to optionally abort the parse sequence after the NAME section. While here, garbage collect the unused void *arg attribute of struct mparse and mparse_alloc() and fix some errors in mandoc(3). This reduces the processing time of mandocdb(8) on /usr/share/man by a factor of 2 and the database size by a factor of 4. However, it still takes 5 times the time and 6 times the space of makewhatis(8), so more work is clearly needed.
* Since the functions in read.c are part of the mandoc(3) library,Ingo Schwarze2014-01-021-17/+41
| | | | | | do not print to stderr. Instead, properly use the mmsg callback. Issue noticed by Abhinav Upadhyay <er dot abhinav dot upadhyay at gmail dot com> and Thomas Klausner <wiz at NetBSD>.
* One of the WARNING messages has to use the word "section" twice in twoIngo Schwarze2013-09-161-2/+2
| | | | | | | | | | different meanings, that cannot be helped. But we can make this less confusing by stating that the second instance refers to stuff like (2), (3), and (9), and by adding the sections header the first instance refers to, for example ERRORS or RETURN VALUES. Source for confusion noticed by Jan Stary <hans at stare dot cz>, better wording suggested by jmc@, tweaked by me.
* Rudimentary implementation of the .it request (input line trap).Ingo Schwarze2013-07-131-1/+2
| | | | | | | | | | As with any low-level roff request involving subtle interactions with macro internals, this implementation is not exact, but it does handle the simplest cases. This request occurs in man(7) code generated from DocBook, for example mysql(1) and yasm_arch(7). Thanks to brad@ for reporting the issue back in January 2011.
* Sync to OpenBSD, no functional change:Ingo Schwarze2013-06-021-7/+4
| | | | | | * 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.
* 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.
* 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.
* Do not crash on stray .Ta macros found outside column lists.Ingo Schwarze2012-11-191-2/+3
| | | | Problem reported by jmc@, thanks.
* In groff, trying to redefine standard man(7) macros before .TH has no effect;Ingo Schwarze2012-11-191-2/+2
| | | | | | | | | | | | | | 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.
* Warn about unknown volume or arch in Dt macro arguments;Ingo Schwarze2012-11-161-1/+2
| | | | patch written by Nicolas Joly <njoly at pasteur dot fr>.