* mdocml: Distinguish OPEN, MIDDLE and CLOSE delimiters (using an enum).
@ 2010-05-15 8:54 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-05-15 8:54 UTC (permalink / raw)
To: source
Log Message:
-----------
Distinguish OPEN, MIDDLE and CLOSE delimiters (using an enum).
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@
Modified Files:
--------------
mdocml:
libmdoc.h
mdoc_argv.c
mdoc_macro.c
mdoc_strings.c
Revision Data
-------------
Index: mdoc_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_macro.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.66 -r1.67
--- mdoc_macro.c
+++ mdoc_macro.c
@@ -640,7 +640,7 @@ append_delims(struct mdoc *m, int line,
else if (ARGS_EOLN == ac)
break;
- assert(mdoc_isdelim(p));
+ assert(DELIM_NONE != mdoc_isdelim(p));
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
@@ -750,10 +750,11 @@ blk_exp_close(MACRO_PROT_ARGS)
static int
in_line(MACRO_PROT_ARGS)
{
- int la, lastpunct, cnt, d, nc, nl;
+ int la, lastpunct, cnt, nc, nl;
enum margverr av;
enum mdoct ntok;
enum margserr ac;
+ enum mdelim d;
struct mdoc_arg *arg;
char *p;
@@ -846,9 +847,9 @@ in_line(MACRO_PROT_ARGS)
* the word.
*/
- d = ARGS_QWORD == ac ? 0 : mdoc_isdelim(p);
+ d = ARGS_QWORD == ac ? DELIM_NONE : mdoc_isdelim(p);
- if (ARGS_QWORD != ac && d) {
+ if (ARGS_QWORD != ac && DELIM_NONE != d) {
if (0 == lastpunct && ! rew_elem(m, tok))
return(0);
lastpunct = 1;
@@ -858,7 +859,7 @@ in_line(MACRO_PROT_ARGS)
lastpunct = 0;
}
- if ( ! d)
+ if (DELIM_NONE == d)
cnt++;
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
@@ -1000,7 +1001,7 @@ blk_full(MACRO_PROT_ARGS)
ARGS_PHRASE != ac &&
ARGS_PPHRASE != ac &&
ARGS_QWORD != ac &&
- 1 == mdoc_isdelim(p)) {
+ DELIM_OPEN == mdoc_isdelim(p)) {
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
continue;
@@ -1133,7 +1134,7 @@ blk_part_imp(MACRO_PROT_ARGS)
break;
if (NULL == body && ARGS_QWORD != ac &&
- 1 == mdoc_isdelim(p)) {
+ DELIM_OPEN == mdoc_isdelim(p)) {
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
continue;
@@ -1252,7 +1253,7 @@ blk_part_exp(MACRO_PROT_ARGS)
/* Flush out leading punctuation. */
if (NULL == head && ARGS_QWORD != ac &&
- 1 == mdoc_isdelim(p)) {
+ DELIM_OPEN == mdoc_isdelim(p)) {
assert(NULL == body);
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
@@ -1397,7 +1398,7 @@ in_line_argn(MACRO_PROT_ARGS)
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) &&
ARGS_QWORD != ac &&
- 0 == j && 1 == mdoc_isdelim(p)) {
+ 0 == j && DELIM_OPEN == mdoc_isdelim(p)) {
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
continue;
@@ -1425,7 +1426,8 @@ in_line_argn(MACRO_PROT_ARGS)
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) &&
ARGS_QWORD != ac &&
- ! flushed && mdoc_isdelim(p)) {
+ ! flushed &&
+ DELIM_NONE != mdoc_isdelim(p)) {
if ( ! rew_elem(m, tok))
return(0);
flushed = 1;
Index: libmdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmdoc.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.45 -r1.46
--- libmdoc.h
+++ libmdoc.h
@@ -131,6 +131,13 @@ enum margverr {
ARGV_WORD
};
+enum mdelim {
+ DELIM_NONE = 0,
+ DELIM_OPEN,
+ DELIM_MIDDLE,
+ DELIM_CLOSE
+};
+
extern const struct mdoc_macro *const mdoc_macros;
__BEGIN_DECLS
@@ -161,8 +168,8 @@ int mdoc_body_alloc(struct mdoc *, in
void mdoc_node_delete(struct mdoc *, struct mdoc_node *);
void mdoc_hash_init(void);
enum mdoct mdoc_hash_find(const char *);
-int mdoc_iscdelim(char);
-int mdoc_isdelim(const char *);
+enum mdelim mdoc_iscdelim(char);
+enum mdelim mdoc_isdelim(const char *);
size_t mdoc_isescape(const char *);
enum mdoc_sec mdoc_str2sec(const char *);
time_t mdoc_atotime(const char *);
Index: mdoc_argv.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_argv.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -Lmdoc_argv.c -Lmdoc_argv.c -u -p -r1.47 -r1.48
--- mdoc_argv.c
+++ mdoc_argv.c
@@ -421,9 +421,10 @@ args(struct mdoc *m, int line, int *pos,
* we ONLY care about closing delimiters.
*/
- if ((fl & ARGS_DELIM) && mdoc_iscdelim(buf[*pos]) > 1) {
+ if ((fl & ARGS_DELIM) && DELIM_CLOSE == mdoc_iscdelim(buf[*pos])) {
for (i = *pos; buf[i]; ) {
- if (mdoc_iscdelim(buf[i]) < 2)
+ enum mdelim d = mdoc_iscdelim(buf[i]);
+ if (DELIM_NONE == d || DELIM_OPEN == d)
break;
i++;
if ('\0' == buf[i] || ' ' != buf[i])
Index: mdoc_strings.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_strings.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lmdoc_strings.c -Lmdoc_strings.c -u -p -r1.19 -r1.20
--- mdoc_strings.c
+++ mdoc_strings.c
@@ -57,17 +57,17 @@ static const char * const secnames[SEC__
* FIXME: this is repeated in print_text() (html.c) and term_word()
* (term.c).
*/
-int
+enum mdelim
mdoc_iscdelim(char p)
{
switch (p) {
- case('|'):
- /* FALLTHROUGH */
case('('):
/* FALLTHROUGH */
case('['):
- return(1);
+ return(DELIM_OPEN);
+ case('|'):
+ return(DELIM_MIDDLE);
case('.'):
/* FALLTHROUGH */
case(','):
@@ -83,16 +83,16 @@ mdoc_iscdelim(char p)
case(')'):
/* FALLTHROUGH */
case(']'):
- return(2);
+ return(DELIM_CLOSE);
default:
break;
}
- return(0);
+ return(DELIM_NONE);
}
-int
+enum mdelim
mdoc_isdelim(const char *p)
{
@@ -106,7 +106,7 @@ mdoc_isdelim(const char *p)
* is treated in exactly the same way as the vertical bar. This
* is the only function that checks for this.
*/
- return(0 == strcmp(p, "\\*(Ba"));
+ return(strcmp(p, "\\*(Ba") ? DELIM_NONE : DELIM_MIDDLE);
}
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-05-15 8:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-15 8:54 mdocml: Distinguish OPEN, MIDDLE and CLOSE delimiters (using an enum) kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).