version 1.40, 2019/04/12 21:37:07 |
version 1.45, 2019/04/16 14:58:19 |
|
|
int nline; /* Line number of next token. */ |
int nline; /* Line number of next token. */ |
int ncol; /* Column number of next token. */ |
int ncol; /* Column number of next token. */ |
int del; /* Levels of nested nodes being deleted. */ |
int del; /* Levels of nested nodes being deleted. */ |
|
int nofill; /* Levels of open no-fill displays. */ |
int flags; |
int flags; |
#define PFLAG_WARN (1 << 0) /* Print warning messages. */ |
#define PFLAG_WARN (1 << 0) /* Print warning messages. */ |
#define PFLAG_SPC (1 << 1) /* Whitespace before the next element. */ |
#define PFLAG_SPC (1 << 1) /* Whitespace before the next element. */ |
|
|
|
|
static const struct alias aliases[] = { |
static const struct alias aliases[] = { |
{ "acronym", NODE_IGNORE }, |
{ "acronym", NODE_IGNORE }, |
|
{ "affiliation", NODE_IGNORE }, |
{ "anchor", NODE_DELETE }, |
{ "anchor", NODE_DELETE }, |
|
{ "application", NODE_COMMAND }, |
{ "article", NODE_SECTION }, |
{ "article", NODE_SECTION }, |
|
{ "articleinfo", NODE_BOOKINFO }, |
{ "book", NODE_SECTION }, |
{ "book", NODE_SECTION }, |
{ "chapter", NODE_SECTION }, |
{ "chapter", NODE_SECTION }, |
|
{ "caption", NODE_IGNORE }, |
{ "code", NODE_LITERAL }, |
{ "code", NODE_LITERAL }, |
{ "computeroutput", NODE_LITERAL }, |
{ "computeroutput", NODE_LITERAL }, |
{ "!doctype", NODE_DOCTYPE }, |
{ "!doctype", NODE_DOCTYPE }, |
|
{ "figure", NODE_IGNORE }, |
{ "firstname", NODE_PERSONNAME }, |
{ "firstname", NODE_PERSONNAME }, |
{ "glossary", NODE_VARIABLELIST }, |
{ "glossary", NODE_VARIABLELIST }, |
{ "glossdef", NODE_IGNORE }, |
{ "glossdef", NODE_IGNORE }, |
{ "glossdiv", NODE_IGNORE }, |
{ "glossdiv", NODE_IGNORE }, |
{ "glossentry", NODE_VARLISTENTRY }, |
{ "glossentry", NODE_VARLISTENTRY }, |
{ "glosslist", NODE_VARIABLELIST }, |
{ "glosslist", NODE_VARIABLELIST }, |
|
{ "holder", NODE_IGNORE }, |
|
{ "imageobject", NODE_IGNORE }, |
{ "indexterm", NODE_DELETE }, |
{ "indexterm", NODE_DELETE }, |
{ "informaltable", NODE_TABLE }, |
{ "informaltable", NODE_TABLE }, |
|
{ "keycap", NODE_KEYSYM }, |
|
{ "keycode", NODE_IGNORE }, |
|
{ "mediaobject", NODE_BLOCKQUOTE }, |
|
{ "orgname", NODE_IGNORE }, |
{ "othercredit", NODE_AUTHOR }, |
{ "othercredit", NODE_AUTHOR }, |
{ "othername", NODE_PERSONNAME }, |
{ "othername", NODE_PERSONNAME }, |
{ "part", NODE_SECTION }, |
{ "part", NODE_SECTION }, |
{ "phrase", NODE_IGNORE }, |
{ "phrase", NODE_IGNORE }, |
{ "primary", NODE_DELETE }, |
{ "primary", NODE_DELETE }, |
|
{ "property", NODE_PARAMETER }, |
{ "refsect1", NODE_SECTION }, |
{ "refsect1", NODE_SECTION }, |
{ "refsect2", NODE_SECTION }, |
{ "refsect2", NODE_SECTION }, |
{ "refsect3", NODE_SECTION }, |
{ "refsect3", NODE_SECTION }, |
{ "refsection", NODE_SECTION }, |
{ "refsection", NODE_SECTION }, |
|
{ "releaseinfo", NODE_IGNORE }, |
|
{ "returnvalue", NODE_IGNORE }, |
{ "secondary", NODE_DELETE }, |
{ "secondary", NODE_DELETE }, |
{ "sect1", NODE_SECTION }, |
{ "sect1", NODE_SECTION }, |
{ "sect2", NODE_SECTION }, |
{ "sect2", NODE_SECTION }, |
Line 106 static const struct alias aliases[] = { |
|
Line 121 static const struct alias aliases[] = { |
|
{ "trademark", NODE_IGNORE }, |
{ "trademark", NODE_IGNORE }, |
{ "ulink", NODE_LINK }, |
{ "ulink", NODE_LINK }, |
{ "userinput", NODE_LITERAL }, |
{ "userinput", NODE_LITERAL }, |
|
{ "year", NODE_IGNORE }, |
{ NULL, NODE_IGNORE } |
{ NULL, NODE_IGNORE } |
}; |
}; |
|
|
Line 269 xml_text(struct parse *p, const char *word, int sz) |
|
Line 285 xml_text(struct parse *p, const char *word, int sz) |
|
case CLASS_VOID: |
case CLASS_VOID: |
case CLASS_TEXT: |
case CLASS_TEXT: |
case CLASS_BLOCK: |
case CLASS_BLOCK: |
|
case CLASS_NOFILL: |
np = NULL; |
np = NULL; |
break; |
break; |
case CLASS_TRANS: |
case CLASS_TRANS: |
Line 510 xml_elem_start(struct parse *p, const char *name) |
|
Line 527 xml_elem_start(struct parse *p, const char *name) |
|
case CLASS_ENCL: |
case CLASS_ENCL: |
n->spc = (p->flags & PFLAG_SPC) != 0; |
n->spc = (p->flags & PFLAG_SPC) != 0; |
break; |
break; |
|
case CLASS_NOFILL: |
|
p->nofill++; |
|
/* FALLTHROUGH */ |
default: |
default: |
n->spc = 1; |
n->spc = 1; |
break; |
break; |
Line 634 xml_elem_end(struct parse *p, const char *name) |
|
Line 654 xml_elem_end(struct parse *p, const char *name) |
|
warn_msg(p, "element not open: </%s>", name); |
warn_msg(p, "element not open: </%s>", name); |
break; |
break; |
} |
} |
|
if (pnode_class(node) == CLASS_NOFILL) |
|
p->nofill--; |
|
|
/* |
/* |
* Refrain from actually closing the document element. |
* Refrain from actually closing the document element. |
Line 741 parse_string(struct parse *p, char *b, size_t rlen, |
|
Line 763 parse_string(struct parse *p, char *b, size_t rlen, |
|
enum pstate *pstate, int refill) |
enum pstate *pstate, int refill) |
{ |
{ |
char *cp; |
char *cp; |
|
size_t pws; /* Parse offset including whitespace. */ |
size_t poff; /* Parse offset in b[]. */ |
size_t poff; /* Parse offset in b[]. */ |
size_t pend; /* Offset of the end of the current word. */ |
size_t pend; /* Offset of the end of the current word. */ |
int elem_end; |
int elem_end; |
|
|
pend = 0; |
pend = pws = 0; |
for (;;) { |
for (;;) { |
|
|
/* Proceed to the next token, skipping whitespace. */ |
/* Proceed to the next token, skipping whitespace. */ |
Line 758 parse_string(struct parse *p, char *b, size_t rlen, |
|
Line 781 parse_string(struct parse *p, char *b, size_t rlen, |
|
break; |
break; |
if (isspace((unsigned char)b[pend])) { |
if (isspace((unsigned char)b[pend])) { |
p->flags |= PFLAG_SPC; |
p->flags |= PFLAG_SPC; |
|
if (b[pend] == '\n') |
|
pws = pend + 1; |
increment(p, b, &pend, refill); |
increment(p, b, &pend, refill); |
continue; |
continue; |
} |
} |
Line 919 parse_string(struct parse *p, char *b, size_t rlen, |
|
Line 944 parse_string(struct parse *p, char *b, size_t rlen, |
|
advance(p, b, rlen, &pend, |
advance(p, b, rlen, &pend, |
p->ncur == NODE_DOCTYPE ? "<&]\n" : "<&\n", |
p->ncur == NODE_DOCTYPE ? "<&]\n" : "<&\n", |
refill); |
refill); |
|
if (p->nofill) |
|
poff = pws; |
xml_text(p, b + poff, pend - poff); |
xml_text(p, b + poff, pend - poff); |
if (b[pend] == '\n') |
if (b[pend] == '\n') |
pnode_closetext(p, 0); |
pnode_closetext(p, 0); |
} |
} |
|
pws = pend; |
} |
} |
return poff; |
return poff; |
} |
} |