version 1.192, 2014/02/14 22:27:41 |
version 1.194, 2014/02/14 23:24:26 |
|
|
ROFF_am, |
ROFF_am, |
ROFF_ami, |
ROFF_ami, |
ROFF_am1, |
ROFF_am1, |
|
ROFF_as, |
ROFF_cc, |
ROFF_cc, |
|
ROFF_ce, |
ROFF_de, |
ROFF_de, |
ROFF_dei, |
ROFF_dei, |
ROFF_de1, |
ROFF_de1, |
Line 233 static struct roffmac roffs[ROFF_MAX] = { |
|
Line 235 static struct roffmac roffs[ROFF_MAX] = { |
|
{ "am", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
{ "am", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
{ "ami", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
{ "ami", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
{ "am1", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
{ "am1", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
|
{ "as", roff_ds, NULL, NULL, 0, NULL }, |
{ "cc", roff_cc, NULL, NULL, 0, NULL }, |
{ "cc", roff_cc, NULL, NULL, 0, NULL }, |
|
{ "ce", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "de", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
{ "de", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
{ "dei", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
{ "dei", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
{ "de1", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
{ "de1", roff_block, roff_block_text, roff_block_sub, 0, NULL }, |
Line 939 roff_block(ROFF_ARGS) |
|
Line 943 roff_block(ROFF_ARGS) |
|
/* |
/* |
* At the beginning of a `de' macro, clear the existing string |
* At the beginning of a `de' macro, clear the existing string |
* with the same name, if there is one. New content will be |
* with the same name, if there is one. New content will be |
* added from roff_block_text() in multiline mode. |
* appended from roff_block_text() in multiline mode. |
*/ |
*/ |
|
|
if (ROFF_de == tok) |
if (ROFF_de == tok) |
Line 1029 roff_block_sub(ROFF_ARGS) |
|
Line 1033 roff_block_sub(ROFF_ARGS) |
|
*/ |
*/ |
if (ROFF_cblock != t) { |
if (ROFF_cblock != t) { |
if (ROFF_de == tok) |
if (ROFF_de == tok) |
roff_setstr(r, r->last->name, *bufp + ppos, 1); |
roff_setstr(r, r->last->name, *bufp + ppos, 2); |
return(ROFF_IGN); |
return(ROFF_IGN); |
} |
} |
|
|
Line 1045 roff_block_text(ROFF_ARGS) |
|
Line 1049 roff_block_text(ROFF_ARGS) |
|
{ |
{ |
|
|
if (ROFF_de == tok) |
if (ROFF_de == tok) |
roff_setstr(r, r->last->name, *bufp + pos, 1); |
roff_setstr(r, r->last->name, *bufp + pos, 2); |
|
|
return(ROFF_IGN); |
return(ROFF_IGN); |
} |
} |
Line 1348 roff_ds(ROFF_ARGS) |
|
Line 1352 roff_ds(ROFF_ARGS) |
|
string++; |
string++; |
|
|
/* The rest is the value. */ |
/* The rest is the value. */ |
roff_setstr(r, name, string, 0); |
roff_setstr(r, name, string, ROFF_as == tok); |
return(ROFF_IGN); |
return(ROFF_IGN); |
} |
} |
|
|
Line 1848 roff_getname(struct roff *r, char **cpp, int ln, int p |
|
Line 1852 roff_getname(struct roff *r, char **cpp, int ln, int p |
|
|
|
/* |
/* |
* Store *string into the user-defined string called *name. |
* Store *string into the user-defined string called *name. |
* In multiline mode, append to an existing entry and append '\n'; |
|
* else replace the existing entry, if there is one. |
|
* To clear an existing entry, call with (*r, *name, NULL, 0). |
* To clear an existing entry, call with (*r, *name, NULL, 0). |
|
* append == 0: replace mode |
|
* append == 1: single-line append mode |
|
* append == 2: multiline append mode, append '\n' after each call |
*/ |
*/ |
static void |
static void |
roff_setstr(struct roff *r, const char *name, const char *string, |
roff_setstr(struct roff *r, const char *name, const char *string, |
int multiline) |
int append) |
{ |
{ |
|
|
roff_setstrn(&r->strtab, name, strlen(name), string, |
roff_setstrn(&r->strtab, name, strlen(name), string, |
string ? strlen(string) : 0, multiline); |
string ? strlen(string) : 0, append); |
} |
} |
|
|
static void |
static void |
roff_setstrn(struct roffkv **r, const char *name, size_t namesz, |
roff_setstrn(struct roffkv **r, const char *name, size_t namesz, |
const char *string, size_t stringsz, int multiline) |
const char *string, size_t stringsz, int append) |
{ |
{ |
struct roffkv *n; |
struct roffkv *n; |
char *c; |
char *c; |
Line 1885 roff_setstrn(struct roffkv **r, const char *name, size |
|
Line 1890 roff_setstrn(struct roffkv **r, const char *name, size |
|
n->val.sz = 0; |
n->val.sz = 0; |
n->next = *r; |
n->next = *r; |
*r = n; |
*r = n; |
} else if (0 == multiline) { |
} else if (0 == append) { |
/* In multiline mode, append; else replace. */ |
|
free(n->val.p); |
free(n->val.p); |
n->val.p = NULL; |
n->val.p = NULL; |
n->val.sz = 0; |
n->val.sz = 0; |
Line 1899 roff_setstrn(struct roffkv **r, const char *name, size |
|
Line 1903 roff_setstrn(struct roffkv **r, const char *name, size |
|
* One additional byte for the '\n' in multiline mode, |
* One additional byte for the '\n' in multiline mode, |
* and one for the terminating '\0'. |
* and one for the terminating '\0'. |
*/ |
*/ |
newch = stringsz + (multiline ? 2u : 1u); |
newch = stringsz + (1 < append ? 2u : 1u); |
|
|
if (NULL == n->val.p) { |
if (NULL == n->val.p) { |
n->val.p = mandoc_malloc(newch); |
n->val.p = mandoc_malloc(newch); |
Line 1926 roff_setstrn(struct roffkv **r, const char *name, size |
|
Line 1930 roff_setstrn(struct roffkv **r, const char *name, size |
|
} |
} |
|
|
/* Append terminating bytes. */ |
/* Append terminating bytes. */ |
if (multiline) |
if (1 < append) |
*c++ = '\n'; |
*c++ = '\n'; |
|
|
*c = '\0'; |
*c = '\0'; |