version 1.208, 2014/01/05 20:26:36 |
version 1.211, 2014/03/23 12:44:56 |
|
|
#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> |
|
|
|
|
#include "mdoc.h" |
#include "mdoc.h" |
#include "mandoc.h" |
#include "mandoc.h" |
|
#include "mandoc_aux.h" |
#include "libmdoc.h" |
#include "libmdoc.h" |
#include "libmandoc.h" |
#include "libmandoc.h" |
|
|
Line 593 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 1021 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; |
} |
} |