]>
git.cameronkatri.com Git - mandoc.git/blob - roff.c
7467fe0e11c29305693c5fff6d51a86dbd363647
1 /* $Id: roff.c,v 1.102 2010/09/04 20:18:53 kristaps Exp $ */
3 * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
32 #include "libmandoc.h"
34 #define RSTACK_MAX 128
37 ('.' == (c) || '\'' == (c))
40 #define ROFF_DEBUG(fmt, args...) \
41 do { /* Nothing. */ } while (/*CONSTCOND*/ 0)
43 #define ROFF_DEBUG(fmt, args...) \
44 do { fprintf(stderr, fmt , ##args); } while (/*CONSTCOND*/ 0)
62 ROFF_ccond
, /* FIXME: remove this. */
74 char *name
; /* key of symbol */
75 char *string
; /* current value */
76 struct roffstr
*next
; /* next in list */
80 struct roffnode
*last
; /* leaf of stack */
81 mandocmsg msg
; /* err/warn/fatal messages */
82 void *data
; /* privdata for messages */
83 enum roffrule rstack
[RSTACK_MAX
]; /* stack of !`ie' rules */
84 int rstackpos
; /* position in rstack */
85 struct regset
*regs
; /* read/writable registers */
86 struct roffstr
*first_string
;
90 enum rofft tok
; /* type of node */
91 struct roffnode
*parent
; /* up one in stack */
92 int line
; /* parse line */
93 int col
; /* parse col */
94 char *end
; /* end-rules: custom token */
95 int endspan
; /* end-rules: next-line or infty */
96 enum roffrule rule
; /* current evaluation rule */
99 #define ROFF_ARGS struct roff *r, /* parse ctx */ \
100 enum rofft tok, /* tok of macro */ \
101 char **bufp, /* input buffer */ \
102 size_t *szp, /* size of input buffer */ \
103 int ln, /* parse line */ \
104 int ppos, /* original pos in buffer */ \
105 int pos, /* current pos in buffer */ \
106 int *offs /* reset offset of buffer data */
108 typedef enum rofferr (*roffproc
)(ROFF_ARGS
);
111 const char *name
; /* macro name */
112 roffproc proc
; /* process new macro */
113 roffproc text
; /* process as child text of macro */
114 roffproc sub
; /* process as child of macro */
116 #define ROFFMAC_STRUCT (1 << 0) /* always interpret */
117 struct roffmac
*next
;
120 static enum rofferr
roff_block(ROFF_ARGS
);
121 static enum rofferr
roff_block_text(ROFF_ARGS
);
122 static enum rofferr
roff_block_sub(ROFF_ARGS
);
123 static enum rofferr
roff_cblock(ROFF_ARGS
);
124 static enum rofferr
roff_ccond(ROFF_ARGS
);
125 static enum rofferr
roff_cond(ROFF_ARGS
);
126 static enum rofferr
roff_cond_text(ROFF_ARGS
);
127 static enum rofferr
roff_cond_sub(ROFF_ARGS
);
128 static enum rofferr
roff_ds(ROFF_ARGS
);
129 static enum roffrule
roff_evalcond(const char *, int *);
130 static void roff_freestr(struct roff
*);
131 static const char *roff_getstrn(const struct roff
*,
132 const char *, size_t);
133 static enum rofferr
roff_line(ROFF_ARGS
);
134 static enum rofferr
roff_nr(ROFF_ARGS
);
135 static int roff_res(struct roff
*,
136 char **, size_t *, int);
137 static void roff_setstr(struct roff
*,
138 const char *, const char *);
139 static char *roff_strdup(const char *);
141 /* See roff_hash_find() */
145 #define HASHWIDTH (ASCII_HI - ASCII_LO + 1)
147 static struct roffmac
*hash
[HASHWIDTH
];
149 static struct roffmac roffs
[ROFF_MAX
] = {
150 { "am", roff_block
, roff_block_text
, roff_block_sub
, 0, NULL
},
151 { "ami", roff_block
, roff_block_text
, roff_block_sub
, 0, NULL
},
152 { "am1", roff_block
, roff_block_text
, roff_block_sub
, 0, NULL
},
153 { "de", roff_block
, roff_block_text
, roff_block_sub
, 0, NULL
},
154 { "dei", roff_block
, roff_block_text
, roff_block_sub
, 0, NULL
},
155 { "de1", roff_block
, roff_block_text
, roff_block_sub
, 0, NULL
},
156 { "ds", roff_ds
, NULL
, NULL
, 0, NULL
},
157 { "el", roff_cond
, roff_cond_text
, roff_cond_sub
, ROFFMAC_STRUCT
, NULL
},
158 { "ie", roff_cond
, roff_cond_text
, roff_cond_sub
, ROFFMAC_STRUCT
, NULL
},
159 { "if", roff_cond
, roff_cond_text
, roff_cond_sub
, ROFFMAC_STRUCT
, NULL
},
160 { "ig", roff_block
, roff_block_text
, roff_block_sub
, 0, NULL
},
161 { "rm", roff_line
, NULL
, NULL
, 0, NULL
},
162 { "tr", roff_line
, NULL
, NULL
, 0, NULL
},
163 { ".", roff_cblock
, NULL
, NULL
, 0, NULL
},
164 { "\\}", roff_ccond
, NULL
, NULL
, 0, NULL
},
165 { "nr", roff_nr
, NULL
, NULL
, 0, NULL
},
168 static void roff_free1(struct roff
*);
169 static enum rofft
roff_hash_find(const char *);
170 static void roff_hash_init(void);
171 static void roffnode_cleanscope(struct roff
*);
172 static void roffnode_push(struct roff
*,
173 enum rofft
, int, int);
174 static void roffnode_pop(struct roff
*);
175 static enum rofft
roff_parse(const char *, int *);
176 static int roff_parse_nat(const char *, unsigned int *);
178 /* See roff_hash_find() */
179 #define ROFF_HASH(p) (p[0] - ASCII_LO)
187 for (i
= 0; i
< (int)ROFF_MAX
; i
++) {
188 assert(roffs
[i
].name
[0] >= ASCII_LO
);
189 assert(roffs
[i
].name
[0] <= ASCII_HI
);
191 buc
= ROFF_HASH(roffs
[i
].name
);
193 if (NULL
!= (n
= hash
[buc
])) {
194 for ( ; n
->next
; n
= n
->next
)
198 hash
[buc
] = &roffs
[i
];
204 * Look up a roff token by its name. Returns ROFF_MAX if no macro by
205 * the nil-terminated string name could be found.
208 roff_hash_find(const char *p
)
214 * libroff has an extremely simple hashtable, for the time
215 * being, which simply keys on the first character, which must
216 * be printable, then walks a chain. It works well enough until
220 if (p
[0] < ASCII_LO
|| p
[0] > ASCII_HI
)
225 if (NULL
== (n
= hash
[buc
]))
227 for ( ; n
; n
= n
->next
)
228 if (0 == strcmp(n
->name
, p
))
229 return((enum rofft
)(n
- roffs
));
236 * Pop the current node off of the stack of roff instructions currently
240 roffnode_pop(struct roff
*r
)
247 if (ROFF_el
== p
->tok
)
248 if (r
->rstackpos
> -1)
251 ROFF_DEBUG("roff: popping scope\n");
252 r
->last
= r
->last
->parent
;
260 * Push a roff node onto the instruction stack. This must later be
261 * removed with roffnode_pop().
264 roffnode_push(struct roff
*r
, enum rofft tok
, int line
, int col
)
268 p
= mandoc_calloc(1, sizeof(struct roffnode
));
273 p
->rule
= p
->parent
? p
->parent
->rule
: ROFFRULE_DENY
;
280 roff_free1(struct roff
*r
)
290 roff_reset(struct roff
*r
)
298 roff_free(struct roff
*r
)
307 roff_alloc(struct regset
*regs
, void *data
, const mandocmsg msg
)
311 r
= mandoc_calloc(1, sizeof(struct roff
));
323 * Pre-filter each and every line for reserved words (one beginning with
324 * `\*', e.g., `\*(ab'). These must be handled before the actual line
328 roff_res(struct roff
*r
, char **bufp
, size_t *szp
, int pos
)
330 const char *cp
, *cpp
, *st
, *res
;
336 for (cp
= &(*bufp
)[pos
]; (cpp
= strstr(cp
, "\\*")); cp
++) {
354 for (i
= 0; 0 == maxl
|| i
< maxl
; i
++, cp
++) {
356 return(1); /* Error. */
357 if (0 == maxl
&& ']' == *cp
)
361 res
= roff_getstrn(r
, st
, (size_t)i
);
368 ROFF_DEBUG("roff: splicing reserved: [%.*s]\n", i
, st
);
370 nsz
= *szp
+ strlen(res
) + 1;
371 n
= mandoc_malloc(nsz
);
375 strlcat(n
, *bufp
, (size_t)(cpp
- *bufp
+ 1));
376 strlcat(n
, res
, nsz
);
377 strlcat(n
, cp
+ (maxl
? 0 : 1), nsz
);
391 roff_parseln(struct roff
*r
, int ln
, char **bufp
,
392 size_t *szp
, int pos
, int *offs
)
398 * Run the reserved-word filter only if we have some reserved
402 if (r
->first_string
&& ! roff_res(r
, bufp
, szp
, pos
))
406 * First, if a scope is open and we're not a macro, pass the
407 * text through the macro's filter. If a scope isn't open and
408 * we're not a macro, just let it through.
411 if (r
->last
&& ! ROFF_CTL((*bufp
)[pos
])) {
413 assert(roffs
[t
].text
);
414 ROFF_DEBUG("roff: intercept scoped text: %s, [%s]\n",
415 roffs
[t
].name
, &(*bufp
)[pos
]);
416 return((*roffs
[t
].text
)
418 ln
, pos
, pos
, offs
));
419 } else if ( ! ROFF_CTL((*bufp
)[pos
]))
423 * If a scope is open, go to the child handler for that macro,
424 * as it may want to preprocess before doing anything with it.
429 assert(roffs
[t
].sub
);
430 ROFF_DEBUG("roff: intercept scoped context: %s, [%s]\n",
431 roffs
[t
].name
, &(*bufp
)[pos
]);
432 return((*roffs
[t
].sub
)
434 ln
, pos
, pos
, offs
));
438 * Lastly, as we've no scope open, try to look up and execute
439 * the new macro. If no macro is found, simply return and let
440 * the compilers handle it.
444 if (ROFF_MAX
== (t
= roff_parse(*bufp
, &pos
)))
447 ROFF_DEBUG("roff: intercept new-scope: %s, [%s]\n",
448 roffs
[t
].name
, &(*bufp
)[pos
]);
449 assert(roffs
[t
].proc
);
450 return((*roffs
[t
].proc
)
452 ln
, ppos
, pos
, offs
));
457 roff_endparse(struct roff
*r
)
462 return((*r
->msg
)(MANDOCERR_SCOPEEXIT
, r
->data
, r
->last
->line
,
463 r
->last
->col
, NULL
));
468 * Parse a roff node's type from the input buffer. This must be in the
469 * form of ".foo xxx" in the usual way.
472 roff_parse(const char *buf
, int *pos
)
478 assert(ROFF_CTL(buf
[*pos
]));
481 while (buf
[*pos
] && (' ' == buf
[*pos
] || '\t' == buf
[*pos
]))
484 if ('\0' == buf
[*pos
])
487 for (j
= 0; j
< 4; j
++, (*pos
)++)
488 if ('\0' == (mac
[j
] = buf
[*pos
]))
490 else if (' ' == buf
[*pos
] || (j
&& '\\' == buf
[*pos
]))
498 if (ROFF_MAX
== (t
= roff_hash_find(mac
)))
501 while (buf
[*pos
] && ' ' == buf
[*pos
])
509 roff_parse_nat(const char *buf
, unsigned int *res
)
515 lval
= strtol(buf
, &ep
, 10);
516 if (buf
[0] == '\0' || *ep
!= '\0')
518 if ((errno
== ERANGE
&&
519 (lval
== LONG_MAX
|| lval
== LONG_MIN
)) ||
520 (lval
> INT_MAX
|| lval
< 0))
523 *res
= (unsigned int)lval
;
530 roff_cblock(ROFF_ARGS
)
534 * A block-close `..' should only be invoked as a child of an
535 * ignore macro, otherwise raise a warning and just ignore it.
538 if (NULL
== r
->last
) {
539 if ( ! (*r
->msg
)(MANDOCERR_NOSCOPE
, r
->data
, ln
, ppos
, NULL
))
544 switch (r
->last
->tok
) {
560 if ( ! (*r
->msg
)(MANDOCERR_NOSCOPE
, r
->data
, ln
, ppos
, NULL
))
566 if ( ! (*r
->msg
)(MANDOCERR_ARGSLOST
, r
->data
, ln
, pos
, NULL
))
570 roffnode_cleanscope(r
);
577 roffnode_cleanscope(struct roff
*r
)
581 if (--r
->last
->endspan
< 0)
590 roff_ccond(ROFF_ARGS
)
593 if (NULL
== r
->last
) {
594 if ( ! (*r
->msg
)(MANDOCERR_NOSCOPE
, r
->data
, ln
, ppos
, NULL
))
599 switch (r
->last
->tok
) {
607 if ( ! (*r
->msg
)(MANDOCERR_NOSCOPE
, r
->data
, ln
, ppos
, NULL
))
612 if (r
->last
->endspan
> -1) {
613 if ( ! (*r
->msg
)(MANDOCERR_NOSCOPE
, r
->data
, ln
, ppos
, NULL
))
619 if ( ! (*r
->msg
)(MANDOCERR_ARGSLOST
, r
->data
, ln
, pos
, NULL
))
623 roffnode_cleanscope(r
);
630 roff_block(ROFF_ARGS
)
635 if (ROFF_ig
!= tok
&& '\0' == (*bufp
)[pos
]) {
636 if ( ! (*r
->msg
)(MANDOCERR_NOARGS
, r
->data
, ln
, ppos
, NULL
))
639 } else if (ROFF_ig
!= tok
) {
640 while ((*bufp
)[pos
] && ' ' != (*bufp
)[pos
])
642 while (' ' == (*bufp
)[pos
])
646 roffnode_push(r
, tok
, ln
, ppos
);
648 if ('\0' == (*bufp
)[pos
])
652 while ((*bufp
)[pos
] && ' ' != (*bufp
)[pos
] &&
653 '\t' != (*bufp
)[pos
])
657 * Note: groff does NOT like escape characters in the input.
658 * Instead of detecting this, we're just going to let it fly and
663 sz
= (size_t)(pos
- sv
);
665 if (1 == sz
&& '.' == (*bufp
)[sv
])
668 r
->last
->end
= mandoc_malloc(sz
+ 1);
670 memcpy(r
->last
->end
, *bufp
+ sv
, sz
);
671 r
->last
->end
[(int)sz
] = '\0';
674 if ( ! (*r
->msg
)(MANDOCERR_ARGSLOST
, r
->data
, ln
, pos
, NULL
))
683 roff_block_sub(ROFF_ARGS
)
689 * First check whether a custom macro exists at this level. If
690 * it does, then check against it. This is some of groff's
691 * stranger behaviours. If we encountered a custom end-scope
692 * tag and that tag also happens to be a "real" macro, then we
693 * need to try interpreting it again as a real macro. If it's
694 * not, then return ignore. Else continue.
699 while (' ' == (*bufp
)[i
] || '\t' == (*bufp
)[i
])
702 for (j
= 0; r
->last
->end
[j
]; j
++, i
++)
703 if ((*bufp
)[i
] != r
->last
->end
[j
])
706 if ('\0' == r
->last
->end
[j
] &&
707 ('\0' == (*bufp
)[i
] ||
709 '\t' == (*bufp
)[i
])) {
711 roffnode_cleanscope(r
);
713 if (ROFF_MAX
!= roff_parse(*bufp
, &pos
))
720 * If we have no custom end-query or lookup failed, then try
721 * pulling it out of the hashtable.
725 t
= roff_parse(*bufp
, &pos
);
727 /* If we're not a comment-end, then throw it away. */
728 if (ROFF_cblock
!= t
)
731 assert(roffs
[t
].proc
);
732 return((*roffs
[t
].proc
)(r
, t
, bufp
, szp
,
733 ln
, ppos
, pos
, offs
));
739 roff_block_text(ROFF_ARGS
)
748 roff_cond_sub(ROFF_ARGS
)
757 * Clean out scope. If we've closed ourselves, then don't
761 roffnode_cleanscope(r
);
763 if (ROFF_MAX
== (t
= roff_parse(*bufp
, &pos
))) {
764 if ('\\' == (*bufp
)[pos
] && '}' == (*bufp
)[pos
+ 1])
766 (r
, ROFF_ccond
, bufp
, szp
,
767 ln
, pos
, pos
+ 2, offs
));
768 return(ROFFRULE_DENY
== rr
? ROFF_IGN
: ROFF_CONT
);
772 * A denied conditional must evaluate its children if and only
773 * if they're either structurally required (such as loops and
774 * conditionals) or a closing macro.
776 if (ROFFRULE_DENY
== rr
)
777 if ( ! (ROFFMAC_STRUCT
& roffs
[t
].flags
))
781 assert(roffs
[t
].proc
);
782 return((*roffs
[t
].proc
)(r
, t
, bufp
, szp
,
783 ln
, ppos
, pos
, offs
));
789 roff_cond_text(ROFF_ARGS
)
797 * We display the value of the text if out current evaluation
798 * scope permits us to do so.
801 /* FIXME: use roff_ccond? */
804 if (NULL
== (ep
= strstr(st
, "\\}"))) {
805 roffnode_cleanscope(r
);
806 return(ROFFRULE_DENY
== rr
? ROFF_IGN
: ROFF_CONT
);
809 if (ep
== st
|| (ep
> st
&& '\\' != *(ep
- 1)))
812 roffnode_cleanscope(r
);
813 return(ROFFRULE_DENY
== rr
? ROFF_IGN
: ROFF_CONT
);
818 roff_evalcond(const char *v
, int *pos
)
824 return(ROFFRULE_ALLOW
);
831 return(ROFFRULE_DENY
);
836 while (v
[*pos
] && ' ' != v
[*pos
])
838 return(ROFFRULE_DENY
);
858 /* Stack overflow! */
860 if (ROFF_ie
== tok
&& r
->rstackpos
== RSTACK_MAX
- 1) {
861 (*r
->msg
)(MANDOCERR_MEM
, r
->data
, ln
, ppos
, NULL
);
865 /* First, evaluate the conditional. */
867 if (ROFF_el
== tok
) {
869 * An `.el' will get the value of the current rstack
870 * entry set in prior `ie' calls or defaults to DENY.
872 if (r
->rstackpos
< 0)
873 rule
= ROFFRULE_DENY
;
875 rule
= r
->rstack
[r
->rstackpos
];
877 rule
= roff_evalcond(*bufp
, &pos
);
881 while (' ' == (*bufp
)[pos
])
885 * Roff is weird. If we have just white-space after the
886 * conditional, it's considered the BODY and we exit without
887 * really doing anything. Warn about this. It's probably
891 if ('\0' == (*bufp
)[pos
] && sv
!= pos
) {
892 if ((*r
->msg
)(MANDOCERR_NOARGS
, r
->data
, ln
, ppos
, NULL
))
897 roffnode_push(r
, tok
, ln
, ppos
);
899 r
->last
->rule
= rule
;
901 ROFF_DEBUG("roff: cond: %s -> %s\n", roffs
[tok
].name
,
902 ROFFRULE_ALLOW
== rule
? "allow" : "deny");
904 if (ROFF_ie
== tok
) {
906 * An if-else will put the NEGATION of the current
907 * evaluated conditional into the stack.
910 if (ROFFRULE_DENY
== r
->last
->rule
)
911 r
->rstack
[r
->rstackpos
] = ROFFRULE_ALLOW
;
913 r
->rstack
[r
->rstackpos
] = ROFFRULE_DENY
;
916 /* If the parent has false as its rule, then so do we. */
918 if (r
->last
->parent
&& ROFFRULE_DENY
== r
->last
->parent
->rule
) {
919 r
->last
->rule
= ROFFRULE_DENY
;
920 ROFF_DEBUG("roff: cond override: %s -> deny\n",
925 * Determine scope. If we're invoked with "\{" trailing the
926 * conditional, then we're in a multiline scope. Else our scope
927 * expires on the next line.
930 r
->last
->endspan
= 1;
932 if ('\\' == (*bufp
)[pos
] && '{' == (*bufp
)[pos
+ 1]) {
933 r
->last
->endspan
= -1;
935 ROFF_DEBUG("roff: cond-scope: %s, multi-line\n",
938 ROFF_DEBUG("roff: cond-scope: %s, one-line\n",
942 * If there are no arguments on the line, the next-line scope is
946 if ('\0' == (*bufp
)[pos
])
949 /* Otherwise re-run the roff parser after recalculating. */
963 * A symbol is named by the first word following the macro
964 * invocation up to a space. Its value is anything after the
965 * name's trailing whitespace and optional double-quote. Thus,
969 * will have `bar " ' as its value.
977 /* Read until end of name. */
978 while (*string
&& ' ' != *string
)
981 /* Nil-terminate name. */
985 /* Read past spaces. */
986 while (*string
&& ' ' == *string
)
989 /* Read passed initial double-quote. */
990 if (*string
&& '"' == *string
)
993 /* The rest is the value. */
994 roff_setstr(r
, name
, string
);
1003 const char *key
, *val
;
1006 key
= &(*bufp
)[pos
];
1009 /* Parse register request. */
1010 while ((*bufp
)[pos
] && ' ' != (*bufp
)[pos
])
1014 * Set our nil terminator. Because this line is going to be
1015 * ignored anyway, we can munge it as we please.
1018 (*bufp
)[pos
++] = '\0';
1020 /* Skip whitespace to register token. */
1021 while ((*bufp
)[pos
] && ' ' == (*bufp
)[pos
])
1024 val
= &(*bufp
)[pos
];
1026 /* Process register token. */
1028 if (0 == strcmp(key
, "nS")) {
1029 rg
[(int)REG_nS
].set
= 1;
1030 if ( ! roff_parse_nat(val
, &rg
[(int)REG_nS
].v
.u
))
1031 rg
[(int)REG_nS
].v
.u
= 0;
1033 ROFF_DEBUG("roff: register nS: %u\n",
1034 rg
[(int)REG_nS
].v
.u
);
1036 ROFF_DEBUG("roff: ignoring register: %s\n", key
);
1043 roff_strdup(const char *name
)
1045 char *namecopy
, *sv
;
1048 * This isn't a nice simple mandoc_strdup() because we must
1049 * handle roff's stupid double-escape rule.
1051 sv
= namecopy
= mandoc_malloc(strlen(name
) + 1);
1053 if ('\\' == *name
&& '\\' == *(name
+ 1))
1055 *namecopy
++ = *name
++;
1064 roff_setstr(struct roff
*r
, const char *name
, const char *string
)
1069 n
= r
->first_string
;
1070 while (n
&& strcmp(name
, n
->name
))
1074 namecopy
= mandoc_strdup(name
);
1075 n
= mandoc_malloc(sizeof(struct roffstr
));
1077 n
->next
= r
->first_string
;
1078 r
->first_string
= n
;
1082 /* Don't use mandoc_strdup: clean out double-escapes. */
1083 n
->string
= string
? roff_strdup(string
) : NULL
;
1084 ROFF_DEBUG("roff: new symbol: [%s] = [%s]\n", name
, n
->string
);
1089 roff_getstrn(const struct roff
*r
, const char *name
, size_t len
)
1091 const struct roffstr
*n
;
1093 n
= r
->first_string
;
1094 while (n
&& (strncmp(name
, n
->name
, len
) || '\0' != n
->name
[(int)len
]))
1097 return(n
? n
->string
: NULL
);
1102 roff_freestr(struct roff
*r
)
1104 struct roffstr
*n
, *nn
;
1106 for (n
= r
->first_string
; n
; n
= nn
) {
1113 r
->first_string
= NULL
;