[BACK]Return to parse.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / docbook2mdoc

Diff for /docbook2mdoc/parse.c between version 1.39 and 1.47

version 1.39, 2019/04/12 16:40:53 version 1.47, 2019/04/20 04:15:06
Line 56  struct parse {
Line 56  struct parse {
         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. */
Line 70  struct alias {
Line 71  struct alias {
   
 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 },
         { "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 },
           { "sect3",              NODE_SECTION },
           { "sect4",              NODE_SECTION },
         { "sgmltag",            NODE_MARKUP },          { "sgmltag",            NODE_MARKUP },
         { "simpara",            NODE_PARA },          { "simpara",            NODE_PARA },
         { "structfield",        NODE_PARAMETER },          { "structfield",        NODE_PARAMETER },
Line 105  static const struct alias aliases[] = {
Line 123  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 268  xml_text(struct parse *p, const char *word, int sz)
Line 287  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 509  xml_elem_start(struct parse *p, const char *name)
Line 529  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 530  xml_attrkey(struct parse *p, const char *name)
Line 553  xml_attrkey(struct parse *p, const char *name)
         const char      *value;          const char      *value;
         enum attrkey     key;          enum attrkey     key;
   
         if (p->del > 0 || p->ncur == NODE_IGNORE || *name == '\0')          if (p->del > 0 || p->ncur >= NODE_UNKNOWN || *name == '\0')
                 return;                  return;
   
         if ((p->ncur == NODE_DOCTYPE || p->ncur == NODE_ENTITY) &&          if ((p->ncur == NODE_DOCTYPE || p->ncur == NODE_ENTITY) &&
Line 567  xml_attrval(struct parse *p, const char *name)
Line 590  xml_attrval(struct parse *p, const char *name)
 {  {
         struct pattr    *a;          struct pattr    *a;
   
         if (p->del > 0 || p->ncur == NODE_IGNORE ||          if (p->del > 0 || p->ncur >= NODE_UNKNOWN ||
             (p->flags & PFLAG_ATTR) == 0)              (p->flags & PFLAG_ATTR) == 0)
                 return;                  return;
         if ((a = TAILQ_LAST(&p->cur->attrq, pattrq)) == NULL)          if ((a = TAILQ_LAST(&p->cur->attrq, pattrq)) == NULL)
Line 633  xml_elem_end(struct parse *p, const char *name)
Line 656  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 740  parse_string(struct parse *p, char *b, size_t rlen,
Line 765  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 757  parse_string(struct parse *p, char *b, size_t rlen,
Line 783  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 918  parse_string(struct parse *p, char *b, size_t rlen,
Line 946  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;
 }  }

Legend:
Removed from v.1.39  
changed lines
  Added in v.1.47

CVSweb