summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-10-31 06:10:57 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-10-31 06:10:57 +0000
commita1af4f3969c284fb243f1c0534b332232d54dd98 (patch)
treea6470eccaa1d9774d21bfaf1de23bed99b2d5a75
parentb9ac7e789aa2c1bf358e1d967a0b87ef2322744b (diff)
downloadmandoc-a1af4f3969c284fb243f1c0534b332232d54dd98.tar.gz
mandoc-a1af4f3969c284fb243f1c0534b332232d54dd98.tar.zst
mandoc-a1af4f3969c284fb243f1c0534b332232d54dd98.zip
Using perror() instead of fprintf for failure from library functions.
-rw-r--r--chars.c6
-rw-r--r--html.c6
-rw-r--r--main.c30
-rw-r--r--man_action.c4
-rw-r--r--mandoc.c10
-rw-r--r--mdoc_action.c4
-rw-r--r--mdoc_html.c4
-rw-r--r--mdoc_validate.c3
-rw-r--r--term.c6
9 files changed, 33 insertions, 40 deletions
diff --git a/chars.c b/chars.c
index 34b1e9cd..880a1f6d 100644
--- a/chars.c
+++ b/chars.c
@@ -1,4 +1,4 @@
-/* $Id: chars.c,v 1.10 2009/10/30 18:43:24 kristaps Exp $ */
+/* $Id: chars.c,v 1.11 2009/10/31 06:10:57 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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);
}
diff --git a/html.c b/html.c
index f096720f..643896ef 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.74 2009/10/30 18:53:08 kristaps Exp $ */
+/* $Id: html.c,v 1.75 2009/10/31 06:10:57 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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;
diff --git a/main.c b/main.c
index 943bd620..e7392dd5 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.52 2009/10/30 05:58:37 kristaps Exp $ */
+/* $Id: main.c,v 1.53 2009/10/31 06:10:57 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 838cd263..a39f05fb 100644
--- a/man_action.c
+++ b/man_action.c
@@ -1,4 +1,4 @@
-/* $Id: man_action.c,v 1.22 2009/10/30 05:58:37 kristaps Exp $ */
+/* $Id: man_action.c,v 1.23 2009/10/31 06:10:58 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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;
diff --git a/mandoc.c b/mandoc.c
index 068b365d..7e880d47 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.5 2009/10/30 05:58:38 kristaps Exp $ */
+/* $Id: mandoc.c,v 1.6 2009/10/31 06:10:58 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 72c0e085..56057e06 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.47 2009/10/30 18:50:11 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.48 2009/10/31 06:10:58 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 186d9a5d..956bcf5e 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.43 2009/10/30 18:53:08 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.44 2009/10/31 06:10:58 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 0ca6190e..922546c2 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.51 2009/10/26 04:09:46 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.52 2009/10/31 06:10:58 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -18,7 +18,6 @@
#include <assert.h>
#include <ctype.h>
-#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
diff --git a/term.c b/term.c
index b9ee9e4c..fd30d990 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.119 2009/10/30 18:53:09 kristaps Exp $ */
+/* $Id: term.c,v 1.120 2009/10/31 06:10:58 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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;