diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-10-31 06:10:57 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-10-31 06:10:57 +0000 |
commit | fecec57074220c2494d1098ec3e1fa90362a1e44 (patch) | |
tree | 496a201f25ed00e58a64f0ead626620bb1c08a5e | |
parent | 9b34de59b184407dc87af383dc2b149c837e3b8b (diff) | |
download | mandoc-fecec57074220c2494d1098ec3e1fa90362a1e44.tar.gz |
Using perror() instead of fprintf for failure from library functions.
-rw-r--r-- | chars.c | 4 | ||||
-rw-r--r-- | html.c | 4 | ||||
-rw-r--r-- | main.c | 28 | ||||
-rw-r--r-- | man_action.c | 2 | ||||
-rw-r--r-- | mandoc.c | 8 | ||||
-rw-r--r-- | mdoc_action.c | 2 | ||||
-rw-r--r-- | mdoc_html.c | 2 | ||||
-rw-r--r-- | mdoc_validate.c | 1 | ||||
-rw-r--r-- | term.c | 4 |
9 files changed, 24 insertions, 31 deletions
@@ -91,13 +91,13 @@ chars_init(enum chars type) tab = malloc(sizeof(struct tbl)); if (NULL == tab) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } htab = calloc(PRINT_HI - PRINT_LO + 1, sizeof(struct ln **)); if (NULL == htab) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } @@ -101,7 +101,7 @@ html_alloc(char *outopts) h = calloc(1, sizeof(struct html)); if (NULL == h) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } @@ -354,7 +354,7 @@ print_otag(struct html *h, enum htmltag tag, if ( ! (HTML_NOSTACK & htmltags[tag].flags)) { t = malloc(sizeof(struct tag)); if (NULL == t) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } t->tag = tag; @@ -17,7 +17,6 @@ #include <sys/stat.h> #include <assert.h> -#include <err.h> #include <fcntl.h> #include <stdio.h> #include <stdint.h> @@ -285,14 +284,14 @@ ffile(struct buf *blk, struct buf *ln, curp->file = file; if (-1 == (curp->fd = open(curp->file, O_RDONLY, 0))) { - warn("%s", curp->file); + perror(curp->file); return(-1); } c = fdesc(blk, ln, curp); if (-1 == close(curp->fd)) - warn("%s", curp->file); + perror(curp->file); return(c); } @@ -319,15 +318,15 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp) */ if (-1 == fstat(curp->fd, &st)) - warn("%s", curp->file); + perror(curp->file); else if ((size_t)st.st_blksize > sz) sz = st.st_blksize; if (sz > blk->sz) { blk->buf = realloc(blk->buf, sz); if (NULL == blk->buf) { - warn("realloc"); - return(-1); + perror(NULL); + exit(EXIT_FAILURE); } blk->sz = sz; } @@ -336,7 +335,7 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp) for (lnn = pos = comment = 0; ; ) { if (-1 == (ssz = read(curp->fd, blk->buf, sz))) { - warn("%s", curp->file); + perror(curp->file); return(-1); } else if (0 == ssz) break; @@ -348,8 +347,8 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp) ln->sz += 256; /* Step-size. */ ln->buf = realloc(ln->buf, ln->sz); if (NULL == ln->buf) { - warn("realloc"); - return(-1); + perror(NULL); + return(EXIT_FAILURE); } } @@ -412,8 +411,7 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp) /* NOTE a parser may not have been assigned, yet. */ if ( ! (man || mdoc)) { - (void)fprintf(stderr, "%s: not a manual\n", - curp->file); + fprintf(stderr, "%s: Not a manual\n", curp->file); return(0); } @@ -528,7 +526,7 @@ moptions(enum intt *tflags, char *arg) else if (0 == strcmp(arg, "an")) *tflags = INTT_MAN; else { - warnx("bad argument: -m%s", arg); + fprintf(stderr, "%s: Bad argument", arg); return(0); } @@ -549,7 +547,7 @@ toptions(enum outt *tflags, char *arg) else if (0 == strcmp(arg, "html")) *tflags = OUTT_HTML; else { - warnx("bad argument: -T%s", arg); + fprintf(stderr, "%s: Bad argument", arg); return(0); } @@ -598,7 +596,7 @@ foptions(int *fflags, char *arg) *fflags &= ~NO_IGN_ESCAPE; break; default: - warnx("bad argument: -f%s", o); + fprintf(stderr, "%s: Bad argument", o); return(0); } } @@ -627,7 +625,7 @@ woptions(int *wflags, char *arg) *wflags |= WARN_WERR; break; default: - warnx("bad argument: -W%s", o); + fprintf(stderr, "%s: Bad argument", o); return(0); } } diff --git a/man_action.c b/man_action.c index 876beabf..19e11e39 100644 --- a/man_action.c +++ b/man_action.c @@ -17,7 +17,6 @@ #include <sys/utsname.h> #include <assert.h> -#include <errno.h> #include <stdlib.h> #include <string.h> @@ -149,7 +148,6 @@ post_TH(struct man *m) n = n->next; assert(n); - errno = 0; lval = strtol(n->string, &ep, 10); if (n->string[0] != '\0' && *ep == '\0') m->meta.msec = (int)lval; @@ -113,7 +113,7 @@ mandoc_calloc(size_t num, size_t size) ptr = calloc(num, size); if (NULL == ptr) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } @@ -128,7 +128,7 @@ mandoc_malloc(size_t size) ptr = malloc(size); if (NULL == ptr) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } @@ -142,7 +142,7 @@ mandoc_realloc(void *ptr, size_t size) ptr = realloc(ptr, size); if (NULL == ptr) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } @@ -157,7 +157,7 @@ mandoc_strdup(const char *ptr) p = strdup(ptr); if (NULL == p) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } diff --git a/mdoc_action.c b/mdoc_action.c index 9fc20184..d41f5073 100644 --- a/mdoc_action.c +++ b/mdoc_action.c @@ -19,7 +19,6 @@ #endif #include <assert.h> -#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -504,7 +503,6 @@ post_dt(POST_ARGS) if (cp) { /* FIXME: where is strtonum!? */ m->meta.vol = mandoc_strdup(cp); - errno = 0; lval = strtol(nn->string, &ep, 10); if (nn->string[0] != '\0' && *ep == '\0') m->meta.msec = (int)lval; diff --git a/mdoc_html.c b/mdoc_html.c index 3d635df2..d79cb5d8 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1115,7 +1115,7 @@ mdoc_bl_pre(MDOC_ARGS) ord = malloc(sizeof(struct ord)); if (NULL == ord) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } ord->cookie = n; diff --git a/mdoc_validate.c b/mdoc_validate.c index 55f13212..61d4c3c6 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -18,7 +18,6 @@ #include <assert.h> #include <ctype.h> -#include <errno.h> #include <limits.h> #include <stdarg.h> #include <stdlib.h> @@ -78,7 +78,7 @@ term_alloc(enum termenc enc) p = calloc(1, sizeof(struct termp)); if (NULL == p) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } p->maxrmargin = 78; @@ -545,7 +545,7 @@ buffer(struct termp *p, char c) s = p->maxcols * 2; p->buf = realloc(p->buf, s); if (NULL == p->buf) { - fprintf(stderr, "memory exhausted\n"); + perror(NULL); exit(EXIT_FAILURE); } p->maxcols = s; |