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

Diff for /docbook2mdoc/parse.c between version 1.29 and 1.38

version 1.29, 2019/04/09 15:23:51 version 1.38, 2019/04/12 11:37:09
Line 89  static const struct element elements[] = {
Line 89  static const struct element elements[] = {
         { "code",               NODE_LITERAL },          { "code",               NODE_LITERAL },
         { "colspec",            NODE_COLSPEC },          { "colspec",            NODE_COLSPEC },
         { "command",            NODE_COMMAND },          { "command",            NODE_COMMAND },
           { "computeroutput",     NODE_LITERAL },
         { "constant",           NODE_CONSTANT },          { "constant",           NODE_CONSTANT },
         { "contrib",            NODE_CONTRIB },          { "contrib",            NODE_CONTRIB },
         { "copyright",          NODE_COPYRIGHT },          { "copyright",          NODE_COPYRIGHT },
Line 134  static const struct element elements[] = {
Line 135  static const struct element elements[] = {
         { "literal",            NODE_LITERAL },          { "literal",            NODE_LITERAL },
         { "literallayout",      NODE_LITERALLAYOUT },          { "literallayout",      NODE_LITERALLAYOUT },
         { "manvolnum",          NODE_MANVOLNUM },          { "manvolnum",          NODE_MANVOLNUM },
           { "markup",             NODE_MARKUP },
         { "member",             NODE_MEMBER },          { "member",             NODE_MEMBER },
         { "mml:math",           NODE_MML_MATH },          { "mml:math",           NODE_MML_MATH },
         { "mml:mfenced",        NODE_MML_MFENCED },          { "mml:mfenced",        NODE_MML_MFENCED },
Line 186  static const struct element elements[] = {
Line 188  static const struct element elements[] = {
         { "sect1",              NODE_SECTION },          { "sect1",              NODE_SECTION },
         { "sect2",              NODE_SECTION },          { "sect2",              NODE_SECTION },
         { "section",            NODE_SECTION },          { "section",            NODE_SECTION },
         { "sgmltag",            NODE_SGMLTAG },          { "sgmltag",            NODE_MARKUP },
         { "simpara",            NODE_PARA },          { "simpara",            NODE_PARA },
         { "simplelist",         NODE_SIMPLELIST },          { "simplelist",         NODE_SIMPLELIST },
         { "spanspec",           NODE_SPANSPEC },          { "spanspec",           NODE_SPANSPEC },
Line 322  warn_msg(struct parse *p, const char *fmt, ...)
Line 324  warn_msg(struct parse *p, const char *fmt, ...)
  * Otherwise, create a new one as a child of the current node.   * Otherwise, create a new one as a child of the current node.
  */   */
 static void  static void
 xml_char(struct parse *ps, const char *p, int sz)  xml_text(struct parse *p, const char *word, int sz)
 {  {
         struct pnode    *dat;          struct pnode    *n, *np;
         size_t           newsz;          size_t           oldsz, newsz;
           int              i;
   
         if (ps->del > 0)          assert(sz > 0);
           if (p->del > 0)
                 return;                  return;
   
         if (ps->cur == NULL) {          if ((n = p->cur) == NULL) {
                 error_msg(ps, "discarding text before document: %.*s", sz, p);                  error_msg(p, "discarding text before document: %.*s",
                       sz, word);
                 return;                  return;
         }          }
   
         if (ps->cur->node != NODE_TEXT) {          /* Append to the current text node, if one is open. */
                 if ((dat = calloc(1, sizeof(*dat))) == NULL)  
                         fatal(ps);          if (n->node == NODE_TEXT) {
                 dat->node = NODE_TEXT;                  oldsz = strlen(n->b);
                 dat->spc = (ps->flags & PFLAG_SPC) != 0;                  newsz = oldsz + sz;
                 dat->parent = ps->cur;                  if (oldsz && (p->flags & PFLAG_SPC))
                 TAILQ_INIT(&dat->childq);                          newsz++;
                 TAILQ_INIT(&dat->attrq);                  if ((n->b = realloc(n->b, newsz + 1)) == NULL)
                 TAILQ_INSERT_TAIL(&ps->cur->childq, dat, child);                          fatal(p);
                 ps->cur = dat;                  if (oldsz && (p->flags & PFLAG_SPC))
                           n->b[oldsz++] = ' ';
                   memcpy(n->b + oldsz, word, sz);
                   n->b[newsz] = '\0';
                   p->flags &= ~PFLAG_SPC;
                   return;
         }          }
   
         if (ps->tree->flags & TREE_CLOSED &&          if (p->tree->flags & TREE_CLOSED && n == p->tree->root)
             ps->cur->parent == ps->tree->root)                  warn_msg(p, "text after end of document: %.*s", sz, word);
                 warn_msg(ps, "text after end of document: %.*s", sz, p);  
   
         /* Append to the current text node. */          /* Create a new text node. */
   
         assert(sz >= 0);          if ((n = pnode_alloc(p->cur)) == NULL)
         newsz = ps->cur->bsz + (ps->cur->bsz && (ps->flags & PFLAG_SPC)) + sz;                  fatal(p);
         if ((ps->cur->b = realloc(ps->cur->b, newsz + 1)) == NULL)          n->node = NODE_TEXT;
                 fatal(ps);          n->spc = (p->flags & PFLAG_SPC) != 0;
         if (ps->cur->bsz && (ps->flags & PFLAG_SPC))          p->flags &= ~PFLAG_SPC;
                 ps->cur->b[ps->cur->bsz++] = ' ';  
         memcpy(ps->cur->b + ps->cur->bsz, p, sz);          /*
         ps->cur->b[ps->cur->bsz = newsz] = '\0';           * If this node follows a non-text node without intervening
         ps->cur->real = ps->cur->b;           * whitespace, keep the text in it as short as possible,
         ps->flags &= ~PFLAG_SPC;           * and do not keep it open.
            */
   
           if (n->spc == 0 &&
               (np = TAILQ_PREV(n, pnodeq, child)) != NULL &&
               np->node != NODE_TEXT && np->node != NODE_ESCAPE) {
                   i = 0;
                   while (i < sz && !isspace((unsigned char)word[i]))
                           i++;
                   if ((n->b = strndup(word, i)) == NULL)
                           fatal(p);
                   if (i == sz)
                           return;
                   while (i < sz && isspace((unsigned char)word[i]))
                           i++;
                   if (i == sz) {
                           p->flags |= PFLAG_SPC;
                           return;
                   }
   
                   /* Put any remaining text into a second node. */
   
                   if ((n = pnode_alloc(p->cur)) == NULL)
                           fatal(p);
                   n->node = NODE_TEXT;
                   n->spc = 1;
                   word += i;
                   sz -= i;
           }
           if ((n->b = strndup(word, sz)) == NULL)
                   fatal(p);
   
           /* The new node remains open for later pnode_closetext(). */
   
           p->cur = n;
 }  }
   
 /*  /*
  * Close out the text node and strip trailing whitespace, if one is open.   * Close out the text node and strip trailing whitespace, if one is open.
  */   */
 static void  static void
 pnode_closetext(struct parse *p)  pnode_closetext(struct parse *p, int check_last_word)
 {  {
         struct pnode    *n;          struct pnode    *n;
           char            *cp, *last_word;
   
         if ((n = p->cur) == NULL || n->node != NODE_TEXT)          if ((n = p->cur) == NULL || n->node != NODE_TEXT)
                 return;                  return;
         p->cur = n->parent;          p->cur = n->parent;
         while (n->bsz > 0 && isspace((unsigned char)n->b[n->bsz - 1])) {          for (cp = strchr(n->b, '\0');
                 n->b[--n->bsz] = '\0';              cp > n->b && isspace((unsigned char)cp[-1]);
               *--cp = '\0')
                 p->flags |= PFLAG_SPC;                  p->flags |= PFLAG_SPC;
         }  
           if (p->flags & PFLAG_SPC || !check_last_word)
                   return;
   
           /*
            * Find the beginning of the last word
            * and delete whitespace before it.
            */
   
           while (cp > n->b && !isspace((unsigned char)cp[-1]))
                   cp--;
           if (cp == n->b)
                   return;
   
           last_word = cp;
           while (cp > n->b && isspace((unsigned char)cp[-1]))
               *--cp = '\0';
   
           /* Move the last word into its own node, for use with .Pf. */
   
           if ((n = pnode_alloc(p->cur)) == NULL)
                   fatal(p);
           n->node = NODE_TEXT;
           n->spc = 1;
           if ((n->b = strdup(last_word)) == NULL)
                   fatal(p);
 }  }
   
 static void  static void
 xml_entity(struct parse *p, const char *name)  xml_entity(struct parse *p, const char *name)
 {  {
         const struct entity     *entity;          const struct entity     *entity;
         struct pnode            *dat;          struct pnode            *n;
         const char              *ccp;          const char              *ccp;
         char                    *cp;          char                    *cp;
         enum pstate              pstate;          enum pstate              pstate;
Line 399  xml_entity(struct parse *p, const char *name)
Line 469  xml_entity(struct parse *p, const char *name)
                 return;                  return;
         }          }
   
         pnode_closetext(p);          pnode_closetext(p, 0);
   
         if (p->tree->flags & TREE_CLOSED && p->cur == p->tree->root)          if (p->tree->flags & TREE_CLOSED && p->cur == p->tree->root)
                 warn_msg(p, "entity after end of document: &%s;", name);                  warn_msg(p, "entity after end of document: &%s;", name);
Line 410  xml_entity(struct parse *p, const char *name)
Line 480  xml_entity(struct parse *p, const char *name)
   
         if (entity->roff == NULL) {          if (entity->roff == NULL) {
                 if (p->doctype != NULL) {                  if (p->doctype != NULL) {
                         TAILQ_FOREACH(dat, &p->doctype->childq, child) {                          TAILQ_FOREACH(n, &p->doctype->childq, child) {
                                 if ((ccp = pnode_getattr_raw(dat,                                  if ((ccp = pnode_getattr_raw(n,
                                      ATTRKEY_NAME, NULL)) == NULL ||                                       ATTRKEY_NAME, NULL)) == NULL ||
                                     strcmp(ccp, name) != 0)                                      strcmp(ccp, name) != 0)
                                         continue;                                          continue;
                                 if ((ccp = pnode_getattr_raw(dat,                                  if ((ccp = pnode_getattr_raw(n,
                                     ATTRKEY_SYSTEM, NULL)) != NULL) {                                      ATTRKEY_SYSTEM, NULL)) != NULL) {
                                         parse_file(p, -1, ccp);                                          parse_file(p, -1, ccp);
                                         p->flags &= ~PFLAG_SPC;                                          p->flags &= ~PFLAG_SPC;
                                         return;                                          return;
                                 }                                  }
                                 if ((ccp = pnode_getattr_raw(dat,                                  if ((ccp = pnode_getattr_raw(n,
                                      ATTRKEY_DEFINITION, NULL)) == NULL)                                       ATTRKEY_DEFINITION, NULL)) == NULL)
                                         continue;                                          continue;
                                 if ((cp = strdup(ccp)) == NULL)                                  if ((cp = strdup(ccp)) == NULL)
Line 438  xml_entity(struct parse *p, const char *name)
Line 508  xml_entity(struct parse *p, const char *name)
         }          }
   
         /* Create, append, and close out an entity node. */          /* Create, append, and close out an entity node. */
         if ((dat = calloc(1, sizeof(*dat))) == NULL ||          if ((n = pnode_alloc(p->cur)) == NULL ||
             (dat->b = dat->real = strdup(entity->roff)) == NULL)              (n->b = strdup(entity->roff)) == NULL)
                 fatal(p);                  fatal(p);
         dat->node = NODE_ESCAPE;          n->node = NODE_ESCAPE;
         dat->bsz = strlen(dat->b);          n->spc = (p->flags & PFLAG_SPC) != 0;
         dat->spc = (p->flags & PFLAG_SPC) != 0;  
         dat->parent = p->cur;  
         TAILQ_INIT(&dat->childq);  
         TAILQ_INIT(&dat->attrq);  
         TAILQ_INSERT_TAIL(&p->cur->childq, dat, child);  
         p->flags &= ~PFLAG_SPC;          p->flags &= ~PFLAG_SPC;
 }  }
   
Line 455  xml_entity(struct parse *p, const char *name)
Line 520  xml_entity(struct parse *p, const char *name)
  * Begin an element.   * Begin an element.
  */   */
 static void  static void
 xml_elem_start(struct parse *ps, const char *name)  xml_elem_start(struct parse *p, const char *name)
 {  {
         const struct element    *elem;          const struct element    *elem;
         struct pnode            *dat;          struct pnode            *n;
   
         /*          /*
          * An ancestor is excluded from the tree;           * An ancestor is excluded from the tree;
          * keep track of the number of levels excluded.           * keep track of the number of levels excluded.
          */           */
         if (ps->del > 0) {          if (p->del > 0) {
                 if (*name != '!' && *name != '?')                  if (*name != '!' && *name != '?')
                         ps->del++;                          p->del++;
                 return;                  return;
         }          }
   
         pnode_closetext(ps);          pnode_closetext(p, 1);
   
         for (elem = elements; elem->name != NULL; elem++)          for (elem = elements; elem->name != NULL; elem++)
                 if (strcmp(elem->name, name) == 0)                  if (strcmp(elem->name, name) == 0)
Line 479  xml_elem_start(struct parse *ps, const char *name)
Line 544  xml_elem_start(struct parse *ps, const char *name)
         if (elem->name == NULL) {          if (elem->name == NULL) {
                 if (*name == '!' || *name == '?')                  if (*name == '!' || *name == '?')
                         return;                          return;
                 error_msg(ps, "unknown element <%s>", name);                  error_msg(p, "unknown element <%s>", name);
         }          }
   
         ps->ncur = elem->node;          p->ncur = elem->node;
   
         switch (ps->ncur) {          switch (p->ncur) {
         case NODE_DELETE_WARN:          case NODE_DELETE_WARN:
                 warn_msg(ps, "skipping element <%s>", name);                  warn_msg(p, "skipping element <%s>", name);
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case NODE_DELETE:          case NODE_DELETE:
                 ps->del = 1;                  p->del = 1;
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case NODE_IGNORE:          case NODE_IGNORE:
                 return;                  return;
         case NODE_INLINEEQUATION:  
                 ps->tree->flags |= TREE_EQN;  
                 break;  
         default:          default:
                 break;                  break;
         }          }
   
         if (ps->tree->flags & TREE_CLOSED && ps->cur->parent == NULL)          if (p->tree->flags & TREE_CLOSED && p->cur->parent == NULL)
                 warn_msg(ps, "element after end of document: <%s>", name);                  warn_msg(p, "element after end of document: <%s>", name);
   
         if ((dat = calloc(1, sizeof(*dat))) == NULL)          if ((n = pnode_alloc(p->cur)) == NULL)
                 fatal(ps);                  fatal(p);
   
         /*          /*
          * Nodes that begin a new macro or request line or start by           * Nodes that begin a new macro or request line or start by
          * printing text always want whitespace before themselves.           * printing text always want whitespace before themselves.
          */           */
   
         switch (dat->node = elem->node) {          switch (n->node = elem->node) {
         case NODE_DOCTYPE:          case NODE_DOCTYPE:
         case NODE_ENTITY:          case NODE_ENTITY:
         case NODE_SBR:          case NODE_SBR:
                 ps->flags |= PFLAG_EEND;                  p->flags |= PFLAG_EEND;
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case NODE_APPENDIX:          case NODE_APPENDIX:
         case NODE_AUTHORGROUP:          case NODE_AUTHORGROUP:
Line 549  xml_elem_start(struct parse *ps, const char *name)
Line 611  xml_elem_start(struct parse *ps, const char *name)
         case NODE_VARIABLELIST:          case NODE_VARIABLELIST:
         case NODE_VARLISTENTRY:          case NODE_VARLISTENTRY:
         case NODE_WARNING:          case NODE_WARNING:
                 dat->spc = 1;                  n->spc = 1;
                 break;                  break;
         default:          default:
                 dat->spc = (ps->flags & PFLAG_SPC) != 0;                  n->spc = (p->flags & PFLAG_SPC) != 0;
                 break;                  break;
         }          }
         dat->parent = ps->cur;          p->cur = n;
         TAILQ_INIT(&dat->childq);          if (n->node == NODE_DOCTYPE) {
         TAILQ_INIT(&dat->attrq);                  if (p->doctype == NULL)
                           p->doctype = n;
         if (ps->cur != NULL)  
                 TAILQ_INSERT_TAIL(&ps->cur->childq, dat, child);  
   
         ps->cur = dat;  
         if (dat->node == NODE_DOCTYPE) {  
                 if (ps->doctype == NULL)  
                         ps->doctype = dat;  
                 else                  else
                         error_msg(ps, "duplicate doctype");                          error_msg(p, "duplicate doctype");
         } else if (dat->parent == NULL && ps->tree->root == NULL)          } else if (n->parent == NULL && p->tree->root == NULL)
                 ps->tree->root = dat;                  p->tree->root = n;
 }  }
   
 static void  static void
 xml_attrkey(struct parse *ps, const char *name)  xml_attrkey(struct parse *p, const char *name)
 {  {
         struct pattr    *attr;          struct pattr    *a;
         const char      *value;          const char      *value;
         enum attrkey     key;          enum attrkey     key;
   
         if (ps->del > 0 || ps->ncur == NODE_IGNORE || *name == '\0')          if (p->del > 0 || p->ncur == NODE_IGNORE || *name == '\0')
                 return;                  return;
   
         if ((ps->ncur == NODE_DOCTYPE || ps->ncur == NODE_ENTITY) &&          if ((p->ncur == NODE_DOCTYPE || p->ncur == NODE_ENTITY) &&
             TAILQ_FIRST(&ps->cur->attrq) == NULL) {              TAILQ_FIRST(&p->cur->attrq) == NULL) {
                 value = name;                  value = name;
                 name = "NAME";                  name = "NAME";
         } else          } else
                 value = NULL;                  value = NULL;
   
         if ((key = attrkey_parse(name)) == ATTRKEY__MAX) {          if ((key = attrkey_parse(name)) == ATTRKEY__MAX) {
                 ps->flags &= ~PFLAG_ATTR;                  p->flags &= ~PFLAG_ATTR;
                 return;                  return;
         }          }
         if ((attr = calloc(1, sizeof(*attr))) == NULL)          if ((a = calloc(1, sizeof(*a))) == NULL)
                 fatal(ps);                  fatal(p);
   
         attr->key = key;          a->key = key;
         attr->val = ATTRVAL__MAX;          a->val = ATTRVAL__MAX;
         if (value == NULL) {          if (value == NULL) {
                 attr->rawval = NULL;                  a->rawval = NULL;
                 ps->flags |= PFLAG_ATTR;                  p->flags |= PFLAG_ATTR;
         } else {          } else {
                 if ((attr->rawval = strdup(value)) == NULL)                  if ((a->rawval = strdup(value)) == NULL)
                         fatal(ps);                          fatal(p);
                 ps->flags &= ~PFLAG_ATTR;                  p->flags &= ~PFLAG_ATTR;
         }          }
         TAILQ_INSERT_TAIL(&ps->cur->attrq, attr, child);          TAILQ_INSERT_TAIL(&p->cur->attrq, a, child);
         if (ps->ncur == NODE_ENTITY && key == ATTRKEY_NAME)          if (p->ncur == NODE_ENTITY && key == ATTRKEY_NAME)
                 xml_attrkey(ps, "DEFINITION");                  xml_attrkey(p, "DEFINITION");
 }  }
   
 static void  static void
 xml_attrval(struct parse *ps, const char *name)  xml_attrval(struct parse *p, const char *name)
 {  {
         struct pattr    *attr;          struct pattr    *a;
   
         if (ps->del > 0 || ps->ncur == NODE_IGNORE ||          if (p->del > 0 || p->ncur == NODE_IGNORE ||
             (ps->flags & PFLAG_ATTR) == 0)              (p->flags & PFLAG_ATTR) == 0)
                 return;                  return;
         if ((attr = TAILQ_LAST(&ps->cur->attrq, pattrq)) == NULL)          if ((a = TAILQ_LAST(&p->cur->attrq, pattrq)) == NULL)
                 return;                  return;
         if ((attr->val = attrval_parse(name)) == ATTRVAL__MAX &&          if ((a->val = attrval_parse(name)) == ATTRVAL__MAX &&
             (attr->rawval = strdup(name)) == NULL)              (a->rawval = strdup(name)) == NULL)
                 fatal(ps);                  fatal(p);
         ps->flags &= ~PFLAG_ATTR;          p->flags &= ~PFLAG_ATTR;
 }  }
   
 /*  /*
Line 632  xml_attrval(struct parse *ps, const char *name)
Line 687  xml_attrval(struct parse *ps, const char *name)
  * If we're at a text node, roll that one up first.   * If we're at a text node, roll that one up first.
  */   */
 static void  static void
 xml_elem_end(struct parse *ps, const char *name)  xml_elem_end(struct parse *p, const char *name)
 {  {
         const struct element    *elem;          const struct element    *elem;
         struct pnode            *n;          struct pnode            *n;
Line 643  xml_elem_end(struct parse *ps, const char *name)
Line 698  xml_elem_end(struct parse *ps, const char *name)
          * An ancestor is excluded from the tree;           * An ancestor is excluded from the tree;
          * keep track of the number of levels excluded.           * keep track of the number of levels excluded.
          */           */
         if (ps->del > 1) {          if (p->del > 1) {
                 ps->del--;                  p->del--;
                 return;                  return;
         }          }
   
         if (ps->del == 0)          if (p->del == 0)
                 pnode_closetext(ps);                  pnode_closetext(p, 0);
   
         if (name != NULL) {          if (name != NULL) {
                 for (elem = elements; elem->name != NULL; elem++)                  for (elem = elements; elem->name != NULL; elem++)
Line 657  xml_elem_end(struct parse *ps, const char *name)
Line 712  xml_elem_end(struct parse *ps, const char *name)
                                 break;                                  break;
                 node = elem->node;                  node = elem->node;
         } else          } else
                 node = ps->ncur;                  node = p->ncur;
   
         switch (node) {          switch (node) {
         case NODE_DELETE_WARN:          case NODE_DELETE_WARN:
         case NODE_DELETE:          case NODE_DELETE:
                 if (ps->del > 0)                  if (p->del > 0)
                         ps->del--;                          p->del--;
                 break;                  break;
         case NODE_IGNORE:          case NODE_IGNORE:
                 break;                  break;
         case NODE_INCLUDE:          case NODE_INCLUDE:
                 n = ps->cur;                  n = p->cur;
                 ps->cur = ps->cur->parent;                  p->cur = p->cur->parent;
                 cp = pnode_getattr_raw(n, ATTRKEY_HREF, NULL);                  cp = pnode_getattr_raw(n, ATTRKEY_HREF, NULL);
                 if (cp == NULL)                  if (cp == NULL)
                         error_msg(ps, "<xi:include> element "                          error_msg(p, "<xi:include> element "
                             "without href attribute");                              "without href attribute");
                 else                  else
                         parse_file(ps, -1, cp);                          parse_file(p, -1, cp);
                 pnode_unlink(n);                  pnode_unlink(n);
                 ps->flags &= ~PFLAG_SPC;                  p->flags &= ~PFLAG_SPC;
                 break;                  break;
         case NODE_DOCTYPE:          case NODE_DOCTYPE:
                 ps->flags &= ~PFLAG_EEND;          case NODE_SBR:
                   p->flags &= ~PFLAG_EEND;
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         default:          default:
                 if (ps->cur == NULL || node != ps->cur->node) {                  if (p->cur == NULL || node != p->cur->node) {
                         warn_msg(ps, "element not open: </%s>", name);                          warn_msg(p, "element not open: </%s>", name);
                         break;                          break;
                 }                  }
   
Line 695  xml_elem_end(struct parse *ps, const char *name)
Line 751  xml_elem_end(struct parse *ps, const char *name)
                  * obviously better than discarding it or crashing.                   * obviously better than discarding it or crashing.
                  */                   */
   
                 if (ps->cur->parent != NULL || node == NODE_DOCTYPE) {                  if (p->cur->parent != NULL || node == NODE_DOCTYPE) {
                         ps->cur = ps->cur->parent;                          p->cur = p->cur->parent;
                         if (ps->cur != NULL)                          if (p->cur != NULL)
                                 ps->ncur = ps->cur->node;                                  p->ncur = p->cur->node;
                 } else                  } else
                         ps->tree->flags |= TREE_CLOSED;                          p->tree->flags |= TREE_CLOSED;
                 ps->flags &= ~PFLAG_SPC;                  p->flags &= ~PFLAG_SPC;
                 break;                  break;
         }          }
         assert(ps->del == 0);          assert(p->del == 0);
 }  }
   
 struct parse *  struct parse *
Line 970  parse_string(struct parse *p, char *b, size_t rlen,
Line 1026  parse_string(struct parse *p, char *b, size_t rlen,
   
                 } else {                  } else {
                         advance(p, b, rlen, &pend,                          advance(p, b, rlen, &pend,
                             p->ncur == NODE_DOCTYPE ? "<&]" : "<&",                              p->ncur == NODE_DOCTYPE ? "<&]\n" : "<&\n",
                             refill);                              refill);
                         xml_char(p, b + poff, pend - poff);                          xml_text(p, b + poff, pend - poff);
                           if (b[pend] == '\n')
                                   pnode_closetext(p, 0);
                 }                  }
         }          }
         return poff;          return poff;
Line 1057  parse_file(struct parse *p, int fd, const char *fname)
Line 1115  parse_file(struct parse *p, int fd, const char *fname)
         /* On the top level, finalize the parse tree. */          /* On the top level, finalize the parse tree. */
   
         if (save_fname == NULL) {          if (save_fname == NULL) {
                 pnode_closetext(p);                  pnode_closetext(p, 0);
                 if (p->tree->root == NULL)                  if (p->tree->root == NULL)
                         error_msg(p, "empty document");                          error_msg(p, "empty document");
                 else if ((p->tree->flags & TREE_CLOSED) == 0)                  else if ((p->tree->flags & TREE_CLOSED) == 0)

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.38

CVSweb