diff options
author | charnier <charnier@FreeBSD.org> | 2002-04-12 13:08:00 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 2002-04-12 13:08:00 +0000 |
commit | eddee890415600dcbfacd7d1980e46a60cbc1979 (patch) | |
tree | 83b0b3eac3883d968424957e9b994ef3ef51bbd0 /usr.bin/mkstr | |
parent | 2bdf833956ffe1975ab810bd7e40ee2b7548a2dd (diff) | |
download | FreeBSD-src-eddee890415600dcbfacd7d1980e46a60cbc1979.zip FreeBSD-src-eddee890415600dcbfacd7d1980e46a60cbc1979.tar.gz |
Add FBSDID. Do not put spaces inside [] in usage string. Test memory allocation
return code. Correct and update C example in man page. Uppercase program name
(.Nm) after a dot.
Diffstat (limited to 'usr.bin/mkstr')
-rw-r--r-- | usr.bin/mkstr/mkstr.1 | 16 | ||||
-rw-r--r-- | usr.bin/mkstr/mkstr.c | 9 |
2 files changed, 13 insertions, 12 deletions
diff --git a/usr.bin/mkstr/mkstr.1 b/usr.bin/mkstr/mkstr.1 index c656630..03f37c1 100644 --- a/usr.bin/mkstr/mkstr.1 +++ b/usr.bin/mkstr/mkstr.1 @@ -86,7 +86,7 @@ ed program. .El .Pp -.Nm +.Nm Mkstr finds error messages in the source by searching for the string .Li \&`error("' @@ -108,14 +108,12 @@ error(a1, a2, a3, a4) if (efil < 0) { efil = open(efilname, 0); - if (efil < 0) { -oops: - perror(efilname); - exit 1 ; - } + if (efil < 0) + err(1, "%s", efilname); } - if (lseek(efil, (long) a1, 0) \ read(efil, buf, 256) <= 0) - goto oops; + if (lseek(efil, (off_t)a1, SEEK_SET) < 0 || + read(efil, buf, 256) <= 0) + err(1, "%s", efilname); printf(buf, a2, a3, a4); } .Ed @@ -127,7 +125,7 @@ oops: appeared in .Bx 3.0 . .Sh BUGS -.Nm +.Nm Mkstr was intended for the limited architecture of the PDP 11 family. Very few programs actually use it. The Pascal interpreter, diff --git a/usr.bin/mkstr/mkstr.c b/usr.bin/mkstr/mkstr.c index 2889cfd..fa526f2 100644 --- a/usr.bin/mkstr/mkstr.c +++ b/usr.bin/mkstr/mkstr.c @@ -41,10 +41,11 @@ static const char copyright[] = #if 0 static char sccsid[] = "@(#)mkstr.c 8.1 (Berkeley) 6/6/93"; #endif -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <err.h> #include <stdio.h> #include <stdlib.h> @@ -128,7 +129,7 @@ main(argc, argv) static void usage() { - fprintf(stderr, "usage: mkstr [ - ] mesgfile prefix file ...\n"); + fprintf(stderr, "usage: mkstr [-] mesgfile prefix file ...\n"); exit(1); } @@ -300,6 +301,8 @@ hashit(str, really, fakept) } if (!really || hp == 0) { hp = (struct hash *) calloc(1, sizeof *hp); + if (hp == NULL) + err(1, NULL); hp->hnext = bucket[i]; hp->hval = hashval; hp->hpt = really ? ftell(mesgwrite) : fakept; |