mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-04 12:52:15 +00:00
Add usage(), use err(3).
This commit is contained in:
parent
d49712cacf
commit
710d46eadc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27312
@ -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':
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user