Merge from verdor branch (v_3_4_2) and remove obsolete files.
This commit is contained in:
parent
6ba7b1c961
commit
f4a2ce54a0
@ -1,38 +0,0 @@
|
||||
GLOBAL cannot recognize following macros and functions.
|
||||
|
||||
1. Macro which doesn't end with ';'.
|
||||
|
||||
GLOBAL cannot recognize func() after M(a), because M(a) seems to be
|
||||
function definition.
|
||||
|
||||
#define M(a) static char *string = a;
|
||||
|
||||
M(a)
|
||||
|
||||
func() {
|
||||
...
|
||||
}
|
||||
|
||||
It should be follows.
|
||||
|
||||
#define M(a) static char *string = a
|
||||
|
||||
M(a);
|
||||
|
||||
func() {
|
||||
...
|
||||
}
|
||||
|
||||
2. Macro which is a renamed function.
|
||||
|
||||
#define func _func
|
||||
|
||||
_func() {
|
||||
...
|
||||
}
|
||||
main() {
|
||||
func();
|
||||
}
|
||||
|
||||
In fact, main() calls _func() instead of func() but GLOBAL cannot
|
||||
recognize it.
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -28,9 +28,10 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* btreeop.c 6-Nov-97
|
||||
* btreeop.c 12-Nov-98
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctype.h>
|
||||
@ -38,21 +39,20 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "dbio.h"
|
||||
#include "global.h"
|
||||
|
||||
char *dbdefault = "btree"; /* default database name */
|
||||
char *progname = "btreeop"; /* command name */
|
||||
const char *dbdefault = "btree"; /* default database name */
|
||||
const char *progname = "btreeop"; /* command name */
|
||||
|
||||
static void usage __P((void));
|
||||
void signal_setup __P((void));
|
||||
void onintr __P((int));
|
||||
void main __P((int, char **));
|
||||
void dbwrite __P((DBIO *));
|
||||
void dbkey __P((DBIO *, char *, int));
|
||||
void dbscan __P((DBIO *, char *, int));
|
||||
void dbdel __P((DBIO *, char *, int));
|
||||
void dbbysecondkey __P((DBIO *, int, char *, int));
|
||||
int main __P((int, char **));
|
||||
void dbwrite __P((DBOP *));
|
||||
void dbkey __P((DBOP *, char *, int));
|
||||
void dbscan __P((DBOP *, char *, int));
|
||||
void dbdel __P((DBOP *, char *, int));
|
||||
void dbbysecondkey __P((DBOP *, int, char *, int));
|
||||
|
||||
#define F_KEY 0
|
||||
#define F_DEL 1
|
||||
@ -61,7 +61,7 @@ static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "%s\n",
|
||||
"usage: btreeop [-A][-C][-D[n] key][-K[n] key][-L][-k prefix][dbname]");
|
||||
"usage: btreeop [-A][-C][-D[n] key][-K[n] key][-L[2]][-k prefix][dbname]");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ signal_setup()
|
||||
signal(SIGTERM, onintr);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
@ -94,11 +94,12 @@ char *argv[];
|
||||
char command = 'R';
|
||||
char *key = NULL;
|
||||
int mode = 0;
|
||||
char *dbname;
|
||||
DBIO *dbio;
|
||||
const char *db_name;
|
||||
DBOP *dbop;
|
||||
int i, c;
|
||||
int secondkey = 0;
|
||||
char *prefix = (char *)0;
|
||||
int keylist = 0;
|
||||
char *prefix = NULL;
|
||||
|
||||
for (i = 1; i < argc && argv[i][0] == '-'; ++i) {
|
||||
switch (c = argv[i][1]) {
|
||||
@ -106,22 +107,34 @@ char *argv[];
|
||||
case 'K':
|
||||
if (argv[i][2] && isdigit(argv[i][2]))
|
||||
secondkey = atoi(&argv[i][2]);
|
||||
key = argv[++i];
|
||||
if (++i < argc)
|
||||
key = argv[i];
|
||||
else
|
||||
usage();
|
||||
/* FALLTHROUGH */
|
||||
case 'A':
|
||||
case 'C':
|
||||
case 'L':
|
||||
if (command != 'R')
|
||||
usage();
|
||||
command = c;
|
||||
if (command == 'L') {
|
||||
keylist = 1;
|
||||
if (argv[i][2] == '2')
|
||||
keylist = 2;
|
||||
}
|
||||
break;
|
||||
case 'k':
|
||||
prefix = argv[++i];
|
||||
if (++i < argc)
|
||||
prefix = argv[i];
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
dbname = (i < argc) ? argv[i] : dbdefault;
|
||||
db_name = (i < argc) ? argv[i] : dbdefault;
|
||||
switch (command) {
|
||||
case 'A':
|
||||
case 'D':
|
||||
@ -136,27 +149,35 @@ char *argv[];
|
||||
mode = 0;
|
||||
break;
|
||||
}
|
||||
dbio = db_open(dbname, mode, 0644, DBIO_DUP);
|
||||
if (dbio == NULL)
|
||||
die1("db_open failed (dbname = %s).", dbname);
|
||||
|
||||
dbop = dbop_open(db_name, mode, 0644, DBOP_DUP);
|
||||
if (dbop == NULL) {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
case 2:
|
||||
die1("cannot open '%s'.", db_name);
|
||||
break;
|
||||
case 1:
|
||||
die1("cannot create '%s'.", db_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (command) {
|
||||
case 'A': /* Append records */
|
||||
case 'C': /* Create database */
|
||||
dbwrite(dbio);
|
||||
dbwrite(dbop);
|
||||
break;
|
||||
case 'D': /* Delete records */
|
||||
dbdel(dbio, key, secondkey);
|
||||
dbdel(dbop, key, secondkey);
|
||||
break;
|
||||
case 'K': /* Keyed (indexed) read */
|
||||
dbkey(dbio, key, secondkey);
|
||||
dbkey(dbop, key, secondkey);
|
||||
break;
|
||||
case 'R': /* sequencial Read */
|
||||
case 'L': /* primary key List */
|
||||
dbscan(dbio, prefix, (command == 'L') ? 1 : 0);
|
||||
dbscan(dbop, prefix, keylist);
|
||||
break;
|
||||
}
|
||||
db_close(dbio);
|
||||
dbop_close(dbop);
|
||||
if (exitflag)
|
||||
exit(1);
|
||||
exit(0);
|
||||
@ -164,11 +185,11 @@ char *argv[];
|
||||
/*
|
||||
* dbwrite: write to database
|
||||
*
|
||||
* i) dbio database
|
||||
* i) dbop database
|
||||
*/
|
||||
void
|
||||
dbwrite(dbio)
|
||||
DBIO *dbio;
|
||||
dbwrite(dbop)
|
||||
DBOP *dbop;
|
||||
{
|
||||
char *p;
|
||||
char keybuf[MAXKEYLEN+1];
|
||||
@ -194,7 +215,7 @@ DBIO *dbio;
|
||||
* +------------------
|
||||
* | __.VERSION 2
|
||||
*/
|
||||
while ((p = mgets(stdin, 0, NULL)) != NULL) {
|
||||
while ((p = mgets(stdin, NULL, 0)) != NULL) {
|
||||
if (exitflag)
|
||||
break;
|
||||
c = p;
|
||||
@ -215,89 +236,93 @@ DBIO *dbio;
|
||||
if (*c == 0)
|
||||
die("data part is null.");
|
||||
entab(p);
|
||||
db_put(dbio, keybuf, p);
|
||||
dbop_put(dbop, keybuf, p);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dbkey: Keyed search
|
||||
*
|
||||
* i) dbio database
|
||||
* i) dbop database
|
||||
* i) skey key for search
|
||||
* i) secondkey 0: primary key, >0: secondary key
|
||||
*/
|
||||
void
|
||||
dbkey(dbio, skey, secondkey)
|
||||
DBIO *dbio;
|
||||
dbkey(dbop, skey, secondkey)
|
||||
DBOP *dbop;
|
||||
char *skey;
|
||||
int secondkey;
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (!secondkey) {
|
||||
for (p = db_first(dbio, skey, 0); p; p = db_next(dbio))
|
||||
for (p = dbop_first(dbop, skey, 0); p; p = dbop_next(dbop))
|
||||
detab(stdout, p);
|
||||
return;
|
||||
}
|
||||
dbbysecondkey(dbio, F_KEY, skey, secondkey);
|
||||
dbbysecondkey(dbop, F_KEY, skey, secondkey);
|
||||
}
|
||||
|
||||
/*
|
||||
* dbscan: Scan records
|
||||
*
|
||||
* i) dbio database
|
||||
* i) dbop database
|
||||
* i) prefix prefix of primary key
|
||||
* i) keylist 0: key and data, 1: primary key only
|
||||
* i) keylist 0: data, 1: key, 2: key and data
|
||||
*/
|
||||
void
|
||||
dbscan(dbio, prefix, keylist)
|
||||
DBIO *dbio;
|
||||
dbscan(dbop, prefix, keylist)
|
||||
DBOP *dbop;
|
||||
char *prefix;
|
||||
int keylist;
|
||||
{
|
||||
char *p;
|
||||
int flags = DBIO_SKIPMETA;
|
||||
int flags = 0;
|
||||
|
||||
if (prefix)
|
||||
flags |= DBIO_PREFIX;
|
||||
flags |= DBOP_PREFIX;
|
||||
if (keylist)
|
||||
flags |= DBIO_KEY;
|
||||
flags |= DBOP_KEY;
|
||||
|
||||
for (p = db_first(dbio, prefix, flags); p; p = db_next(dbio))
|
||||
detab(stdout, p);
|
||||
for (p = dbop_first(dbop, prefix, flags); p; p = dbop_next(dbop)) {
|
||||
if (keylist == 2)
|
||||
fprintf(stdout, "%s %s\n", p, dbop->lastdat);
|
||||
else
|
||||
detab(stdout, p);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dbdel: Delete records
|
||||
*
|
||||
* i) dbio database
|
||||
* i) dbop database
|
||||
* i) skey key for search
|
||||
* i) secondkey 0: primary key, >0: secondary key
|
||||
*/
|
||||
void
|
||||
dbdel(dbio, skey, secondkey)
|
||||
DBIO *dbio;
|
||||
dbdel(dbop, skey, secondkey)
|
||||
DBOP *dbop;
|
||||
char *skey;
|
||||
int secondkey;
|
||||
{
|
||||
signal_setup();
|
||||
if (!secondkey) {
|
||||
db_del(dbio, skey);
|
||||
dbop_del(dbop, skey);
|
||||
return;
|
||||
}
|
||||
dbbysecondkey(dbio, F_DEL, skey, secondkey);
|
||||
dbbysecondkey(dbop, F_DEL, skey, secondkey);
|
||||
}
|
||||
/*
|
||||
* dbbysecondkey: proc by second key
|
||||
*
|
||||
* i) dbio database
|
||||
* i) dbop database
|
||||
* i) func F_KEY, F_DEL
|
||||
* i) skey
|
||||
* i) secondkey
|
||||
*/
|
||||
void
|
||||
dbbysecondkey(dbio, func, skey, secondkey)
|
||||
DBIO *dbio;
|
||||
dbbysecondkey(dbop, func, skey, secondkey)
|
||||
DBOP *dbop;
|
||||
int func;
|
||||
char *skey;
|
||||
int secondkey;
|
||||
@ -312,7 +337,7 @@ int secondkey;
|
||||
for (c = skey+strlen(skey)-1; *c && isspace(*c); c--)
|
||||
*c = 0;
|
||||
|
||||
for (p = db_first(dbio, NULL, DBIO_SKIPMETA); p; p = db_next(dbio)) {
|
||||
for (p = dbop_first(dbop, NULL, 0); p; p = dbop_next(dbop)) {
|
||||
if (exitflag)
|
||||
break;
|
||||
c = p;
|
||||
@ -334,7 +359,7 @@ int secondkey;
|
||||
detab(stdout, p);
|
||||
break;
|
||||
case F_DEL:
|
||||
db_del(dbio, NULL);
|
||||
dbop_del(dbop, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,379 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
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)
|
||||
static const char rcsid[] =
|
||||
"$Id: ctags.c,v 1.1.1.2 1997/12/15 23:08:35 cwt Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ctags.h"
|
||||
#ifdef GLOBAL
|
||||
#include "lookup.h"
|
||||
#include "die.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ctags: create a tags file
|
||||
*/
|
||||
|
||||
NODE *head; /* head of the sorted binary tree */
|
||||
|
||||
/* boolean "func" (see init()) */
|
||||
bool _wht[256], _etk[256], _itk[256], _btk[256], _gd[256];
|
||||
|
||||
FILE *inf; /* ioptr for current input file */
|
||||
FILE *outf; /* ioptr for tags file */
|
||||
|
||||
long lineftell; /* ftell after getc( inf ) == '\n' */
|
||||
|
||||
int lineno; /* line number of current line */
|
||||
#ifdef GLOBAL
|
||||
int cflag; /* -c: compact index */
|
||||
#endif
|
||||
int dflag; /* -d: non-macro defines */
|
||||
#ifdef GLOBAL
|
||||
int eflag; /* -e: '{' at 0 column force function end */
|
||||
#endif
|
||||
int tflag; /* -t: create tags for typedefs */
|
||||
int vflag; /* -v: vgrind style index output */
|
||||
int wflag; /* -w: suppress warnings */
|
||||
int xflag; /* -x: cxref style output */
|
||||
#ifdef GLOBAL
|
||||
int Dflag; /* -D: allow duplicate entrys */
|
||||
int rflag; /* -r: function reference */
|
||||
int sflag; /* -s: collect symbols */
|
||||
#endif
|
||||
#ifdef YACC
|
||||
int yaccfile; /* yacc file */
|
||||
#endif
|
||||
|
||||
char *curfile; /* current input file name */
|
||||
char searchar = '/'; /* use /.../ searches by default */
|
||||
char lbuf[LINE_MAX];
|
||||
char *progname = "gctags"; /* program name */
|
||||
|
||||
void init __P((void));
|
||||
void find_entries __P((char *));
|
||||
void main __P((int, char **));
|
||||
static void usage __P((void));
|
||||
|
||||
void
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
static char *outfile = "tags"; /* output file */
|
||||
int aflag; /* -a: append to tags */
|
||||
int uflag; /* -u: update tags */
|
||||
int exit_val; /* exit value */
|
||||
int step; /* step through args */
|
||||
int ch; /* getopts char */
|
||||
char cmd[100]; /* too ugly to explain */
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
aflag = uflag = NO;
|
||||
#ifdef GLOBAL
|
||||
while ((ch = getopt(argc, argv, "BDFacdef:rstuwvx")) != -1)
|
||||
#else
|
||||
while ((ch = getopt(argc, argv, "BFadf:tuwvx")) != -1)
|
||||
#endif
|
||||
switch(ch) {
|
||||
case 'B':
|
||||
searchar = '?';
|
||||
break;
|
||||
#ifdef GLOBAL
|
||||
case 'D':
|
||||
Dflag++;
|
||||
break;
|
||||
#endif
|
||||
case 'F':
|
||||
searchar = '/';
|
||||
break;
|
||||
#ifdef GLOBAL
|
||||
case 's':
|
||||
sflag++;
|
||||
break;
|
||||
#endif
|
||||
case 'a':
|
||||
aflag++;
|
||||
break;
|
||||
#ifdef GLOBAL
|
||||
case 'c':
|
||||
cflag++;
|
||||
break;
|
||||
#endif
|
||||
case 'd':
|
||||
dflag++;
|
||||
break;
|
||||
#ifdef GLOBAL
|
||||
case 'e':
|
||||
eflag++;
|
||||
break;
|
||||
#endif
|
||||
case 'f':
|
||||
outfile = optarg;
|
||||
break;
|
||||
#ifdef GLOBAL
|
||||
case 'r':
|
||||
rflag++;
|
||||
break;
|
||||
#endif
|
||||
case 't':
|
||||
tflag++;
|
||||
break;
|
||||
case 'u':
|
||||
uflag++;
|
||||
break;
|
||||
case 'w':
|
||||
wflag++;
|
||||
break;
|
||||
case 'v':
|
||||
vflag++;
|
||||
case 'x':
|
||||
xflag++;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
if (!argc)
|
||||
usage();
|
||||
#ifdef GLOBAL
|
||||
if (sflag && rflag)
|
||||
die("-s and -r conflict.");
|
||||
if (rflag) {
|
||||
char *dbpath;
|
||||
|
||||
if (!(dbpath = getenv("GTAGSDBPATH")))
|
||||
dbpath = ".";
|
||||
lookupopen(dbpath);
|
||||
}
|
||||
#endif
|
||||
init();
|
||||
|
||||
for (exit_val = step = 0; step < argc; ++step)
|
||||
if (!(inf = fopen(argv[step], "r"))) {
|
||||
fprintf(stderr, "%s: %s cannot open\n", progname, argv[step]);
|
||||
exit_val = 1;
|
||||
}
|
||||
else {
|
||||
curfile = argv[step];
|
||||
find_entries(argv[step]);
|
||||
(void)fclose(inf);
|
||||
}
|
||||
|
||||
if (head)
|
||||
if (xflag) {
|
||||
put_entries(head);
|
||||
#ifdef GLOBAL
|
||||
if (cflag)
|
||||
compact_print("", 0, "");/* flush last record */
|
||||
#endif
|
||||
} else {
|
||||
if (uflag) {
|
||||
for (step = 0; step < argc; step++) {
|
||||
(void)sprintf(cmd,
|
||||
"mv %s OTAGS; fgrep -v '\t%s\t' OTAGS >%s; rm OTAGS",
|
||||
outfile, argv[step],
|
||||
outfile);
|
||||
system(cmd);
|
||||
}
|
||||
++aflag;
|
||||
}
|
||||
if (!(outf = fopen(outfile, aflag ? "a" : "w"))) {
|
||||
fprintf(stderr, "%s: %s cannot open\n", progname, outfile);
|
||||
exit(exit_val);
|
||||
}
|
||||
put_entries(head);
|
||||
(void)fclose(outf);
|
||||
if (uflag) {
|
||||
(void)sprintf(cmd, "sort -o %s %s",
|
||||
outfile, outfile);
|
||||
system(cmd);
|
||||
}
|
||||
}
|
||||
#ifdef GLOBAL
|
||||
if (rflag)
|
||||
lookupclose();
|
||||
#endif
|
||||
exit(exit_val);
|
||||
}
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
#ifdef GLOBAL
|
||||
"usage: gctags [-BDFacderstuvwx] [-f tagsfile] file ...\n");
|
||||
#else
|
||||
"usage: ctags [-BFadtuwvx] [-f tagsfile] file ...\n");
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* init --
|
||||
* this routine sets up the boolean psuedo-functions which work by
|
||||
* setting boolean flags dependent upon the corresponding character.
|
||||
* Every char which is NOT in that string is false with respect to
|
||||
* the pseudo-function. Therefore, all of the array "_wht" is NO
|
||||
* by default and then the elements subscripted by the chars in
|
||||
* CWHITE are set to YES. Thus, "_wht" of a char is YES if it is in
|
||||
* the string CWHITE, else NO.
|
||||
*/
|
||||
void
|
||||
init()
|
||||
{
|
||||
int i;
|
||||
unsigned char *sp;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
_wht[i] = _etk[i] = _itk[i] = _btk[i] = NO;
|
||||
_gd[i] = YES;
|
||||
}
|
||||
#define CWHITE " \f\t\n"
|
||||
for (sp = (unsigned char *)CWHITE; *sp; sp++) /* white space chars */
|
||||
_wht[*sp] = YES;
|
||||
#define CTOKEN " \t\n\"'#()[]{}=-+%*/&|^~!<>;,.:?"
|
||||
for (sp = (unsigned char *)CTOKEN; *sp; sp++) /* token ending chars */
|
||||
_etk[*sp] = YES;
|
||||
#define CINTOK "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789"
|
||||
for (sp = (unsigned char *)CINTOK; *sp; sp++) /* valid in-token chars */
|
||||
_itk[*sp] = YES;
|
||||
#define CBEGIN "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
|
||||
for (sp = (unsigned char *)CBEGIN; *sp; sp++) /* token starting chars */
|
||||
_btk[*sp] = YES;
|
||||
#define CNOTGD ",;"
|
||||
for (sp = (unsigned char *)CNOTGD; *sp; sp++) /* invalid after-function chars */
|
||||
_gd[*sp] = NO;
|
||||
}
|
||||
|
||||
/*
|
||||
* find_entries --
|
||||
* this routine opens the specified file and calls the function
|
||||
* which searches the file.
|
||||
*/
|
||||
void
|
||||
find_entries(file)
|
||||
char *file;
|
||||
{
|
||||
char *cp;
|
||||
|
||||
lineno = 0; /* should be 1 ?? KB */
|
||||
if ((cp = strrchr(file, '.')) != NULL) {
|
||||
if (cp[1] == 'l' && !cp[2]) {
|
||||
int c;
|
||||
|
||||
#ifdef GLOBAL
|
||||
if (rflag)
|
||||
fprintf(stderr, "-r option is ignored in lisp file (Warning only)\n");
|
||||
#endif
|
||||
for (;;) {
|
||||
if (GETC(==, EOF))
|
||||
return;
|
||||
if (!iswhite(c)) {
|
||||
rewind(inf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#define LISPCHR ";(["
|
||||
/* lisp */ if (strchr(LISPCHR, c)) {
|
||||
l_entries();
|
||||
return;
|
||||
}
|
||||
/* lex */ else {
|
||||
/*
|
||||
* we search all 3 parts of a lex file
|
||||
* for C references. This may be wrong.
|
||||
*/
|
||||
toss_yysec();
|
||||
(void)strcpy(lbuf, "%%$");
|
||||
pfnote("yylex", lineno);
|
||||
rewind(inf);
|
||||
}
|
||||
}
|
||||
/* yacc */ else if (cp[1] == 'y' && !cp[2]) {
|
||||
#ifdef YACC
|
||||
/*
|
||||
* we search all part of a yacc file for C references.
|
||||
* but ignore yacc rule tags.
|
||||
*/
|
||||
yaccfile = YES;
|
||||
c_entries();
|
||||
return;
|
||||
#endif
|
||||
/*
|
||||
* we search only the 3rd part of a yacc file
|
||||
* for C references. This may be wrong.
|
||||
*/
|
||||
toss_yysec();
|
||||
(void)strcpy(lbuf, "%%$");
|
||||
pfnote("yyparse", lineno);
|
||||
y_entries();
|
||||
}
|
||||
#ifdef GLOBAL
|
||||
/* assembler */ else if ((cp[1] == 's' || cp[1] == 'S') && !cp[2]) {
|
||||
asm_entries();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
/* fortran */ else if ((cp[1] != 'c' && cp[1] != 'h') && !cp[2]) {
|
||||
#ifdef GLOBAL
|
||||
if (rflag)
|
||||
fprintf(stderr, "-r option is ignored in fortran file (Warning only)\n");
|
||||
#endif
|
||||
if (PF_funcs())
|
||||
return;
|
||||
rewind(inf);
|
||||
}
|
||||
}
|
||||
#ifdef YACC
|
||||
yaccfile = NO;
|
||||
#endif
|
||||
/* C */ c_entries();
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ctags.h 8.3 (Berkeley) 4/2/94
|
||||
*/
|
||||
|
||||
/* Definition for gctags */
|
||||
#define GLOBAL 1
|
||||
#define YACC 1
|
||||
|
||||
#define bool char
|
||||
|
||||
#define YES 1
|
||||
#define NO 0
|
||||
#define EOS '\0'
|
||||
|
||||
#define ENDLINE 50 /* max length of pattern */
|
||||
#define MAXTOKEN 250 /* max size of single token */
|
||||
|
||||
#ifndef LINE_MAX
|
||||
#define LINE_MAX 2048
|
||||
#endif
|
||||
|
||||
#define SETLINE {++lineno;lineftell = ftell(inf);}
|
||||
#ifdef GLOBAL
|
||||
#define GETC(op,exp) ((((c = getc(inf)) == '\r') ? (c = getc(inf)) : c) op (int)exp)
|
||||
#else
|
||||
#define GETC(op,exp) ((c = getc(inf)) op (int)exp)
|
||||
#endif
|
||||
|
||||
#define iswhite(arg) (_wht[(unsigned)arg]) /* T if char is white */
|
||||
#define begtoken(arg) (_btk[(unsigned)arg]) /* T if char can start token */
|
||||
#define intoken(arg) (_itk[(unsigned)arg]) /* T if char can be in token */
|
||||
#define endtoken(arg) (_etk[(unsigned)arg]) /* T if char ends tokens */
|
||||
#define isgood(arg) (_gd[(unsigned)arg]) /* T if char can be after ')' */
|
||||
|
||||
typedef struct nd_st { /* sorting structure */
|
||||
struct nd_st *left,
|
||||
*right; /* left and right sons */
|
||||
char *entry, /* function or type name */
|
||||
*file, /* file name */
|
||||
*pat; /* search pattern */
|
||||
int lno; /* for -x option */
|
||||
bool been_warned; /* set if noticed dup */
|
||||
} NODE;
|
||||
|
||||
extern char *curfile; /* current input file name */
|
||||
extern NODE *head; /* head of the sorted binary tree */
|
||||
extern FILE *inf; /* ioptr for current input file */
|
||||
extern FILE *outf; /* ioptr for current output file */
|
||||
extern long lineftell; /* ftell after getc( inf ) == '\n' */
|
||||
extern int lineno; /* line number of current line */
|
||||
#ifdef GLOBAL
|
||||
extern int cflag; /* -c: compact index */
|
||||
extern int eflag; /* -e: '{' at 0 column force function end */
|
||||
extern int Dflag; /* -D: allow duplicate entrys */
|
||||
extern int rflag; /* -r: function reference */
|
||||
extern int sflag; /* -s: collect symbols */
|
||||
#endif
|
||||
extern int dflag; /* -d: non-macro defines */
|
||||
extern int tflag; /* -t: create tags for typedefs */
|
||||
extern int vflag; /* -v: vgrind style index output */
|
||||
extern int wflag; /* -w: suppress warnings */
|
||||
extern int xflag; /* -x: cxref style output */
|
||||
extern bool _wht[], _etk[], _itk[], _btk[], _gd[];
|
||||
extern char lbuf[LINE_MAX];
|
||||
extern char *lbp;
|
||||
extern char searchar; /* ex search character */
|
||||
extern char *progname; /* program name */
|
||||
|
||||
#ifndef __P
|
||||
#ifdef __STDC__
|
||||
#define __P(protos) protos
|
||||
#else
|
||||
#define __P(protos) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int cicmp __P((char *));
|
||||
void getline __P((void));
|
||||
void pfnote __P((char *, int));
|
||||
int skip_key __P((int));
|
||||
void put_entries __P((NODE *));
|
||||
void toss_yysec __P((void));
|
||||
void l_entries __P((void));
|
||||
void y_entries __P((void));
|
||||
int PF_funcs __P((void));
|
||||
void c_entries __P((void));
|
||||
void skip_comment __P((void));
|
||||
#ifdef GLOBAL
|
||||
void asm_entries __P((void));
|
||||
void compact_print __P((char *, int, char *));
|
||||
int portable_getc __P((FILE *));
|
||||
#endif
|
@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)fortran.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ctags.h"
|
||||
|
||||
static void takeprec __P((void));
|
||||
|
||||
char *lbp; /* line buffer pointer */
|
||||
|
||||
int
|
||||
PF_funcs()
|
||||
{
|
||||
bool pfcnt; /* pascal/fortran functions found */
|
||||
char *cp;
|
||||
char tok[MAXTOKEN];
|
||||
|
||||
for (pfcnt = NO;;) {
|
||||
lineftell = ftell(inf);
|
||||
if (!fgets(lbuf, sizeof(lbuf), inf))
|
||||
return (pfcnt);
|
||||
++lineno;
|
||||
lbp = lbuf;
|
||||
if (*lbp == '%') /* Ratfor escape to fortran */
|
||||
++lbp;
|
||||
for (; isspace(*lbp); ++lbp)
|
||||
continue;
|
||||
if (!*lbp)
|
||||
continue;
|
||||
switch (*lbp | ' ') { /* convert to lower-case */
|
||||
case 'c':
|
||||
if (cicmp("complex") || cicmp("character"))
|
||||
takeprec();
|
||||
break;
|
||||
case 'd':
|
||||
if (cicmp("double")) {
|
||||
for (; isspace(*lbp); ++lbp)
|
||||
continue;
|
||||
if (!*lbp)
|
||||
continue;
|
||||
if (cicmp("precision"))
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
if (cicmp("integer"))
|
||||
takeprec();
|
||||
break;
|
||||
case 'l':
|
||||
if (cicmp("logical"))
|
||||
takeprec();
|
||||
break;
|
||||
case 'r':
|
||||
if (cicmp("real"))
|
||||
takeprec();
|
||||
break;
|
||||
}
|
||||
for (; isspace(*lbp); ++lbp)
|
||||
continue;
|
||||
if (!*lbp)
|
||||
continue;
|
||||
switch (*lbp | ' ') {
|
||||
case 'f':
|
||||
if (cicmp("function"))
|
||||
break;
|
||||
continue;
|
||||
case 'p':
|
||||
if (cicmp("program") || cicmp("procedure"))
|
||||
break;
|
||||
continue;
|
||||
case 's':
|
||||
if (cicmp("subroutine"))
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
for (; isspace(*lbp); ++lbp)
|
||||
continue;
|
||||
if (!*lbp)
|
||||
continue;
|
||||
for (cp = lbp + 1; *cp && intoken(*cp); ++cp)
|
||||
continue;
|
||||
if (cp == lbp + 1)
|
||||
continue;
|
||||
*cp = EOS;
|
||||
(void)strcpy(tok, lbp);
|
||||
getline(); /* process line for ex(1) */
|
||||
pfnote(tok, lineno);
|
||||
pfcnt = YES;
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
/*
|
||||
* cicmp --
|
||||
* do case-independent strcmp
|
||||
*/
|
||||
int
|
||||
cicmp(cp)
|
||||
char *cp;
|
||||
{
|
||||
int len;
|
||||
char *bp;
|
||||
|
||||
for (len = 0, bp = lbp; *cp && (*cp &~ ' ') == (*bp++ &~ ' ');
|
||||
++cp, ++len)
|
||||
continue;
|
||||
if (!*cp) {
|
||||
lbp += len;
|
||||
return (YES);
|
||||
}
|
||||
return (NO);
|
||||
}
|
||||
|
||||
static void
|
||||
takeprec()
|
||||
{
|
||||
for (; isspace(*lbp); ++lbp)
|
||||
continue;
|
||||
if (*lbp == '*') {
|
||||
for (++lbp; isspace(*lbp); ++lbp)
|
||||
continue;
|
||||
if (!isdigit(*lbp))
|
||||
--lbp; /* force failure */
|
||||
else
|
||||
while (isdigit(*++lbp))
|
||||
continue;
|
||||
}
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)lisp.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ctags.h"
|
||||
|
||||
/*
|
||||
* lisp tag functions
|
||||
* just look for (def or (DEF
|
||||
*/
|
||||
void
|
||||
l_entries()
|
||||
{
|
||||
int special;
|
||||
char *cp;
|
||||
char savedc;
|
||||
char tok[MAXTOKEN];
|
||||
|
||||
for (;;) {
|
||||
lineftell = ftell(inf);
|
||||
if (!fgets(lbuf, sizeof(lbuf), inf))
|
||||
return;
|
||||
++lineno;
|
||||
lbp = lbuf;
|
||||
if (!cicmp("(def"))
|
||||
continue;
|
||||
special = NO;
|
||||
switch(*lbp | ' ') {
|
||||
case 'm':
|
||||
if (cicmp("method"))
|
||||
special = YES;
|
||||
break;
|
||||
case 'w':
|
||||
if (cicmp("wrapper") || cicmp("whopper"))
|
||||
special = YES;
|
||||
}
|
||||
for (; !isspace(*lbp); ++lbp)
|
||||
continue;
|
||||
for (; isspace(*lbp); ++lbp)
|
||||
continue;
|
||||
for (cp = lbp; *cp && *cp != '\n'; ++cp)
|
||||
continue;
|
||||
*cp = EOS;
|
||||
if (special) {
|
||||
if (!(cp = strchr(lbp, ')')))
|
||||
continue;
|
||||
for (; cp >= lbp && *cp != ':'; --cp)
|
||||
continue;
|
||||
if (cp < lbp)
|
||||
continue;
|
||||
lbp = cp;
|
||||
for (; *cp && *cp != ')' && *cp != ' '; ++cp)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
for (cp = lbp + 1;
|
||||
*cp && *cp != '(' && *cp != ' '; ++cp)
|
||||
continue;
|
||||
savedc = *cp;
|
||||
*cp = EOS;
|
||||
(void)strcpy(tok, lbp);
|
||||
*cp = savedc;
|
||||
getline();
|
||||
pfnote(tok, lineno);
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
@ -1,178 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)print.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "die.h"
|
||||
#include "ctags.h"
|
||||
|
||||
/*
|
||||
* getline --
|
||||
* get the line the token of interest occurred on,
|
||||
* prepare it for printing.
|
||||
*/
|
||||
void
|
||||
getline()
|
||||
{
|
||||
long saveftell;
|
||||
int c;
|
||||
int cnt;
|
||||
char *cp;
|
||||
|
||||
saveftell = ftell(inf);
|
||||
(void)fseek(inf, lineftell, SEEK_SET);
|
||||
if (xflag)
|
||||
for (cp = lbuf; GETC(!=, EOF) && c != '\n'; *cp++ = c)
|
||||
continue;
|
||||
/*
|
||||
* do all processing here, so we don't step through the
|
||||
* line more than once; means you don't call this routine
|
||||
* unless you're sure you've got a keeper.
|
||||
*/
|
||||
else for (cnt = 0, cp = lbuf; GETC(!=, EOF) && cnt < ENDLINE; ++cnt) {
|
||||
if (c == '\\') { /* backslashes */
|
||||
if (cnt > ENDLINE - 2)
|
||||
break;
|
||||
*cp++ = '\\'; *cp++ = '\\';
|
||||
++cnt;
|
||||
}
|
||||
else if (c == (int)searchar) { /* search character */
|
||||
if (cnt > ENDLINE - 2)
|
||||
break;
|
||||
*cp++ = '\\'; *cp++ = c;
|
||||
++cnt;
|
||||
}
|
||||
else if (c == '\n') { /* end of keep */
|
||||
*cp++ = '$'; /* can find whole line */
|
||||
break;
|
||||
}
|
||||
else
|
||||
*cp++ = c;
|
||||
}
|
||||
*cp = EOS;
|
||||
(void)fseek(inf, saveftell, SEEK_SET);
|
||||
}
|
||||
#ifdef GLOBAL
|
||||
void
|
||||
compact_print(entry, lno, file)
|
||||
char *entry;
|
||||
int lno;
|
||||
char *file;
|
||||
{
|
||||
static int first = 1;
|
||||
static char p_entry[128];
|
||||
static char p_file[1024];
|
||||
static int p_lno;
|
||||
static char *buf;
|
||||
static int bufsize = 512;
|
||||
static char *p;
|
||||
|
||||
if (first) {
|
||||
if (!(buf = (char *)malloc(bufsize)))
|
||||
die("short of memory.");
|
||||
buf[0] = 0;
|
||||
p = buf;
|
||||
first = 0;
|
||||
}
|
||||
if (strcmp(p_entry, entry) || strcmp(p_file, file)) {
|
||||
if (buf[0])
|
||||
printf("%s\n", buf);
|
||||
if (!entry[0]) /* flush */
|
||||
return;
|
||||
strcpy(p_entry, entry);
|
||||
strcpy(p_file, file);
|
||||
p_lno = lno;
|
||||
buf[0] = 0;
|
||||
sprintf(buf, "%s %s %d", entry, file, lno);
|
||||
p = buf;
|
||||
p += strlen(p);
|
||||
} else {
|
||||
if (p_lno > lno)
|
||||
die("impossible!");
|
||||
if (p_lno < lno) {
|
||||
if (buf + bufsize < p + 10) {
|
||||
int offset = p - buf;
|
||||
bufsize *= 2;
|
||||
if (!(buf = (char *)realloc(buf, bufsize)))
|
||||
die("short of memory.");
|
||||
p = buf + offset;
|
||||
}
|
||||
sprintf(p, ",%d", lno);
|
||||
p += strlen(p);
|
||||
p_lno = lno;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* put_entries --
|
||||
* write out the tags
|
||||
*/
|
||||
void
|
||||
put_entries(node)
|
||||
NODE *node;
|
||||
{
|
||||
|
||||
if (node->left)
|
||||
put_entries(node->left);
|
||||
if (vflag)
|
||||
printf("%s %s %d\n",
|
||||
node->entry, node->file, (node->lno + 63) / 64);
|
||||
#ifdef GLOBAL
|
||||
else if (xflag && cflag)
|
||||
compact_print(node->entry, node->lno, node->file);
|
||||
#endif
|
||||
else if (xflag)
|
||||
#ifdef GLOBAL
|
||||
/* separate 'entry' and 'lno' */
|
||||
if (strlen(node->entry) >= 16 && node->lno >= 1000)
|
||||
printf("%-16s %4d %-16s %s\n",
|
||||
node->entry, node->lno, node->file, node->pat);
|
||||
else /* for compatibility */
|
||||
#endif
|
||||
printf("%-16s%4d %-16s %s\n",
|
||||
node->entry, node->lno, node->file, node->pat);
|
||||
else
|
||||
fprintf(outf, "%s\t%s\t%c^%s%c\n",
|
||||
node->entry, node->file, searchar, node->pat, searchar);
|
||||
if (node->right)
|
||||
put_entries(node->right);
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)tree.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "die.h"
|
||||
#include "ctags.h"
|
||||
|
||||
static void add_node __P((NODE *, NODE *));
|
||||
static void free_tree __P((NODE *));
|
||||
|
||||
/*
|
||||
* pfnote --
|
||||
* enter a new node in the tree
|
||||
*/
|
||||
void
|
||||
pfnote(name, ln)
|
||||
char *name;
|
||||
int ln;
|
||||
{
|
||||
NODE *np;
|
||||
char *fp;
|
||||
char nbuf[MAXTOKEN];
|
||||
|
||||
/*NOSTRICT*/
|
||||
if (!(np = (NODE *)malloc(sizeof(NODE)))) {
|
||||
fprintf(stderr, "too many entries to sort\n");
|
||||
put_entries(head);
|
||||
free_tree(head);
|
||||
/*NOSTRICT*/
|
||||
if (!(head = np = (NODE *)malloc(sizeof(NODE))))
|
||||
die("out of space");
|
||||
}
|
||||
if (!xflag && !strcmp(name, "main")) {
|
||||
if (!(fp = strrchr(curfile, '/')))
|
||||
fp = curfile;
|
||||
else
|
||||
++fp;
|
||||
(void)sprintf(nbuf, "M%s", fp);
|
||||
fp = strrchr(nbuf, '.');
|
||||
if (fp && !fp[2])
|
||||
*fp = EOS;
|
||||
name = nbuf;
|
||||
}
|
||||
if (!(np->entry = strdup(name)))
|
||||
die("out of space");
|
||||
np->file = curfile;
|
||||
np->lno = ln;
|
||||
np->left = np->right = 0;
|
||||
if (!(np->pat = strdup(lbuf)))
|
||||
die("out of space");
|
||||
if (!head)
|
||||
head = np;
|
||||
else
|
||||
add_node(np, head);
|
||||
}
|
||||
|
||||
static void
|
||||
add_node(node, cur_node)
|
||||
NODE *node,
|
||||
*cur_node;
|
||||
{
|
||||
int dif;
|
||||
|
||||
dif = strcmp(node->entry, cur_node->entry);
|
||||
#ifdef GLOBAL
|
||||
if (!Dflag && !dif) /* -D option allows duplicate entries. */
|
||||
#else
|
||||
if (!dif)
|
||||
#endif
|
||||
{
|
||||
if (node->file == cur_node->file) {
|
||||
if (!wflag)
|
||||
fprintf(stderr, "Duplicate entry in file %s, line %d: %s\nSecond entry ignored\n", node->file, lineno, node->entry);
|
||||
return;
|
||||
}
|
||||
if (!cur_node->been_warned)
|
||||
if (!wflag)
|
||||
fprintf(stderr, "Duplicate entry in files %s and %s: %s (Warning only)\n", node->file, cur_node->file, node->entry);
|
||||
cur_node->been_warned = YES;
|
||||
}
|
||||
else if (dif < 0)
|
||||
if (cur_node->left)
|
||||
add_node(node, cur_node->left);
|
||||
else
|
||||
cur_node->left = node;
|
||||
else if (cur_node->right)
|
||||
add_node(node, cur_node->right);
|
||||
else
|
||||
cur_node->right = node;
|
||||
}
|
||||
|
||||
static void
|
||||
free_tree(node)
|
||||
NODE *node;
|
||||
{
|
||||
while (node) {
|
||||
if (node->right)
|
||||
free_tree(node->right);
|
||||
free(node);
|
||||
node = node->left;
|
||||
}
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)yacc.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ctags.h"
|
||||
|
||||
/*
|
||||
* y_entries:
|
||||
* find the yacc tags and put them in.
|
||||
*/
|
||||
void
|
||||
y_entries()
|
||||
{
|
||||
int c;
|
||||
char *sp;
|
||||
bool in_rule;
|
||||
char tok[MAXTOKEN];
|
||||
|
||||
in_rule = NO;
|
||||
|
||||
while (GETC(!=, EOF))
|
||||
switch (c) {
|
||||
case '\n':
|
||||
SETLINE;
|
||||
/* FALLTHROUGH */
|
||||
case ' ':
|
||||
case '\f':
|
||||
case '\r':
|
||||
case '\t':
|
||||
break;
|
||||
case '{':
|
||||
if (skip_key('}'))
|
||||
in_rule = NO;
|
||||
break;
|
||||
case '\'':
|
||||
case '"':
|
||||
if (skip_key(c))
|
||||
in_rule = NO;
|
||||
break;
|
||||
case '%':
|
||||
if (GETC(==, '%'))
|
||||
return;
|
||||
(void)ungetc(c, inf);
|
||||
break;
|
||||
case '/':
|
||||
if (GETC(==, '*'))
|
||||
skip_comment();
|
||||
else
|
||||
(void)ungetc(c, inf);
|
||||
break;
|
||||
case '|':
|
||||
case ';':
|
||||
in_rule = NO;
|
||||
break;
|
||||
default:
|
||||
if (in_rule || (!isalpha(c) && c != '.' && c != '_'))
|
||||
break;
|
||||
sp = tok;
|
||||
*sp++ = c;
|
||||
while (GETC(!=, EOF) && (intoken(c) || c == '.'))
|
||||
*sp++ = c;
|
||||
*sp = EOS;
|
||||
getline(); /* may change before ':' */
|
||||
while (iswhite(c)) {
|
||||
if (c == '\n')
|
||||
SETLINE;
|
||||
if (GETC(==, EOF))
|
||||
return;
|
||||
}
|
||||
if (c == ':') {
|
||||
pfnote(tok, lineno);
|
||||
in_rule = YES;
|
||||
}
|
||||
else
|
||||
(void)ungetc(c, inf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* toss_yysec --
|
||||
* throw away lines up to the next "\n%%\n"
|
||||
*/
|
||||
void
|
||||
toss_yysec()
|
||||
{
|
||||
int c; /* read character */
|
||||
int state;
|
||||
|
||||
/*
|
||||
* state == 0 : waiting
|
||||
* state == 1 : received a newline
|
||||
* state == 2 : received first %
|
||||
* state == 3 : recieved second %
|
||||
*/
|
||||
lineftell = ftell(inf);
|
||||
for (state = 0; GETC(!=, EOF);)
|
||||
switch (c) {
|
||||
case '\n':
|
||||
++lineno;
|
||||
lineftell = ftell(inf);
|
||||
if (state == 3) /* done! */
|
||||
return;
|
||||
state = 1; /* start over */
|
||||
break;
|
||||
case '%':
|
||||
if (state) /* if 1 or 2 */
|
||||
++state; /* goto 3 */
|
||||
break;
|
||||
default:
|
||||
state = 0; /* reset */
|
||||
break;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
;;; gtags.el --- gtags facility for Emacs
|
||||
|
||||
;;
|
||||
;; Copyright (c) 1997 Shigio Yamaguchi. All rights reserved.
|
||||
;; Copyright (c) 1997, 1998, 1999 Shigio Yamaguchi. All rights reserved.
|
||||
;;
|
||||
;; Redistribution and use in source and binary forms, with or without
|
||||
;; modification, are permitted provided that the following conditions
|
||||
@ -30,12 +30,12 @@
|
||||
;; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
;; SUCH DAMAGE.
|
||||
;;
|
||||
;; gtags.el 31-Aug-97
|
||||
;; gtags.el 8-Jan-99
|
||||
;;
|
||||
|
||||
;; This file is part of GLOBAL.
|
||||
;; Author: Shigio Yamaguchi <shigio@wafu.netgate.net>
|
||||
;; Version: 1.1
|
||||
;; Version: 1.5
|
||||
;; Keywords: tools
|
||||
|
||||
;;; Code
|
||||
@ -59,6 +59,7 @@
|
||||
(define-key gtags-mode-map "\es" 'gtags-find-symbol)
|
||||
(define-key gtags-mode-map "\eg" 'gtags-find-pattern)
|
||||
(define-key gtags-mode-map "\C-]" 'gtags-find-tag-from-here)
|
||||
(define-key gtags-mode-map "\eh" 'gtags-display-browser)
|
||||
(define-key gtags-mode-map "\C-t" 'gtags-pop-stack)
|
||||
(define-key gtags-mode-map "\e." 'etags-style-find-tag)
|
||||
(define-key gtags-mode-map [mouse-2] 'gtags-find-tag-by-event)
|
||||
@ -83,7 +84,7 @@
|
||||
;;
|
||||
;; utility
|
||||
;;
|
||||
(defun match-string (n)
|
||||
(defun util-match-string (n)
|
||||
(buffer-substring (match-beginning n) (match-end n)))
|
||||
|
||||
;; Return a default tag to search for, based on the text at point.
|
||||
@ -99,7 +100,7 @@
|
||||
(if (and (bolp) (looking-at definition-regexp))
|
||||
(goto-char (match-end 0)))
|
||||
(if (looking-at symbol-regexp)
|
||||
(match-string 0) nil))
|
||||
(util-match-string 0) nil))
|
||||
|
||||
;; push current context to stack
|
||||
(defun push-context ()
|
||||
@ -132,18 +133,20 @@
|
||||
;; is it a definition?
|
||||
(defun is-definition ()
|
||||
(save-excursion
|
||||
(if (bolp)
|
||||
(if (and (string-match "\.java$" buffer-file-name) (looking-at "[^(]+([^)]*)[ \t]*{"))
|
||||
t
|
||||
(forward-word -1)
|
||||
(cond
|
||||
((looking-at "define")
|
||||
(forward-char -1)
|
||||
(while (and (not (bolp)) (looking-at "[ \t]"))
|
||||
(forward-char -1))
|
||||
(if (and (bolp) (looking-at "#"))
|
||||
t nil))
|
||||
((looking-at "ENTRY\\|ALTENTRY")
|
||||
(if (bolp) t nil))))))
|
||||
(if (bolp)
|
||||
t
|
||||
(forward-word -1)
|
||||
(cond
|
||||
((looking-at "define")
|
||||
(forward-char -1)
|
||||
(while (and (not (bolp)) (looking-at "[ \t]"))
|
||||
(forward-char -1))
|
||||
(if (and (bolp) (looking-at "#"))
|
||||
t nil))
|
||||
((looking-at "ENTRY\\|ALTENTRY")
|
||||
(if (bolp) t nil)))))))
|
||||
|
||||
;;
|
||||
;; interactive command
|
||||
@ -216,6 +219,18 @@
|
||||
(push-context)
|
||||
(gtags-goto-tag tagname flag))))
|
||||
|
||||
(defun gtags-display-browser ()
|
||||
"Display current screen on hypertext browser."
|
||||
(interactive)
|
||||
(let (lno)
|
||||
(save-excursion
|
||||
(end-of-line)
|
||||
(if (equal (point-min) (point))
|
||||
(setq lno 1)
|
||||
(setq lno (count-lines (point-min) (point)))))
|
||||
(message (number-to-string lno))
|
||||
(call-process "gozilla" nil t nil (concat "+" (number-to-string lno)) buffer-file-name)))
|
||||
|
||||
(defun gtags-find-tag-by-event (event)
|
||||
"Get the expression as a tagname around here and move there."
|
||||
(interactive "e")
|
||||
@ -307,8 +322,8 @@
|
||||
;; (if (not (looking-at "[A-Za-z_][A-Za-z_0-9]*[ \t]+\\([0-9]+\\)[ \t]\\([^ \t]+\\)[ \t]"))
|
||||
(if (not (looking-at "[^ \t]+[ \t]+\\([0-9]+\\)[ \t]\\([^ \t]+\\)[ \t]"))
|
||||
(pop-context)
|
||||
(setq line (string-to-number (match-string 1)))
|
||||
(setq file (match-string 2))
|
||||
(setq line (string-to-number (util-match-string 1)))
|
||||
(setq file (util-match-string 2))
|
||||
(if delete (kill-buffer (current-buffer)))
|
||||
;; move to the context
|
||||
(if gtags-read-only (find-file-read-only file) (find-file file))
|
||||
@ -317,13 +332,15 @@
|
||||
|
||||
;; make complete list
|
||||
(defun make-gtags-complete-list ()
|
||||
;; "Make tag name list for completion."
|
||||
;; (interactive)
|
||||
(save-excursion
|
||||
(setq gtags-complete-list (make-vector 63 0))
|
||||
(set-buffer (generate-new-buffer "*Completions*"))
|
||||
(call-process "global" nil t nil "-c")
|
||||
(goto-char (point-min))
|
||||
(while (looking-at symbol-regexp)
|
||||
(intern (match-string 0) gtags-complete-list)
|
||||
(intern (util-match-string 0) gtags-complete-list)
|
||||
(forward-line))
|
||||
(kill-buffer (current-buffer))))
|
||||
|
||||
@ -331,7 +348,8 @@
|
||||
(defun gtags-mode ()
|
||||
"Minor mode for browsing C source using GLOBAL."
|
||||
(interactive)
|
||||
(make-gtags-complete-list)
|
||||
(if (y-or-n-p "Do you use function name completion?")
|
||||
(make-gtags-complete-list))
|
||||
(use-local-map gtags-mode-map)
|
||||
(run-hooks 'gtags-mode-hook))
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -28,10 +28,10 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* gtags.c 12-Dec-97
|
||||
* gtags.c 8-Oct-98
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctype.h>
|
||||
@ -43,46 +43,90 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
char *progname = "gtags"; /* command name */
|
||||
const char *progname = "gtags"; /* command name */
|
||||
|
||||
static void usage __P((void));
|
||||
void main __P((int, char **));
|
||||
int incremental __P((char *));
|
||||
void tagadd __P((int, char *));
|
||||
void createtags __P((char *, int));
|
||||
char *current __P((void));
|
||||
int main __P((int, char **));
|
||||
int incremental __P((char *, char *));
|
||||
void updatetags __P((char *, char *, char *, int));
|
||||
void createtags __P((char *, char *, int));
|
||||
int printconf __P((char *));
|
||||
char *now __P((void));
|
||||
|
||||
static int iflag;
|
||||
static int oflag;
|
||||
static int vflag;
|
||||
int cflag; /* compact format */
|
||||
int iflag; /* incremental update */
|
||||
int oflag; /* suppress making GSYMS */
|
||||
int wflag; /* warning message */
|
||||
int vflag; /* verbose mode */
|
||||
|
||||
int extractmethod = 0;
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "usage:\t%s [-i][-o][-v][dbpath]\n", progname);
|
||||
fprintf(stderr, "usage:\t%s [-c][-i][-l][-o][-w][-v][dbpath]\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
char dbpath[MAXPATHLEN+1];
|
||||
char cwd[MAXPATHLEN+1];
|
||||
char env[MAXENVLEN+1];
|
||||
char *p;
|
||||
STRBUF *sb = stropen();
|
||||
int db;
|
||||
|
||||
while (--argc > 0 && (++argv)[0][0] == '-') {
|
||||
char *p;
|
||||
/*
|
||||
* Secret option for htags(1).
|
||||
*/
|
||||
if (!strcmp(argv[0], "--config")) {
|
||||
if (argc == 1)
|
||||
fprintf(stdout, "%s\n", configpath());
|
||||
else if (argc == 2) {
|
||||
if (!printconf(argv[1]))
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[0], "--find")) {
|
||||
for (findopen(); (p = findread(NULL)) != NULL; )
|
||||
fprintf(stdout, "%s\n", p);
|
||||
findclose();
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[0], "--expand")) {
|
||||
FILE *ip;
|
||||
|
||||
++argv; --argc;
|
||||
if (argc && argv[0][0] == '-') {
|
||||
settabs(atoi(&argv[0][1]));
|
||||
++argv; --argc;
|
||||
}
|
||||
ip = (argc) ? fopen(argv[0], "r") : stdin;
|
||||
if (ip == NULL)
|
||||
exit(1);
|
||||
while ((p = mgets(ip, NULL, 0)) != NULL)
|
||||
detab(stdout, p);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for (p = argv[0] + 1; *p; p++) {
|
||||
switch (*p) {
|
||||
case 'c':
|
||||
cflag++;
|
||||
break;
|
||||
case 'i':
|
||||
iflag++;
|
||||
break;
|
||||
case 'o':
|
||||
oflag++;
|
||||
break;
|
||||
case 'w':
|
||||
wflag++;
|
||||
break;
|
||||
case 'v':
|
||||
vflag++;
|
||||
break;
|
||||
@ -95,30 +139,48 @@ char *argv[];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (argc > 0) {
|
||||
strcpy(dbpath, *argv);
|
||||
} else {
|
||||
if (!getcwd(dbpath, MAXPATHLEN))
|
||||
die("cannot get current directory.");
|
||||
}
|
||||
if (!getcwd(cwd, MAXPATHLEN))
|
||||
die("cannot get current directory.");
|
||||
if (argc > 0)
|
||||
realpath(*argv,dbpath) ;
|
||||
else
|
||||
strcpy(dbpath, cwd);
|
||||
if (!strcmp(dbpath, "/"))
|
||||
die("It's root directory! What are you doing?");
|
||||
if (!test("d", dbpath))
|
||||
die1("directory '%s' not found.", dbpath);
|
||||
if (vflag)
|
||||
fprintf(stderr, "[%s] Gtags started\n", current());
|
||||
fprintf(stderr, "[%s] Gtags started\n", now());
|
||||
/*
|
||||
* load .gtagsrc or /etc/gtags.conf
|
||||
*/
|
||||
openconf();
|
||||
if (getconfb("extractmethod"))
|
||||
extractmethod = 1;
|
||||
strstart(sb);
|
||||
if (getconfs("format", sb) && !strcmp(strvalue(sb), "compact"))
|
||||
cflag++;
|
||||
/*
|
||||
* teach gctags(1) where is dbpath.
|
||||
*/
|
||||
sprintf(env, "GTAGSDBPATH=%s", dbpath);
|
||||
putenv(env);
|
||||
if (wflag) {
|
||||
sprintf(env, "GTAGSWARNING=1");
|
||||
putenv(env);
|
||||
}
|
||||
/*
|
||||
* incremental update.
|
||||
*/
|
||||
if (iflag && test("f", makepath(dbpath, dbname(GTAGS))) &&
|
||||
test("f", makepath(dbpath, dbname(GRTAGS))))
|
||||
{
|
||||
(void)incremental(dbpath);
|
||||
/* open for version check */
|
||||
GTOP *gtop = gtagsopen(dbpath, cwd, GTAGS, GTAGS_MODIFY, 0);
|
||||
gtagsclose(gtop);
|
||||
if (!test("f", makepath(dbpath, "GPATH")))
|
||||
die("Old version tag file found. Please remake it.");
|
||||
(void)incremental(dbpath, cwd);
|
||||
exit(0);
|
||||
}
|
||||
if (iflag && vflag)
|
||||
@ -127,32 +189,43 @@ char *argv[];
|
||||
* create GTAGS, GRTAGS and GSYMS
|
||||
*/
|
||||
for (db = GTAGS; db < GTAGLIM; db++) {
|
||||
|
||||
if (oflag && db == GSYMS)
|
||||
continue;
|
||||
strstart(sb);
|
||||
if (!getconfs(dbname(db), sb))
|
||||
continue;
|
||||
if (!usable(strmake(strvalue(sb), " \t")))
|
||||
die1("Parser '%s' not found or not executable.", strmake(strvalue(sb), " \t"));
|
||||
if (vflag)
|
||||
fprintf(stderr, "[%s] Creating '%s'.\n", current(), dbname(db));
|
||||
createtags(dbpath, db);
|
||||
fprintf(stderr, "[%s] Creating '%s'.\n", now(), dbname(db));
|
||||
createtags(dbpath, cwd, db);
|
||||
}
|
||||
|
||||
if (vflag)
|
||||
fprintf(stderr, "[%s] Done.\n", current());
|
||||
fprintf(stderr, "[%s] Done.\n", now());
|
||||
closeconf();
|
||||
exit(0);
|
||||
}
|
||||
/*
|
||||
* incremental: incremental update
|
||||
*
|
||||
* i) dbpath dbpath directory
|
||||
* i) root root directory of source tree
|
||||
* r) 0: not updated, 1: updated
|
||||
*/
|
||||
int
|
||||
incremental(dbpath)
|
||||
incremental(dbpath, root)
|
||||
char *dbpath;
|
||||
char *root;
|
||||
{
|
||||
struct stat sb;
|
||||
struct stat statp;
|
||||
time_t gtags_mtime;
|
||||
STRBUF *addlist = stropen();
|
||||
STRBUF *updatelist = stropen();
|
||||
STRBUF *deletelist = stropen();
|
||||
int updated = 0;
|
||||
char *path;
|
||||
int db;
|
||||
|
||||
if (vflag) {
|
||||
fprintf(stderr, " Tag found in '%s'.\n", dbpath);
|
||||
@ -162,145 +235,255 @@ char *dbpath;
|
||||
* get modified time of GTAGS.
|
||||
*/
|
||||
path = makepath(dbpath, dbname(GTAGS));
|
||||
if (stat(path, &sb) < 0)
|
||||
if (stat(path, &statp) < 0)
|
||||
die1("stat failed '%s'.", path);
|
||||
gtags_mtime = sb.st_mtime;
|
||||
gtags_mtime = statp.st_mtime;
|
||||
|
||||
if (pathopen(dbpath, 0) < 0)
|
||||
die("GPATH not found.");
|
||||
/*
|
||||
* make add list and update list.
|
||||
*/
|
||||
for (findopen(); (path = findread(NULL)) != NULL; ) {
|
||||
if (stat(path, &sb) < 0)
|
||||
if (stat(path, &statp) < 0)
|
||||
die1("stat failed '%s'.", path);
|
||||
/*
|
||||
* only the path modified after GTAGS was modified.
|
||||
*/
|
||||
if (gtags_mtime < sb.st_mtime) {
|
||||
updated = 1;
|
||||
if (vflag)
|
||||
fprintf(stderr, " Updating tags of '%s' ...", path + 2);
|
||||
for (db = GTAGS; db < GTAGLIM; db++) {
|
||||
if (db == GSYMS && !test("f", makepath(dbpath, dbname(db))))
|
||||
continue;
|
||||
if (vflag)
|
||||
fprintf(stderr, "%s", dbname(db));
|
||||
tagopen(dbpath, db, 2);
|
||||
/*
|
||||
* GTAGS needed to make GRTAGS.
|
||||
*/
|
||||
if (db == GRTAGS)
|
||||
lookupopen(dbpath);
|
||||
tagdelete(path);
|
||||
if (vflag)
|
||||
fprintf(stderr, "..");
|
||||
tagadd(db, path);
|
||||
if (db == GRTAGS)
|
||||
lookupclose();
|
||||
tagclose();
|
||||
}
|
||||
if (vflag)
|
||||
fprintf(stderr, " Done.\n");
|
||||
}
|
||||
if (!pathget(path))
|
||||
strnputs(addlist, path, strlen(path) + 1);
|
||||
else if (gtags_mtime < statp.st_mtime)
|
||||
strnputs(updatelist, path, strlen(path) + 1);
|
||||
}
|
||||
findclose();
|
||||
/*
|
||||
* make delete list.
|
||||
*/
|
||||
{
|
||||
int i, limit = nextkey();
|
||||
|
||||
for (i = 0; i < limit; i++) {
|
||||
if ((path = pathiget(i)) == NULL)
|
||||
continue;
|
||||
if (!test("f", path))
|
||||
strnputs(deletelist, path, strlen(path) + 1);
|
||||
}
|
||||
}
|
||||
pathclose();
|
||||
if (strbuflen(addlist) + strbuflen(deletelist) + strbuflen(updatelist))
|
||||
updated = 1;
|
||||
/*
|
||||
* execute updating.
|
||||
*/
|
||||
if (strbuflen(updatelist) > 0) {
|
||||
char *start = strvalue(updatelist);
|
||||
char *end = start + strbuflen(updatelist);
|
||||
char *p;
|
||||
|
||||
for (p = start; p < end; p += strlen(p) + 1)
|
||||
updatetags(dbpath, root, p, 0);
|
||||
updated = 1;
|
||||
}
|
||||
if (strbuflen(addlist) > 0) {
|
||||
char *start = strvalue(addlist);
|
||||
char *end = start + strbuflen(addlist);
|
||||
char *p;
|
||||
|
||||
for (p = start; p < end; p += strlen(p) + 1)
|
||||
updatetags(dbpath, root, p, 1);
|
||||
updated = 1;
|
||||
}
|
||||
if (strbuflen(deletelist) > 0) {
|
||||
char *start = strvalue(deletelist);
|
||||
char *end = start + strbuflen(deletelist);
|
||||
char *p;
|
||||
|
||||
for (p = start; p < end; p += strlen(p) + 1)
|
||||
updatetags(dbpath, root, p, 2);
|
||||
|
||||
pathopen(dbpath, 2);
|
||||
for (p = start; p < end; p += strlen(p) + 1)
|
||||
pathdel(p);
|
||||
pathclose();
|
||||
updated = 1;
|
||||
}
|
||||
if (vflag) {
|
||||
if (updated)
|
||||
fprintf(stderr, " Global databases have been modified.\n");
|
||||
else
|
||||
fprintf(stderr, " Global databases are up to date.\n");
|
||||
fprintf(stderr, "[%s] Done.\n", current());
|
||||
|
||||
fprintf(stderr, " Done.\n");
|
||||
fprintf(stderr, "[%s] Done.\n", now());
|
||||
}
|
||||
strclose(addlist);
|
||||
strclose(deletelist);
|
||||
strclose(updatelist);
|
||||
return updated;
|
||||
}
|
||||
/*
|
||||
* tagadd: add records which has specified path.
|
||||
* updatetags: update tag file.
|
||||
*
|
||||
* i) db 0: GTAGS, 1: GRTAGS, 2: GSYMS
|
||||
* i) path source file
|
||||
* i) dbpath directory in which tag file exist
|
||||
* i) root root directory of source tree
|
||||
* i) path path which should be updated
|
||||
* i) type 0:update, 1:add, 2:delete
|
||||
*/
|
||||
void
|
||||
tagadd(db, path)
|
||||
int db;
|
||||
updatetags(dbpath, root, path, type)
|
||||
char *dbpath;
|
||||
char *root;
|
||||
char *path;
|
||||
int type;
|
||||
{
|
||||
char *tagline, *p, *q;
|
||||
char key[IDENTLEN+1];
|
||||
FILE *ip;
|
||||
GTOP *gtop;
|
||||
STRBUF *sb = stropen();
|
||||
int db;
|
||||
const char *msg = NULL;
|
||||
|
||||
stropen();
|
||||
/*
|
||||
* make command line.
|
||||
*/
|
||||
strputs("gctags -Dex");
|
||||
if (db == GRTAGS)
|
||||
strputs("r");
|
||||
if (db == GSYMS)
|
||||
strputs("sc");
|
||||
strputc(' ');
|
||||
strputs(path);
|
||||
p = strclose();
|
||||
if (!(ip = popen(p, "r")))
|
||||
die1("cannot execute '%s'.", p);
|
||||
while ((tagline = mgets(ip, 0, NULL)) != NULL) {
|
||||
p = tagline;
|
||||
q = key;
|
||||
while (*p && !isspace(*p))
|
||||
*q++ = *p++;
|
||||
*q = 0;
|
||||
tagput(key, tagline);
|
||||
switch (type) {
|
||||
case 0: msg = "Updating"; break;
|
||||
case 1: msg = "Adding"; break;
|
||||
case 2: msg = "Deleting"; break;
|
||||
}
|
||||
pclose(ip);
|
||||
if (vflag)
|
||||
fprintf(stderr, " %s tags of '%s' ...", msg, path + 2);
|
||||
for (db = GTAGS; db < GTAGLIM; db++) {
|
||||
int flags = 0;
|
||||
|
||||
if (db == GSYMS && !test("f", makepath(dbpath, dbname(db))))
|
||||
continue;
|
||||
if (vflag)
|
||||
fprintf(stderr, "%s", dbname(db));
|
||||
/*
|
||||
* get tag command.
|
||||
*/
|
||||
strstart(sb);
|
||||
if (!getconfs(dbname(db), sb))
|
||||
die1("cannot get tag command. (%s)", dbname(db));
|
||||
gtop = gtagsopen(dbpath, root, db, GTAGS_MODIFY, 0);
|
||||
/*
|
||||
* GTAGS needed to make GRTAGS.
|
||||
*/
|
||||
if (db == GRTAGS && !test("f", makepath(dbpath, "GTAGS")))
|
||||
die("GTAGS needed to create GRTAGS.");
|
||||
if (type != 1)
|
||||
gtagsdelete(gtop, path);
|
||||
if (vflag)
|
||||
fprintf(stderr, "..");
|
||||
if (type != 2) {
|
||||
if (db == GSYMS)
|
||||
flags |= GTAGS_UNIQUE;
|
||||
if (extractmethod)
|
||||
flags |= GTAGS_EXTRACTMETHOD;
|
||||
gtagsadd(gtop, strvalue(sb), path, flags);
|
||||
}
|
||||
gtagsclose(gtop);
|
||||
}
|
||||
if (vflag)
|
||||
fprintf(stderr, " Done.\n");
|
||||
strclose(sb);
|
||||
}
|
||||
/*
|
||||
* createtags: create tags file
|
||||
*
|
||||
* i) dbpath dbpath directory
|
||||
* i) root root directory of source tree
|
||||
* i) db GTAGS, GRTAGS, GSYMS
|
||||
*/
|
||||
void
|
||||
createtags(dbpath, db)
|
||||
createtags(dbpath, root, db)
|
||||
char *dbpath;
|
||||
char *root;
|
||||
int db;
|
||||
{
|
||||
char *path;
|
||||
GTOP *gtop;
|
||||
int flags;
|
||||
char *comline;
|
||||
STRBUF *sb = stropen();
|
||||
|
||||
/*
|
||||
* get tag command.
|
||||
*/
|
||||
if (!getconfs(dbname(db), sb))
|
||||
die1("cannot get tag command. (%s)", dbname(db));
|
||||
comline = strdup(strvalue(sb));
|
||||
if (!comline)
|
||||
die("short of memory.");
|
||||
/*
|
||||
* GTAGS needed to make GRTAGS.
|
||||
*/
|
||||
if (db == GRTAGS)
|
||||
lookupopen(dbpath);
|
||||
tagopen(dbpath, db, 1);
|
||||
if (db == GRTAGS && !test("f", makepath(dbpath, "GTAGS")))
|
||||
die("GTAGS needed to create GRTAGS.");
|
||||
flags = 0;
|
||||
strstart(sb);
|
||||
if (cflag) {
|
||||
flags |= GTAGS_COMPACT;
|
||||
flags |= GTAGS_PATHINDEX;
|
||||
}
|
||||
strstart(sb);
|
||||
if (vflag > 1 && getconfs(dbname(db), sb))
|
||||
fprintf(stderr, " using tag command '%s <path>'.\n", strvalue(sb));
|
||||
gtop = gtagsopen(dbpath, root, db, GTAGS_CREATE, flags);
|
||||
for (findopen(); (path = findread(NULL)) != NULL; ) {
|
||||
int gflags = 0;
|
||||
/*
|
||||
* GSYMS doesn't treat asembler.
|
||||
*/
|
||||
if (db == GSYMS) {
|
||||
char *p = path + strlen(path) - 1;
|
||||
if ((*p == 's' || *p == 'S') && *(p - 1) == '.')
|
||||
if (db == GSYMS)
|
||||
if (locatestring(path, ".s", MATCH_AT_LAST) != NULL ||
|
||||
locatestring(path, ".S", MATCH_AT_LAST) != NULL)
|
||||
continue;
|
||||
}
|
||||
if (vflag)
|
||||
fprintf(stderr, " extracting tags of %s.\n", path);
|
||||
tagadd(db, path);
|
||||
if (db == GSYMS)
|
||||
gflags |= GTAGS_UNIQUE;
|
||||
if (extractmethod)
|
||||
gflags |= GTAGS_EXTRACTMETHOD;
|
||||
gtagsadd(gtop, comline, path, gflags);
|
||||
}
|
||||
findclose();
|
||||
tagclose();
|
||||
if (db == GRTAGS)
|
||||
lookupclose();
|
||||
gtagsclose(gtop);
|
||||
free(comline);
|
||||
strclose(sb);
|
||||
}
|
||||
/*
|
||||
* current: current date and time
|
||||
* now: current date and time
|
||||
*
|
||||
* r) date and time
|
||||
*/
|
||||
char *
|
||||
current(void)
|
||||
char *
|
||||
now(void)
|
||||
{
|
||||
static char buf[80];
|
||||
time_t tval;
|
||||
|
||||
if (time(&tval) == -1)
|
||||
die("cannot get current time.");
|
||||
(void)strftime(buf, sizeof(buf), "%+", localtime(&tval));
|
||||
|
||||
(void)strftime(buf, sizeof(buf), "%a %b %e %H:%M:%S %Z %Y", localtime(&tval));
|
||||
return buf;
|
||||
}
|
||||
/*
|
||||
* printconf: print configuration data.
|
||||
*
|
||||
* i) name label of config data
|
||||
* r) exit code
|
||||
*/
|
||||
int
|
||||
printconf(name)
|
||||
char *name;
|
||||
{
|
||||
STRBUF *sb;
|
||||
int num;
|
||||
int exist = 1;
|
||||
|
||||
if (getconfn(name, &num))
|
||||
fprintf(stdout, "%d\n", num);
|
||||
else if (getconfb(name))
|
||||
fprintf(stdout, "1\n");
|
||||
else {
|
||||
sb = stropen();
|
||||
if (getconfs(name, sb))
|
||||
fprintf(stdout, "%s\n", strvalue(sb));
|
||||
else
|
||||
exist = 0;
|
||||
strclose(sb);
|
||||
}
|
||||
return exist;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\"
|
||||
.\" Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
.\" Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
@ -28,16 +28,18 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd June 28, 1997
|
||||
.Dd Oct 11, 1998
|
||||
.Dt HTAGS 1
|
||||
.Os BSD 4
|
||||
.Sh NAME
|
||||
.Nm htags
|
||||
.Nd generate hypertext from C and Yacc source code
|
||||
.Nd generate hypertext from C, Yacc and Java source code
|
||||
.Sh SYNOPSIS
|
||||
.Nm htags
|
||||
.Op Fl a
|
||||
.Op Fl c
|
||||
.Op Fl f
|
||||
.Op Fl h
|
||||
.Op Fl l
|
||||
.Op Fl n
|
||||
.Op Fl v
|
||||
@ -47,47 +49,59 @@
|
||||
.Op Ar dir
|
||||
.Sh DESCRIPTION
|
||||
.Nm Htags
|
||||
makes hypertext from C and Yacc source code using GLOBAL database (GTAGS, GRTAGS).
|
||||
makes hypertext from C, Yacc and Java source code using GLOBAL database (GTAGS, GRTAGS).
|
||||
.Pp
|
||||
In advance of using this command, you must execute
|
||||
.Xr gtags 1
|
||||
at the root directory of the source tree.
|
||||
from the root directory of the source tree.
|
||||
Then you can execute
|
||||
.Nm htags
|
||||
at the same place.
|
||||
from the same place.
|
||||
.Nm Htags
|
||||
makes HTML directory and generate hypertext in it.
|
||||
makes an HTML directory and generates hypertext in it.
|
||||
.Pp
|
||||
You can start browsing from 'HTML/index.html'.
|
||||
Once hypertext generated, you can move it anywhere and browse it
|
||||
by any browsers.
|
||||
Once the hypertext is generated, you can move it anywhere and browse it
|
||||
in any browsers.
|
||||
.Pp
|
||||
.br
|
||||
.Bl -tag -width Ds
|
||||
.It Fl a
|
||||
make an alphabetical function index. It's suitable for large project.
|
||||
Make an alphabetical function index, suitable for a large project.
|
||||
.It Fl c
|
||||
Compress html files by
|
||||
.Xr gzip 1 .
|
||||
You need to set up an HTTP server so that
|
||||
.Xr gzip 1
|
||||
is invoked for each compressed
|
||||
files. See skelton file 'HTML/.htaccess.skel' that is generated by htags.
|
||||
.It Fl f
|
||||
support input form and dynamic index by CGI program.
|
||||
You need to setup HTTP server for it.
|
||||
Support an input form and a dynamic index with a CGI program.
|
||||
You need to set up an HTTP server for this.
|
||||
.It Fl h
|
||||
Add title header frame. By default, doesn't add this.
|
||||
.It Fl l
|
||||
make name tag(<A NAME=line number>) for each line so that outer hypertext
|
||||
can point any line of this hypertext.
|
||||
By default, make it only for lines which have referred object.
|
||||
Make a name tag(<A NAME=line number>) for each line, so that other hypertext
|
||||
can link to any line of this hypertext.
|
||||
By default, htags makes it only for lines that are referred to by an object.
|
||||
.It Fl n
|
||||
print line number. By default, doesn't print it.
|
||||
Print the line numbers (they are not printed by default).
|
||||
.It Fl v
|
||||
verbose mode.
|
||||
Verbose mode.
|
||||
.It Fl w
|
||||
print warning message.
|
||||
Print a warning message.
|
||||
.It Fl d Ar tagdir
|
||||
the directory in which GTAGS and GRTAGS exist. Default is current directory.
|
||||
Specifies the directory in which GTAGS and GRTAGS exist. The default is the
|
||||
current directory.
|
||||
.It Fl t Ar title
|
||||
Title of this hypertext. Default is the last component of current path.
|
||||
The title of this hypertext. Defaults to the last component of the current
|
||||
path.
|
||||
.It Ar dir
|
||||
the directory in which hypertext generated. Default is current directory.
|
||||
The directory in which hypertext is generated. The default is the current
|
||||
directory.
|
||||
.Sh EXAMPLES
|
||||
% cd /usr/src/sys
|
||||
# gtags -se
|
||||
# gtags -o
|
||||
# htags -fnvat 'Welcom to FreeBSD kernel source tour!'
|
||||
% lynx HTML/index.html
|
||||
.Sh FILES
|
||||
@ -95,17 +109,17 @@ the directory in which hypertext generated. Default is current directory.
|
||||
.It Pa HTML/index.html
|
||||
Index file.
|
||||
.It Pa GTAGS
|
||||
tags file for function definitions.
|
||||
Tags file for function definitions.
|
||||
.It Pa GRTAGS
|
||||
tags file for function references.
|
||||
Tags file for function references.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
The following environment variables affect the execution of htags.
|
||||
.Pp
|
||||
.Bl -tag -width indent
|
||||
.It Ev TMPDIR
|
||||
If this variable is set, its value is used as the directory to make temporary file.
|
||||
Default is /tmp.
|
||||
If this variable is set, its value is used as the directory to make temporary files.
|
||||
The default is /tmp.
|
||||
.Sh DIAGNOSTICS
|
||||
.Nm Htags
|
||||
exits with a non 0 value if an error occurred, 0 otherwise.
|
||||
|
@ -1,328 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redilogibution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redilogibutions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redilogibutions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the dilogibution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* dbio.c 14-Dec-97
|
||||
*
|
||||
*/
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "dbio.h"
|
||||
#include "die.h"
|
||||
#include "test.h"
|
||||
|
||||
DBT key; /* key of record */
|
||||
DBT dat; /* data of record */
|
||||
/*
|
||||
* db_open: open db database.
|
||||
*
|
||||
* i) dbname database name
|
||||
* i) mode 0: read only, 1: write only, 2: read & write
|
||||
* i) perm file permission
|
||||
* i) flags
|
||||
* DBIO_DUP: allow duplicate records.
|
||||
* DBIO_REMOVE: remove on closed.
|
||||
* r) descripter for db_xxx()
|
||||
*
|
||||
* db_open leaves database permission 0600. please chmod(2) to make public.
|
||||
*/
|
||||
DBIO *
|
||||
db_open(dbname, mode, perm, flags)
|
||||
char *dbname;
|
||||
int mode;
|
||||
int perm;
|
||||
int flags;
|
||||
{
|
||||
DB *db;
|
||||
int rw;
|
||||
BTREEINFO info;
|
||||
DBIO *dbio;
|
||||
|
||||
/*
|
||||
* setup argments.
|
||||
*/
|
||||
if (mode == 0)
|
||||
rw = O_RDONLY;
|
||||
else if (mode == 1)
|
||||
rw = O_RDWR|O_CREAT|O_TRUNC;
|
||||
else if (mode == 2)
|
||||
rw = O_RDWR;
|
||||
else
|
||||
die("db_open illegal mode.");
|
||||
info.flags = (flags & DBIO_DUP) ? R_DUP : 0;
|
||||
info.cachesize = 500000;
|
||||
info.maxkeypage = 0;
|
||||
info.minkeypage = 0;
|
||||
info.psize = 0;
|
||||
info.compare = NULL;
|
||||
info.prefix = NULL;
|
||||
info.lorder = LITTLE_ENDIAN;
|
||||
|
||||
/*
|
||||
* if unlink do job normally, those who already open tag file can use
|
||||
* it until closing.
|
||||
*/
|
||||
if (mode == 1 && test("f", dbname))
|
||||
(void)unlink(dbname);
|
||||
db = dbopen(dbname, rw, 0600, DB_BTREE, &info);
|
||||
if (!db)
|
||||
die1("db_open failed (dbname = %s).", dbname);
|
||||
if (!(dbio = (DBIO *)malloc(sizeof(DBIO))))
|
||||
die("short of memory.");
|
||||
strcpy(dbio->dbname, dbname);
|
||||
dbio->db = db;
|
||||
dbio->openflags = flags;
|
||||
dbio->perm = (mode == 1) ? perm : 0;
|
||||
dbio->lastkey = (char *)0;
|
||||
dbio->lastdat = (char *)0;
|
||||
|
||||
return dbio;
|
||||
}
|
||||
/*
|
||||
* db_get: get data by a key.
|
||||
*
|
||||
* i) dbio descripter
|
||||
* i) k key
|
||||
* r) pointer to data
|
||||
*/
|
||||
char *
|
||||
db_get(dbio, k)
|
||||
DBIO *dbio;
|
||||
char *k;
|
||||
{
|
||||
DB *db = dbio->db;
|
||||
int status;
|
||||
|
||||
key.data = k;
|
||||
key.size = strlen(k)+1;
|
||||
|
||||
status = (*db->get)(db, &key, &dat, 0);
|
||||
dbio->lastkey = (char *)key.data;
|
||||
dbio->lastdat = (char *)dat.data;
|
||||
switch (status) {
|
||||
case RET_SUCCESS:
|
||||
break;
|
||||
case RET_ERROR:
|
||||
die("db_get failed.");
|
||||
case RET_SPECIAL:
|
||||
return((char *)0);
|
||||
}
|
||||
return((char *)dat.data);
|
||||
}
|
||||
/*
|
||||
* db_put: put data by a key.
|
||||
*
|
||||
* i) dbio descripter
|
||||
* i) k key
|
||||
* i) d data
|
||||
*/
|
||||
void
|
||||
db_put(dbio, k, d)
|
||||
DBIO *dbio;
|
||||
char *k;
|
||||
char *d;
|
||||
{
|
||||
DB *db = dbio->db;
|
||||
int status;
|
||||
|
||||
if (strlen(k) > MAXKEYLEN)
|
||||
die("primary key too long.");
|
||||
key.data = k;
|
||||
key.size = strlen(k)+1;
|
||||
dat.data = d;
|
||||
dat.size = strlen(d)+1;
|
||||
|
||||
status = (*db->put)(db, &key, &dat, 0);
|
||||
switch (status) {
|
||||
case RET_SUCCESS:
|
||||
break;
|
||||
case RET_ERROR:
|
||||
case RET_SPECIAL:
|
||||
die("db_put failed.");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* db_del: delete record by a key.
|
||||
*
|
||||
* i) dbio descripter
|
||||
* i) k key
|
||||
*/
|
||||
void
|
||||
db_del(dbio, k)
|
||||
DBIO *dbio;
|
||||
char *k;
|
||||
{
|
||||
DB *db = dbio->db;
|
||||
int status;
|
||||
|
||||
if (k) {
|
||||
key.data = k;
|
||||
key.size = strlen(k)+1;
|
||||
status = (*db->del)(db, &key, 0);
|
||||
} else
|
||||
status = (*db->del)(db, &key, R_CURSOR);
|
||||
if (status == RET_ERROR)
|
||||
die("db_del failed.");
|
||||
}
|
||||
/*
|
||||
* db_first: get first record.
|
||||
*
|
||||
* i) dbio dbio descripter
|
||||
* i) k key
|
||||
* !=NULL: indexed read by key
|
||||
* ==NULL: sequential read
|
||||
* i) flags following db_next call take over this.
|
||||
* DBIO_KEY read key part
|
||||
* DBIO_PREFIX prefix read
|
||||
* DBIO_SKIPMETA skip META record
|
||||
* only valied when sequential read
|
||||
* r) data
|
||||
*/
|
||||
char *
|
||||
db_first(dbio, k, flags)
|
||||
DBIO *dbio;
|
||||
char *k;
|
||||
int flags;
|
||||
{
|
||||
DB *db = dbio->db;
|
||||
int status;
|
||||
|
||||
if (flags & DBIO_PREFIX && !k)
|
||||
flags &= ~DBIO_PREFIX;
|
||||
if (flags & DBIO_SKIPMETA && k)
|
||||
flags &= ~DBIO_SKIPMETA;
|
||||
if (k) {
|
||||
if (strlen(k) > MAXKEYLEN)
|
||||
die("primary key too long.");
|
||||
strcpy(dbio->key, k);
|
||||
key.data = k;
|
||||
key.size = strlen(k);
|
||||
/*
|
||||
* includes NULL character unless prefix read.
|
||||
*/
|
||||
if (!(flags & DBIO_PREFIX))
|
||||
key.size++;
|
||||
dbio->keylen = key.size;
|
||||
status = (*db->seq)(db, &key, &dat, R_CURSOR);
|
||||
} else {
|
||||
dbio->keylen = dbio->key[0] = 0;
|
||||
for (status = (*db->seq)(db, &key, &dat, R_FIRST);
|
||||
status == RET_SUCCESS &&
|
||||
flags & DBIO_SKIPMETA &&
|
||||
*((char *)dat.data) == ' ';
|
||||
status = (*db->seq)(db, &key, &dat, R_NEXT))
|
||||
;
|
||||
}
|
||||
dbio->lastkey = (char *)key.data;
|
||||
dbio->lastdat = (char *)dat.data;
|
||||
switch (status) {
|
||||
case RET_SUCCESS:
|
||||
break;
|
||||
case RET_ERROR:
|
||||
die("db_first failed.");
|
||||
case RET_SPECIAL:
|
||||
return ((char *)0);
|
||||
}
|
||||
dbio->ioflags = flags;
|
||||
if (flags & DBIO_PREFIX) {
|
||||
if (strncmp((char *)key.data, dbio->key, dbio->keylen))
|
||||
return (char *)0;
|
||||
} else if (dbio->keylen) {
|
||||
if (strcmp((char *)key.data, dbio->key))
|
||||
return (char *)0;
|
||||
}
|
||||
if (flags & DBIO_KEY) {
|
||||
strcpy(dbio->prev, (char *)key.data);
|
||||
return (char *)key.data;
|
||||
}
|
||||
return ((char *)dat.data);
|
||||
}
|
||||
/*
|
||||
* db_next: get next record.
|
||||
*
|
||||
* i) dbio dbio descripter
|
||||
* r) data
|
||||
*/
|
||||
char *
|
||||
db_next(dbio)
|
||||
DBIO *dbio;
|
||||
{
|
||||
DB *db = dbio->db;
|
||||
int flags = dbio->ioflags;
|
||||
int status;
|
||||
|
||||
while ((status = (*db->seq)(db, &key, &dat, R_NEXT)) == RET_SUCCESS) {
|
||||
if (flags & DBIO_SKIPMETA) {
|
||||
if (*((char *)dat.data) == ' ')
|
||||
continue;
|
||||
}
|
||||
if (flags & DBIO_KEY) {
|
||||
if (!strcmp(dbio->prev, (char *)key.data))
|
||||
continue;
|
||||
if (strlen((char *)key.data) > MAXKEYLEN)
|
||||
die("primary key too long.");
|
||||
strcpy(dbio->prev, (char *)key.data);
|
||||
}
|
||||
dbio->lastkey = (char *)key.data;
|
||||
dbio->lastdat = (char *)dat.data;
|
||||
if (flags & DBIO_PREFIX) {
|
||||
if (strncmp((char *)key.data, dbio->key, dbio->keylen))
|
||||
return (char *)0;
|
||||
} else if (dbio->keylen) {
|
||||
if (strcmp((char *)key.data, dbio->key))
|
||||
return (char *)0;
|
||||
}
|
||||
return (flags & DBIO_KEY) ? (char *)key.data : (char *)dat.data;
|
||||
}
|
||||
if (status == RET_ERROR)
|
||||
die("db_next failed.");
|
||||
return (char *)0;
|
||||
}
|
||||
/*
|
||||
* db_close: close db
|
||||
*
|
||||
* i) dbio dbio descripter
|
||||
*/
|
||||
void
|
||||
db_close(dbio)
|
||||
DBIO *dbio;
|
||||
{
|
||||
DB *db = dbio->db;
|
||||
(void)db->close(db);
|
||||
if (dbio->openflags & DBIO_REMOVE)
|
||||
(void)unlink(dbio->dbname);
|
||||
else if (dbio->perm && chmod(dbio->dbname, dbio->perm) < 0)
|
||||
die("cannot change file mode.");
|
||||
(void)free(dbio);
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redilogibution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redilogibutions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redilogibutions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the dilogibution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* dbio.h 14-Dec-97
|
||||
*
|
||||
*/
|
||||
#ifndef _DBIO_H_
|
||||
#define _DBIO_H_
|
||||
|
||||
#include <db.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#ifndef LITTLE_ENDIAN
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
#ifndef BIG_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
|
||||
#define MAXKEYLEN 300
|
||||
|
||||
typedef struct {
|
||||
DB *db; /* descripter of DB */
|
||||
char dbname[MAXPATHLEN+1]; /* dbname */
|
||||
char key[MAXKEYLEN+1]; /* key */
|
||||
int keylen; /* key length */
|
||||
char prev[MAXKEYLEN+1]; /* previous key value */
|
||||
char *lastkey; /* the key of last located record */
|
||||
char *lastdat; /* the data of last located record */
|
||||
int openflags; /* flags of db_open() */
|
||||
int ioflags; /* flags of db_first() */
|
||||
int perm; /* file permission */
|
||||
} DBIO;
|
||||
|
||||
/*
|
||||
* openflags
|
||||
*/
|
||||
#define DBIO_DUP 1 /* allow duplicate records */
|
||||
#define DBIO_REMOVE 2 /* remove file when closed */
|
||||
/*
|
||||
* ioflags
|
||||
*/
|
||||
#define DBIO_KEY 1 /* read key part */
|
||||
#define DBIO_PREFIX 2 /* prefixed read */
|
||||
#define DBIO_SKIPMETA 4 /* skip META record */
|
||||
|
||||
#ifndef __P
|
||||
#if defined(__STDC__)
|
||||
#define __P(protos) protos
|
||||
#else
|
||||
#define __P(protos) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
DBIO *db_open __P((char *, int, int, int));
|
||||
char *db_get __P((DBIO *, char *));
|
||||
void db_put __P((DBIO *, char *, char *));
|
||||
void db_del __P((DBIO *, char *));
|
||||
char *db_first __P((DBIO *, char *, int));
|
||||
char *db_next __P((DBIO *));
|
||||
void db_close __P((DBIO *));
|
||||
#endif /* _DBIO_H_ */
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* dbname.c 20-Oct-97
|
||||
*
|
||||
*/
|
||||
#include "dbname.h"
|
||||
|
||||
static char *tagslist[] = {"GTAGS", "GRTAGS", "GSYMS"};
|
||||
/*
|
||||
* dbname: return db name
|
||||
*
|
||||
* i) db 0: GTAGS, 1: GRTAGS, 2: GSYMS
|
||||
* r) dbname
|
||||
*/
|
||||
char *
|
||||
dbname(db)
|
||||
int db;
|
||||
{
|
||||
return tagslist[db];
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* dbname.h 16-Oct-97
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DBNAME_H_
|
||||
#define _DBNAME_H_
|
||||
|
||||
#ifndef __P
|
||||
#if defined(__STDC__)
|
||||
#define __P(protos) protos
|
||||
#else
|
||||
#define __P(protos) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define GTAGS 0
|
||||
#define GRTAGS 1
|
||||
#define GSYMS 2
|
||||
#define GTAGLIM 3
|
||||
|
||||
char *dbname __P((int));
|
||||
|
||||
#endif /* ! _DBNAME_H_ */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -28,115 +28,159 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* find.c 20-Oct-97
|
||||
* find.c 1-May-98
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
/*
|
||||
* USEFIND use find(1) to traverse directory tree.
|
||||
* Otherwise, use dirent(3) library.
|
||||
*/
|
||||
#define USEFIND
|
||||
|
||||
#include <sys/param.h>
|
||||
#include "gparam.h"
|
||||
#include "find.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#ifndef USEFIND
|
||||
#include <dirent.h>
|
||||
#ifndef BSD4_4
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include "conf.h"
|
||||
#include "die.h"
|
||||
#include "find.h"
|
||||
#include "gparam.h"
|
||||
#include "locatestring.h"
|
||||
#include "makepath.h"
|
||||
#include "strbuf.h"
|
||||
|
||||
/*
|
||||
* usage of findxxx()
|
||||
*
|
||||
* findopen();
|
||||
* findopen(db);
|
||||
* while (path = findread(&length)) {
|
||||
* ...
|
||||
* }
|
||||
* findclose();
|
||||
*
|
||||
*/
|
||||
static char *skippath[] = {
|
||||
"y.tab.c",
|
||||
"y.tab.h",
|
||||
"SCCS/",
|
||||
"RCS/",
|
||||
};
|
||||
static char *ext[] = {
|
||||
"c",
|
||||
"h",
|
||||
"y",
|
||||
"s",
|
||||
"S",
|
||||
};
|
||||
static char findcom[MAXCOMLINE+1];
|
||||
static regex_t skip_area;
|
||||
static regex_t *skip;
|
||||
static FILE *ip;
|
||||
static regex_t *skip = &skip_area;
|
||||
static int opened;
|
||||
|
||||
int
|
||||
issource(path)
|
||||
char *path;
|
||||
static void trim __P((char *));
|
||||
|
||||
/*
|
||||
* trim: remove blanks and '\'.
|
||||
*/
|
||||
static void
|
||||
trim(s)
|
||||
char *s;
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (!(p = locatestring(path, ".", 2)))
|
||||
return 0;
|
||||
++p;
|
||||
if (sizeof(ext) != 0) {
|
||||
int i, lim = sizeof(ext)/sizeof(char *);
|
||||
for (i = 0; i < lim; i++)
|
||||
if (*ext[i] == *p && !strcmp(ext[i], p))
|
||||
return 1;
|
||||
for (p = s; *s; s++) {
|
||||
if (isspace(*s))
|
||||
continue;
|
||||
if (*s == '\\' && *(s + 1))
|
||||
s++;
|
||||
*p++ = *s;
|
||||
}
|
||||
return 0;
|
||||
*p = 0;
|
||||
}
|
||||
#ifdef USEFIND
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* find command version */
|
||||
/*----------------------------------------------------------------------*/
|
||||
static FILE *ip;
|
||||
|
||||
void
|
||||
findopen(void)
|
||||
findopen()
|
||||
{
|
||||
char edit[512], *p, *q;
|
||||
int i, lim;
|
||||
char *findcom, *p, *q;
|
||||
STRBUF *sb;
|
||||
char *sufflist = NULL;
|
||||
char *skiplist = NULL;
|
||||
|
||||
if (opened)
|
||||
die("nested call to findopen.");
|
||||
assert(opened == 0);
|
||||
opened = 1;
|
||||
p = findcom;
|
||||
strcpy(p, "find . \\( -type f -o -type l \\) \\(");
|
||||
p += strlen(p);
|
||||
lim = sizeof(ext)/sizeof(char *);
|
||||
for (i = 0; i < lim; i++) {
|
||||
sprintf(p, " -name '*.%s'%s", ext[i], (i + 1 < lim) ? " -o" : "");
|
||||
p += strlen(p);
|
||||
|
||||
sb = stropen();
|
||||
if (!getconfs("suffixes", sb))
|
||||
die("cannot get suffixes data.");
|
||||
sufflist = strdup(strvalue(sb));
|
||||
if (!sufflist)
|
||||
die("short of memory.");
|
||||
trim(sufflist);
|
||||
strstart(sb);
|
||||
if (getconfs("skip", sb)) {
|
||||
skiplist = strdup(strvalue(sb));
|
||||
if (!skiplist)
|
||||
die("short of memory.");
|
||||
trim(skiplist);
|
||||
}
|
||||
sprintf(p, " \\) -print");
|
||||
if (sizeof(skippath) != 0) {
|
||||
int i, lim = sizeof(skippath)/sizeof(char *);
|
||||
|
||||
strstart(sb);
|
||||
strputs(sb, "find . \\( -type f -o -type l \\) \\(");
|
||||
for (p = sufflist; p; ) {
|
||||
char *suff = p;
|
||||
if ((p = locatestring(p, ",", MATCH_FIRST)) != NULL)
|
||||
*p++ = 0;
|
||||
strputs(sb, " -name '*.");
|
||||
strputs(sb, suff);
|
||||
strputs(sb, "'");
|
||||
if (p)
|
||||
strputs(sb, " -o");
|
||||
}
|
||||
strputs(sb, " \\) -print");
|
||||
findcom = strvalue(sb);
|
||||
|
||||
if (skiplist) {
|
||||
char *reg;
|
||||
STRBUF *sbb = stropen();
|
||||
/*
|
||||
* construct regular expression.
|
||||
*/
|
||||
p = edit;
|
||||
*p++ = '(';
|
||||
for (i = 0; i < lim; i++) {
|
||||
*p++ = '/';
|
||||
for (q = skippath[i]; *q; q++) {
|
||||
strputc(sbb, '('); /* ) */
|
||||
for (p = skiplist; p; ) {
|
||||
char *skipf = p;
|
||||
if ((p = locatestring(p, ",", MATCH_FIRST)) != NULL)
|
||||
*p++ = 0;
|
||||
strputc(sbb, '/');
|
||||
for (q = skipf; *q; q++) {
|
||||
if (*q == '.')
|
||||
*p++ = '\\';
|
||||
*p++ = *q;
|
||||
strputc(sbb, '\\');
|
||||
strputc(sbb, *q);
|
||||
}
|
||||
if (*(q - 1) != '/')
|
||||
*p++ = '$';
|
||||
*p++ = '|';
|
||||
strputc(sbb, '$');
|
||||
if (p)
|
||||
strputc(sbb, '|');
|
||||
}
|
||||
*(p - 1) = ')';
|
||||
*p = 0;
|
||||
strputc(sbb, ')');
|
||||
reg = strvalue(sbb);
|
||||
/*
|
||||
* compile regular expression.
|
||||
*/
|
||||
skip = &skip_area;
|
||||
if (regcomp(skip, edit, REG_EXTENDED|REG_NEWLINE) != 0)
|
||||
if (regcomp(skip, reg, REG_EXTENDED|REG_NEWLINE) != 0)
|
||||
die("cannot compile regular expression.");
|
||||
strclose(sbb);
|
||||
} else {
|
||||
skip = (regex_t *)0;
|
||||
}
|
||||
if (!(ip = popen(findcom, "r")))
|
||||
die("cannot execute find.");
|
||||
strclose(sb);
|
||||
if (sufflist)
|
||||
free(sufflist);
|
||||
if (skiplist)
|
||||
free(skiplist);
|
||||
}
|
||||
char *
|
||||
findread(length)
|
||||
@ -145,8 +189,12 @@ int *length;
|
||||
static char path[MAXPATHLEN+1];
|
||||
char *p;
|
||||
|
||||
assert(opened == 1);
|
||||
while (fgets(path, MAXPATHLEN, ip)) {
|
||||
if (!skip || regexec(skip, path, 0, 0, 0) != 0) {
|
||||
/*
|
||||
* chop(path)
|
||||
*/
|
||||
p = path + strlen(path) - 1;
|
||||
if (*p != '\n')
|
||||
die("output of find(1) is wrong (findread).");
|
||||
@ -156,11 +204,242 @@ int *length;
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return (char *)0;
|
||||
return NULL;
|
||||
}
|
||||
void
|
||||
findclose(void)
|
||||
{
|
||||
assert(opened == 1);
|
||||
pclose(ip);
|
||||
opened = 0;
|
||||
}
|
||||
#else /* USEFIND */
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* dirent version findxxx() */
|
||||
/*----------------------------------------------------------------------*/
|
||||
#define STACKSIZE 50
|
||||
static char dir[MAXPATHLEN+1]; /* directory path */
|
||||
static struct {
|
||||
STRBUF *sb;
|
||||
char *dirp, *start, *end, *p;
|
||||
} stack[STACKSIZE], *topp, *curp; /* stack */
|
||||
|
||||
static regex_t suff_area;
|
||||
static regex_t *suff = &suff_area;
|
||||
|
||||
static int
|
||||
getdirs(dir, sb)
|
||||
char *dir;
|
||||
STRBUF *sb;
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
#ifndef BSD4_4
|
||||
struct stat st;
|
||||
#endif
|
||||
|
||||
if ((dirp = opendir(dir)) == NULL)
|
||||
return -1;
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
#ifdef BSD4_4
|
||||
if (dp->d_namlen == 1 && dp->d_name[0] == '.')
|
||||
continue;
|
||||
if (dp->d_namlen == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')
|
||||
continue;
|
||||
if (dp->d_type == DT_DIR)
|
||||
strputc(sb, 'd');
|
||||
else if (dp->d_type == DT_REG)
|
||||
strputc(sb, 'f');
|
||||
else if (dp->d_type == DT_LNK)
|
||||
strputc(sb, 'l');
|
||||
else
|
||||
strputc(sb, ' ');
|
||||
strnputs(sb, dp->d_name, (int)dp->d_namlen);
|
||||
#else
|
||||
if (stat(path, &st) < 0) {
|
||||
fprintf(stderr, "cannot stat '%s'. (Ignored)\n", path);
|
||||
continue;
|
||||
}
|
||||
if (S_ISDIR(st.st_mode))
|
||||
strputc(sb, 'd');
|
||||
else if (S_ISREG(st.st_mode))
|
||||
strputc(sb, 'f');
|
||||
else if (S_ISLNK(st.st_mode))
|
||||
strputc(sb, 'l');
|
||||
else
|
||||
strputc(sb, ' ');
|
||||
strputs(sb, dp->d_name);
|
||||
#endif /* BSD4_4 */
|
||||
strputc(sb, '\0');
|
||||
}
|
||||
(void)closedir(dirp);
|
||||
return 0;
|
||||
}
|
||||
void
|
||||
findopen()
|
||||
{
|
||||
STRBUF *sb = stropen();
|
||||
char *sufflist = NULL;
|
||||
char *skiplist = NULL;
|
||||
|
||||
assert(opened == 0);
|
||||
opened = 1;
|
||||
|
||||
/*
|
||||
* setup stack.
|
||||
*/
|
||||
curp = &stack[0];
|
||||
topp = curp + STACKSIZE;
|
||||
strcpy(dir, ".");
|
||||
|
||||
curp->dirp = dir + strlen(dir);
|
||||
curp->sb = stropen();
|
||||
if (getdirs(dir, curp->sb) < 0)
|
||||
die("cannot open '.' directory.");
|
||||
curp->start = curp->p = strvalue(curp->sb);
|
||||
curp->end = curp->start + strbuflen(curp->sb);
|
||||
|
||||
/*
|
||||
* preparing regular expression.
|
||||
*/
|
||||
strstart(sb);
|
||||
if (!getconfs("suffixes", sb))
|
||||
die("cannot get suffixes data.");
|
||||
sufflist = strdup(strvalue(sb));
|
||||
if (!sufflist)
|
||||
die("short of memory.");
|
||||
trim(sufflist);
|
||||
strstart(sb);
|
||||
if (getconfs("skip", sb)) {
|
||||
skiplist = strdup(strvalue(sb));
|
||||
if (!skiplist)
|
||||
die("short of memory.");
|
||||
trim(skiplist);
|
||||
}
|
||||
{
|
||||
char *p;
|
||||
|
||||
strstart(sb);
|
||||
strputc(sb, '('); /* ) */
|
||||
for (p = sufflist; p; ) {
|
||||
char *suffp = p;
|
||||
if ((p = locatestring(p, ",", MATCH_FIRST)) != NULL)
|
||||
*p++ = 0;
|
||||
strputs(sb, "\\.");
|
||||
strputs(sb, suffp);
|
||||
strputc(sb, '$');
|
||||
if (p)
|
||||
strputc(sb, '|');
|
||||
}
|
||||
strputc(sb, ')');
|
||||
/*
|
||||
* compile regular expression.
|
||||
*/
|
||||
if (regcomp(suff, strvalue(sb), REG_EXTENDED) != 0)
|
||||
die("cannot compile regular expression.");
|
||||
}
|
||||
if (skiplist) {
|
||||
char *p, *q;
|
||||
/*
|
||||
* construct regular expression.
|
||||
*/
|
||||
strstart(sb);
|
||||
strputc(sb, '('); /* ) */
|
||||
for (p = skiplist; p; ) {
|
||||
char *skipf = p;
|
||||
if ((p = locatestring(p, ",", MATCH_FIRST)) != NULL)
|
||||
*p++ = 0;
|
||||
strputc(sb, '/');
|
||||
for (q = skipf; *q; q++) {
|
||||
if (*q == '.')
|
||||
strputc(sb, '\\');
|
||||
strputc(sb, *q);
|
||||
}
|
||||
if (*(q - 1) != '/')
|
||||
strputc(sb, '$');
|
||||
if (p)
|
||||
strputc(sb, '|');
|
||||
}
|
||||
strputc(sb, ')');
|
||||
/*
|
||||
* compile regular expression.
|
||||
*/
|
||||
if (regcomp(skip, strvalue(sb), REG_EXTENDED) != 0)
|
||||
die("cannot compile regular expression.");
|
||||
} else {
|
||||
skip = (regex_t *)0;
|
||||
}
|
||||
strclose(sb);
|
||||
if (sufflist)
|
||||
free(sufflist);
|
||||
if (skiplist)
|
||||
free(skiplist);
|
||||
}
|
||||
char *
|
||||
findread(length)
|
||||
int *length;
|
||||
{
|
||||
static char val[MAXPATHLEN+1];
|
||||
|
||||
for (;;) {
|
||||
while (curp->p < curp->end) {
|
||||
char type = *(curp->p);
|
||||
char *unit = curp->p + 1;
|
||||
|
||||
curp->p += strlen(curp->p) + 1;
|
||||
if (type == 'f' || type == 'l') {
|
||||
char *path = makepath(dir, unit);
|
||||
if (regexec(suff, path, 0, 0, 0) != 0)
|
||||
continue;
|
||||
if (skip && regexec(skip, path, 0, 0, 0) == 0)
|
||||
continue;
|
||||
strcpy(val, path);
|
||||
return val;
|
||||
}
|
||||
if (type == 'd') {
|
||||
STRBUF *sb = stropen();
|
||||
char *dirp = curp->dirp;
|
||||
|
||||
strcat(dirp, "/");
|
||||
strcat(dirp, unit);
|
||||
if (getdirs(dir, sb) < 0) {
|
||||
fprintf(stderr, "cannot open directory '%s'. (Ignored)\n", dir);
|
||||
strclose(sb);
|
||||
*(curp->dirp) = 0;
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Push stack.
|
||||
*/
|
||||
if (++curp >= topp)
|
||||
die("directory stack over flow.");
|
||||
curp->dirp = dirp + strlen(dirp);
|
||||
curp->sb = sb;
|
||||
curp->start = curp->p = strvalue(sb);
|
||||
curp->end = curp->start + strbuflen(sb);
|
||||
}
|
||||
}
|
||||
strclose(curp->sb);
|
||||
curp->sb = NULL;
|
||||
if (curp == &stack[0])
|
||||
break;
|
||||
/*
|
||||
* Pop stack.
|
||||
*/
|
||||
curp--;
|
||||
*(curp->dirp) = 0;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void
|
||||
findclose(void)
|
||||
{
|
||||
assert(opened == 1);
|
||||
for (curp = &stack[0]; curp < topp; curp++)
|
||||
if (curp->sb != NULL)
|
||||
strclose(curp->sb);
|
||||
else
|
||||
break;
|
||||
opened = 0;
|
||||
}
|
||||
#endif /* !USEFIND */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -41,12 +41,10 @@
|
||||
|
||||
#include "die.h"
|
||||
#include "getdbpath.h"
|
||||
#include "locatestring.h"
|
||||
#include "test.h"
|
||||
|
||||
static char *makeobjdirprefix; /* obj partition */
|
||||
static char *makeobjdir; /* obj directory */
|
||||
static int bsd; /* if BSD */
|
||||
static const char *makeobjdirprefix; /* obj partition */
|
||||
static const char *makeobjdir; /* obj directory */
|
||||
|
||||
/*
|
||||
* gtagsexist: test whether GTAGS's existence.
|
||||
@ -67,17 +65,15 @@ char *dbpath;
|
||||
strcpy(dbpath, candidate);
|
||||
return 1;
|
||||
}
|
||||
if (bsd) {
|
||||
sprintf(path, "%s/%s/GTAGS", candidate, makeobjdir);
|
||||
if (test("fr", path)) {
|
||||
sprintf(dbpath, "%s/%s", candidate, makeobjdir);
|
||||
return 1;
|
||||
}
|
||||
sprintf(path, "%s%s/GTAGS", makeobjdirprefix, candidate);
|
||||
if (test("fr", path)) {
|
||||
sprintf(dbpath, "%s%s", makeobjdirprefix, candidate);
|
||||
return 1;
|
||||
}
|
||||
sprintf(path, "%s/%s/GTAGS", candidate, makeobjdir);
|
||||
if (test("fr", path)) {
|
||||
sprintf(dbpath, "%s/%s", candidate, makeobjdir);
|
||||
return 1;
|
||||
}
|
||||
sprintf(path, "%s%s/GTAGS", makeobjdirprefix, candidate);
|
||||
if (test("fr", path)) {
|
||||
sprintf(dbpath, "%s%s", makeobjdirprefix, candidate);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -110,17 +106,14 @@ char *dbpath;
|
||||
if (!strcmp(cwd, "/"))
|
||||
die("It's root directory! What are you doing?");
|
||||
|
||||
if (getenv("OSTYPE") && locatestring(getenv("OSTYPE"), "BSD", 0)) {
|
||||
if ((p = getenv("MAKEOBJDIRPREFIX")) != NULL)
|
||||
makeobjdirprefix = p;
|
||||
else
|
||||
makeobjdirprefix = "/usr/obj";
|
||||
if ((p = getenv("MAKEOBJDIR")) != NULL)
|
||||
makeobjdir = p;
|
||||
else
|
||||
makeobjdir = "obj";
|
||||
bsd = 1;
|
||||
}
|
||||
if ((p = getenv("MAKEOBJDIRPREFIX")) != NULL)
|
||||
makeobjdirprefix = p;
|
||||
else
|
||||
makeobjdirprefix = "/usr/obj";
|
||||
if ((p = getenv("MAKEOBJDIR")) != NULL)
|
||||
makeobjdir = p;
|
||||
else
|
||||
makeobjdir = "obj";
|
||||
|
||||
if ((p = getenv("GTAGSROOT")) != NULL) {
|
||||
if (*p != '/')
|
||||
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* gtagsopen.c 20-Oct-97
|
||||
*
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <db.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dbio.h"
|
||||
#include "dbname.h"
|
||||
#include "die.h"
|
||||
#include "gtagsopen.h"
|
||||
#include "makepath.h"
|
||||
|
||||
#define VERSIONKEY " __.VERSION"
|
||||
static int support_version = 1; /* accept this format version */
|
||||
|
||||
/*
|
||||
* gtagsopen: open global database.
|
||||
*
|
||||
* i) dbpath dbpath directory
|
||||
* i) db GTAGS, GRTAGS, GSYMS
|
||||
* i) mode 0: read only
|
||||
* 1: write only
|
||||
* 2: read and write
|
||||
* r) DB structure
|
||||
*
|
||||
* when error occurred, gtagopen doesn't return.
|
||||
*/
|
||||
DBIO *
|
||||
gtagsopen(dbpath, db, mode)
|
||||
char *dbpath;
|
||||
int db;
|
||||
int mode;
|
||||
{
|
||||
DBIO *dbio;
|
||||
int version_number;
|
||||
char *p;
|
||||
|
||||
/*
|
||||
* allow duplicate records.
|
||||
*/
|
||||
dbio = db_open(makepath(dbpath, dbname(db)), mode, 0644, DBIO_DUP);
|
||||
if (dbio == NULL) {
|
||||
if (mode == 1)
|
||||
die1("cannot make database (%s).", makepath(dbpath, dbname(db)));
|
||||
die1("database not found (%s).", makepath(dbpath, dbname(db)));
|
||||
}
|
||||
if (mode == 1) {
|
||||
/* nothing to do now */
|
||||
} else {
|
||||
/*
|
||||
* recognize format version of GTAGS. 'format version record'
|
||||
* is saved as a META record in GTAGS and GRTAGS.
|
||||
* if 'format version record' is not found, it's assumed
|
||||
* version 1.
|
||||
*/
|
||||
if ((p = db_get(dbio, VERSIONKEY)) != NULL) {
|
||||
for (p += strlen(VERSIONKEY); *p && isspace(*p); p++)
|
||||
;
|
||||
version_number = atoi(p);
|
||||
} else
|
||||
version_number = 1;
|
||||
if (version_number > support_version)
|
||||
die("GTAGS seems new format. Please install the latest GLOBAL.");
|
||||
}
|
||||
return dbio;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* gtagsopen.h 16-Oct-97
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GTAGSOPEN_H_
|
||||
#define _GTAGSOPEN_H_
|
||||
#include "dbio.h"
|
||||
|
||||
DBIO *gtagsopen __P((char *, int, int));
|
||||
|
||||
#endif /* ! _GTAGSOPEN_H_ */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -28,7 +28,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* locatestring.c 20-Oct-97
|
||||
* locatestring.c 25-Jul-98
|
||||
*
|
||||
*/
|
||||
#include <string.h>
|
||||
@ -40,35 +40,36 @@
|
||||
*
|
||||
* i) string string
|
||||
* i) pattern pattern
|
||||
* i) flag 0: match first
|
||||
* 1: match only at first column
|
||||
* 2: match last
|
||||
* 3: match only at last column
|
||||
* i) flag MATCH_FIRST: match first
|
||||
* MATCH_AT_FIRST: match only at first column
|
||||
* MATCH_LAST: match last
|
||||
* MATCH_AT_LAST: match only at last column
|
||||
* r) pointer or NULL
|
||||
*
|
||||
* This function is made to avoid compatibility problems.
|
||||
*/
|
||||
char *
|
||||
locatestring(string, pattern, flag)
|
||||
char *string;
|
||||
char *pattern;
|
||||
const char *string;
|
||||
const char *pattern;
|
||||
int flag;
|
||||
{
|
||||
int c = *pattern;
|
||||
char *p = (char *)0;
|
||||
int slen, plen;
|
||||
const char *p = NULL;
|
||||
|
||||
if (flag == 3 && strlen(string) > strlen(pattern)) {
|
||||
string += strlen(string) - strlen(pattern);
|
||||
}
|
||||
plen = strlen(pattern);
|
||||
if (flag == MATCH_AT_LAST && (slen = strlen(string)) > plen)
|
||||
string += (slen - plen);
|
||||
for (; *string; string++) {
|
||||
if (*string == c)
|
||||
if (!strncmp(string, pattern, strlen(pattern))) {
|
||||
if (!strncmp(string, pattern, plen)) {
|
||||
p = string;
|
||||
if (flag == 0)
|
||||
if (flag == MATCH_FIRST)
|
||||
break;
|
||||
}
|
||||
if (flag == 1 || flag == 3)
|
||||
if (flag == MATCH_AT_FIRST || flag == MATCH_AT_LAST)
|
||||
break;
|
||||
}
|
||||
return p;
|
||||
return (char *)p;
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* lookup.c 20-Oct-97
|
||||
*
|
||||
*/
|
||||
#include "gtagsopen.h"
|
||||
#include "lookup.h"
|
||||
#include "dbio.h"
|
||||
#include "die.h"
|
||||
#include "dbname.h"
|
||||
|
||||
static DBIO *dbio;
|
||||
static int opened;
|
||||
|
||||
void
|
||||
lookupopen(dbpath)
|
||||
char *dbpath;
|
||||
{
|
||||
if (opened)
|
||||
die("nested call to lookupopen.");
|
||||
opened = 1;
|
||||
dbio = gtagsopen(dbpath, GTAGS, 0);
|
||||
}
|
||||
int
|
||||
lookup(name)
|
||||
char *name;
|
||||
{
|
||||
char *p = db_get(dbio, name);
|
||||
return (p) ? 1 : 0;
|
||||
}
|
||||
void
|
||||
lookupclose(void)
|
||||
{
|
||||
db_close(dbio);
|
||||
opened = 0;
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* lookup.h 16-Oct-97
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LOOKUP_H_
|
||||
#define _LOOKUP_H_
|
||||
|
||||
#ifndef __P
|
||||
#if defined(__STDC__)
|
||||
#define __P(protos) protos
|
||||
#else
|
||||
#define __P(protos) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void lookupopen __P((char *));
|
||||
int lookup __P((char *));
|
||||
void lookupclose __P((void));
|
||||
|
||||
#endif /* ! _LOOKUP_H_ */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -28,12 +28,16 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* makepath.c 20-Oct-97
|
||||
* makepath.c 15-May-98
|
||||
*
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include "die.h"
|
||||
#include "makepath.h"
|
||||
#include "strbuf.h"
|
||||
|
||||
static STRBUF *sb;
|
||||
/*
|
||||
* makepath: make path from directory and file.
|
||||
*
|
||||
@ -43,16 +47,21 @@
|
||||
*/
|
||||
char *
|
||||
makepath(dir, file)
|
||||
char *dir;
|
||||
char *file;
|
||||
const char *dir;
|
||||
const char *file;
|
||||
{
|
||||
static char path[MAXPATHLEN+1];
|
||||
char *p;
|
||||
int length;
|
||||
|
||||
strcpy(path, dir);
|
||||
p = path + strlen(path);
|
||||
if (*(p - 1) != '/')
|
||||
*p++ = '/';
|
||||
strcpy(p, file);
|
||||
return path;
|
||||
if (sb == NULL)
|
||||
sb = stropen();
|
||||
strstart(sb);
|
||||
if ((length = strlen(dir)) > MAXPATHLEN)
|
||||
die1("path name too long. '%s'\n", dir);
|
||||
strputs(sb, dir);
|
||||
strunputc(sb, '/');
|
||||
strputc(sb, '/');
|
||||
strputs(sb, file);
|
||||
if ((length = strlen(strvalue(sb))) > MAXPATHLEN)
|
||||
die1("path name too long. '%s'\n", dir);
|
||||
return strvalue(sb);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -28,17 +28,20 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* mgets.c 8-Nov-97
|
||||
* mgets.c 29-Aug-98
|
||||
*
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mgets.h"
|
||||
#include "die.h"
|
||||
#include "mgets.h"
|
||||
|
||||
#define EXPANDSIZE 127
|
||||
#define MINSIZE 16
|
||||
|
||||
#define EXPANDSIZE 512
|
||||
static int mbufsize = EXPANDSIZE;
|
||||
static char *mbuf;
|
||||
|
||||
@ -46,20 +49,21 @@ static char *mbuf;
|
||||
* mgets: read whole record into allocated buffer
|
||||
*
|
||||
* i) ip input stream
|
||||
* o) length record length
|
||||
* i) flags flags
|
||||
* MGETS_CONT \\ + \n -> \n
|
||||
* MGETS_CONT \\ + \n -> ''
|
||||
* MGETS_SKIPCOM skip line which start with '#'.
|
||||
* o) length length of record
|
||||
* MGETS_TAILCUT remove following blanks
|
||||
* r) record buffer (NULL at end of file)
|
||||
*
|
||||
* Returned buffer has whole record.
|
||||
* The buffer end with '\0' and doesn't include '\r' and '\n'.
|
||||
*/
|
||||
char *
|
||||
mgets(ip, flags, length)
|
||||
mgets(ip, length, flags)
|
||||
FILE *ip;
|
||||
int flags;
|
||||
int *length;
|
||||
int flags;
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -73,27 +77,33 @@ int *length;
|
||||
* read whole record.
|
||||
*/
|
||||
if (!fgets(mbuf, mbufsize, ip))
|
||||
return (char *)0;
|
||||
return NULL;
|
||||
if (flags & MGETS_SKIPCOM)
|
||||
while (*mbuf == '#')
|
||||
if (!fgets(mbuf, mbufsize, ip))
|
||||
return (char *)0;
|
||||
return NULL;
|
||||
p = mbuf + strlen(mbuf);
|
||||
|
||||
for (;;) {
|
||||
/*
|
||||
* get a line.
|
||||
*/
|
||||
while (*(p - 1) != '\n') {
|
||||
/*
|
||||
* expand and read additionally.
|
||||
* expand buffer and read additionally.
|
||||
*/
|
||||
int count = p - mbuf;
|
||||
mbufsize += EXPANDSIZE;
|
||||
if (!(mbuf = (char *)realloc(mbuf, mbufsize + 1)))
|
||||
die("short of memory.");
|
||||
p = mbuf + count;
|
||||
if (!fgets(p, mbufsize - count, ip))
|
||||
die("illegal end of file.");
|
||||
|
||||
if (mbufsize - count < MINSIZE) {
|
||||
mbufsize += EXPANDSIZE;
|
||||
if (!(mbuf = (char *)realloc(mbuf, mbufsize + 1)))
|
||||
die("short of memory.");
|
||||
p = mbuf + count;
|
||||
}
|
||||
if (!fgets(p, mbufsize - count, ip)) {
|
||||
*p++ = '\n';
|
||||
break;
|
||||
}
|
||||
p += strlen(p);
|
||||
}
|
||||
/*
|
||||
@ -110,6 +120,17 @@ int *length;
|
||||
else
|
||||
break;
|
||||
}
|
||||
/*
|
||||
if (flags & MGETS_SKIPCOM)
|
||||
for (p = mbuf; *p; p++)
|
||||
if (*p == '#') {
|
||||
*p = 0;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
if (flags & MGETS_TAILCUT)
|
||||
while (isspace(*(--p)))
|
||||
*p = 0;
|
||||
if (length)
|
||||
*length = p - mbuf;
|
||||
return mbuf;
|
||||
|
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* strop.c 20-Oct-97
|
||||
*
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "die.h"
|
||||
#include "strop.h"
|
||||
|
||||
/*
|
||||
* usage: string buffer
|
||||
*
|
||||
* stropen();
|
||||
* for (s = string; *s; s++)
|
||||
* strputc(*s);
|
||||
* s = strclose();
|
||||
*/
|
||||
#define EXPANDSIZE 80
|
||||
static char *sbuf;
|
||||
static char *endp;
|
||||
static char *curp;
|
||||
static int sbufsize;
|
||||
static int opened;
|
||||
|
||||
void
|
||||
stropen(void)
|
||||
{
|
||||
if (opened)
|
||||
die("nested call to stropen.");
|
||||
opened = 1;
|
||||
/*
|
||||
* allocate initial buffer.
|
||||
*/
|
||||
if (!sbuf)
|
||||
if (!(sbuf = (char *)malloc(sbufsize + 1)))
|
||||
die("short of memory.");
|
||||
curp = sbuf;
|
||||
endp = sbuf + sbufsize;
|
||||
*curp = 0;
|
||||
}
|
||||
void
|
||||
strputs(s)
|
||||
char *s;
|
||||
{
|
||||
int length = strlen(s);
|
||||
|
||||
strnputs(s, length);
|
||||
}
|
||||
void
|
||||
strnputs(s, length)
|
||||
char *s;
|
||||
int length;
|
||||
{
|
||||
if (curp + length > endp) {
|
||||
int count = curp - sbuf;
|
||||
|
||||
sbufsize += (length > EXPANDSIZE) ? length : EXPANDSIZE;
|
||||
if (!(sbuf = (char *)realloc(sbuf, sbufsize + 1)))
|
||||
die("short of memory.");
|
||||
curp = sbuf + count;
|
||||
endp = sbuf + sbufsize;
|
||||
}
|
||||
strncpy(curp, s, length);
|
||||
curp += length;
|
||||
*curp = 0;
|
||||
}
|
||||
void
|
||||
strputc(c)
|
||||
int c;
|
||||
{
|
||||
if (curp + 1 > endp) {
|
||||
int count = curp - sbuf;
|
||||
|
||||
sbufsize += EXPANDSIZE;
|
||||
if (!(sbuf = (char *)realloc(sbuf, sbufsize + 1)))
|
||||
die("short of memory.");
|
||||
curp = sbuf + count;
|
||||
endp = sbuf + sbufsize;
|
||||
}
|
||||
*curp++ = c;
|
||||
*curp = 0;
|
||||
}
|
||||
char *
|
||||
strclose(void)
|
||||
{
|
||||
opened = 0;
|
||||
/*
|
||||
* doesn't free area in current implementation.
|
||||
*/
|
||||
return sbuf;
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* strop.h 16-Oct-97
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STROP_H_
|
||||
#define _STROP_H_
|
||||
|
||||
#ifndef __P
|
||||
#if defined(__STDC__)
|
||||
#define __P(protos) protos
|
||||
#else
|
||||
#define __P(protos) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void stropen __P((void));
|
||||
void strputs __P((char *));
|
||||
void strnputs __P((char *, int));
|
||||
void strputc __P((int));
|
||||
char *strclose __P((void));
|
||||
|
||||
#endif /* ! _STROP_H_ */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -28,14 +28,29 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* tab.c 20-Oct-97
|
||||
* tab.c 8-Oct-98
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "tab.h"
|
||||
|
||||
#define TABPOS(i) ((i)%8 == 0)
|
||||
static int tabs = 8;
|
||||
|
||||
#define TABPOS(i) ((i)%tabs == 0)
|
||||
/*
|
||||
* settabs: set default tab stop
|
||||
*
|
||||
* i) n tab stop
|
||||
*/
|
||||
void
|
||||
settabs(n)
|
||||
int n;
|
||||
{
|
||||
if (n < 1 || n > 32)
|
||||
return;
|
||||
tabs = n;
|
||||
}
|
||||
/*
|
||||
* detab: convert tabs into spaces and print
|
||||
*
|
||||
@ -84,7 +99,8 @@ char *buf;
|
||||
blanks++; /* count blanks */
|
||||
continue;
|
||||
}
|
||||
buf[dst++] = '\t';
|
||||
/* don't convert single blank into tab */
|
||||
buf[dst++] = (blanks == 0) ? ' ' : '\t';
|
||||
} else if (c == '\t') {
|
||||
while (!TABPOS(++pos))
|
||||
;
|
||||
@ -97,5 +113,8 @@ char *buf;
|
||||
}
|
||||
blanks = 0;
|
||||
}
|
||||
if (blanks > 0)
|
||||
while (blanks--)
|
||||
buf[dst++] = ' ';
|
||||
buf[dst] = 0;
|
||||
}
|
||||
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* tag.c 20-Oct-97
|
||||
*
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "dbio.h"
|
||||
#include "die.h"
|
||||
#include "gtagsopen.h"
|
||||
#include "locatestring.h"
|
||||
#include "tab.h"
|
||||
#include "tag.h"
|
||||
|
||||
|
||||
static DBIO *dbio;
|
||||
static int opened;
|
||||
|
||||
void
|
||||
tagopen(dbpath, db, mode)
|
||||
char *dbpath;
|
||||
int db;
|
||||
int mode;
|
||||
{
|
||||
if (opened)
|
||||
die("nested call to tagopen.");
|
||||
opened = 1;
|
||||
dbio = gtagsopen(dbpath, db, mode);
|
||||
}
|
||||
void
|
||||
tagput(entry, record)
|
||||
char *entry;
|
||||
char *record;
|
||||
{
|
||||
entab(record);
|
||||
db_put(dbio, entry, record);
|
||||
}
|
||||
void
|
||||
tagdelete(path)
|
||||
char *path;
|
||||
{
|
||||
char *p;
|
||||
int length = strlen(path);
|
||||
|
||||
for (p = db_first(dbio, NULL, DBIO_SKIPMETA); p; p = db_next(dbio)) {
|
||||
p = locatestring(p, "./", 0);
|
||||
if (!strncmp(p, path, length) && isspace(*(p + length)))
|
||||
db_del(dbio, NULL);
|
||||
}
|
||||
}
|
||||
void
|
||||
tagclose(void)
|
||||
{
|
||||
db_close(dbio);
|
||||
opened = 0;
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Shigio Yamaguchi.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* tag.h 16-Oct-97
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TAG_H_
|
||||
#define _TAG_H_
|
||||
|
||||
#ifndef __P
|
||||
#if defined(__STDC__)
|
||||
#define __P(protos) protos
|
||||
#else
|
||||
#define __P(protos) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void tagopen __P((char *, int, int));
|
||||
void tagput __P((char *, char *));
|
||||
void tagdelete __P((char *));
|
||||
void tagclose __P((void));
|
||||
|
||||
#endif /* ! _TAG_H_ */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
|
||||
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -31,8 +31,8 @@
|
||||
* test.c 12-Dec-97
|
||||
*
|
||||
*/
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
@ -50,21 +50,23 @@
|
||||
* "x" [ -x path ]
|
||||
*
|
||||
* i) path path
|
||||
* if NULL then previous path.
|
||||
* r) 0: no, 1: ok
|
||||
*
|
||||
* You can specify more than one character. It assumed 'and' test.
|
||||
*/
|
||||
int
|
||||
test(flags, path)
|
||||
char *flags;
|
||||
char *path;
|
||||
const char *flags;
|
||||
const char *path;
|
||||
{
|
||||
struct stat sb;
|
||||
static struct stat sb;
|
||||
int c;
|
||||
|
||||
if (stat(path, &sb) < 0)
|
||||
return 0;
|
||||
while ((c = *flags++) != NULL) {
|
||||
if (path != NULL)
|
||||
if (stat(path, &sb) < 0)
|
||||
return 0;
|
||||
while ((c = *flags++) != 0) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
if (!S_ISREG(sb.st_mode))
|
||||
|
@ -1,900 +0,0 @@
|
||||
diff -c -r -N /usr/src/usr.bin/vi/USD.doc/vi.man/vi.1 ./USD.doc/vi.man/vi.1
|
||||
*** /usr/src/usr.bin/vi/USD.doc/vi.man/vi.1 Wed Aug 17 08:36:39 1994
|
||||
--- ./USD.doc/vi.man/vi.1 Sat Dec 14 11:54:14 1996
|
||||
***************
|
||||
*** 39,59 ****
|
||||
.Nd text editors
|
||||
.Sh SYNOPSIS
|
||||
.Nm \&ex
|
||||
! .Op Fl eFRrsv
|
||||
.Op Fl c Ar cmd
|
||||
.Op Fl t Ar tag
|
||||
.Op Fl w Ar size
|
||||
.\".Op Fl X Ar \&aw
|
||||
.Op Ar "file ..."
|
||||
.Nm \&vi
|
||||
! .Op Fl eFRrv
|
||||
.Op Fl c Ar cmd
|
||||
.Op Fl t Ar tag
|
||||
.Op Fl w Ar size
|
||||
.\".Op Fl X Ar \&aw
|
||||
.Op Ar "file ..."
|
||||
.Nm view
|
||||
! .Op Fl eFRrv
|
||||
.Op Fl c Ar cmd
|
||||
.Op Fl t Ar tag
|
||||
.Op Fl w Ar size
|
||||
--- 39,59 ----
|
||||
.Nd text editors
|
||||
.Sh SYNOPSIS
|
||||
.Nm \&ex
|
||||
! .Op Fl eFGRrsv
|
||||
.Op Fl c Ar cmd
|
||||
.Op Fl t Ar tag
|
||||
.Op Fl w Ar size
|
||||
.\".Op Fl X Ar \&aw
|
||||
.Op Ar "file ..."
|
||||
.Nm \&vi
|
||||
! .Op Fl eFGRrv
|
||||
.Op Fl c Ar cmd
|
||||
.Op Fl t Ar tag
|
||||
.Op Fl w Ar size
|
||||
.\".Op Fl X Ar \&aw
|
||||
.Op Ar "file ..."
|
||||
.Nm view
|
||||
! .Op Fl eFGRrv
|
||||
.Op Fl c Ar cmd
|
||||
.Op Fl t Ar tag
|
||||
.Op Fl w Ar size
|
||||
***************
|
||||
*** 124,129 ****
|
||||
--- 124,131 ----
|
||||
Don't copy the entire file when first starting to edit.
|
||||
(The default is to make a copy in case someone else modifies
|
||||
the file during your edit session.)
|
||||
+ .It Fl G
|
||||
+ Start editing in gtags mode, as if the gtagsmode option was set.
|
||||
.It Fl R
|
||||
Start editing in read-only mode, as if the command name was
|
||||
.Nm view ,
|
||||
***************
|
||||
*** 377,382 ****
|
||||
--- 379,385 ----
|
||||
Move the cursor down
|
||||
.Li count
|
||||
lines to the first nonblank character of that line.
|
||||
+ In gtags select mode, <control-M> select current line as a tag.
|
||||
.It Sy "[count] <control-P>"
|
||||
.It Sy "[count] k"
|
||||
Move the cursor up
|
||||
***************
|
||||
*** 402,408 ****
|
||||
.Nm \&ex
|
||||
commands or cancel partial commands.
|
||||
.It Sy "<control-]>"
|
||||
! Push a tag reference onto the tag stack.
|
||||
.It Sy "<control-^>"
|
||||
Switch to the most recently edited file.
|
||||
.It Sy "[count] <space>"
|
||||
--- 405,412 ----
|
||||
.Nm \&ex
|
||||
commands or cancel partial commands.
|
||||
.It Sy "<control-]>"
|
||||
! Push a tag reference onto the tag stack. In gtagsmode, if at the first column
|
||||
! of line, locate function references otherwise function definitions.
|
||||
.It Sy "<control-^>"
|
||||
Switch to the most recently edited file.
|
||||
.It Sy "[count] <space>"
|
||||
***************
|
||||
*** 780,785 ****
|
||||
--- 784,793 ----
|
||||
Grow or shrink the current screen.
|
||||
.It Sy "rew[ind][!]"
|
||||
Rewind the argument list.
|
||||
+ .It Sy "rta[g][!] tagstring"
|
||||
+ Edit the file refering the specified tag. (Only in gtagsmode)
|
||||
+ .It Sy "se[lect]"
|
||||
+ Select a tag from gtags list.
|
||||
.It Sy "se[t] [option[=[value]] ...] [nooption ...] [option? ...] [all]"
|
||||
Display or set editor options.
|
||||
.It Sy "sh[ell]"
|
||||
***************
|
||||
*** 901,906 ****
|
||||
--- 909,916 ----
|
||||
style) expressions.
|
||||
.It Sy "flash [on]"
|
||||
Flash the screen instead of beeping the keyboard on error.
|
||||
+ .It Sy "gtagsmode, gt [off]"
|
||||
+ Use GTAGS and GRTAGS instead of tags.
|
||||
.It Sy "hardtabs, ht [8]"
|
||||
Set the spacing between hardware tab settings.
|
||||
.It Sy "ignorecase, ic [off]"
|
||||
diff -c -r -N /usr/src/usr.bin/vi/common/Makefile ./common/Makefile
|
||||
*** /usr/src/usr.bin/vi/common/Makefile Mon Sep 12 07:01:45 1994
|
||||
--- ./common/Makefile Sat Dec 14 11:55:27 1996
|
||||
***************
|
||||
*** 9,15 ****
|
||||
LINKS+= ${BINDIR}/${VI} ${BINDIR}/view
|
||||
MAN1= ${.CURDIR}/../USD.doc/vi.man/vi.1
|
||||
|
||||
! CFLAGS+=-I. -I${.CURDIR}
|
||||
DPADD+= ${LIBCURSES} ${LIBTERMCAP} ${LIBUTIL}
|
||||
LDADD+= -lcurses -ltermcap -lutil
|
||||
|
||||
--- 9,15 ----
|
||||
LINKS+= ${BINDIR}/${VI} ${BINDIR}/view
|
||||
MAN1= ${.CURDIR}/../USD.doc/vi.man/vi.1
|
||||
|
||||
! CFLAGS+=-I. -I${.CURDIR} -DGTAGS
|
||||
DPADD+= ${LIBCURSES} ${LIBTERMCAP} ${LIBUTIL}
|
||||
LDADD+= -lcurses -ltermcap -lutil
|
||||
|
||||
diff -c -r -N /usr/src/usr.bin/vi/common/exf.c ./common/exf.c
|
||||
*** /usr/src/usr.bin/vi/common/exf.c Tue May 30 15:35:44 1995
|
||||
--- ./common/exf.c Sat Dec 14 11:54:15 1996
|
||||
***************
|
||||
*** 156,162 ****
|
||||
--- 156,169 ----
|
||||
* Required FRP initialization; the only flag we keep is the
|
||||
* cursor information.
|
||||
*/
|
||||
+ #ifdef GTAGS
|
||||
+ /*
|
||||
+ * we must keep gtagstmp information too.
|
||||
+ */
|
||||
+ F_CLR(frp, ~(FR_CURSORSET|FR_GTAGSTMP));
|
||||
+ #else
|
||||
F_CLR(frp, ~FR_CURSORSET);
|
||||
+ #endif
|
||||
|
||||
/*
|
||||
* Required EXF initialization:
|
||||
***************
|
||||
*** 290,295 ****
|
||||
--- 297,305 ----
|
||||
* an error.
|
||||
*/
|
||||
if (rcv_name == NULL)
|
||||
+ #ifdef GTAGS
|
||||
+ if (!F_ISSET(frp, FR_GTAGSTMP))
|
||||
+ #endif
|
||||
switch (file_lock(oname,
|
||||
&ep->fcntl_fd, ep->db->fd(ep->db), 0)) {
|
||||
case LOCK_FAILED:
|
||||
diff -c -r -N /usr/src/usr.bin/vi/common/gs.h ./common/gs.h
|
||||
*** /usr/src/usr.bin/vi/common/gs.h Wed Aug 17 08:36:42 1994
|
||||
--- ./common/gs.h Sat Dec 14 11:54:15 1996
|
||||
***************
|
||||
*** 48,53 ****
|
||||
--- 48,56 ----
|
||||
|
||||
sigset_t blockset; /* Signal mask. */
|
||||
|
||||
+ #ifdef GTAGS
|
||||
+ char *gtagstmp; /* gtagstmp made by -t option */
|
||||
+ #endif
|
||||
#ifdef DEBUG
|
||||
FILE *tracefp; /* Trace file pointer. */
|
||||
#endif
|
||||
diff -c -r -N /usr/src/usr.bin/vi/common/main.c ./common/main.c
|
||||
*** /usr/src/usr.bin/vi/common/main.c Tue May 30 15:35:45 1995
|
||||
--- ./common/main.c Sat Dec 14 11:54:15 1996
|
||||
***************
|
||||
*** 98,103 ****
|
||||
--- 98,106 ----
|
||||
SCR *sp;
|
||||
u_int flags, saved_vi_mode;
|
||||
int ch, eval, flagchk, readonly, silent, snapshot;
|
||||
+ #ifdef GTAGS
|
||||
+ int gtags = 0;
|
||||
+ #endif
|
||||
char *excmdarg, *myname, *p, *tag_f, *trace_f, *wsizearg;
|
||||
char path[MAXPATHLEN];
|
||||
|
||||
***************
|
||||
*** 134,140 ****
|
||||
--- 137,147 ----
|
||||
excmdarg = tag_f = trace_f = wsizearg = NULL;
|
||||
silent = 0;
|
||||
snapshot = 1;
|
||||
+ #ifdef GTAGS
|
||||
+ while ((ch = getopt(argc, argv, "c:eFGRrsT:t:vw:X:")) != EOF)
|
||||
+ #else
|
||||
while ((ch = getopt(argc, argv, "c:eFRrsT:t:vw:X:")) != EOF)
|
||||
+ #endif
|
||||
switch (ch) {
|
||||
case 'c': /* Run the command. */
|
||||
excmdarg = optarg;
|
||||
***************
|
||||
*** 146,151 ****
|
||||
--- 153,163 ----
|
||||
case 'F': /* No snapshot. */
|
||||
snapshot = 0;
|
||||
break;
|
||||
+ #ifdef GTAGS
|
||||
+ case 'G': /* gtags mode. */
|
||||
+ gtags = 1;
|
||||
+ break;
|
||||
+ #endif
|
||||
case 'R': /* Readonly. */
|
||||
readonly = 1;
|
||||
break;
|
||||
***************
|
||||
*** 245,250 ****
|
||||
--- 257,266 ----
|
||||
goto err;
|
||||
if (readonly) /* Global read-only bit. */
|
||||
O_SET(sp, O_READONLY);
|
||||
+ #ifdef GTAGS
|
||||
+ if (gtags) /* Global gtags bit. */
|
||||
+ O_SET(sp, O_GTAGSMODE);
|
||||
+ #endif
|
||||
if (silent) { /* Ex batch mode. */
|
||||
O_CLR(sp, O_AUTOPRINT);
|
||||
O_CLR(sp, O_PROMPT);
|
||||
***************
|
||||
*** 515,520 ****
|
||||
--- 531,539 ----
|
||||
LIST_INIT(&gp->cutq);
|
||||
LIST_INIT(&gp->seqq);
|
||||
|
||||
+ #ifdef GTAGS
|
||||
+ gp->gtagstmp = NULL;
|
||||
+ #endif
|
||||
/* Set a flag if we're reading from the tty. */
|
||||
if (isatty(STDIN_FILENO))
|
||||
F_SET(gp, G_STDIN_TTY);
|
||||
***************
|
||||
*** 554,559 ****
|
||||
--- 573,584 ----
|
||||
SCR *sp;
|
||||
char *tty;
|
||||
|
||||
+ #ifdef GTAGS
|
||||
+ if (gp->gtagstmp) {
|
||||
+ if (!strncmp(gp->gtagstmp, _PATH_GTAGSTMP, strlen(_PATH_GTAGSTMP)))
|
||||
+ (void)unlink(gp->gtagstmp);
|
||||
+ }
|
||||
+ #endif
|
||||
/* Default buffer storage. */
|
||||
(void)text_lfree(&gp->dcb_store.textq);
|
||||
|
||||
diff -c -r -N /usr/src/usr.bin/vi/common/msg.c ./common/msg.c
|
||||
*** /usr/src/usr.bin/vi/common/msg.c Thu Aug 18 10:10:54 1994
|
||||
--- ./common/msg.c Sat Dec 14 11:54:15 1996
|
||||
***************
|
||||
*** 338,343 ****
|
||||
--- 338,352 ----
|
||||
#else
|
||||
pid = "";
|
||||
#endif
|
||||
+ #ifdef GTAGS
|
||||
+ if (F_ISSET(sp->frp, FR_GTAGSTMP)) {
|
||||
+ if (file_lline(sp, ep, &last)) {
|
||||
+ return (1);
|
||||
+ }
|
||||
+ msgq(sp, M_INFO, "[GTAGS SELECT MODE] %d lines", last);
|
||||
+ return (0);
|
||||
+ }
|
||||
+ #endif
|
||||
/*
|
||||
* See nvi/exf.c:file_init() for a description of how and
|
||||
* when the read-only bit is set.
|
||||
diff -c -r -N /usr/src/usr.bin/vi/common/options.c ./common/options.c
|
||||
*** /usr/src/usr.bin/vi/common/options.c Tue May 30 15:35:46 1995
|
||||
--- ./common/options.c Sat Dec 14 11:54:15 1996
|
||||
***************
|
||||
*** 103,108 ****
|
||||
--- 103,112 ----
|
||||
{"extended", NULL, OPT_0BOOL, 0},
|
||||
/* O_FLASH HPUX */
|
||||
{"flash", NULL, OPT_1BOOL, 0},
|
||||
+ #ifdef GTAGS
|
||||
+ /* O_GTAGSMODE SPECIAL */
|
||||
+ {"gtagsmode", NULL, OPT_0BOOL, 0},
|
||||
+ #endif
|
||||
/* O_HARDTABS 4BSD */
|
||||
{"hardtabs", NULL, OPT_NUM, 0},
|
||||
/* O_IGNORECASE 4BSD */
|
||||
***************
|
||||
*** 228,233 ****
|
||||
--- 232,240 ----
|
||||
{"eb", O_ERRORBELLS}, /* 4BSD */
|
||||
{"ed", O_EDCOMPATIBLE}, /* 4BSD */
|
||||
{"ex", O_EXRC}, /* System V (undocumented) */
|
||||
+ #ifdef GTAGS
|
||||
+ {"gt", O_GTAGSMODE}, /* Special */
|
||||
+ #endif
|
||||
{"ht", O_HARDTABS}, /* 4BSD */
|
||||
{"ic", O_IGNORECASE}, /* 4BSD */
|
||||
{"li", O_LINES}, /* 4.4BSD */
|
||||
diff -c -r -N /usr/src/usr.bin/vi/common/pathnames.h ./common/pathnames.h
|
||||
*** /usr/src/usr.bin/vi/common/pathnames.h Wed Aug 17 08:36:43 1994
|
||||
--- ./common/pathnames.h Sat Dec 14 11:54:15 1996
|
||||
***************
|
||||
*** 43,45 ****
|
||||
--- 43,48 ----
|
||||
#define _PATH_TAGS "tags"
|
||||
#define _PATH_TMP "/tmp"
|
||||
#define _PATH_TTY "/dev/tty"
|
||||
+ #ifdef GTAGS
|
||||
+ #define _PATH_GTAGSTMP "/var/tmp/gtags"
|
||||
+ #endif
|
||||
diff -c -r -N /usr/src/usr.bin/vi/common/screen.h ./common/screen.h
|
||||
*** /usr/src/usr.bin/vi/common/screen.h Wed Aug 17 08:36:43 1994
|
||||
--- ./common/screen.h Sat Dec 14 11:54:15 1996
|
||||
***************
|
||||
*** 87,92 ****
|
||||
--- 87,95 ----
|
||||
#define FR_TMPEXIT 0x100 /* Modified temporary file, no exit. */
|
||||
#define FR_TMPFILE 0x200 /* If file has no name. */
|
||||
#define FR_UNLOCKED 0x400 /* File couldn't be locked. */
|
||||
+ #ifdef GTAGS
|
||||
+ #define FR_GTAGSTMP 0x800 /* File is gtags temporary file. */
|
||||
+ #endif
|
||||
u_int16_t flags;
|
||||
};
|
||||
|
||||
diff -c -r -N /usr/src/usr.bin/vi/ex/ex_tag.c ./ex/ex_tag.c
|
||||
*** /usr/src/usr.bin/vi/ex/ex_tag.c Thu Aug 18 10:13:20 1994
|
||||
--- ./ex/ex_tag.c Sat Dec 14 11:54:15 1996
|
||||
***************
|
||||
*** 64,69 ****
|
||||
--- 64,72 ----
|
||||
#include "vi.h"
|
||||
#include "excmd.h"
|
||||
#include "tag.h"
|
||||
+ #ifdef GTAGS
|
||||
+ #include "pathnames.h"
|
||||
+ #endif
|
||||
|
||||
static char *binary_search __P((char *, char *, char *));
|
||||
static int compare __P((char *, char *, char *));
|
||||
***************
|
||||
*** 71,76 ****
|
||||
--- 74,288 ----
|
||||
static int search __P((SCR *, char *, char *, char **));
|
||||
static int tag_get __P((SCR *, char *, char **, char **, char **));
|
||||
|
||||
+ #ifdef DEBUG
|
||||
+ void
|
||||
+ trace(fp)
|
||||
+ FILE *fp;
|
||||
+ {
|
||||
+ SCR *sp;
|
||||
+ TAG *tp;
|
||||
+ FREF *frp;
|
||||
+ int scr, fref, tag;
|
||||
+
|
||||
+ fprintf(fp, "------------------------------------\n");
|
||||
+ scr = 0;
|
||||
+ for (sp = __global_list->dq.cqh_first; sp != (void *)&__global_list->dq; sp = sp->q.cqe_next) {
|
||||
+ fprintf(fp, "screen %d {\n", ++scr);
|
||||
+ fref = 0;
|
||||
+ for (frp = sp->frefq.cqh_first;
|
||||
+ frp != (FREF *)&sp->frefq; frp = frp->q.cqe_next) {
|
||||
+ fprintf(fp, " FREF %d ", ++fref);
|
||||
+ if (F_ISSET(frp, FR_GTAGSTMP))
|
||||
+ fprintf(fp, "<%s>\n", frp->name);
|
||||
+ else
|
||||
+ fprintf(fp, "%s\n", frp->name);
|
||||
+ }
|
||||
+ tag = 0;
|
||||
+ if (!EXP(sp))
|
||||
+ continue;
|
||||
+ fprintf(fp, " ................................\n");
|
||||
+ for (tp = EXP(sp)->tagq.tqh_first; tp != NULL; tp = tp->q.tqe_next) {
|
||||
+ fprintf(fp, " TAG %d ", ++tag);
|
||||
+ if (F_ISSET(tp->frp, FR_GTAGSTMP))
|
||||
+ fprintf(fp, "<%s>\n", tp->frp->name);
|
||||
+ else
|
||||
+ fprintf(fp, "%s\n", tp->frp->name);
|
||||
+ }
|
||||
+ fprintf(fp, "}\n");
|
||||
+ }
|
||||
+ fprintf(fp, "------------------------------------\n");
|
||||
+ }
|
||||
+ #endif
|
||||
+ #ifdef GTAGS
|
||||
+ /*
|
||||
+ * getentry --
|
||||
+ * get tag information from current line.
|
||||
+ *
|
||||
+ * gtags temporary file format.
|
||||
+ * <tag> <lineno> <file> <image>
|
||||
+ *
|
||||
+ * sample.
|
||||
+ * +------------------------------------------------
|
||||
+ * |main 30 main.c main(argc, argv)
|
||||
+ * |func 21 subr.c func(arg)
|
||||
+ */
|
||||
+ static int
|
||||
+ getentry(buf, tag, file, line)
|
||||
+ char *buf, *tag, *file, *line;
|
||||
+ {
|
||||
+ char *p;
|
||||
+
|
||||
+ p = tag;
|
||||
+ while (*buf && !isspace(*buf)) /* tag name */
|
||||
+ *p++ = *buf++;
|
||||
+ *p = 0;
|
||||
+ while (*buf && isspace(*buf)) /* skip blanks */
|
||||
+ buf++;
|
||||
+ p = line;
|
||||
+ while (*buf && !isspace(*buf)) /* line no */
|
||||
+ *p++ = *buf++;
|
||||
+ *p = 0;
|
||||
+ while (*buf && isspace(*buf)) /* skip blanks */
|
||||
+ buf++;
|
||||
+ p = file;
|
||||
+ while (*buf && !isspace(*buf)) /* file name */
|
||||
+ *p++ = *buf++;
|
||||
+ *p = 0;
|
||||
+
|
||||
+ /* value check */
|
||||
+ if (strlen(tag) && strlen(line) && strlen(file) && atoi(line) > 0)
|
||||
+ return 1; /* OK */
|
||||
+ return 0; /* ERROR */
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * gtag_get --
|
||||
+ * Get a gtag from the GTAGS files.
|
||||
+ */
|
||||
+ static int
|
||||
+ gtag_get(sp, ref, gtagselect, tag, tagp, filep, searchp)
|
||||
+ SCR *sp;
|
||||
+ int ref;
|
||||
+ int *gtagselect;
|
||||
+ char *tag, **tagp, **filep, **searchp;
|
||||
+ {
|
||||
+ static char name[80], file[200], line[10], gtagstmp[80];
|
||||
+ char command[200];
|
||||
+ char buf[BUFSIZ+1];
|
||||
+ FILE *fp;
|
||||
+
|
||||
+ sprintf(gtagstmp, "%s.XXXXXXXX", _PATH_GTAGSTMP);
|
||||
+ if (mktemp(gtagstmp) == 0) {
|
||||
+ msgq(sp, M_ERR, "cannot generate temporary file name");
|
||||
+ return (1);
|
||||
+ }
|
||||
+ sprintf(command, "global -%s '%s' > %s; chmod 600 %s",
|
||||
+ ref ? "rx" : "x", tag, gtagstmp, gtagstmp);
|
||||
+ if (system(command)) {
|
||||
+ msgq(sp, M_ERR, "cannot exec global");
|
||||
+ goto err;
|
||||
+ }
|
||||
+ if (!(fp = fopen(gtagstmp, "r"))) {
|
||||
+ msgq(sp, M_ERR, "tag file cannot open.");
|
||||
+ goto err;
|
||||
+ }
|
||||
+ if (!(fgets(buf, BUFSIZ, fp))) {
|
||||
+ msgq(sp, M_ERR, "%s: tag not found", tag);
|
||||
+ fclose(fp);
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+ if (getentry(buf, name, file, line) == 0) {
|
||||
+ msgq(sp, M_ERR, "%s: illegal tag entry", tag);
|
||||
+ fclose(fp);
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+ if (!(fgets(buf, BUFSIZ, fp))) { /* just one line */
|
||||
+ fclose(fp);
|
||||
+ (void)unlink(gtagstmp);
|
||||
+ *gtagselect = 0; /* go to user's file immediately */
|
||||
+ *tagp = strdup(name);
|
||||
+ *filep = file;
|
||||
+ *searchp = line;
|
||||
+ if (*tagp == NULL) {
|
||||
+ msgq(sp, M_SYSERR, NULL);
|
||||
+ return (1);
|
||||
+ }
|
||||
+ return (0);
|
||||
+ }
|
||||
+ fclose(fp);
|
||||
+ *gtagselect = 1; /* go to gtags select mode */
|
||||
+ *tagp = strdup(name);
|
||||
+ *filep = gtagstmp;
|
||||
+ *searchp = "1";
|
||||
+ if (*tagp == NULL) {
|
||||
+ msgq(sp, M_SYSERR, NULL);
|
||||
+ return (1);
|
||||
+ }
|
||||
+ return (0);
|
||||
+ err:
|
||||
+ (void)unlink(gtagstmp);
|
||||
+ return (1);
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * ex_gtagselect --
|
||||
+ * The tag code can be entered from gtag select mode.
|
||||
+ */
|
||||
+ int
|
||||
+ ex_gtagselect(sp, ep, cmdp)
|
||||
+ SCR *sp;
|
||||
+ EXF *ep;
|
||||
+ EXCMDARG *cmdp;
|
||||
+ {
|
||||
+ if (!F_ISSET(sp->frp, FR_GTAGSTMP)) {
|
||||
+ msgq(sp, M_ERR, "illegal tag entry");
|
||||
+ return (1);
|
||||
+ }
|
||||
+ cmdp->cmd = &cmds[C_TAG];
|
||||
+ cmdp->flags |= (E_GTAGSELECT|E_FORCE);
|
||||
+ return ex_tagpush(sp, ep, cmdp);
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * should_delete --
|
||||
+ * 1: should delete, 0: should not delete
|
||||
+ */
|
||||
+ int
|
||||
+ should_delete(gtagstmp)
|
||||
+ char *gtagstmp;
|
||||
+ {
|
||||
+ SCR *sp;
|
||||
+ TAG *tp;
|
||||
+ int tagcnt = 0;
|
||||
+
|
||||
+ /* make sure */
|
||||
+ if (strncmp(gtagstmp, _PATH_GTAGSTMP, strlen(_PATH_GTAGSTMP)))
|
||||
+ return 0;
|
||||
+ /* this gtag is generated by -t option. don't delete here */
|
||||
+ if (__global_list->gtagstmp && !strcmp(gtagstmp, __global_list->gtagstmp))
|
||||
+ return 0;
|
||||
+
|
||||
+ for (sp = __global_list->dq.cqh_first; sp != (void *)&__global_list->dq; sp = sp->q.cqe_next) {
|
||||
+ if (!EXP(sp))
|
||||
+ continue;
|
||||
+ for (tp = EXP(sp)->tagq.tqh_first; tp != NULL; tp = tp->q.tqe_next) {
|
||||
+ if (!tp->frp || !F_ISSET(tp->frp, FR_GTAGSTMP))
|
||||
+ continue;
|
||||
+ if (!strcmp(tp->frp->name, gtagstmp))
|
||||
+ ++tagcnt;
|
||||
+ }
|
||||
+ }
|
||||
+ if (tagcnt == 1)
|
||||
+ return 1;
|
||||
+ if (tagcnt > 1)
|
||||
+ return 0;
|
||||
+ /* IMPOSSIBLE */
|
||||
+ return 0;
|
||||
+ }
|
||||
+ #endif
|
||||
+
|
||||
/*
|
||||
* ex_tagfirst --
|
||||
* The tag code can be entered from main, i.e. "vi -t tag".
|
||||
***************
|
||||
*** 86,96 ****
|
||||
--- 298,317 ----
|
||||
u_int flags;
|
||||
int sval;
|
||||
char *p, *tag, *name, *search;
|
||||
+ #ifdef GTAGS
|
||||
+ int gtagselect = 0;
|
||||
+ #endif
|
||||
|
||||
/* Taglength may limit the number of characters. */
|
||||
if ((tl = O_VAL(sp, O_TAGLENGTH)) != 0 && strlen(tagarg) > tl)
|
||||
tagarg[tl] = '\0';
|
||||
|
||||
+ #ifdef GTAGS
|
||||
+ if (O_ISSET(sp, O_GTAGSMODE)) {
|
||||
+ if (gtag_get(sp, 0, >agselect, tagarg, &tag, &name, &search))
|
||||
+ return (1);
|
||||
+ } else
|
||||
+ #endif
|
||||
/* Get the tag information. */
|
||||
if (tag_get(sp, tagarg, &tag, &name, &search))
|
||||
return (1);
|
||||
***************
|
||||
*** 106,111 ****
|
||||
--- 327,336 ----
|
||||
* The historic tags file format (from a long, long time ago...)
|
||||
* used a line number, not a search string. I got complaints, so
|
||||
* people are still using the format.
|
||||
+ #ifdef GTAGS
|
||||
+ * Yes, gtags use the old format. Search string is very flexible
|
||||
+ * but is not suitable to treat duplicate entries.
|
||||
+ #endif
|
||||
*/
|
||||
if (isdigit(search[0])) {
|
||||
m.lno = atoi(search);
|
||||
***************
|
||||
*** 132,137 ****
|
||||
--- 357,371 ----
|
||||
frp->lno = m.lno;
|
||||
frp->cno = m.cno;
|
||||
F_SET(frp, FR_CURSORSET);
|
||||
+ #ifdef GTAGS
|
||||
+ if (gtagselect) {
|
||||
+ F_SET(frp, FR_GTAGSTMP);
|
||||
+ if (!(sp->gp->gtagstmp = strdup(name))) {
|
||||
+ msgq(sp, M_SYSERR, NULL);
|
||||
+ return (1);
|
||||
+ }
|
||||
+ }
|
||||
+ #endif
|
||||
|
||||
/* Might as well make this the default tag. */
|
||||
if ((EXP(sp)->tlast = strdup(tagarg)) == NULL) {
|
||||
***************
|
||||
*** 142,153 ****
|
||||
--- 376,399 ----
|
||||
}
|
||||
|
||||
/* Free a tag or tagf structure from a queue. */
|
||||
+ #ifdef GTAGS
|
||||
#define FREETAG(tp) { \
|
||||
+ if (F_ISSET(tp->frp, FR_GTAGSTMP)) \
|
||||
+ if (should_delete(tp->frp->name)) \
|
||||
+ unlink(tp->frp->name); \
|
||||
TAILQ_REMOVE(&exp->tagq, (tp), q); \
|
||||
if ((tp)->search != NULL) \
|
||||
free((tp)->search); \
|
||||
FREE((tp), sizeof(TAGF)); \
|
||||
}
|
||||
+ #else
|
||||
+ #define FREETAG(tp) { \
|
||||
+ TAILQ_REMOVE(&exp->tagq, (tp), q); \
|
||||
+ if ((tp)->search != NULL) \
|
||||
+ free((tp)->search); \
|
||||
+ FREE((tp), sizeof(TAGF)); \
|
||||
+ }
|
||||
+ #endif
|
||||
#define FREETAGF(tfp) { \
|
||||
TAILQ_REMOVE(&exp->tagfq, (tfp), q); \
|
||||
free((tfp)->name); \
|
||||
***************
|
||||
*** 182,189 ****
|
||||
--- 428,464 ----
|
||||
int sval;
|
||||
long tl;
|
||||
char *name, *p, *search, *tag;
|
||||
+ #ifdef GTAGS
|
||||
+ int gtagselect = 0;
|
||||
+ char *line;
|
||||
+ size_t len;
|
||||
+ char tagbuf[80], namebuf[200], linebuf[10];
|
||||
+ #endif
|
||||
|
||||
exp = EXP(sp);
|
||||
+ #ifdef GTAGS
|
||||
+ /*
|
||||
+ * Enter from gtag select mode.
|
||||
+ * get tag information from current line.
|
||||
+ */
|
||||
+ if (F_ISSET(cmdp, E_GTAGSELECT)) {
|
||||
+ if ((line = file_gline(sp, ep, sp->lno, &len)) == NULL) {
|
||||
+ GETLINE_ERR(sp, sp->lno);
|
||||
+ return (1);
|
||||
+ }
|
||||
+ if (getentry(line, tagbuf, namebuf, linebuf) == 0) {
|
||||
+ msgq(sp, M_ERR, "illegal tag entry");
|
||||
+ return (1);
|
||||
+ }
|
||||
+ if (!(tag = strdup(tagbuf))) {
|
||||
+ msgq(sp, M_SYSERR, NULL);
|
||||
+ return (1);
|
||||
+ }
|
||||
+ name = namebuf;
|
||||
+ search = linebuf;
|
||||
+ goto getfref;
|
||||
+ }
|
||||
+ #endif
|
||||
switch (cmdp->argc) {
|
||||
case 1:
|
||||
if (exp->tlast != NULL)
|
||||
***************
|
||||
*** 207,216 ****
|
||||
--- 482,504 ----
|
||||
if ((tl = O_VAL(sp, O_TAGLENGTH)) != 0 && strlen(exp->tlast) > tl)
|
||||
exp->tlast[tl] = '\0';
|
||||
|
||||
+ #ifdef GTAGS
|
||||
+ if (O_ISSET(sp, O_GTAGSMODE)) {
|
||||
+ if (gtag_get(sp, F_ISSET(cmdp->cmd, E_REFERENCE), >agselect,
|
||||
+ exp->tlast, &tag, &name, &search))
|
||||
+ return (1);
|
||||
+ } else if (F_ISSET(cmdp->cmd, E_REFERENCE)) {
|
||||
+ msgq(sp, M_ERR, "Please set gtagsmode");
|
||||
+ return (1);
|
||||
+ } else
|
||||
+ #endif
|
||||
/* Get the tag information. */
|
||||
if (tag_get(sp, exp->tlast, &tag, &name, &search))
|
||||
return (1);
|
||||
|
||||
+ #ifdef GTAGS
|
||||
+ getfref:
|
||||
+ #endif
|
||||
/* Get the (possibly new) FREF structure. */
|
||||
if ((frp = file_add(sp, name)) == NULL)
|
||||
goto err;
|
||||
***************
|
||||
*** 305,310 ****
|
||||
--- 593,603 ----
|
||||
sp->cno = m.cno;
|
||||
break;
|
||||
}
|
||||
+ #ifdef GTAGS
|
||||
+ if (gtagselect) {
|
||||
+ F_SET(frp, FR_GTAGSTMP);
|
||||
+ }
|
||||
+ #endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
***************
|
||||
*** 490,495 ****
|
||||
--- 783,793 ----
|
||||
for (cnt = 1, tp = exp->tagq.tqh_first; tp != NULL;
|
||||
++cnt, tp = tp->q.tqe_next) {
|
||||
len = strlen(name = tp->frp->name); /* The original name. */
|
||||
+ #ifdef GTAGS
|
||||
+ if (F_ISSET(tp->frp, FR_GTAGSTMP)) {
|
||||
+ (void)ex_printf(EXCOOKIE, "%2d [GTAGS]\n", cnt);
|
||||
+ } else
|
||||
+ #endif
|
||||
if (len > maxlen || len + tp->slen > sp->cols)
|
||||
if (tp == NULL || tp->search == NULL)
|
||||
(void)ex_printf(EXCOOKIE,
|
||||
diff -c -r -N /usr/src/usr.bin/vi/ex/excmd.c ./ex/excmd.c
|
||||
*** /usr/src/usr.bin/vi/ex/excmd.c Thu Aug 18 10:13:29 1994
|
||||
--- ./ex/excmd.c Sat Dec 14 11:54:15 1996
|
||||
***************
|
||||
*** 319,324 ****
|
||||
--- 319,331 ----
|
||||
"!",
|
||||
"rew[ind][!]",
|
||||
"re-edit all the files in the file argument list"},
|
||||
+ #ifdef GTAGS
|
||||
+ /* C_RTAG */
|
||||
+ {"rtag", ex_tagpush, E_NOGLOBAL|E_REFERENCE,
|
||||
+ "!w1o",
|
||||
+ "rta[g][!] [string]",
|
||||
+ "edit the file containing the tag"},
|
||||
+ #endif
|
||||
/* C_SUBSTITUTE */
|
||||
{"substitute", ex_substitute, E_ADDR2|E_NORC,
|
||||
"s",
|
||||
***************
|
||||
*** 329,334 ****
|
||||
--- 336,348 ----
|
||||
"!f1o",
|
||||
"sc[ript][!] [file]",
|
||||
"run a shell in a screen"},
|
||||
+ #ifdef GTAGS
|
||||
+ /* C_GTAGSELECT */
|
||||
+ {"select", ex_gtagselect, E_NOGLOBAL,
|
||||
+ "",
|
||||
+ "sel[ect]",
|
||||
+ "edit the file containing the tag"},
|
||||
+ #endif
|
||||
/* C_SET */
|
||||
{"set", ex_set, E_NOGLOBAL,
|
||||
"wN",
|
||||
diff -c -r -N /usr/src/usr.bin/vi/ex/excmd.h.stub ./ex/excmd.h.stub
|
||||
*** /usr/src/usr.bin/vi/ex/excmd.h.stub Wed Aug 17 08:36:28 1994
|
||||
--- ./ex/excmd.h.stub Sat Dec 14 11:54:15 1996
|
||||
***************
|
||||
*** 69,74 ****
|
||||
--- 69,79 ----
|
||||
#define E_NORC 0x0800000 /* Not from a .exrc or EXINIT. */
|
||||
#define E_ZERO 0x1000000 /* 0 is a legal addr1. */
|
||||
#define E_ZERODEF 0x2000000 /* 0 is default addr1 of empty files. */
|
||||
+
|
||||
+ #ifdef GTAGS
|
||||
+ #define E_REFERENCE 0x4000000 /* locate function references */
|
||||
+ #define E_GTAGSELECT 0x8000000 /* current line is gtags entry */
|
||||
+ #endif
|
||||
u_int32_t flags;
|
||||
char *syntax; /* Syntax script. */
|
||||
char *usage; /* Usage line. */
|
||||
***************
|
||||
*** 234,239 ****
|
||||
--- 239,245 ----
|
||||
EXPROTO(ex_fg);
|
||||
EXPROTO(ex_file);
|
||||
EXPROTO(ex_global);
|
||||
+ EXPROTO(ex_gtagselect);
|
||||
EXPROTO(ex_help);
|
||||
EXPROTO(ex_insert);
|
||||
EXPROTO(ex_join);
|
||||
diff -c -r -N /usr/src/usr.bin/vi/svi/svi_refresh.c ./svi/svi_refresh.c
|
||||
*** /usr/src/usr.bin/vi/svi/svi_refresh.c Tue May 30 15:35:56 1995
|
||||
--- ./svi/svi_refresh.c Sat Dec 14 11:54:16 1996
|
||||
***************
|
||||
*** 725,731 ****
|
||||
--- 725,736 ----
|
||||
EXF *ep;
|
||||
{
|
||||
size_t cols, curlen, endpoint, len, midpoint;
|
||||
+ #ifdef GTAGS
|
||||
+ char *p, buf[30];
|
||||
+ recno_t last;
|
||||
+ #else
|
||||
char *p, buf[20];
|
||||
+ #endif
|
||||
|
||||
/* Clear the mode line. */
|
||||
MOVE(sp, INFOLINE(sp), 0);
|
||||
***************
|
||||
*** 746,751 ****
|
||||
--- 751,765 ----
|
||||
|
||||
curlen = 0;
|
||||
if (sp->q.cqe_next != (void *)&sp->gp->dq) {
|
||||
+ #ifdef GTAGS
|
||||
+ if (F_ISSET(sp->frp, FR_GTAGSTMP)) {
|
||||
+ if (file_lline(sp, ep, &last)) {
|
||||
+ return (1);
|
||||
+ }
|
||||
+ sprintf(buf, "[GTAGS SELECT MODE] %d lines", last);
|
||||
+ p = buf;
|
||||
+ } else {
|
||||
+ #endif
|
||||
for (p = sp->frp->name; *p != '\0'; ++p);
|
||||
while (--p > sp->frp->name) {
|
||||
if (*p == '/') {
|
||||
***************
|
||||
*** 758,764 ****
|
||||
break;
|
||||
}
|
||||
}
|
||||
!
|
||||
MOVE(sp, INFOLINE(sp), 0);
|
||||
standout();
|
||||
for (; *p != '\0'; ++p)
|
||||
--- 772,780 ----
|
||||
break;
|
||||
}
|
||||
}
|
||||
! #ifdef GTAGS
|
||||
! }
|
||||
! #endif
|
||||
MOVE(sp, INFOLINE(sp), 0);
|
||||
standout();
|
||||
for (; *p != '\0'; ++p)
|
||||
diff -c -r -N /usr/src/usr.bin/vi/vi/v_ex.c ./vi/v_ex.c
|
||||
*** /usr/src/usr.bin/vi/vi/v_ex.c Thu Aug 18 10:15:03 1994
|
||||
--- ./vi/v_ex.c Sat Dec 14 11:54:16 1996
|
||||
***************
|
||||
*** 298,303 ****
|
||||
--- 298,308 ----
|
||||
ARGS *ap[2], a;
|
||||
EXCMDARG cmd;
|
||||
|
||||
+ #ifdef GTAGS
|
||||
+ if (O_ISSET(sp, O_GTAGSMODE) && vp->m_start.cno == 0)
|
||||
+ excmd(&cmd, C_RTAG, 0, OOBLNO, 0, 0, ap, &a, vp->keyword);
|
||||
+ else
|
||||
+ #endif
|
||||
excmd(&cmd, C_TAG, 0, OOBLNO, 0, 0, ap, &a, vp->keyword);
|
||||
return (sp->s_ex_cmd(sp, ep, &cmd, &vp->m_final));
|
||||
}
|
||||
diff -c -r -N /usr/src/usr.bin/vi/vi/v_scroll.c ./vi/v_scroll.c
|
||||
*** /usr/src/usr.bin/vi/vi/v_scroll.c Thu Aug 18 10:15:15 1994
|
||||
--- ./vi/v_scroll.c Sat Dec 14 11:54:16 1996
|
||||
***************
|
||||
*** 255,260 ****
|
||||
--- 255,269 ----
|
||||
EXF *ep;
|
||||
VICMDARG *vp;
|
||||
{
|
||||
+ #ifdef GTAGS
|
||||
+ EXCMDARG cmd;
|
||||
+
|
||||
+ if (F_ISSET(sp->frp, FR_GTAGSTMP)) {
|
||||
+ memset(&cmd, 0, sizeof(EXCMDARG));
|
||||
+ cmd.cmd = &cmds[C_GTAGSELECT];
|
||||
+ return (sp->s_ex_cmd(sp, ep, &cmd, &vp->m_final));
|
||||
+ }
|
||||
+ #endif
|
||||
/*
|
||||
* If it's a script window, exec the line,
|
||||
* otherwise it's the same as v_down().
|
Loading…
Reference in New Issue
Block a user