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

Diff for /mandoc/roff.c between version 1.267 and 1.270

version 1.267, 2015/04/19 14:25:41 version 1.270, 2015/05/01 16:02:47
Line 1022  roff_node_append(struct roff_man *man, struct roff_nod
Line 1022  roff_node_append(struct roff_man *man, struct roff_nod
                 /* NOTREACHED */                  /* NOTREACHED */
         }          }
         n->parent->nchild++;          n->parent->nchild++;
           n->parent->last = n;
   
         /*          /*
          * Copy over the normalised-data pointer of our parent.  Not           * Copy over the normalised-data pointer of our parent.  Not
Line 1096  roff_word_append(struct roff_man *man, const char *wor
Line 1097  roff_word_append(struct roff_man *man, const char *wor
         man->next = ROFF_NEXT_SIBLING;          man->next = ROFF_NEXT_SIBLING;
 }  }
   
   void
   roff_elem_alloc(struct roff_man *man, int line, int pos, int tok)
   {
           struct roff_node        *n;
   
           n = roff_node_alloc(man, line, pos, ROFFT_ELEM, tok);
           roff_node_append(man, n);
           man->next = ROFF_NEXT_CHILD;
   }
   
 struct roff_node *  struct roff_node *
   roff_block_alloc(struct roff_man *man, int line, int pos, int tok)
   {
           struct roff_node        *n;
   
           n = roff_node_alloc(man, line, pos, ROFFT_BLOCK, tok);
           roff_node_append(man, n);
           man->next = ROFF_NEXT_CHILD;
           return(n);
   }
   
   struct roff_node *
 roff_head_alloc(struct roff_man *man, int line, int pos, int tok)  roff_head_alloc(struct roff_man *man, int line, int pos, int tok)
 {  {
         struct roff_node        *n;          struct roff_node        *n;
Line 1207  roff_node_delete(struct roff_man *man, struct roff_nod
Line 1229  roff_node_delete(struct roff_man *man, struct roff_nod
         assert(n->nchild == 0);          assert(n->nchild == 0);
         roff_node_unlink(man, n);          roff_node_unlink(man, n);
         roff_node_free(n);          roff_node_free(n);
   }
   
   void
   deroff(char **dest, const struct roff_node *n)
   {
           char    *cp;
           size_t   sz;
   
           if (n->type != ROFFT_TEXT) {
                   for (n = n->child; n != NULL; n = n->next)
                           deroff(dest, n);
                   return;
           }
   
           /* Skip leading whitespace and escape sequences. */
   
           cp = n->string;
           while (*cp != '\0') {
                   if ('\\' == *cp) {
                           cp++;
                           mandoc_escape((const char **)&cp, NULL, NULL);
                   } else if (isspace((unsigned char)*cp))
                           cp++;
                   else
                           break;
           }
   
           /* Skip trailing whitespace. */
   
           for (sz = strlen(cp); sz; sz--)
                   if ( ! isspace((unsigned char)cp[sz-1]))
                           break;
   
           /* Skip empty strings. */
   
           if (sz == 0)
                   return;
   
           if (*dest == NULL) {
                   *dest = mandoc_strndup(cp, sz);
                   return;
           }
   
           mandoc_asprintf(&cp, "%s %*s", *dest, (int)sz, cp);
           free(*dest);
           *dest = cp;
 }  }
   
 /* --- main functions of the roff parser ---------------------------------- */  /* --- main functions of the roff parser ---------------------------------- */

Legend:
Removed from v.1.267  
changed lines
  Added in v.1.270

CVSweb