Update to version 1.9.

Submitted by:	Shigio Yamaguchi <shigio@wafu.netgate.net>
This commit is contained in:
Jordan K. Hubbard 1997-04-22 18:02:52 +00:00
parent 9afb31b0e2
commit 804974bacc
15 changed files with 270 additions and 71 deletions

View File

@ -80,7 +80,8 @@ version 1.7 make suitable for large project (mainly FreeBSD kernel) [17-Feb-97]
function too. function too.
- works MUCH faster than previous version. - works MUCH faster than previous version.
[fixed bug] [fixed bug]
htags - string 'param' follows '&' means specific charactor in hypertext. htags - generate path name including '&param'. (It means special
charactor in hypertertext.)
So, changed internal separator from '&' to '|'. So, changed internal separator from '&' to '|'.
[added] [added]
gtags - -s option added. If specified, gtags extract ENTRY() and gtags - -s option added. If specified, gtags extract ENTRY() and
@ -129,3 +130,32 @@ version 1.81 make global to understand 'obj' directory and bug fix. [14-Apr-97]
[changed] [changed]
global global
- can find tag file in obj directory. - can find tag file in obj directory.
version 1.9 fix some bugs, add options and support of 1.79 nvi [21-Apr-97]
[fixed bug]
htags - doesn't keep the code formatted correctly.
So, changed to convert tabs in source files into spaces.
(expand(1) needed)
Thanks to Andy Newman.
- cannot print error message correctly.
[changed]
gctags, btreeop
- modify for SunOS 4.1.3.
Thanks to Yoshiharu Ito.
[added]
btreeop - META record and 'format version record' is available.
(It will be used in the furture.)
- -A and -D option added. (It will be used in the future.)
htags - use temporary directory specified by TMPDIR environment
variable.
- -l option added.
Thanks to Jeff Trawick. This option is his idea.
nvi-1.79.diff
- patch for nvi 1.79 to make extended vi.

View File

@ -1,9 +1,9 @@
HISTORY Histroy of GLOBAL. HISTORY Histroy of GLOBAL.
INSTALL Installation method INSTALL Installation method
MANIFEST This file. MANIFEST This file.
Makefile Makefile for generic UNIX(including BSD). Makefile Makefile for BSD.
Makefile.bsd Makefile for BSD.
Makefile.inc A part of Makefile for BSD. Makefile.inc A part of Makefile for BSD.
Makefile.generic Makefile for generic UNIX(including BSD).
README Readme (introduction and usage). README Readme (introduction and usage).
VERSION Version number. VERSION Version number.
btreeop/ Btreeop command directory. btreeop/ Btreeop command directory.
@ -14,3 +14,4 @@ htags/ Htags command directory.
systags/ Script for kernel. systags/ Script for kernel.
nvi-1.34.diff Patch for nvi 1.34. nvi-1.34.diff Patch for nvi 1.34.
nvi-1.76.diff Patch for nvi 1.76. nvi-1.76.diff Patch for nvi 1.76.
nvi-1.79.diff Patch for nvi 1.79.

View File

@ -3,13 +3,13 @@
@- @- @- @-
@- @- @- @-
@- @- @@@@@- @@@@@@- @@- @- @- @- @@@@@- @@@@@@- @@- @-
@- F o r a l l h a c h e r s. version 1.8 @- F o r a l l h a c h e r s. version 1.9
@- @@@@@@-@- @- @- @@@@@- @- @- @- @- @@@@@@-@- @- @- @@@@@- @- @- @-
@- @- @- @- @- @- @- @@@@@- @- @- @- @- @- @- @- @- @@@@@- @-
@- @- @- @- @- @- @-@- @- @- @- @- @- @- @- @- @-@- @- @-
@@@@@@@@- @@@@- @@@@@- @@@@@@-@@@- @@@@- @@@@@@- @@@@@@@@- @@@@- @@@@@- @@@@@@-@@@- @@@@- @@@@@@-
Shigio Yamaguchi 5-Apr-97 Shigio Yamaguchi 21-Apr-97
Copyright 1996, 1997 Shigio Yamaguchi All right resereved. Copyright 1996, 1997 Shigio Yamaguchi All right resereved.
@ -387,7 +387,7 @@ All the functions for GLOBAL are enabled only in 'gtagsmode'.
set gtagsmode set gtagsmode
set leftright set leftright
[Extended vi based 1.76 nvi] [Extended vi based 1.79 nvi]
Vi goes to the first tag. Vi goes to the first tag.
Then you can go to next tag by ':tagnext' or back by ':tagprev'. Then you can go to next tag by ':tagnext' or back by ':tagprev'.
@ -399,7 +399,7 @@ All the functions for GLOBAL are enabled only in 'gtagsmode'.
== WHY TWO STYLE EXIST ? == == WHY TWO STYLE EXIST ? ==
1.34 nvi cannot treat duplicate tag entries, so I made 'GTAGS SELECT MODE' 1.34 nvi cannot treat duplicate tag entries, so I made 'GTAGS SELECT MODE'
in it. But 1.76 nvi (1.61 and later) can treat them, so I adapted GLOBAL in it. But 1.79 nvi (1.61 and later) can treat them, so I adapted GLOBAL
tags to nvi's tag structure. tags to nvi's tag structure.
o <control-]> command is available. o <control-]> command is available.
@ -481,7 +481,7 @@ All the functions for GLOBAL are enabled only in 'gtagsmode'.
source code(/usr/src/sys) 14MB source code(/usr/src/sys) 14MB
tag database(GTAGS,GRTAGS) 9MB(!) tag database(GTAGS,GRTAGS) 9MB(!)
hypertext(HTML/*) 42MB(!!!) hypertext(HTML/*) 45MB(!!!)
Please do the followings. Please do the followings.
@ -519,7 +519,7 @@ All the functions for GLOBAL are enabled only in 'gtagsmode'.
You can use one level nested index and browse assembler source file too. You can use one level nested index and browse assembler source file too.
Thank you for your reading of my poor english. Thank you for your reading of my poor english.
And of course, thank you Keith Bostic (the author of nvi(1) and db(3)). And of course, I'm grateful to Keith Bostic for his excellent nvi(1) and db(3).
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
E-Mail: <shigio@wafu.netgate.net> E-Mail: <shigio@wafu.netgate.net>
WWW: <http://wafu.netgate.net/tama/unix/indexe.html> WWW: <http://wafu.netgate.net/tama/unix/indexe.html>

View File

@ -1 +1 @@
1.81 1.9

View File

@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.Dd April 21, 1996 .Dd April 21, 1997
.Dt BTREEOP 1 .Dt BTREEOP 1
.Os BSD 4 .Os BSD 4
.Sh NAME .Sh NAME
@ -36,7 +36,9 @@
.Nd btree database maintenance tool .Nd btree database maintenance tool
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm btreeop .Nm btreeop
.Op Fl A
.Op Fl C .Op Fl C
.Op Fl D Ar key
.Op Fl K Ar key .Op Fl K Ar key
.Op Fl b .Op Fl b
.Op Fl c Ar cashesize .Op Fl c Ar cashesize
@ -49,16 +51,21 @@ execute simple operations for
.Xr btree 3 .Xr btree 3
database. database.
.Nm Btreeop .Nm Btreeop
can create database and read (sequential or index) from it . can create database, write record, read record (sequential or index) and
delete record from it.
Duplicate entries are allowed. Duplicate entries are allowed.
.Sh OPTIONS .Sh OPTIONS
A capital letter means a command. If no command specified A capital letter means a command. If no command specified
then it assume sequential read operation. then it assume sequential read operation.
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl A
append records. If database doesn't exist, btreeop creates it.
.It Fl C .It Fl C
create database. create database and write records to it.
.It Fl D Ar key
delete records by the key.
.It Fl K Ar key .It Fl K Ar key
search data by the key. search records by the key.
.It Fl b .It Fl b
assume BIG_ENDIAN byte order. default is LITTLE_ENDIAN. assume BIG_ENDIAN byte order. default is LITTLE_ENDIAN.
.It Fl c Ar cashesize .It Fl c Ar cashesize
@ -74,7 +81,7 @@ of BTREEINFO. (see btree(3))
.It Ar dbname .It Ar dbname
database name. default is 'btree'. database name. default is 'btree'.
.Sh DATA FORMAT .Sh DATA FORMAT
To creat database, To creat (or append) database,
.Nm btreeop .Nm btreeop
read data from stdin. read data from stdin.
The format of the data is the following. The format of the data is the following.
@ -96,6 +103,10 @@ Key cannot include blank.
Data can include blank. Data can include blank.
.It .It
Null Data not allowed. Null Data not allowed.
.It
Additionally, META record is available. META record has a key that start with
a blank. You can read this record only by indexed search (with -K option).
Usage is unlimited by Btreeop.
.El .El
.Sh EXAMPLES .Sh EXAMPLES
Create database. Create database.
@ -103,11 +114,18 @@ Create database.
% btreeop -C % btreeop -C
key1 data1 key1 data1
key2 data2 key2 data2
key2 data2-2
key3 data3 key3 data3
^D ^D
% %
Append records.
% btreeop -A
__.VERSION 2
key2 data2-2
^D
%
Sequential read. Sequential read.
% btreeop % btreeop
@ -122,6 +140,14 @@ Indexed read.
% btreeop -K key2 % btreeop -K key2
key2 data2-2 key2 data2-2
key2 data2 key2 data2
% btreeop -K ' __.VERSION'
__.VERSION 2
%
Delete record.
% btreeop -D ' __.VERSION'
% btreeop -K ' __.VERSION'
% %
.Sh FILES .Sh FILES
@ -133,10 +159,10 @@ default database name.
.Nm Btreeop .Nm Btreeop
exits with a value of 1 if an error occurred, 0 otherwise. exits with a value of 1 if an error occurred, 0 otherwise.
.Sh SEE ALSO .Sh SEE ALSO
.Xr btree 3 ,
.Sh BUGS
.Nm btreeop
cannot utilize all features of
.Xr btree 3 .Xr btree 3
.Sh AUTHOR .Sh AUTHOR
Shigio Yamaguchi (shigio@wafu.netgate.net) Shigio Yamaguchi (shigio@wafu.netgate.net)
.Sh HISTORY
The
.Nm
command appeared in FreeBSD 2.2.

View File

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* btreeop.c 5-Apr-97 * btreeop.c 21-Apr-97
* *
*/ */
#include <stdio.h> #include <stdio.h>
@ -56,9 +56,12 @@ void die __P((char *));
void usage __P((void)); void usage __P((void));
void entab __P((char *)); void entab __P((char *));
void main __P((int, char **)); void main __P((int, char **));
int dbcreate __P((DB *)); int dbwrite __P((DB *));
int dbkey __P((DB *, char *)); int dbkey __P((DB *, char *));
int dbscan __P((DB *)); int dbscan __P((DB *));
int dbdel __P((DB *, char *));
DB *db;
char *key;
#ifndef LITTLE_ENDIAN #ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234 #define LITTLE_ENDIAN 1234
@ -78,7 +81,7 @@ char *s;
void void
usage() { usage() {
fprintf(stderr, fprintf(stderr,
"usage: %s [-C][-K key][-b][-c cachesize][-l][-p psize][dbname]\n", "usage: %s [-A][-C][-D key][-K key][-b][-c cachesize][-l][-p psize][dbname]\n",
progname); progname);
exit(1); exit(1);
} }
@ -126,11 +129,14 @@ main(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
{ {
char command = 0; char command = 'R';
char *key = NULL; char *key = NULL;
DB *db; DB *db;
BTREEINFO info; BTREEINFO info;
int c; int c;
int flags;
extern char *optarg;
extern int optind;
info.flags = R_DUP; /* allow duplicate entries */ info.flags = R_DUP; /* allow duplicate entries */
info.cachesize = 500000; info.cachesize = 500000;
@ -141,11 +147,15 @@ char *argv[];
info.prefix = NULL; info.prefix = NULL;
info.lorder = LITTLE_ENDIAN; info.lorder = LITTLE_ENDIAN;
while ((c = getopt(argc, argv, "CK:bc:lp:")) != EOF) { while ((c = getopt(argc, argv, "ACD:K:bc:lp:")) != EOF) {
switch (c) { switch (c) {
case 'K': case 'K':
case 'D':
key = optarg; key = optarg;
case 'A':
case 'C': case 'C':
if (command != 'R')
usage();
command = c; command = c;
break; break;
case 'b': case 'b':
@ -166,21 +176,35 @@ char *argv[];
} }
dbname = (optind < argc) ? argv[optind] : dbdefault; dbname = (optind < argc) ? argv[optind] : dbdefault;
db = dbopen(dbname, command == 'C' ? switch (command) {
O_RDWR|O_CREAT|O_TRUNC : O_RDONLY, case 'A':
0644, DB_BTREE, &info); case 'D':
flags = O_RDWR|O_CREAT;
break;
case 'C':
flags = O_RDWR|O_CREAT|O_TRUNC;
break;
case 'K':
case 'R':
flags = O_RDONLY;
break;
}
db = dbopen(dbname, flags, 0644, DB_BTREE, &info);
if (db == NULL) { if (db == NULL) {
die("dbopen failed."); die("dbopen failed.");
} }
switch (command) { switch (command) {
case 'A': /* Append records */
case 'C': /* Create database */ case 'C': /* Create database */
dbcreate(db); dbwrite(db);
break; break;
case 'K': /* Keyed search */ case 'D': /* Delete records */
dbdel(db, key);
break;
case 'K': /* Keyed (indexed) read */
dbkey(db, key); dbkey(db, key);
break; break;
default: /* Scan all data */ case 'R': /* sequencial Read */
dbscan(db); dbscan(db);
break; break;
} }
@ -190,13 +214,13 @@ char *argv[];
exit(0); exit(0);
} }
/* /*
* dbcreate: create database * dbwrite: write to database
* *
* i) db * i) db
* r) 0: normal * r) 0: normal
*/ */
int int
dbcreate(db) dbwrite(db)
DB *db; DB *db;
{ {
DBT key, dat; DBT key, dat;
@ -216,6 +240,12 @@ DB *db;
* - Key cannot include blank. * - Key cannot include blank.
* - Data can include blank. * - Data can include blank.
* - Null Data not allowed. * - Null Data not allowed.
*
* META record:
* You can write meta record by making key start with a ' '.
* You can read this record only by indexed read ('-K' option).
* +------------------
* | __.VERSION 2
*/ */
while (fgets(buf, BUFSIZ, stdin)) { while (fgets(buf, BUFSIZ, stdin)) {
if (buf[strlen(buf)-1] == '\n') /* chop(buf) */ if (buf[strlen(buf)-1] == '\n') /* chop(buf) */
@ -223,7 +253,12 @@ DB *db;
else else
while (fgetc(stdin) != '\n') while (fgetc(stdin) != '\n')
; ;
for (c = buf; *c && !isspace(*c); c++) /* skip key part */ c = buf;
if (*c == ' ') { /* META record */
if (*++c == ' ')
die("illegal format.");
}
for (; *c && !isspace(*c); c++) /* skip key part */
; ;
if (*c == 0) if (*c == 0)
die("data part not found."); die("data part not found.");
@ -277,14 +312,13 @@ char *skey;
status = (*db->seq)(db, &key, &dat, R_NEXT)) { status = (*db->seq)(db, &key, &dat, R_NEXT)) {
(void)fprintf(stdout, "%s\n", (char *)dat.data); (void)fprintf(stdout, "%s\n", (char *)dat.data);
} }
if (status == RET_ERROR) if (status == RET_ERROR)
die("db->seq failed."); die("db->seq failed.");
return (0); return (0);
} }
/* /*
* dbscan: Scan all data * dbscan: Scan all records
* *
* i) db * i) db
* r) 0: normal * r) 0: normal
@ -300,9 +334,37 @@ DB *db;
for (status = (*db->seq)(db, &key, &dat, R_FIRST); for (status = (*db->seq)(db, &key, &dat, R_FIRST);
status == RET_SUCCESS; status == RET_SUCCESS;
status = (*db->seq)(db, &key, &dat, R_NEXT)) { status = (*db->seq)(db, &key, &dat, R_NEXT)) {
/* skip META record */
if (*(char *)key.data == ' ')
continue;
(void)fprintf(stdout, "%s\n", (char *)dat.data); (void)fprintf(stdout, "%s\n", (char *)dat.data);
} }
if (status == RET_ERROR) if (status == RET_ERROR)
die("db->seq failed."); die("db->seq failed.");
return (0); return (0);
} }
/*
* dbdel: Delete records
*
* i) db
* i) key key
* r) 0: normal
* 1: not found
*/
int
dbdel(db, skey)
DB *db;
char *skey;
{
DBT key;
int status;
key.data = skey;
key.size = strlen(skey)+1;
status = (*db->del)(db, &key, 0);
if (status == RET_ERROR)
die("db->del failed.");
return (0);
}

View File

@ -100,6 +100,8 @@ main(argc, argv)
int step; /* step through args */ int step; /* step through args */
int ch; /* getopts char */ int ch; /* getopts char */
char cmd[100]; /* too ugly to explain */ char cmd[100]; /* too ugly to explain */
extern char *optarg;
extern int optind;
#ifndef lint #ifndef lint
copyright[0] = copyright[0]; /* to satisfy compiler */ copyright[0] = copyright[0]; /* to satisfy compiler */

View File

@ -31,7 +31,7 @@
.\" .\"
.\" @(#)gctags.1 8.1 (Berkeley) 6/6/93 .\" @(#)gctags.1 8.1 (Berkeley) 6/6/93
.\" .\"
.Dd June 6, 1993 .Dd Apr 21, 1997
.Dt GCTAGS 1 .Dt GCTAGS 1
.Os BSD 4 .Os BSD 4
.Sh NAME .Sh NAME
@ -220,9 +220,5 @@ the searching pattern. The last line of multiple line
will similarly be noted. will similarly be noted.
.Sh HISTORY .Sh HISTORY
The The
.Nm Ctags
command appeared in
.Bx 3.0 .
The
.Nm .Nm
command appeared in GLOBAL 1.6 . command appeared in FreeBSD 2.2.

View File

@ -28,12 +28,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.Dd Jul 28, 1996 .Dd Apr 21, 1997
.Dt GLOBAL 1 .Dt GLOBAL 1
.Os BSD 4 .Os BSD 4
.Sh NAME .Sh NAME
.Nm global .Nm global
.Nd print the locations of specified function in C and Yacc source files. .Nd print the locations of specified function.
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm global .Nm global
.Op Fl acrx .Op Fl acrx
@ -128,3 +128,7 @@ exits with a non 0 value if an error occurred, 0 otherwise.
.Xr btreeop 1 .Xr btreeop 1
.Sh AUTHORS .Sh AUTHORS
Shigio Yamaguchi (shigio@wafu.netgate.net) Shigio Yamaguchi (shigio@wafu.netgate.net)
.Sh HISTORY
The
.Nm
command appeared in FreeBSD 2.2.

View File

@ -29,7 +29,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE. # SUCH DAMAGE.
# #
# global.pl 14-Apr-97 # global.pl 21-Apr-97
# #
sub getcwd { sub getcwd {
local($dir); local($dir);
@ -51,7 +51,9 @@ while ($ARGV[0] =~ /^-/) {
} }
if (@ARGV == 0) { if (@ARGV == 0) {
die($usage) if (! $cflag); die($usage) if (! $cflag);
} elsif ($ARGV[0] =~ /[][.*\^\$+?|(){}\\]/) { # include regular expression ? }
$ARGV[0] =~ s/^[ \t]+//; # remove leading blanks
if ($ARGV[0] =~ /[][.*\^\$+?|(){}\\]/) { # include regular expression ?
$regex = 1; $regex = 1;
} }
if ($cflag) { if ($cflag) {
@ -102,6 +104,23 @@ foreach $step (@step) {
push(@com, "-e 's!\\.\\./$step/!!'"); push(@com, "-e 's!\\.\\./$step/!!'");
} }
# #
# 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.
$support_version = 1; # accept this format version
#
open(GTAGS, "btreeop -K ' __.VERSION' $dbpath/$gtagsname |") || die("$com: GTAGS not found.\n");
$rec = <GTAGS>;
close(GTAGS);
if ($rec =~ /^ __\.VERSION[ \t]+([0-9]+)$/) {
$format_version = $1;
} else {
$format_version = 1;
}
if ($format_version > $support_version) {
die("$com: GTAGS seems new format. Please install the latest GLOBAL.\n");
}
#
# complete function name # complete function name
# #
if ($cflag) { if ($cflag) {

View File

@ -3,7 +3,7 @@
MAN1= gtags.1 MAN1= gtags.1
beforeinstall: beforeinstall:
install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${.CURDIR}/gtags.sh ${DESTDIR}/${BINDIR}/gtags ${.CURDIR}/gtags.sh ${DESTDIR}/usr/bin/gtags
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.Dd Feb 17, 1997 .Dd Apr 21, 1997
.Dt GTAGS 1 .Dt GTAGS 1
.Os BSD 4 .Os BSD 4
.Sh NAME .Sh NAME
@ -79,3 +79,7 @@ and ALTENTRY() from source file. Probably valid only for FreeBSD and Linux
kernel source. kernel source.
.Sh AUTHORS .Sh AUTHORS
Shigio Yamaguchi (shigio@wafu.netgate.net) Shigio Yamaguchi (shigio@wafu.netgate.net)
.Sh HISTORY
The
.Nm
command appeared in FreeBSD 2.2.

View File

@ -29,7 +29,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE. # SUCH DAMAGE.
# #
# gtags.sh 17-Feb-97 # gtags.sh 21-Apr-97
# #
com=`echo $0 | sed 's/.*\///'` # command name com=`echo $0 | sed 's/.*\///'` # command name
usage="usage: $com [-e][-s][dbpath]" usage="usage: $com [-e][-s][dbpath]"

View File

@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.Dd Feb 17, 1997 .Dd Apr 21, 1997
.Dt HTAGS 1 .Dt HTAGS 1
.Os BSD 4 .Os BSD 4
.Sh NAME .Sh NAME
@ -37,6 +37,7 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm htags .Nm htags
.Op Fl a .Op Fl a
.Op Fl l
.Op Fl v .Op Fl v
.Op Fl w .Op Fl w
.Op Fl d Ar tagdir .Op Fl d Ar tagdir
@ -44,7 +45,7 @@
.Op Ar dir .Op Ar dir
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm Htags .Nm Htags
makes hypertext from C and Yacc source code using GLOBAL database. makes hypertext from C and Yacc source code using GLOBAL database (GTAGS, GRTAGS).
.Pp .Pp
In advance of using this command, you must execute In advance of using this command, you must execute
.Xr gtags 1 .Xr gtags 1
@ -62,7 +63,11 @@ by any browsers.
.br .br
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl a .It Fl a
make alphabetical function index. It's suitable to large project. make an alphabetical function index. It's suitable for large project.
.It Fl l
make name tag(<A NAME=lno>) 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.
.It Fl v .It Fl v
verbose mode. verbose mode.
.It Fl w .It Fl w
@ -87,6 +92,13 @@ tags file for function definitions.
.It Pa GRTAGS .It Pa GRTAGS
tags file for function references. tags file for function references.
.El .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.
.Sh DIAGNOSTICS .Sh DIAGNOSTICS
.Nm Htags .Nm Htags
exits with a value of 1 if an error occurred, 0 otherwise. exits with a value of 1 if an error occurred, 0 otherwise.
@ -97,3 +109,7 @@ exits with a value of 1 if an error occurred, 0 otherwise.
Generated hypertext is VERY LARGE. In advance, check the space of your disk. Generated hypertext is VERY LARGE. In advance, check the space of your disk.
.Sh AUTHORS .Sh AUTHORS
Shigio Yamaguchi (shigio@wafu.netgate.net) Shigio Yamaguchi (shigio@wafu.netgate.net)
.Sh HISTORY
The
.Nm
command appeared in FreeBSD 2.2.

View File

@ -29,11 +29,11 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE. # SUCH DAMAGE.
# #
# htags.pl 5-Apr-97 # htags.pl 21-Apr-97
# #
$com = $0; $com = $0;
$com =~ s/.*\///; $com =~ s/.*\///;
$usage = "usage: $com [-a][-v][-w][-t title][-d tagdir][dir]"; $usage = "usage: $com [-a][-l][-v][-w][-t title][-d tagdir][dir]";
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# CONFIGURATION # CONFIGURATION
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -52,6 +52,9 @@ $reserved_end = '</B>';
$reserved_words = "auto|break|case|char|continue|default|do|double|else|extern|float|for|goto|if|int|long|register|return|short|sizeof|static|struct|switch|typedef|union|unsigned|void|while"; $reserved_words = "auto|break|case|char|continue|default|do|double|else|extern|float|for|goto|if|int|long|register|return|short|sizeof|static|struct|switch|typedef|union|unsigned|void|while";
# temporary directory # temporary directory
$tmp = '/tmp'; $tmp = '/tmp';
if (defined($ENV{'TMPDIR'}) && -d $ENV{'TMPDIR'}) {
$tmp = $ENV{'TMPDIR'};
}
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# DEFINITION # DEFINITION
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -117,20 +120,31 @@ sub escape {
local($c) = @_; local($c) = @_;
'%' . sprintf("%x", ord($c)); '%' . sprintf("%x", ord($c));
} }
sub usable {
local($com) = @_;
foreach $path (split(/:/, $ENV{'PATH'})) {
if (-x "$path/$com") {
return 1;
}
}
return 0;
}
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# PROCESS START # PROCESS START
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# options check # options check
# #
$aflag = $vflag = $wflag = $sflag = ''; # $sflag is set internally $aflag = $lflag = $vflag = $wflag = $sflag = '';# $sflag is set internally
while ($ARGV[0] =~ /^-/) { while ($ARGV[0] =~ /^-/) {
$opt = shift; $opt = shift;
if ($opt =~ /[^-avwdt]/) { if ($opt =~ /[^-alvwtd]/) {
print STDERR "$usage\n"; print STDERR "$usage\n";
exit 1; exit 1;
} }
if ($opt =~ /a/) { $aflag = 1; } if ($opt =~ /a/) { $aflag = 1; }
if ($opt =~ /l/) { $lflag = 1; }
if ($opt =~ /v/) { $vflag = 1; } if ($opt =~ /v/) { $vflag = 1; }
if ($opt =~ /w/) { $wflag = 1; } if ($opt =~ /w/) { $wflag = 1; }
if ($opt =~ /t/) { if ($opt =~ /t/) {
@ -153,6 +167,26 @@ if (!$dbpath) {
unless (-r "$dbpath/GTAGS" && -r "$dbpath/GRTAGS") { unless (-r "$dbpath/GTAGS" && -r "$dbpath/GRTAGS") {
&error("GTAGS and GRTAGS not found. please type 'gtags[RET]'\n"); &error("GTAGS and GRTAGS not found. please type 'gtags[RET]'\n");
} }
#
# recognize format version
# if version record is not found, it's assumed version 1.
#
$support_version = 1; # understand this format version
#
open(GTAGS, "btreeop -K ' __.VERSION' $dbpath/GTAGS |") || die("$com: GTAGS not found.\n");
$rec = <GTAGS>;
close(GTAGS);
if ($rec =~ /^ __\.VERSION[ \t]+([0-9]+)$/) {
$format_version = $1;
} else {
$format_version = 1;
}
if ($format_version != $support_version) {
die("$com: GTAGS format version unmatched. Please remake it.\n");
}
#
# check directories
#
$html = &getcwd() . '/HTML'; $html = &getcwd() . '/HTML';
if ($ARGV[0]) { if ($ARGV[0]) {
$cwd = &getcwd(); $cwd = &getcwd();
@ -613,15 +647,16 @@ package convert;
sub src2html { sub src2html {
local($file, $html) = @_; local($file, $html) = @_;
local($ncol) = $'ncol; local($ncol) = $'ncol;
local($expand) = &'usable('expand') ? 'expand' : 'cat';
open(HTML, ">$html") || &error("cannot create file <$html>.\n"); open(HTML, ">$html") || &'error("cannot create file <$html>.\n");
local($old) = select(HTML); local($old) = select(HTML);
# #
# load tags belonging to this file. # load tags belonging to this file.
# #
$file =~ s/^\.\///; $file =~ s/^\.\///;
&anchor'load($file); &anchor'load($file);
open(C, $file) || &error("cannot open file <$file>.\n"); open(C, "$expand '$file' |") || &'error("cannot open file <$file>.\n");
# #
# print the header # print the header
# #
@ -659,12 +694,16 @@ sub src2html {
local($define_line) = 0; local($define_line) = 0;
local(@links) = (); local(@links) = ();
local($count) = 0; local($count) = 0;
local($first); local($lno_printed) = 0;
for ($first = 1; int($LNO) == $.; ($LNO, $TAG, $TYPE) = &anchor'next()) { if ($'lflag) {
if ($first) { print "<A NAME=$.>";
$first = 0; $lno_printed = 1;
print "<A NAME=$LNO>" }
for (; int($LNO) == $.; ($LNO, $TAG, $TYPE) = &anchor'next()) {
if (!$lno_printed) {
print "<A NAME=$.>";
$lno_printed = 1;
} }
$define_line = $LNO if ($TYPE eq 'D'); $define_line = $LNO if ($TYPE eq 'D');
$db = ($TYPE eq 'D') ? 'GRTAGS' : 'GTAGS'; $db = ($TYPE eq 'D') ? 'GRTAGS' : 'GTAGS';
@ -689,7 +728,7 @@ sub src2html {
print STDERR "Error: $file $LNO $TAG($TYPE) tag must exist.\n" if ($'wflag); print STDERR "Error: $file $LNO $TAG($TYPE) tag must exist.\n" if ($'wflag);
} }
} else { } else {
print STDERR "Warning: $file $LNO $TAG($TYPE) found but not refered.\n" if ($'wflag); print STDERR "Warning: $file $LNO $TAG($TYPE) found but not referred.\n" if ($'wflag);
} }
} }
# implant links # implant links
@ -831,10 +870,10 @@ package anchor;
# #
sub create { sub create {
$ANCH = "$'tmp/ANCH$$"; $ANCH = "$'tmp/ANCH$$";
open(ANCH, "| btreeop -C $ANCH") || &error("btreeop -C $ANCH failed.\n"); open(ANCH, "| btreeop -C $ANCH") || &'error("btreeop -C $ANCH failed.\n");
foreach $db ('GTAGS', 'GRTAGS') { foreach $db ('GTAGS', 'GRTAGS') {
local($type) = ($db eq 'GTAGS') ? 'D' : 'R'; local($type) = ($db eq 'GTAGS') ? 'D' : 'R';
open(PIPE, "btreeop $'dbpath/$db |") || &error("btreeop $'dbpath/$db failed.\n"); open(PIPE, "btreeop $'dbpath/$db |") || &'error("btreeop $'dbpath/$db failed.\n");
while (<PIPE>) { while (<PIPE>) {
local($tag, $lno, $filename) = split; local($tag, $lno, $filename) = split;
print ANCH "$filename $lno $tag $type\n"; print ANCH "$filename $lno $tag $type\n";
@ -860,7 +899,7 @@ sub load {
$file = './' . $file if ($file !~ /^\.\//); $file = './' . $file if ($file !~ /^\.\//);
@ANCHORS = (); @ANCHORS = ();
open(ANCH, "btreeop -K $file $ANCH|") || &error("btreeop -K $file $ANCH failed.\n"); open(ANCH, "btreeop -K $file $ANCH|") || &'error("btreeop -K $file $ANCH failed.\n");
$n = 0; $n = 0;
while (<ANCH>) { while (<ANCH>) {
local($filename, $lno, $tag, $type) = split; local($filename, $lno, $tag, $type) = split;
@ -870,7 +909,7 @@ $n = 0;
if ($type eq 'R' && ($line = &cache'get('GTAGS', $tag))) { if ($type eq 'R' && ($line = &cache'get('GTAGS', $tag))) {
local($nouse1, $nouse2, $f, $def) = split(/[ \t]+/, $line); local($nouse1, $nouse2, $f, $def) = split(/[ \t]+/, $line);
if ($f !~ /\.h$/ && $f !~ $filename && $def =~ /^#/) { if ($f !~ /\.h$/ && $f !~ $filename && $def =~ /^#/) {
print STDERR "Information: skip <$filename $lno $tag> because this is a macro which is defined in other C source.\n" if ($'wflag); print STDERR "Information: $filename $lno $tag($type) skipped, because this is a macro which is defined in other C source.\n" if ($'wflag);
next; next;
} }
} }
@ -1016,7 +1055,7 @@ sub put {
$cachecount++; $cachecount++;
if ($cachesize >= 0 && $cachecount > $cachesize) { if ($cachesize >= 0 && $cachecount > $cachesize) {
$CACH = "$'tmp/CACH$$"; $CACH = "$'tmp/CACH$$";
dbmopen(%CACH, $CACH, 0600) || &error("make cache database.\n"); dbmopen(%CACH, $CACH, 0600) || &'error("make cache database.\n");
$cachesize = -1; $cachesize = -1;
} }
$CACH{$label.$tag} = $line; $CACH{$label.$tag} = $line;