summaryrefslogtreecommitdiffstats
path: root/read.c
Commit message (Collapse)AuthorAgeFilesLines
* Since the functions in read.c are part of the mandoc(3) library,Ingo Schwarze2014-01-021-16/+40
| | | | | | 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-1/+1
| | | | | | | | | | 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-0/+1
| | | | | | | | | | 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-6/+3
| | | | | | * 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-18/+17
| | | | | | | 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-8/+23
| | | | | | | | 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-1/+2
| | | | Problem reported by jmc@, thanks.
* In groff, trying to redefine standard man(7) macros before .TH has no effect;Ingo Schwarze2012-11-191-1/+1
| | | | | | | | | | | | | | 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-0/+1
| | | | patch written by Nicolas Joly <njoly at pasteur dot fr>.
* Fix handling of paragraph macros inside lists:Ingo Schwarze2012-07-181-0/+1
| | | | | | | * When they are trailing the last item, move them outside the list. * When they are trailing any other none-compact item, drop them. OpenBSD rev. mdoc_validate.c 1.107, mdoc.c 1.91
* The post_nm() validation function crashed when the first .Nm child nodeIngo Schwarze2012-07-121-1/+1
| | | | | | | | | | was a non-text node. Fix this by rewriting post_nm() to always set the meta name to UNKNOWN when the name is missing or unusable. While here, make MANDOCERR_NONAME an ERROR, as it usually renders the page content unintelligible. Bug reported by Maxim <Belooussov at gmail dot com>, thanks. OpenBSD rev. 1.105
* Support -Ios='OpenBSD 5.1' to override uname(3) as the source of theIngo Schwarze2012-05-271-3/+8
| | | | | | | | | | default value for the mdoc(7) .Os macro. Needed for man.cgi on the OpenBSD website. Problem with man.cgi first noticed by deraadt@; beck@ and deraadt@ agree with the way to solve the issue. "Please check them in and I'll look into them later!" kristaps@
* Add mparse_readmem, which allows application to run the parser directlyJoerg Sonnenberger2012-02-161-41/+53
| | | | from memory, e.g. after de-compressing a document.
* Don't silently skip non-ASCII characters, but replace them with ``?''.Joerg Sonnenberger2012-02-051-4/+7
| | | | This is less likely to break the syntax of macros.
* When the HEAD scope of .TP is broken by another block macro,Ingo Schwarze2011-11-071-1/+0
| | | | | | | | do not abort with a FATAL error, but report a report a WARNING, remove the broken .TP from the syntax tree, and prod on. Reported repeatedly by ports people, at least by brad@ and jeremy@. Also fixes rendition(4) in Xenocara. ok kristaps@
* Critical fix in the new -Tman lookaside buffer code. Gah..VERSION.1.12.0Kristaps Dzonsons2011-10-081-1/+2
|
* If -Tman is specified and input is -man, echo the preprocessed (`so'Kristaps Dzonsons2011-10-061-0/+49
| | | | | | | | | | | | | | replaced by file) input. This replaces earlier behaviour of doing nothing, which I found unexpected (mandoc should always output). This requires a buffer in read.c that saves the input lines before being parsed, with a special hook if `so' is invoked. This buffer is just flushed to output if -mman is the input. While mucking around doing this, I also alpha-ordered the mandoc.h functions. Ok schwarze@, with no screaming when the polished patch was published.
* Add support for tdefine and ndefine. Consolidate some error messages. AddKristaps Dzonsons2011-07-231-1/+0
| | | | somem more version notes (getting there). Have the equation nanme be captured.
* Add support for `gsize' eqn token (introduced in second-edition troff).Kristaps Dzonsons2011-07-221-1/+0
|
* Complete eqn.7 parsing. Features all productions from the original 1975Kristaps Dzonsons2011-07-211-0/+3
| | | | | | | | CACM paper in an LR(1) parse (1 -> eqn_rewind()). Right now the code is a little jungly, but will clear up as I consolidate parse components. The AST structure will also be cleaned up, as right now it's pretty ad hoc (this won't change the parse itself). I added the mandoc_strndup() function will here.
* Support nested `{, }' subexpressions in eqn. Document in code.Kristaps Dzonsons2011-07-211-0/+2
|
* Forgot to add these bits to the last commit.Kristaps Dzonsons2011-07-181-0/+1
|
* Make `struct roff' be passed into libmdoc and libman upon creation.Kristaps Dzonsons2011-07-181-8/+5
| | | | | This is required for supporting in-line equations. While here, push registers properly into roff and add an set/get/mod interface.
* Provide implementations of `define', `set', and `unset'.Kristaps Dzonsons2011-07-171-0/+3
| | | | | | Tie them into the stream of data. Document these appropriate, bringing in the grammar as defined by the original eqn manual (Kernighan/Richie).
* Warn if equation `define' key is quoted (groff-ism).Kristaps Dzonsons2011-07-171-0/+3
|
* At least in theory, this patch lets us compile on Windows (which doesKristaps Dzonsons2011-05-261-3/+9
| | | | not have mmap(), from what I can tell).
* No code change: fixing spelling errors. From a patch by uqs@. Thanks!Kristaps Dzonsons2011-04-301-1/+1
|
* Ignore \# lines alongside \". From groff(7):Kristaps Dzonsons2011-04-111-1/+1
| | | | | | \# Everything up to and including the next newline is ignored. This is interpreted in copy mode. This is like \" except that the terminating newline is ignored as well.
* Remove a2roffdeco() and mandoc_special() functions and replace them withKristaps Dzonsons2011-04-091-1/+1
| | | | | | | | | | | | | | | | | | a public (mandoc.h) function mandoc_escape(), which merges the functionality of both prior functions. Reason: code duplication. The a2roffdeco() and mandoc_special() functions were pretty much the same thing and both quite complex. This allows one function to receive improvements in (e.g.) subexpression handling and performance, instead of having to replicate functionality. As such, the mandoc_escape() function already handles a superset of the escapes handled in previous versions and has improvements in performance (using strcspn(), for example) and reliable handling of subexpressions. This code Works For Me, but may need work to catch any regressions. Since the benefits are great (leaner code, simpler API), I'd rather have it in-tree than floating as a patch.
* Add config.h Glue for OpenIndiana (and older OpenSolaris) to build.Kristaps Dzonsons2011-04-041-0/+4
| | | | From a patch by Yuri Pankov, thanks!
* If wlevel in mparse_alloc() is greater than MANDOCLEVEL_FATAL, we'llKristaps Dzonsons2011-04-031-0/+2
| | | | | | throw assertions due to per-file-error not being properly set in mmsg(). This is reasonable behaviour (we shouldn't be able to ignore FATAL after all). Thus, make sure wlevel is sanitised.
* Allow mparse_result() pointers to be NULL.Kristaps Dzonsons2011-04-031-2/+4
|
* Allow a NULL mmsg passed to libmandoc.Kristaps Dzonsons2011-03-311-1/+2
|
* Put mandocerrs and mandoclevels arrays into libmandoc with accessorsKristaps Dzonsons2011-03-281-0/+131
| | | | mparse_strerror() and mparse_strlevel().
* Add a FATAL error for when no manual type was assigned (you can repeatKristaps Dzonsons2011-03-221-7/+2
| | | | this for yourself by having a file consisting only of comments).
* Step 2: blow away roff.h, as all of its functions have been moved intoKristaps Dzonsons2011-03-221-1/+0
| | | | libmandoc.h and there's nothing left.
* Let read.c worry about the currently-open file instead of having thisKristaps Dzonsons2011-03-201-12/+1
| | | | | | information duplicated in main.c. For the time being, remove evt_close and evt_open, as the only known mparse interface (main.c) doesn't need them.
* Consolidate messages. Have all parse-time messages (in libmdoc,Kristaps Dzonsons2011-03-201-26/+61
| | | | | | | | | libroff, etc., etc.) route into mandoc_msg() and mandoc_vmsg(), for the time being in libmandoc.h. This requires struct mparse to be passed into the allocation routines instead of mandocmsg and a void pointer. Then, move some of the functionality of the old mmsg() into read.c's mparse_mmsg() (check against wlevel and setting of file_status) and use main.c's mmsg() as simply a printing tool.
* Change around include ordering for compilation on OpenBSD.Kristaps Dzonsons2011-03-201-1/+1
|
* Split the document parsing sequence out of main.c and into read.c,Kristaps Dzonsons2011-03-201-0/+611
putting the interface into mandoc.h. This effectively makes the function of main.c be command-line handling, invoking the parser, and sending its output to the output handler. The sequence of parsing (pfile(), pdesc(), etc.) has changed very little but for clean-up of some state variables (curp->fd, etc.).