From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id eba9dea8 for ; Sun, 19 Aug 2018 12:46:44 -0500 (EST) Date: Sun, 19 Aug 2018 12:46:44 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: Mostly complete implementation of the 'c' (character available) X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-Id: Log Message: ----------- Mostly complete implementation of the 'c' (character available) roff conditional, except that the .char request still isn't supported and that behaviour differs from groff in many edge cases. But at least valid character names and numbers are now distinguished from invalid ones. This also fixes the bug that parsing of the 'c' conditional was incomplete, which resulted in leaking the tested character to the input parser at the beginning of the body when the condition was inverted. Modified Files: -------------- mandoc: TODO roff.7 roff.c Revision Data ------------- Index: roff.7 =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.7,v retrieving revision 1.100 retrieving revision 1.101 diff -Lroff.7 -Lroff.7 -u -p -r1.100 -r1.101 --- roff.7 +++ roff.7 @@ -1005,13 +1005,13 @@ is or .Sq o .Pq odd page , -it evaluates to true. +it evaluates to true, and the +.Ar body +starts with the next character. .It If the first character of .Ar condition is -.Sq c -.Pq character available , .Sq e .Pq even page , .Sq t @@ -1019,7 +1019,20 @@ is or .Sq v .Pq vroff mode , -it evaluates to false. +it evaluates to false, and the +.Ar body +starts with the next character. +.It +If the first character of +.Ar condition +is +.Sq c +.Pq character available , +it evaluates to true if the following character is an ASCII character +or a valid character escape sequence, or to false otherwise. +The +.Ar body +starts with the character following that next character. .It If the first character of .Ar condition Index: TODO =================================================================== RCS file: /home/cvs/mandoc/mandoc/TODO,v retrieving revision 1.266 retrieving revision 1.267 diff -LTODO -LTODO -u -p -r1.266 -r1.267 --- TODO +++ TODO @@ -181,9 +181,6 @@ are mere guesses, and some may be wrong. pali dot rohar at gmail dot com 16 Jul 2018 13:03:35 +0200 loc * exist *** algo *** size ** imp * -- support .ds requests inside tbl(7) code, - see tbl(1) for an example - - support mdoc(7) and man(7) macros inside tbl(7) code; probably requires the parser reorg and letting tbl(7) use roff_node such that macro sets can mix; @@ -319,9 +316,6 @@ are mere guesses, and some may be wrong. ************************************************************************ * formatting issues: ugly output ************************************************************************ - -- .UR can nest inside .TP, - see roff(7) for examples - revisit empty in-line macros look at the difference between "Em x Em ." and "Sq x Em ." Index: roff.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.c,v retrieving revision 1.335 retrieving revision 1.336 diff -Lroff.c -Lroff.c -u -p -r1.335 -r1.336 --- roff.c +++ roff.c @@ -2168,9 +2168,10 @@ out: static int roff_evalcond(struct roff *r, int ln, char *v, int *pos) { - char *cp, *name; - size_t sz; - int deftype, number, savepos, istrue, wanttrue; + const char *start, *end; + char *cp, *name; + size_t sz; + int deftype, len, number, savepos, istrue, wanttrue; if ('!' == v[*pos]) { wanttrue = 0; @@ -2185,12 +2186,50 @@ roff_evalcond(struct roff *r, int ln, ch case 'o': (*pos)++; return wanttrue; - case 'c': case 'e': case 't': case 'v': (*pos)++; return !wanttrue; + case 'c': + do { + (*pos)++; + } while (v[*pos] == ' '); + + /* + * Quirk for groff compatibility: + * The horizontal tab is neither available nor unavailable. + */ + + if (v[*pos] == '\t') { + (*pos)++; + return 0; + } + + /* Printable ASCII characters are available. */ + + if (v[*pos] != '\\') { + (*pos)++; + return wanttrue; + } + + end = v + ++*pos; + switch (mandoc_escape(&end, &start, &len)) { + case ESCAPE_SPECIAL: + istrue = mchars_spec2cp(start, len) != -1; + break; + case ESCAPE_UNICODE: + istrue = 1; + break; + case ESCAPE_NUMBERED: + istrue = mchars_num2char(start, len) != -1; + break; + default: + istrue = !wanttrue; + break; + } + *pos = end - v; + return istrue == wanttrue; case 'd': case 'r': cp = v + *pos + 1; -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv