version 1.102, 2009/08/19 14:09:33 |
version 1.106, 2009/09/23 11:53:45 |
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
|
#include <sys/types.h> |
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
#include <stdarg.h> |
#include <stdarg.h> |
Line 230 mdoc_free(struct mdoc *mdoc) |
|
Line 232 mdoc_free(struct mdoc *mdoc) |
|
{ |
{ |
|
|
mdoc_free1(mdoc); |
mdoc_free1(mdoc); |
if (mdoc->htab) |
|
mdoc_hash_free(mdoc->htab); |
|
free(mdoc); |
free(mdoc); |
} |
} |
|
|
Line 249 mdoc_alloc(void *data, int pflags, const struct mdoc_c |
|
Line 249 mdoc_alloc(void *data, int pflags, const struct mdoc_c |
|
if (cb) |
if (cb) |
(void)memcpy(&p->cb, cb, sizeof(struct mdoc_cb)); |
(void)memcpy(&p->cb, cb, sizeof(struct mdoc_cb)); |
|
|
|
mdoc_hash_init(); |
|
|
p->data = data; |
p->data = data; |
p->pflags = pflags; |
p->pflags = pflags; |
|
|
if (NULL == (p->htab = mdoc_hash_alloc())) { |
if (mdoc_alloc1(p)) |
free(p); |
|
return(NULL); |
|
} else if (mdoc_alloc1(p)) |
|
return(p); |
return(p); |
|
|
free(p); |
free(p); |
Line 682 macrowarn(struct mdoc *m, int ln, const char *buf) |
|
Line 681 macrowarn(struct mdoc *m, int ln, const char *buf) |
|
int |
int |
parsemacro(struct mdoc *m, int ln, char *buf) |
parsemacro(struct mdoc *m, int ln, char *buf) |
{ |
{ |
int i, j, c, ppos; |
int i, j, c; |
char mac[5]; |
char mac[5]; |
|
|
/* Empty lines are ignored. */ |
/* Empty lines are ignored. */ |
Line 702 parsemacro(struct mdoc *m, int ln, char *buf) |
|
Line 701 parsemacro(struct mdoc *m, int ln, char *buf) |
|
return(1); |
return(1); |
} |
} |
|
|
ppos = i; |
|
|
|
/* Copy the first word into a nil-terminated buffer. */ |
/* Copy the first word into a nil-terminated buffer. */ |
|
|
for (j = 0; j < 4; j++, i++) { |
for (j = 0; j < 4; j++, i++) { |
Line 711 parsemacro(struct mdoc *m, int ln, char *buf) |
|
Line 708 parsemacro(struct mdoc *m, int ln, char *buf) |
|
break; |
break; |
else if (' ' == buf[i]) |
else if (' ' == buf[i]) |
break; |
break; |
|
|
|
/* Check for invalid characters. */ |
|
|
|
if (isgraph((u_char)buf[i])) |
|
continue; |
|
return(mdoc_perr(m, ln, i, EPRINT)); |
} |
} |
|
|
mac[j] = 0; |
mac[j] = 0; |
Line 721 parsemacro(struct mdoc *m, int ln, char *buf) |
|
Line 724 parsemacro(struct mdoc *m, int ln, char *buf) |
|
return(1); |
return(1); |
} |
} |
|
|
if (MDOC_MAX == (c = mdoc_hash_find(m->htab, mac))) { |
if (MDOC_MAX == (c = mdoc_hash_find(mac))) { |
if ( ! macrowarn(m, ln, mac)) |
if ( ! macrowarn(m, ln, mac)) |
goto err; |
goto err; |
return(1); |
return(1); |
Line 736 parsemacro(struct mdoc *m, int ln, char *buf) |
|
Line 739 parsemacro(struct mdoc *m, int ln, char *buf) |
|
* Begin recursive parse sequence. Since we're at the start of |
* Begin recursive parse sequence. Since we're at the start of |
* the line, we don't need to do callable/parseable checks. |
* the line, we don't need to do callable/parseable checks. |
*/ |
*/ |
if ( ! mdoc_macro(m, c, ln, ppos, &i, buf)) |
if ( ! mdoc_macro(m, c, ln, 1, &i, buf)) |
goto err; |
goto err; |
|
|
return(1); |
return(1); |