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

Diff for /mandoc/mdoc.c between version 1.209 and 1.211

version 1.209, 2014/03/23 11:25:26 version 1.211, 2014/03/23 12:44:56
Line 22 
Line 22 
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
   #include <ctype.h>
 #include <stdarg.h>  #include <stdarg.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 594  mdoc_word_append(struct mdoc *mdoc, const char *p)
Line 595  mdoc_word_append(struct mdoc *mdoc, const char *p)
   
         n = mdoc->last;          n = mdoc->last;
         addstr = roff_strdup(mdoc->roff, p);          addstr = roff_strdup(mdoc->roff, p);
         if (-1 == asprintf(&newstr, "%s %s", n->string, addstr)) {          mandoc_asprintf(&newstr, "%s %s", n->string, addstr);
                 perror(NULL);  
                 exit((int)MANDOCLEVEL_SYSERR);  
         }  
         free(addstr);          free(addstr);
         free(n->string);          free(n->string);
         n->string = newstr;          n->string = newstr;
Line 1022  mdoc_isdelim(const char *p)
Line 1020  mdoc_isdelim(const char *p)
                 return(DELIM_MIDDLE);                  return(DELIM_MIDDLE);
   
         return(DELIM_NONE);          return(DELIM_NONE);
   }
   
   void
   mdoc_deroff(char **dest, const struct mdoc_node *n)
   {
           char    *cp;
           size_t   sz;
   
           if (MDOC_TEXT != n->type) {
                   for (n = n->child; n; n = n->next)
                           mdoc_deroff(dest, n);
                   return;
           }
   
           /* Skip leading whitespace. */
   
           for (cp = n->string; '\0' != *cp; cp++)
                   if (0 == isspace((unsigned char)*cp))
                           break;
   
           /* Skip trailing whitespace. */
   
           for (sz = strlen(cp); sz; sz--)
                   if (0 == isspace((unsigned char)cp[sz-1]))
                           break;
   
           /* Skip empty strings. */
   
           if (0 == sz)
                   return;
   
           if (NULL == *dest) {
                   *dest = mandoc_strndup(cp, sz);
                   return;
           }
   
           mandoc_asprintf(&cp, "%s %*s", *dest, (int)sz, cp);
           free(*dest);
           *dest = cp;
 }  }

Legend:
Removed from v.1.209  
changed lines
  Added in v.1.211

CVSweb