summaryrefslogtreecommitdiffstats
path: root/usr.bin/global
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-07-10 06:43:41 +0000
committercharnier <charnier@FreeBSD.org>1997-07-10 06:43:41 +0000
commitfecd0ac4cdef9377593fc851182a346a94294b0e (patch)
tree0fb12c3644db61789c6f527c9682b110e11f998c /usr.bin/global
parent4765108b7fc3b4edb3217b78787d658afad4c1ad (diff)
downloadFreeBSD-src-fecd0ac4cdef9377593fc851182a346a94294b0e.zip
FreeBSD-src-fecd0ac4cdef9377593fc851182a346a94294b0e.tar.gz
Add usage(), use err(3).
Diffstat (limited to 'usr.bin/global')
-rw-r--r--usr.bin/global/btreeop/btreeop.c22
-rw-r--r--usr.bin/global/gctags/ctags.c57
-rw-r--r--usr.bin/global/gctags/tree.c21
3 files changed, 50 insertions, 50 deletions
diff --git a/usr.bin/global/btreeop/btreeop.c b/usr.bin/global/btreeop/btreeop.c
index a202578..d090e59 100644
--- a/usr.bin/global/btreeop/btreeop.c
+++ b/usr.bin/global/btreeop/btreeop.c
@@ -31,6 +31,8 @@
* btreeop.c 21-Apr-97
*
*/
+#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -41,7 +43,6 @@
#include <fcntl.h>
char *dbdefault = "btree"; /* default database name */
-char *progname = "btreeop"; /* command name */
char *dbname;
char buf[BUFSIZ+1];
@@ -53,7 +54,7 @@ char buf[BUFSIZ+1];
#endif
#endif
void die __P((char *));
-void usage __P((void));
+static void usage __P((void));
void entab __P((char *));
void main __P((int, char **));
int dbwrite __P((DB *));
@@ -74,15 +75,15 @@ void
die(s)
char *s;
{
- fprintf(stderr, "%s: %s\n", progname, s);
- exit(1);
+ errx(1, "%s", s);
}
-void
-usage() {
- fprintf(stderr,
- "usage: %s [-A][-C][-D key][-K key][-b][-c cachesize][-l][-p psize][dbname]\n",
- progname);
+static void
+usage()
+{
+ fprintf(stderr, "%s\n%s\n",
+ "usage: btreeop [-A][-C][-D key][-K key][-b][-c cachesize]",
+ " [-l][-p psize][dbname]");
exit(1);
}
@@ -123,7 +124,6 @@ char *buf;
buf[dst] = 0;
}
-#include <errno.h>
void
main(argc, argv)
int argc;
@@ -147,7 +147,7 @@ char *argv[];
info.prefix = NULL;
info.lorder = LITTLE_ENDIAN;
- while ((c = getopt(argc, argv, "ACD:K:bc:lp:")) != EOF) {
+ while ((c = getopt(argc, argv, "ACD:K:bc:lp:")) != -1) {
switch (c) {
case 'K':
case 'D':
diff --git a/usr.bin/global/gctags/ctags.c b/usr.bin/global/gctags/ctags.c
index f73a6bd..4bf8305 100644
--- a/usr.bin/global/gctags/ctags.c
+++ b/usr.bin/global/gctags/ctags.c
@@ -32,15 +32,20 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1987, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
static char sccsid[] = "@(#)ctags.c 8.3 (Berkeley) 4/2/94";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* LIBC_SCCS and not lint */
+#include <err.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
@@ -86,7 +91,7 @@ char lbuf[LINE_MAX];
void init __P((void));
void find_entries __P((char *));
-int main __P((int, char **));
+static void usage __P((void));
int
main(argc, argv)
@@ -108,9 +113,9 @@ main(argc, argv)
#endif
aflag = uflag = NO;
#ifdef GTAGS
- while ((ch = getopt(argc, argv, "BDFadef:rtuwvxy")) != EOF)
+ while ((ch = getopt(argc, argv, "BDFadef:rtuwvxy")) != -1)
#else
- while ((ch = getopt(argc, argv, "BFadf:tuwvx")) != EOF)
+ while ((ch = getopt(argc, argv, "BFadf:tuwvx")) != -1)
#endif
switch(ch) {
case 'B':
@@ -159,19 +164,12 @@ main(argc, argv)
break;
case '?':
default:
- goto usage;
+ usage();
}
argv += optind;
argc -= optind;
- if (!argc) {
-usage: (void)fprintf(stderr,
-#ifdef GTAGS
- "usage: ctags [-BDFadrtuwvx] [-f tagsfile] file ...\n");
-#else
- "usage: ctags [-BFadtuwvx] [-f tagsfile] file ...\n");
-#endif
- exit(1);
- }
+ if (!argc)
+ usage();
#ifdef GTAGS
if (rflag)
gtagopen();
@@ -180,7 +178,7 @@ usage: (void)fprintf(stderr,
for (exit_val = step = 0; step < argc; ++step)
if (!(inf = fopen(argv[step], "r"))) {
- fprintf(stderr, "gctags: %s cannot open\n", argv[step]);
+ warnx("%s cannot open", argv[step]);
exit_val = 1;
}
else {
@@ -204,7 +202,7 @@ usage: (void)fprintf(stderr,
++aflag;
}
if (!(outf = fopen(outfile, aflag ? "a" : "w"))) {
- fprintf(stderr, "gctags: %s cannot open\n", outfile);
+ warnx("%s cannot open", outfile);
exit(exit_val);
}
put_entries(head);
@@ -222,6 +220,18 @@ usage: (void)fprintf(stderr,
exit(exit_val);
}
+static void
+usage()
+{
+ (void)fprintf(stderr,
+#ifdef GTAGS
+ "usage: gctags [-BDFadrtuwvx] [-f tagsfile] file ...\n");
+#else
+ "usage: gctags [-BFadtuwvx] [-f tagsfile] file ...\n");
+#endif
+ exit(1);
+}
+
/*
* init --
* this routine sets up the boolean psuedo-functions which work by
@@ -366,10 +376,8 @@ gtagopen()
#define O_RDONLY 0x0000 /* open for reading only */
db = dbopen(dbname, O_RDONLY, 0, DB_BTREE, &info);
- if (db == 0) {
- fprintf(stderr, "GTAGS file needed.\n");
- exit(1);
- }
+ if (db == 0)
+ errx(1, "GTAGS file needed");
}
int
isdefined(skey)
@@ -386,8 +394,7 @@ char *skey;
case RET_SUCCESS:
return(1); /* exist */
case RET_ERROR:
- fprintf(stderr, "db->get failed.\n");
- exit(1);
+ errx(1, "db->get failed");
case RET_SPECIAL: /* not exist */
break;
}
@@ -396,9 +403,7 @@ char *skey;
void
gtagclose()
{
- if (db->close(db)) {
- fprintf(stderr, "GTAGS cannot close.(dbclose)\n");
- exit(1);
- }
+ if (db->close(db))
+ errx(1, "GTAGS cannot close.(dbclose)");
}
#endif
diff --git a/usr.bin/global/gctags/tree.c b/usr.bin/global/gctags/tree.c
index 831691a..4d6f858 100644
--- a/usr.bin/global/gctags/tree.c
+++ b/usr.bin/global/gctags/tree.c
@@ -35,6 +35,7 @@
static char sccsid[] = "@(#)tree.c 8.3 (Berkeley) 4/2/94";
#endif /* LIBC_SCCS and not lint */
+#include <err.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
@@ -60,14 +61,12 @@ pfnote(name, ln)
/*NOSTRICT*/
if (!(np = (NODE *)malloc(sizeof(NODE)))) {
- fprintf(stderr, "too many entries to sort");
+ warnx("too many entries to sort");
put_entries(head);
free_tree(head);
/*NOSTRICT*/
- if (!(head = np = (NODE *)malloc(sizeof(NODE)))) {
- fprintf(stderr, "gctags: out of space\n");
- exit(1);
- }
+ if (!(head = np = (NODE *)malloc(sizeof(NODE))))
+ errx(1, "out of space");
}
if (!xflag && !strcmp(name, "main")) {
if (!(fp = strrchr(curfile, '/')))
@@ -80,17 +79,13 @@ pfnote(name, ln)
*fp = EOS;
name = nbuf;
}
- if (!(np->entry = strdup(name))) {
- fprintf(stderr, "gctags: out of space\n");
- exit(1);
- }
+ if (!(np->entry = strdup(name)))
+ errx(1, "out of space");
np->file = curfile;
np->lno = ln;
np->left = np->right = 0;
- if (!(np->pat = strdup(lbuf))) {
- fprintf(stderr, "gctags: out of space\n");
- exit(1);
- }
+ if (!(np->pat = strdup(lbuf)))
+ errx(1, "out of space");
if (!head)
head = np;
else
OpenPOWER on IntegriCloud