diff options
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | arch.c | 3 | ||||
-rw-r--r-- | att.c | 3 | ||||
-rw-r--r-- | chars.c | 1 | ||||
-rw-r--r-- | eqn.c | 1 | ||||
-rw-r--r-- | html.c | 1 | ||||
-rw-r--r-- | lib.c | 3 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | man.c | 1 | ||||
-rw-r--r-- | man_hash.c | 1 | ||||
-rw-r--r-- | man_validate.c | 1 | ||||
-rw-r--r-- | mandoc.3 | 80 | ||||
-rw-r--r-- | mandoc.c | 69 | ||||
-rw-r--r-- | mandoc.h | 7 | ||||
-rw-r--r-- | mandocdb.c | 1 | ||||
-rw-r--r-- | manpath.c | 2 | ||||
-rw-r--r-- | mansearch.c | 1 | ||||
-rw-r--r-- | mdoc.c | 1 | ||||
-rw-r--r-- | mdoc_argv.c | 1 | ||||
-rw-r--r-- | mdoc_hash.c | 1 | ||||
-rw-r--r-- | mdoc_man.c | 5 | ||||
-rw-r--r-- | mdoc_validate.c | 1 | ||||
-rw-r--r-- | msec.c | 1 | ||||
-rw-r--r-- | out.c | 1 | ||||
-rw-r--r-- | read.c | 1 | ||||
-rw-r--r-- | roff.c | 1 | ||||
-rw-r--r-- | st.c | 3 | ||||
-rw-r--r-- | tbl.c | 1 | ||||
-rw-r--r-- | tbl_data.c | 1 | ||||
-rw-r--r-- | tbl_layout.c | 2 | ||||
-rw-r--r-- | term.c | 2 | ||||
-rw-r--r-- | term_ascii.c | 2 | ||||
-rw-r--r-- | term_ps.c | 1 | ||||
-rw-r--r-- | vol.c | 3 |
34 files changed, 88 insertions, 126 deletions
@@ -124,6 +124,8 @@ SRCS = Makefile \ mandoc.3 \ mandoc.c \ mandoc.h \ + mandoc_aux.c \ + mandoc_aux.h \ mandoc_char.7 \ mandocdb.8 \ mandocdb.c \ @@ -201,6 +203,7 @@ LIBMANDOC_OBJS = $(LIBMAN_OBJS) \ $(LIBROFF_OBJS) \ chars.o \ mandoc.o \ + mandoc_aux.o \ msec.o \ read.o @@ -225,7 +228,7 @@ vol.o: vol.in $(LIBMAN_OBJS): libman.h $(LIBMDOC_OBJS): libmdoc.h $(LIBROFF_OBJS): libroff.h -$(LIBMANDOC_OBJS): mandoc.h mdoc.h man.h libmandoc.h config.h +$(LIBMANDOC_OBJS): mandoc.h mandoc_aux.h mdoc.h man.h libmandoc.h config.h $(COMPAT_OBJS): config.h compat_ohash.h MANDOC_HTML_OBJS = eqn_html.o \ @@ -252,10 +255,11 @@ MANDOC_OBJS = $(MANDOC_HTML_OBJS) \ main.o \ out.o \ tree.o -$(MANDOC_OBJS): main.h mandoc.h mdoc.h man.h config.h out.h +$(MANDOC_OBJS): main.h mandoc.h mandoc_aux.h mdoc.h man.h config.h out.h MANDOCDB_OBJS = mandocdb.o mansearch_const.o manpath.o -$(MANDOCDB_OBJS): mansearch.h mandoc.h mdoc.h man.h config.h manpath.h +$(MANDOCDB_OBJS): mansearch.h mandoc.h mandoc_aux.h \ + mdoc.h man.h config.h manpath.h PRECONV_OBJS = preconv.o $(PRECONV_OBJS): config.h @@ -18,12 +18,9 @@ #include "config.h" #endif -#include <stdlib.h> #include <string.h> -#include <time.h> #include "mdoc.h" -#include "mandoc.h" #include "libmdoc.h" #define LINE(x, y) \ @@ -18,12 +18,9 @@ #include "config.h" #endif -#include <stdlib.h> #include <string.h> -#include <time.h> #include "mdoc.h" -#include "mandoc.h" #include "libmdoc.h" #define LINE(x, y) \ @@ -25,6 +25,7 @@ #include <string.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "libmandoc.h" #define PRINT_HI 126 @@ -26,6 +26,7 @@ #include <time.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "libmandoc.h" #include "libroff.h" @@ -31,6 +31,7 @@ #include <unistd.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "libmandoc.h" #include "out.h" #include "html.h" @@ -18,12 +18,9 @@ #include "config.h" #endif -#include <stdlib.h> #include <string.h> -#include <time.h> #include "mdoc.h" -#include "mandoc.h" #include "libmdoc.h" #define LINE(x, y) \ @@ -28,6 +28,7 @@ #include <unistd.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "main.h" #include "mdoc.h" #include "man.h" @@ -30,6 +30,7 @@ #include "man.h" #include "mandoc.h" +#include "mandoc_aux.h" #include "libman.h" #include "libmandoc.h" @@ -23,7 +23,6 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <stdlib.h> #include <string.h> #include "man.h" diff --git a/man_validate.c b/man_validate.c index 8ab5c2c5..43f0b691 100644 --- a/man_validate.c +++ b/man_validate.c @@ -32,6 +32,7 @@ #include "man.h" #include "mandoc.h" +#include "mandoc_aux.h" #include "libman.h" #include "libmandoc.h" @@ -20,7 +20,12 @@ .Os .Sh NAME .Nm mandoc , +.Nm mandoc_calloc , .Nm mandoc_escape , +.Nm mandoc_malloc , +.Nm mandoc_realloc , +.Nm mandoc_strdup , +.Nm mandoc_strndup , .Nm man_meta , .Nm man_mparse , .Nm man_node , @@ -45,28 +50,30 @@ .Sh LIBRARY .Lb libmandoc .Sh SYNOPSIS -.In man.h -.In mdoc.h .In mandoc.h +.Fd "#define ASCII_NBRSP" +.Fd "#define ASCII_HYPH" +.Fd "#define ASCII_BREAK" +.Ft "void *" +.Fo mandoc_calloc +.Fa "size_t nmemb" +.Fa "size_t size" +.Fc .Ft "enum mandoc_esc" .Fo mandoc_escape .Fa "const char **end" .Fa "const char **start" .Fa "int *sz" .Fc -.Ft "const struct man_meta *" -.Fo man_meta -.Fa "const struct man *man" -.Fc -.Ft "const struct mparse *" -.Fo man_mparse -.Fa "const struct man *man" -.Fc -.Ft "const struct man_node *" -.Fo man_node -.Fa "const struct man *man" -.Fc +.Ft "void *" +.Fn mandoc_malloc "size_t size" .Ft "struct mchars *" +.Fo mandoc_realloc +.Fa "void *ptr" +.Fa "size_t size" +.Fc +.Ft "char *" +.Fn mandoc_strdup .Fn mchars_alloc "void" .Ft void .Fn mchars_free "struct mchars *p" @@ -87,14 +94,6 @@ .Fa "const char *cp" .Fa "size_t sz" .Fc -.Ft "const struct mdoc_meta *" -.Fo mdoc_meta -.Fa "const struct mdoc *mdoc" -.Fc -.Ft "const struct mdoc_node *" -.Fo mdoc_node -.Fa "const struct mdoc *mdoc" -.Fc .Ft void .Fo mparse_alloc .Fa "enum mparset inttype" @@ -104,6 +103,15 @@ .Fa "int quick" .Fc .Ft void +.Fo (*mandocmsg) +.Fa "enum mandocerr errtype" +.Fa "enum mandoclevel level" +.Fa "const char *file" +.Fa "int line" +.Fa "int col" +.Fa "const char *msg" +.Fc +.Ft void .Fo mparse_free .Fa "struct mparse *parse" .Fc @@ -139,11 +147,33 @@ .Fo mparse_strlevel .Fa "enum mandoclevel" .Fc -.Vt extern const char * const * man_macronames; +.In mandoc.h +.In mdoc.h +.Ft "const struct mdoc_meta *" +.Fo mdoc_meta +.Fa "const struct mdoc *mdoc" +.Fc +.Ft "const struct mdoc_node *" +.Fo mdoc_node +.Fa "const struct mdoc *mdoc" +.Fc .Vt extern const char * const * mdoc_argnames; .Vt extern const char * const * mdoc_macronames; -.Fd "#define ASCII_NBRSP" -.Fd "#define ASCII_HYPH" +.In mandoc.h +.In man.h +.Ft "const struct man_meta *" +.Fo man_meta +.Fa "const struct man *man" +.Fc +.Ft "const struct mparse *" +.Fo man_mparse +.Fa "const struct man *man" +.Fc +.Ft "const struct man_node *" +.Fo man_node +.Fa "const struct man *man" +.Fc +.Vt extern const char * const * man_macronames; .Sh DESCRIPTION The .Nm mandoc @@ -31,6 +31,7 @@ #include <time.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "libmandoc.h" #define DATESIZE 32 @@ -353,74 +354,6 @@ mandoc_escape(const char **end, const char **start, int *sz) return(gly); } -void * -mandoc_calloc(size_t num, size_t size) -{ - void *ptr; - - ptr = calloc(num, size); - if (NULL == ptr) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } - - return(ptr); -} - - -void * -mandoc_malloc(size_t size) -{ - void *ptr; - - ptr = malloc(size); - if (NULL == ptr) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } - - return(ptr); -} - - -void * -mandoc_realloc(void *ptr, size_t size) -{ - - ptr = realloc(ptr, size); - if (NULL == ptr) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } - - return(ptr); -} - -char * -mandoc_strndup(const char *ptr, size_t sz) -{ - char *p; - - p = mandoc_malloc(sz + 1); - memcpy(p, ptr, sz); - p[(int)sz] = '\0'; - return(p); -} - -char * -mandoc_strdup(const char *ptr) -{ - char *p; - - p = strdup(ptr); - if (NULL == p) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } - - return(p); -} - /* * Parse a quoted or unquoted roff-style request or macro argument. * Return a pointer to the parsed argument, which is either the original @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -405,12 +405,7 @@ struct man; __BEGIN_DECLS -void *mandoc_calloc(size_t, size_t); enum mandoc_esc mandoc_escape(const char **, const char **, int *); -void *mandoc_malloc(size_t); -void *mandoc_realloc(void *, size_t); -char *mandoc_strdup(const char *); -char *mandoc_strndup(const char *, size_t); struct mchars *mchars_alloc(void); void mchars_free(struct mchars *); char mchars_num2char(const char *, size_t); @@ -46,6 +46,7 @@ #include "mdoc.h" #include "man.h" #include "mandoc.h" +#include "mandoc_aux.h" #include "manpath.h" #include "mansearch.h" @@ -26,7 +26,7 @@ #include <stdlib.h> #include <string.h> -#include "mandoc.h" +#include "mandoc_aux.h" #include "manpath.h" #define MAN_CONF_FILE "/etc/man.conf" diff --git a/mansearch.c b/mansearch.c index 562ca636..9caf434e 100644 --- a/mansearch.c +++ b/mansearch.c @@ -39,6 +39,7 @@ #include <sqlite3.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "manpath.h" #include "mansearch.h" @@ -30,6 +30,7 @@ #include "mdoc.h" #include "mandoc.h" +#include "mandoc_aux.h" #include "libmdoc.h" #include "libmandoc.h" diff --git a/mdoc_argv.c b/mdoc_argv.c index d0da16d3..a7e609b1 100644 --- a/mdoc_argv.c +++ b/mdoc_argv.c @@ -28,6 +28,7 @@ #include "mdoc.h" #include "mandoc.h" +#include "mandoc_aux.h" #include "libmdoc.h" #include "libmandoc.h" diff --git a/mdoc_hash.c b/mdoc_hash.c index 9aad261a..da9a9836 100644 --- a/mdoc_hash.c +++ b/mdoc_hash.c @@ -28,7 +28,6 @@ #include <string.h> #include "mdoc.h" -#include "mandoc.h" #include "libmdoc.h" static unsigned char table[27 * 12]; @@ -23,6 +23,7 @@ #include <string.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "out.h" #include "man.h" #include "mdoc.h" @@ -461,7 +462,7 @@ print_offs(const char *v) /* * Set up the indentation for a list item; used from pre_it(). */ -void +static void print_width(const char *v, const struct mdoc_node *child, size_t defsz) { char buf[24]; @@ -513,7 +514,7 @@ print_width(const char *v, const struct mdoc_node *child, size_t defsz) TPremain = remain; } -void +static void print_count(int *count) { char buf[12]; diff --git a/mdoc_validate.c b/mdoc_validate.c index fd0db4b6..972c5ab8 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -36,6 +36,7 @@ #include "mdoc.h" #include "mandoc.h" +#include "mandoc_aux.h" #include "libmdoc.h" #include "libmandoc.h" @@ -18,7 +18,6 @@ #include "config.h" #endif -#include <stdlib.h> #include <string.h> #include "mandoc.h" @@ -28,6 +28,7 @@ #include <string.h> #include <time.h> +#include "mandoc_aux.h" #include "mandoc.h" #include "out.h" @@ -37,6 +37,7 @@ #include <unistd.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "libmandoc.h" #include "mdoc.h" #include "man.h" @@ -26,6 +26,7 @@ #include <string.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "libroff.h" #include "libmandoc.h" @@ -18,12 +18,9 @@ #include "config.h" #endif -#include <stdlib.h> #include <string.h> -#include <time.h> #include "mdoc.h" -#include "mandoc.h" #include "libmdoc.h" #define LINE(x, y) \ @@ -26,6 +26,7 @@ #include <time.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "libmandoc.h" #include "libroff.h" @@ -26,6 +26,7 @@ #include <time.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "libmandoc.h" #include "libroff.h" diff --git a/tbl_layout.c b/tbl_layout.c index 618be8c6..835ea613 100644 --- a/tbl_layout.c +++ b/tbl_layout.c @@ -19,13 +19,13 @@ #include "config.h" #endif -#include <assert.h> #include <ctype.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "libmandoc.h" #include "libroff.h" @@ -23,12 +23,12 @@ #include <assert.h> #include <ctype.h> -#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "out.h" #include "term.h" #include "main.h" diff --git a/term_ascii.c b/term_ascii.c index b2e88b9c..3fccc675 100644 --- a/term_ascii.c +++ b/term_ascii.c @@ -20,7 +20,6 @@ #include <sys/types.h> -#include <assert.h> #ifdef USE_WCHAR # include <locale.h> #endif @@ -33,6 +32,7 @@ #endif #include "mandoc.h" +#include "mandoc_aux.h" #include "out.h" #include "term.h" #include "main.h" @@ -30,6 +30,7 @@ #include <unistd.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "out.h" #include "main.h" #include "term.h" @@ -18,12 +18,9 @@ #include "config.h" #endif -#include <stdlib.h> #include <string.h> -#include <time.h> #include "mdoc.h" -#include "mandoc.h" #include "libmdoc.h" #define LINE(x, y) \ |