This commit was generated by cvs2svn to compensate for changes in r42788,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
Hidetoshi Shimokawa 1999-01-18 06:59:18 +00:00
commit 6ba7b1c961
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=42789
63 changed files with 6445 additions and 1078 deletions

View File

@ -1,15 +1,17 @@
@@@@@@@=
@= @=
@= @=
@= @= @@@@@= @@@@@@= @@= @=
@= F o r a l l h a c k e r s. @=@= @=
@= @@@@@@=@= @= @= @@@@@= @= @= @=
@= @= @= @= @= @= @= @@@@@= @=
@= @= @= @= @= @= @=@= @= @=
@@@@@@@@= @@@@= @@@@@= @@@@@@=@@@= @@@@= @@@@@@=
@@@@@@@=)))
@=))) @=))) @=)))
@=))) @=)))
@=))) @=))) @@@@@=)@@@@@@=))) @@=) @=)))
@=))F o r a l l)) h a c k e r s.))) @=@=))@=)))
@=))) @@@@@@=@=)))@=))) @=)@@@@@=)))@= @=))@=)))
@=))) @=))@=)))@=))) @=)@=)))@=)@@@@@=))@=)))
@=))) @=))@=)))@=))) @=)@=)))@=@=)))@=))@=)))
@@@@@@@@=)))@@@@=)@@@@@=)@@@@@@=@@@=)@@@@=)@@@@@@=)))
This software is covered by the following:
This software is covered by the followings:
Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
@ -40,7 +42,8 @@ This software is covered by the following:
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of gozilla(1) are covered by the following:
Portions of gozilla(1):
Copyright 1996 Netscape Communications Corporation, all rights reserved.
Created: Jamie Zawinski <jwz@netscape.com>, 24-Dec-94.

67
contrib/global/FAQ Normal file
View File

@ -0,0 +1,67 @@
Frequentry Asked Questions about GLOBAL.
----------------------------------------------------------------------------
Q1. Htags(1) aborts by short of memory. Why? Any workaround?
% htags
Out of memory!
% _
A1. It seems that Perl4 leaks memory. If you use that version of perl,
then you had better to use Perl5. This works well.
----------------------------------------------------------------------------
Q2. Global(1) and btreeop(1) sometimes core dumps when using a large tag file.
Any workaround?
A2. Btree(3) core dumps with a certain data set.
Please apply the patches in this package. See ./dbpatches/README.
----------------------------------------------------------------------------
Q3. GLOBAL skip some functions.
For example, GLOBAL skip the function 'func' in this example.
#define M(a) static char *string = a;
M(a)
func() { <= GLOBAL skip func().
...
}
A3. GLOBAL cannot recognize that pattern, because M(a) seems to be
a function definition.
It should be follows.
#define M(a) static char *string = a
M(a); <= end with ';'
func() {
...
}
Otherwise, you can tell gtags(1) that by listing the macros in
'.notfunction' file in current directory.
[.notfunction]
+---------------
|M
|...
----------------------------------------------------------------------------
Q4. I have set up 'global.conf' to use emacs's ctags command with GLOBAL
but I cannot use htags.
% gtags
% htags
htags: GTAGS and GRTAGS not found. Please make them.
% ls G*
GPATH GTAGS
A4. Emacs's ctags cannot locate function referencies. So, gtags cannot make
GRTAGS tag file with it. With the result that you cannot use htags and
global's -r option.
----------------------------------------------------------------------------

View File

@ -1,3 +1,4 @@
GLOBAL history
--------------
@ -5,6 +6,8 @@ version 1.0 Initial version [21-Apr-96]
global, gtags, btreeop, extended ctags.
Thanks to Sadaichi Hayashida. Generating relative path is his idea.
version 1.1 Only bugfix [2-May-96]
[fixed bug]
@ -217,8 +220,8 @@ version 2.1 Symbol search, incremental update and gozilla [20-Sep-97]
These options become default, so you need not to specify
them. Gtags accepts these options for compatibility but
no effect.
global - understand not only 'obj'(MAKEOBJDIR) directory but also
'/usr/obj'(MAKEOBJDIRPREFIX) directory of BSD build system.
global - understand 'obj'(MAKEOBJDIR) directory and '/usr/obj'
(MAKEOBJDIRPREFIX) directory of BSD build system.
Thanks to Jordan K. Hubbard. This is his idea.
@ -304,12 +307,12 @@ version 2.21 Bugfix and slightly modified [11-Dec-97]
- replace `lorder $(OBJS) | tsort -q` to already sorted list.
for S.u.S.E Linux 5.1.
Thanks to Christoph Conrad for his information.
Thanks to Christoph Conrad for his information.
gtags, lib/test.c
- some change for Solaris environment.
Thanks to Yamashita TAKAO for his information.
Thanks to Yamashita TAKAO for his information.
htags/Makefile, systags/Makefile
- ${DESTDIR}/usr/bin -> ${DESTDIR}${BINDIR}
@ -323,14 +326,14 @@ version 2.22 GRTAGS support for assembler source [26-Dec-97]
call EXT(xxx)
call _xxx
Thanks to Yamashita TAKAO for his idea.
Thanks to Yamashita TAKAO for his idea.
version 2.23 Bugfix and slightly modified [13-Jan-98]
[fixed bug]
gctags - GRTAGS support in version 2.22 doesn't work.
Thanks to Yamashita TAKAO for his bug report.
Thanks to Yamashita TAKAO for his bug report.
[changed]
gctags/Makefile, gctags/Makefile.generic
@ -347,11 +350,216 @@ version 2.24 Only bugfix [20-Jan-98]
global - generates wrong path name when GTAGSROOT includes symbolic
links.
Thanks to Wolfgang Helbig for his bug report.
Thanks to Wolfgang Helbig for his bug report.
htags - cannot treat path name which includes digit as the second
character like 'i386'. (In fact it was expand(1)'s bug.)
Thanks to Andrew Gallatin for his bug report.
Thanks to Andrew Gallatin for his bug report.
global - doesn't search 'obj' directory correctly.
version 3.0 configuration file and compact format. [25-Jun-98]
[fixed bug]
gozilla - leaks memory.
gctags - -s option pick up symbols which belongs to GTAGS or GRTAGS.
global - cannot treat file which doesn't end with '\n'.
gtags - incremental update cannot detect removed files.
(GPATH file added.)
- make corrupted tag files.
(dbpatches/README added.)
Thanks to Van Trinh for his bug report and information.
htags - cannot be viewed by IE 5.0 because illegal <NOFRAME> tag.
Thanks to Yoshida Masato for his bug report and fix patch.
[changed]
gctags - -c option removed. These code was moved to gtags.
(It was needed for supporting plugged-in parser.)
global - -f option excute tag command instead of reading tag file.
(It became very faster than previous version.)
gtags.el- check whether or not user want to use tag name completion.
htags - URL of GLOBAL home page changed.
systags - gtags's option changed from -v to -cov.
gtags.c - replace "%+" of strftime with "%a %b %e %H:%M:%S %Z %Y".
for Debian GNU linux 1.3.1.
[added]
gtags - -c option added. (compact format)
Thanks to Takeshi Hojo. Compact format is based on his concept.
htags - -c option added. (to make gzipped html file)
Thanks to Oliver Paukstadt. This option is his idea.
gtags, htags
- support configuration file.
(/etc/global.conf or $HOME/.globalrc)
gctags - -n option added.
--config option added. (It's undocumented.)
global - -t option added.
This option is to use with 'tagprg' and 'tagprgonce' command
in Elvis editor (2.1g-beta or later).
Thanks to Steve Kirkendall for his excellent editor and
refined command set.
version 3.01 Almost bugfix [5-Jul-98]
[fixed bug]
global - print file names in a line.
gozilla - assume html file as a source file.
btreeop - insufficient usage check.
htags - cannot treat path including "++".
[changed]
global - -f option became to accept multiple files.
all - fixed warning by -Wall -Wmissing-prototypes.
version 3.1 Support of Java language [4-Aug-98]
[fixed bug]
htags - locate main functions from the path which belongs
GTAGSLIBPATH when there is no main function in the local
source tree.
[added]
gtags, global, htags, gozilla, gtags.el
- java supprt added.
gtags - --find option added. (internal use only - undocumented)
- --expand option added. (internal use only - undocumented)
htags - -h option (title header frame) added.
Thanks to Shigeyuki Yamano. This is his idea.
- line comment('//') detection added.
gctags, systags
- GTAGSSPECIAL environment variable added to treat system
macros like 'SYSINIT' in FreeBSD.
global.conf, lib/conf.c
- 'CVS/' added to 'skip' parameter.
[deleted]
gtags.conf
- 'reserved_words' for htags(1) was deleted.
It is hard coded.
[changed]
htags.pl- print guide links in .h file too.
version 3.2 new patch for nvi-1.79(1.66) and multilingual nvi [31-Aug-98]
[fixed bug]
nvi-1.79.diff
- may have buffer overflow.
Thanks to David Brownlee for his advice.
- suppress error message 'GTAGS not found'.
[added]
nvi-1.79-m17n.diff
- patch for multilingual nvi which is included FreeBSD as
a ports.
nvi-1.66.diff
- patch for nvi-1.66 which is native command of NetBSD 1.3.2
[deleted]
nvi-1.34.diff
- it is old enough to support.
[changed]
gozilla/Imakefile
- make possible to build gozilla alone without building
libgloutil.a.
version 3.3 Rewriting gctags(1) and some bug fix. [13-Sep-98]
[fixed bug]
gctags - look over inner class in a method.(Java)
- cannot treat 'OBJECT.class' pattern correctly.(Java)
[changed]
Makefile*
- library name changed from libutil.a to libgloutil.a becase
that is already used.
- definition of MANDIR deleted.
global.conf
- comment fixed.
systags.sh
- additional support for NetBSD, OpenBSD, GNUmach and GNUhurd.
- doesn't use CGI form by default.
- use gtags -l and -h option by default.
- -g(gtags only), -f(form) and -c(compact) option added.
[deleted]
gctags - fortran and lisp language support were deleted, because
it was not supported in GLOBAL system.
- -a, -d, -f, -t, -u, -w, -v options were deleted,
because it was not used in GLOBAL system.
- -D, -x options were deleted. These options became default.
- GTAGSSPECIAL was deleted.
[added]
gctags - #if (#else #elif) #endif block parsing added.
- pick up #define in assembler source.
- can pick up object like 'definition\n\n() {'.
- -b, -n, -w options were added.
gtags.el- gtags-display-browser(ESC-h) command added.
INSTALL - explanation about formatting online manuals added.
Thanks to Bert Gijsbers for his investigation.
Extended ctags has been completely replaced with new gctags.
Thanks to Ken Arnold and the other people who developped BSD ctags(1).
Without it, GLOBAL had never been here.
version 3.4 Unlimited nested index of htags(1). [8-Nov-98]
[added]
global - --filter option added. (internal use only - undocumented)
htags - tabs parameter added in global.conf to change tab stop.
btreeop - '2' option added to the -L command.
[changed]
htags - unlimited nested index of files supported.
README, htags.1,
- statements fixed.
Thanks to Silas S. Brown for his fixing the statements.
Makefile.generic
- make sub makefiles inherit the macros from the root Makefile.
version 3.41 description added to README file. [10-Dec-98]
[added]
README - usage description added.
'5. Elvis using global'
'A.3. Incremental updating'
INSTALL - description about Elvis added.
[change]
global - -t option is available with -P command.
global - assume "global -c ''" as "global -c".
[deleted]
nvi-1.79-m17n.diff
- because it is difficult for me to maintain. Sorry.
version 3.42 a couple of bugs fixed. [8-Jan-99]
[fixed]
btreeop.c,gctags.c,global.c,gozilla.c,remote.c,gtags.c
- 'void main()' is not valid by the C spec.
Thanks to David Brownlee for his patch.
gtags.el- redefinition problem fixed.
(renamed match-string to util-match-string.)
Thanks to Daisuke Kawahara for his bug report.

View File

@ -1,7 +1,7 @@
Installation of GLOBAL
20-Jan-1998 Shigio Yamaguchi
6-Dec-1998 Shigio Yamaguchi
---------------------------------------------------------------------------
Guide line (C style)
---------------------------------------------------------------------------
@ -14,26 +14,30 @@ if (Your system == FreeBSD) {
case 2.0.5R:
case 2.1.0R:
case 2.1.5R:
There is no problem.
break;
case 2.1.6R:
case 2.1.7R:
I don't know. But it seems same with 2.1.5R.
break;
case 2.2.1R:
It is OK. But your native nvi is version 1.71.
Use 1.79 nvi available on the Internet.
There is no problem.
break;
case 2.2.2R:
case 2.2.5R:
Your system inlucdes GLOBAL 1.9. You can overwrite it
with this 2.2 package.
But skip procedure "3. Extended vi (OPTIONAL)", because
your /usr/bin/nvi is already extended nvi for GLOBAL.
case 2.2.6R:
case 2.2.7R:
Your system includes GLOBAL 1.9 or 2.24.
You can overwrite it with this package.
break;
default:
I don't know. But it seems to be little problem.
}
} else if (Your system == NetBSD 1.3.2) {
You are lucky!
You need not to do procedure "1. Preparation for generic UNIX"
and you can use nvi-1.66.diff for native nvi.
} else if (Your system == Debian GNU linux 1.3.1) {
You are lucky!
You can skip most of "1. Preparation for generic UNIX" except for
"a) Generic makefile".(It's very easy.)
} else {
You may some error messages to make GLOBAL.
But it seems not so difficult to clear it. If you make a patch for it,
@ -43,6 +47,8 @@ if (Your system == FreeBSD) {
Thank you in advance.
}
Please see ./dbpatches/README.
----------------------------------------------------------------------------
Install procedure
----------------------------------------------------------------------------
@ -56,31 +62,47 @@ Install procedure
1. Preparation for generic UNIX
If you are a FreeBSD (all version) user, nothing to do here.
Please go to "2. GLOBAL basic".
If you are a user of FreeBSD (all version) or NetBSD 1.3.2 then
nothing to do here. Please go to "2. GLOBAL basic".
Otherwise, you must install following items before you install GLOBAL.
Otherwise, you must check following items before you install GLOBAL.
a) Generic makefile
a) Generic makefile (necessary)
This package includes generic makefile. Please do the followings.
% make -f Makefile.generic gen
% vi Makefile <- check install directories (BINDIR, MANDIR)
% vi Makefile <- check variables like BINDIR, MANDIR, ...
b) BSD db library version 1.85
b) Some UNIX tools (necessary)
Find(1), sed(1), sort(1), uniq(1) are needed.
If your environment is UNIX, you have them. You can confirm it like this.
% which find
/usr/bin/find
%
c) POSIX regular expression (extension) library (necessary)
If you don't have it, you can use GNU's regex library (regex-0.12.tar.gz).
See following site.
http://www.gnu.org/order/ftp.html
d) BSD db library version 1.85 (necessary)
If you don't have it, you can fetch it from this site.
http://mongoose.bostic.com/db/packages/db.1.85.tar.gz
c) PERL version 4 or later
e) PERL version 4 or later (needed for htags)
If you don't have it, you can fetch it from this site.
ftp://ftp.cis.ufl.edu/pub/perl/CPAN/src/5.0/latest.tar.gz
d) Rewrite some files
f) Rewrite some files (needed for htags)
If you install GLOBAL into other than /usr/bin, you need rewrite
hard coded path in a program. You can find the place by this command.
@ -92,43 +114,33 @@ Install procedure
% grep '/usr/bin/perl' */*.pl
e) POSIX regular expression (extension) library
g) Groff (needed for formatting online manuals)
If you don't have it, you can use GNU's regex library.
Online manuals in GLOBAL are written with 'mandoc' macro which is a part
of GNU groff package. See following site:
f) Some UNIX tools
http://www.gnu.org/order/ftp.html
Find(1), sed(1), sort(1) are needed.
If your environment is UNIX, you have them.
You can format these manuals by following command line manually.
% groff -Wall -Tascii -mandoc global.1
If you replace your system's nroff(1) with GNU's one(nroff.sh) then
you can use man(1) to see GLOBAL's online manuals.
2. GLOBAL basic (NEEDED)
% make
# make install
3. Extended vi (OPTIONAL)
3. Extended nvi (OPTIONAL)
GLOBAL supports two version of nvi.
There is a little defference in behavior between them when a number of
functions located. (please see 'README'.)
Version 1.34 nvi is included by FreeBSD 2.0.5R, 2.1.0R and 2.1.5R.
Version 1.79 nvi is available on
If you use FreeBSD 2.2.2R or later, your nvi is already extended nvi.
Otherwise, please get nvi-1.79 at:
ftp://ftp.cs.berkeley.edu/ucb/4bsd/nvi-1.79.tar.gz.
ftp://ftp.cs.berkeley.edu/ucb/4bsd/nvi-1.79.tar.gz
If you don't have nvi-1.34, use nvi-1.79.
If you use version 1.34 nvi which is a native command in FreeBSD 2.0.5R,
2.1.0R or 2.1.5R then
% cp -r /usr/src/usr.bin/vi vi <- version 1.34 of nex/nvi
% cd vi
% patch -p < ../nvi-1.34.diff
% make
# make install
else if you use version 1.79 nvi which is the latest version then
fetch from ftp://ftp.cs.berkeley.edu/ucb/4bsd/nvi-1.79.tar.gz and
and do the followings.
% tar xzvf nvi-1.79.tar.gz
% cd nvi-1.79
@ -138,10 +150,7 @@ Install procedure
% make
# make install
Caution: If you use FreeBSD 2.2.2R or later, your nvi is already
extended vi. Don't patch with nvi-1.79.diff.
else we have no patch for it.
The patch for nvi-1.66 is also available for NetBSD 1.3.2 users.
4. Extended emacs (OPTIONAL)
@ -149,7 +158,7 @@ Install procedure
Mule 2.3 (= Emacs 19.28). Other emacs version seems to work well,
but I don't confirm it.
You can get it from
You can get it at:
Emacs 19.34b:
ftp://prep.ai.mit.edu/pub/gnu/emacs-19.34b.tar.gz
@ -165,7 +174,16 @@ Install procedure
+-----------------------------------------------
|(setq load-path (cons "~/lisp" load-path))
5. Gozilla (OPTIONAL)
5. Elvis (OPTIONAL)
You need Elvis 2.1. You can get it at:
ftp://ftp.cs.pdx.edu/pub/elvis/elvis-2.1.tar.gz
You need not any patch for it.
6. Gozilla (OPTIONAL)
You need X(1) to install gozilla.
@ -175,4 +193,29 @@ Install procedure
# make install
# make install.man
7. other parser (OPTIONAL)
If you want to use other tag command like etags (tag command for emacs)
as a parser, you need to write global.conf (or $HOME/.globalrc).
Sample gtags.conf has etags's entry. Try this.
a) Install parser.
% cd <emacs's source directory>/lib-src
% make ctags
...
# cp ctags /usr/local/bin/ctags-emacs
b) Select ctags-emacs for GLOBAL system.
% setenv GTAGSLABEL ctags-emacs
or
+------------------------------------------------
|default:\ <== gtags use 'default' entry by default.
| :include=ctags-emacs:include=htags:
Good luck!

View File

@ -1,21 +1,24 @@
COPYING Copyright notice.
FAQ Frequentry asked question.
HISTORY Histroy of GLOBAL.
INSTALL Installation method
MANIFEST This file.
Makefile Makefile for BSD.
Makefile.inc A part of Makefile for BSD.
Makefile.generic Makefile for generic UNIX(including BSD).
PROBLEMS Problem report.
README Readme (introduction and usage).
VERSION Version number.
btreeop/ Btreeop command directory.
global/ Global command directory.
gozilla/ Gozilla command directory.
dbpatches/ Patch files for DB(3).
gctags/ Extended ctags command directory.
global/ Global command directory.
global.conf Configuration file.
gozilla/ Gozilla command directory.
gtags/ Gtags command directory.
gzshrc Gzsh start up file.
htags/ Htags command directory.
systags/ Script for kernel.
lib/ library.
lib/ Private library.
gtags.el Gtags mode for Emacs.
nvi-1.34.diff Patch for nvi 1.34.
nvi-1.66.diff Patch for nvi 1.66.
nvi-1.79.diff Patch for nvi 1.79.

View File

@ -1,7 +1,16 @@
.if !defined(GLOBAL_MAKEFILE_INC_BEEN_HERE)
GLOBAL_MAKEFILE_INC_BEEN_HERE=yes
BINDIR?= /usr/bin
MANDIR?= /usr/share/man/man
.if exists(${.OBJDIR}/../lib)
LIBUTIL=${.OBJDIR}/../lib/libutil.a
LIBDESTDIR= ${.OBJDIR}/../lib
.else
LIBUTIL=${.CURDIR}/../lib/libutil.a
LIBDESTDIR= ${.CURDIR}/../lib
.endif
LDDESTDIR= -L${LIBDESTDIR}
LDADD= -lgloutil
DPADD= ${LIBDESTDIR}/libgloutil.a
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../lib -O \
-Wall -Wwrite-strings -Wmissing-prototypes
.endif

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
2.24
3.42

View File

@ -1,6 +1,3 @@
PROG= btreeop
CFLAGS+=-I${.CURDIR}/../lib
LDADD= $(LIBUTIL)
DPADD= $(LIBUTIL)
.include <bsd.prog.mk>

View File

@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Nov 26, 1997
.Dd Nov 3, 1998
.Dt BTREEOP 1
.Os BSD 4
.Sh NAME
@ -40,7 +40,7 @@
.Op Fl C
.Op Fl D[keyno] Ar key
.Op Fl K[keyno] Ar key
.Op Fl L
.Op Fl L[2]
.Op Fl k Ar prefix
.Op Ar dbname
.Sh DESCRIPTION
@ -66,21 +66,11 @@ create database and write records to it.
delete records by the key. By default, keyno is 0 (primary key).
.It Fl K[keyno] Ar key
search records by the key. By default, keyno is 0 (primary key).
.It Fl L
list all primary keys.
Following two command lines are identical except that the latter is much faster.
btreeop | awk '{print $1}' | uniq
btreeop -L
.It Fl L[2]
list all primary keys. If '2' is specified, list all the key and data pairs.
.It Fl k Ar prefix
scan records which have the prefix as a primary key.
This option is valid only with sequential read operation (-L command or non command).
Following two command lines are identical except that the latter is much faster.
btreeop | awk '$1 ~ /^fo/ {print }'
btreeop -k fo
.It Ar dbname
database name. default is 'btree'.
.Sh DATA FORMAT

View File

@ -0,0 +1,37 @@
Patch for btree(3)
------------------
Btree(3) core dumps on certain data sets.
if (your system == FreeBSD 2.2.6R or former)
needs this patch.
else if (your system == Debian GNU/Linux 1.3.1)
needs this patch.
else
I don't know.
Please apply patch files in this directory.
1. patch your btree(3) source code
% ls
patch.1.2 patch.1.3 patch.1.4
% set dir=`pwd` <- set current directory
% cd /usr/src/lib/libc/db <- your db source code directory
% cd btree <- btree library
% patch < $dir/patch.1.2 <- it must be in this order.
.
.
% patch < $dir/patch.1.3
.
.
% patch < $dir/patch.1.4
.
.
2. remake and install your db(3) library.
3. remake GLOBAL.
4. remake tag files because tag files are already corrupted.
I derived these patches from 'http://www.sleepycat.com/update/'.
Information is found on 'http://www.sleepycat.com/update/patch.185.html'.

View File

@ -0,0 +1,19 @@
*** btree/bt_split.c Tue Jul 26 14:22:02 1994
--- btree/bt_split.c Sat Jan 4 14:38:55 1997
***************
*** 673,679 ****
* where we decide to try and copy too much onto the left page.
* Make sure that doesn't happen.
*/
! if (skip <= off && used + nbytes >= full) {
--off;
break;
}
--- 673,679 ----
* where we decide to try and copy too much onto the left page.
* Make sure that doesn't happen.
*/
! if (skip <= off && used + nbytes >= full || nxt == top - 1) {
--off;
break;
}

View File

@ -0,0 +1,37 @@
*** btree/bt_split.c.orig Sat Feb 8 10:14:10 1997
--- btree/bt_split.c Sat Feb 8 10:14:51 1997
***************
*** 673,679 ****
* where we decide to try and copy too much onto the left page.
* Make sure that doesn't happen.
*/
! if (skip <= off && used + nbytes >= full || nxt == top - 1) {
--off;
break;
}
--- 673,680 ----
* where we decide to try and copy too much onto the left page.
* Make sure that doesn't happen.
*/
! if (skip <= off &&
! used + nbytes + sizeof(indx_t) >= full || nxt == top - 1) {
--off;
break;
}
***************
*** 686,692 ****
memmove((char *)l + l->upper, src, nbytes);
}
! used += nbytes;
if (used >= half) {
if (!isbigkey || bigkeycnt == 3)
break;
--- 687,693 ----
memmove((char *)l + l->upper, src, nbytes);
}
! used += nbytes + sizeof(indx_t);
if (used >= half) {
if (!isbigkey || bigkeycnt == 3)
break;

View File

@ -0,0 +1,22 @@
*** btree/bt_page.c.orig Wed Jul 13 21:29:02 1994
--- btree/bt_page.c Wed Jun 11 20:14:43 1997
***************
*** 65,70 ****
--- 65,71 ----
h->prevpg = P_INVALID;
h->nextpg = t->bt_free;
t->bt_free = h->pgno;
+ F_SET(t, B_METADIRTY);
/* Make sure the page gets written back. */
return (mpool_put(t->bt_mp, h, MPOOL_DIRTY));
***************
*** 92,97 ****
--- 93,99 ----
(h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) {
*npg = t->bt_free;
t->bt_free = h->nextpg;
+ F_SET(t, B_METADIRTY);
return (h);
}
return (mpool_new(t->bt_mp, npg));

92
contrib/global/gctags/C.h Normal file
View File

@ -0,0 +1,92 @@
/*
* 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
* 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 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.
*
* C.h 20-Aug-98
*/
#define DECLARATIONS 0
#define RULES 1
#define PROGRAMS 2
#define C___P 1001
#define C_AUTO 1002
#define C_BREAK 1003
#define C_CASE 1004
#define C_CHAR 1005
#define C_CONTINUE 1006
#define C_DEFAULT 1007
#define C_DO 1008
#define C_DOUBLE 1009
#define C_ELSE 1010
#define C_EXTERN 1011
#define C_FLOAT 1012
#define C_FOR 1013
#define C_GOTO 1014
#define C_IF 1015
#define C_INT 1016
#define C_LONG 1017
#define C_REGISTER 1018
#define C_RETURN 1019
#define C_SHORT 1020
#define C_SIZEOF 1021
#define C_STATIC 1022
#define C_STRUCT 1023
#define C_SWITCH 1024
#define C_TYPEDEF 1025
#define C_UNION 1026
#define C_UNSIGNED 1027
#define C_VOID 1028
#define C_WHILE 1029
#define CP_ELIF 2001
#define CP_ELSE 2002
#define CP_DEFINE 2003
#define CP_IF 2004
#define CP_IFDEF 2005
#define CP_IFNDEF 2006
#define CP_INCLUDE 2007
#define CP_PRAGMA 2008
#define CP_SHARP 2009
#define CP_ERROR 2010
#define CP_UNDEF 2011
#define CP_ENDIF 2012
#define CP_LINE 2013
#define YACC_SEP 3001
#define YACC_BEGIN 3002
#define YACC_END 3003
#define YACC_LEFT 3004
#define YACC_NONASSOC 3005
#define YACC_RIGHT 3006
#define YACC_START 3007
#define YACC_TOKEN 3008
#define YACC_TYPE 3009
#define IS_CTOKEN(c) (c > 1000 && c < 2001)
#define IS_CPTOKEN(c) (c > 2000 && c < 3001)
#define IS_YACCTOKEN(c) (c > 3000 && c < 4001)
#define MAXPIFSTACK 100

View File

@ -1,7 +1,4 @@
PROG= gctags
CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../lib
LDADD= $(LIBUTIL)
DPADD= $(LIBUTIL)
SRCS= C.c ctags.c fortran.c lisp.c print.c tree.c yacc.c assembler.c
SRCS= C.c assembler.c gctags.c java.c
.include <bsd.prog.mk>

View File

@ -1,6 +1,5 @@
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. 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
@ -12,8 +11,7 @@
* 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.
* This product includes software developed by Shigio Yamaguchi.
* 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.
@ -29,80 +27,111 @@
* 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.
*
* assembler.c 20-Aug-98
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)assembler.c 8.3 (Berkeley) 6/6/97";
#endif /* LIBC_SCCS and not lint */
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "ctags.h"
#include "lookup.h"
#include "gctags.h"
#include "defined.h"
#include "token.h"
static int reserved __P((char *));
#define A_CALL 1001
#define A_DEFINE 1002
#define A_ENTRY 1003
#define A_EXT 1004
#define A_ALTENTRY 1005
#ifdef GLOBAL
void
asm_entries()
assembler()
{
char *lbp;
char tok[MAXTOKEN];
char *sp;
int c;
int target;
const char *interested = NULL; /* get all token */
int startline = 1;
int level; /* not used */
for (;;) {
lineftell = ftell(inf);
if (!fgets(lbuf, sizeof(lbuf), inf))
return;
++lineno;
if (rflag) {
/* extract only call EXT(xxx) or call _xxx */
lbp = lbuf;
while (*lbp && isspace(*lbp))
lbp++;
if (*lbp != 'c' || strncmp(lbp, "call", 4))
continue;
lbp += 4;
while (*lbp && isspace(*lbp))
lbp++;
sp = tok;
if (!strncmp(lbp, "EXT(" /* ) */, 4)) {
lbp += 4;
while (*lbp && intoken(*lbp))
*sp++ = *lbp++;
if (*lbp != /* ( */ ')')
continue;
*sp = EOS;
} else if (*lbp == '_') {
lbp++;
while (*lbp && intoken(*lbp))
*sp++ = *lbp++;
*sp = EOS;
} else
continue;
if (!lookup(tok))
continue;
} else {
/* extract only ENTRY() and ALTENTRY(). */
if (lbuf[0] != 'E' && lbuf[0] != 'A')
continue;
lbp = lbuf;
if (!strncmp(lbp, "ENTRY(", 6)) {
lbp += 6;
} else if (!strncmp(lbp, "ALTENTRY(", 9)) {
lbp += 9;
} else
continue;
sp = tok;
while (*lbp && intoken(*lbp))
*sp++ = *lbp++;
if (*lbp != /* ( */ ')')
continue;
*sp = EOS;
level = 0; /* to satisfy compiler */
/* symbol search doesn't supported. */
if (sflag)
return;
target = (rflag) ? REF : DEF;
cmode = 1;
crflag = 1;
while ((c = nexttoken(interested, reserved)) != EOF) {
switch (c) {
case '\n':
startline = 1;
continue;
case A_CALL:
if (!startline || target != REF)
break;
if ((c = nexttoken(interested, reserved)) == A_EXT) {
if ((c = nexttoken(interested, reserved)) == '('/* ) */)
if ((c = nexttoken(interested, reserved)) == SYMBOL)
if (defined(token))
PUT(token, lineno, sp);
} else if (c == SYMBOL && *token == '_') {
if (defined(&token[1]))
PUT(&token[1], lineno, sp);
}
break;
case A_ALTENTRY:
case A_ENTRY:
if (!startline || target != DEF)
break;
if ((c = nexttoken(interested, reserved)) == '('/* ) */)
if ((c = nexttoken(interested, reserved)) == SYMBOL)
if (peekc(1) == /* ( */ ')')
PUT(token, lineno, sp);
break;
case A_DEFINE:
if (!startline || target != DEF)
break;
if ((c = nexttoken(interested, reserved)) == SYMBOL) {
if (peekc(1) == '('/* ) */) {
PUT(token, lineno, sp);
while ((c = nexttoken(interested, reserved)) != EOF && c != '\n' && c != /* ( */ ')')
;
while ((c = nexttoken(interested, reserved)) != EOF && c != '\n')
;
}
}
default:
}
getline();
pfnote(tok, lineno);
startline = 0;
}
/*NOTREACHED*/
}
#endif
static int
reserved(word)
char *word;
{
switch (*word) {
case '#':
if (!strcmp(word, "#define"))
return A_DEFINE;
break;
case 'A':
if (!strcmp(word, "ALTENTRY"))
return A_ALTENTRY;
break;
case 'E':
if (!strcmp(word, "ENTRY"))
return A_ENTRY;
else if (!strcmp(word, "EXT"))
return A_EXT;
break;
case 'c':
if (!strcmp(word, "call"))
return A_CALL;
break;
}
return SYMBOL;
}

View File

@ -1,5 +1,5 @@
.\" Copyright (c) 1987, 1990, 1993
.\" The Regents of the University of California. 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
@ -11,8 +11,7 @@
.\" 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.
.\" This product includes software developed by Shigio Yamaguchi.
.\" 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.
@ -29,109 +28,67 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)gctags.1 8.1 (Berkeley) 6/6/93
.\"
.Dd April 21, 1997
.Dd Aug 19, 1998
.Dt GCTAGS 1
.Os BSD 4
.Sh NAME
.Nm gctags
.Nd create a tags file (special command for GLOBAL)
.Nd print cross reference list for gtags.
.Sh SYNOPSIS
.Nm gctags
.Op Fl BDFacderstuvwx
.Op Fl f Ar tagsfile
.Ar name ...
.Op Fl b
.Op Fl e
.Op Fl n
.Op Fl r
.Op Fl s
.Op Fl w
.Ar file ...
.Sh DESCRIPTION
.Nm Gctags
makes a tags file for
.Xr ex 1
print cross reference list for
.Xr gtags 1
from the specified C,
Pascal, Fortran,
.Tn YACC ,
lex, lisp and assembler sources.
A tags file gives the locations of specified objects in a group of files.
Each line of the tags file contains the object name, the file in which it
is defined, and a search pattern for the object definition, separated by
.Tn JAVA ,
and assembler source to standard output.
Each line of output contains the object name, the line number which it appears,
the file in which it is defined, and a line image separated by
white-space.
Using the
.Ar tags
file,
.Xr ex 1
can quickly locate these object definitions.
It's same with the output of
.Xr ctags 1
with -x option.
.Pp
Depending upon the options provided to
.Nm gctags ,
objects will consist of subroutines, typedefs, defines, structs,
enums and unions.
objects will consist of function definitions, function references and other
symbols.
This command is the default parser of GLOBAL source code tag system.
.Bl -tag -width Ds
.It Fl B
use backward searching patterns
.Pq Li ?...? .
.It Fl D
allow duplicate object names.
.It Fl F
use forward searching patterns
.Pq Li /.../
(the default).
.It Fl a
append to
.Ar tags
file.
.It Fl c
print with compact format. It is valid only with -x option.
.It Fl d
create tags for
.Li #defines
that don't take arguments;
.Li #defines
that take arguments are tagged automatically.
.It Fl b
force level 1 block to begin when reach a '{' at the first column. (C only)
.It Fl e
force a function to end when reach a '}' at the first column. (C source only)
.It Fl f
place the tag descriptions in a file called
.Ar tagsfile .
The default behaviour is to place them in a file called
.Ar tags .
force level 1 block to end when reach a '}' at the first column. (C only)
.It Fl n
suppress output of tags. It is useful to use with
.Fl w
option.
.It Fl r
locate function references instead of function definitions. GTAGS file is
needed at the current directory. (C source only)
needed at the current directory. (C and Java source only)
By default, locate function definitions.
.It Fl s
collect symbols except for functions.
.It Fl t
create tags for typedefs, structs, unions, and enums.
.It Fl u
update the specified files in the
.Ar tags
file, that is, all
references to them are deleted, and the new values are appended to the
file. (Beware: this option is implemented in a way which is rather
slow; it is usually faster to simply rebuild the
.Ar tags
file.)
.It Fl v
An index of the form expected by
.Xr vgrind 1
is produced on the standard output. This listing
contains the object name, file name, and page number (assuming 64
line pages). Since the output will be sorted into lexicographic order,
it may be desired to run the output through
.Xr sort 1 .
Sample use:
.Bd -literal -offset indent
gctags \-v files \&| sort \-f > index
vgrind \-x index
.Ed
collect symbols other than functions. By default, locate function definitions.
.It Fl w
suppress warning diagnostics.
.It Fl x
.Nm gctags
produces a list of object
names, the line number and file name on which each is defined, as well
as the text of that line and prints this on the standard output. This
is a simple index which can be printed out as an off-line readable
function index.
print warning message.
.El
.Pp
The
.Fl r
and
.Fl s
options override each other; the last one specified determines the method used.
.Pp
Files whose names end in
.Nm \&.c
or
@ -144,47 +101,19 @@ are assumed to be
.Tn YACC
source files.
Files whose names end in
.Nm \&.l
are assumed to be lisp files if their
first non-blank character is `;', `(', or `[',
otherwise, they are
treated as lex files.
.Nm \&.java
are assumed to be Java source files.
Files whose names end in
.Nm \&.s
or
.Nm \&.S
are assumed to be Assembler
source files. Other files are first examined to see if they
contain any Pascal or Fortran routine definitions, and, if not, are
searched for C style definitions.
source files. Other files are searched for C style definitions.
.Pp
The tag
.Li main
is treated specially in C programs. The tag formed
is created by prepending
.Ar M
to the name of the file, with the
trailing
.Nm \&.c
and any leading pathname components removed. This
makes use of
.Nm gctags
practical in directories with more than one
program.
.Pp
Yacc and lex files each have a special tag.
Yacc files each have a special tag.
.Ar Yyparse
is the start
of the second section of the yacc file, and
.Ar yylex
is the start of
the second section of the lex file.
.Sh FILES
.Bl -tag -width tags -compact
.It Pa tags
default output tags file
.It Pa GTAGS
tags file for GLOBAL
of the second section of the yacc file.
.El
.Sh DIAGNOSTICS
.Nm Gctags
@ -199,42 +128,15 @@ Duplicate objects are not considered errors.
.Xr vi 1 .
.Sh BUGS
.Pp
Recognition of
.Nm functions ,
.Nm subroutines
and
.Nm procedures
for
.Tn FORTRAN
and Pascal is done is a very simpleminded way. No attempt
is made to deal with block structure; if you have two Pascal procedures
in different blocks with the same name you lose.
.Nm Gctags
doesn't
understand about Pascal types.
.Pp
The method of deciding whether to look for C, Pascal or
.Tn FORTRAN
functions is a hack.
.Pp
.Nm Gctags
relies on the input being well formed, and any syntactical
errors will completely confuse it. It also finds some legal syntax
confusing; for example, since it doesn't understand
.Li #ifdef Ns 's
(incidentally, that's a feature, not a bug), any code with unbalanced
braces inside
.Li #ifdef Ns 's
will cause it to become somewhat disoriented.
In a similar fashion, multiple line changes within a definition will
cause it to enter the last line of the object, rather than the first, as
the searching pattern. The last line of multiple line
.Li typedef Ns 's
will similarly be noted.
errors will completely confuse it.
.Pp
Assembler support is far from completeness. It extracts only ENTRY()
Assembler support is far from complete. It extracts only ENTRY()
and ALTENTRY() from source file. Probably valid only for FreeBSD and Linux
kernel source.
.Sh AUTHORS
Shigio Yamaguchi (shigio@wafu.netgate.net)
.Sh HISTORY
The
.Nm

View File

@ -0,0 +1,181 @@
/*
* Copyright (c) 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
* 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 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.
*
* gctags.c 13-Sep-98
*/
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "global.h"
#include "gctags.h"
int bflag; /* -b: force level 1 block start */
int dflag; /* -d: debug */
int eflag; /* -e: force level 1 block end */
int nflag; /* -n: doen't print tag */
int rflag; /* -r: function reference */
int sflag; /* -s: collect symbols */
int wflag; /* -w: warning message */
int yaccfile; /* yacc file */
const char *progname = "gctags"; /* program name */
char *notfunction;
int main __P((int, char **));
static void usage __P((void));
struct words *words;
static int tablesize;
int
main(argc, argv)
int argc;
char **argv;
{
char *p;
while (--argc > 0 && (++argv)[0][0] == '-') {
for (p = argv[0] + 1; *p; p++) {
switch(*p) {
case 'b':
bflag++;
break;
case 'd':
dflag++;
break;
case 'e':
eflag++;
break;
case 'n':
nflag++;
break;
case 'r':
rflag++;
sflag = 0;
break;
case 's':
sflag++;
rflag = 0;
break;
case 'w':
wflag++;
break;
default:
usage();
}
}
}
if (argc < 1)
usage();
if (getenv("GTAGSWARNING"))
wflag++;
if (test("r", NOTFUNCTION)) {
FILE *ip;
STRBUF *sb = stropen();
int i;
if ((ip = fopen(NOTFUNCTION, "r")) == 0)
die1("'%s' cannot read.", NOTFUNCTION);
for (tablesize = 0; (p = mgets(ip, NULL, 0)) != NULL; tablesize++)
strnputs(sb, p, strlen(p) + 1);
fclose(ip);
if ((words = malloc(sizeof(struct words) * tablesize)) == NULL)
die("short of memory.");
p = strvalue(sb);
for (i = 0; i < tablesize; i++) {
words[i].name = p;
p += strlen(p) + 1;
}
qsort(words, tablesize, sizeof(struct words), cmp);
/* don't call strclose(sb); */
}
for (; argc > 0; argv++, argc--) {
if (!opentoken(argv[0]))
die1("'%s' cannot open.", argv[0]);
if (locatestring(argv[0], ".y", MATCH_AT_LAST))
C(1);
else if (locatestring(argv[0], ".s", MATCH_AT_LAST) ||
locatestring(argv[0], ".S", MATCH_AT_LAST))
assembler();
else if (locatestring(argv[0], ".java", MATCH_AT_LAST))
java();
else
C(0);
closetoken();
}
exit(0);
}
static void
usage()
{
(void)fprintf(stderr, "usage: gctags [-benrsw] file ...\n");
exit(1);
}
int
cmp(s1, s2)
const void *s1, *s2;
{
return strcmp(((struct words *)s1)->name, ((struct words *)s2)->name);
}
int
isnotfunction(name)
char *name;
{
struct words tmp;
struct words *result;
if (words == NULL)
return 0;
tmp.name = name;
result = (struct words *)bsearch(&tmp, words, tablesize, sizeof(struct words), cmp);
return (result != NULL) ? 1 : 0;
}
#ifdef DEBUG
void
dbg_print(level, s)
int level;
const char *s;
{
if (!dflag)
return;
fprintf(stderr, "[%04d]", lineno);
for (; level > 0; level--)
fprintf(stderr, " ");
fprintf(stderr, "%s\n", s);
}
#endif

View File

@ -0,0 +1,91 @@
/*
* Copyright (c) 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
* 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 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.
*
* gctags.h 17-Oct-98
*/
#include <sys/param.h>
#include "token.h"
/*
* target type.
*/
#define DEF 1
#define REF 2
#define SYM 3
#define NOTFUNCTION ".notfunction"
extern int bflag;
extern int dflag;
extern int eflag;
extern int nflag;
extern int rflag;
extern int sflag;
extern int wflag;
extern int yaccfile;
struct words {
const char *name;
int val;
};
#define PUT(tag, lno, line) { \
DBG_PRINT(level, line); \
if (!nflag) { \
if (strlen(tag) >= 16 && lno >= 1000) \
printf("%-16s %4d %-16s %s\n", \
tag, lno, curfile, line); \
else \
printf("%-16s%4d %-16s %s\n", \
tag, lno, curfile, line); \
} \
}
#define IS_RESERVED(a) ((a) > 255)
#ifndef __P
#ifdef __STDC__
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
#ifdef DEBUG
void dbg_print __P((int, const char *));
#define DBG_PRINT(level, a) dbg_print(level, a)
#else
#define DBG_PRINT(level, a)
#endif
int isnotfunction __P((char *));
int cmp __P((const void *, const void *));
void C __P((int));
void assembler __P((void));
void java __P((void));

View File

@ -0,0 +1,240 @@
/*
* Copyright (c) 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
* 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 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.
*
* java.c 2-Sep-98
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gctags.h"
#include "defined.h"
#include "die.h"
#include "java.h"
#include "token.h"
static int reserved __P((char *));
/*
* java: read java file and pickup tag entries.
*/
void
java()
{
int c;
int level; /* brace level */
int target;
int startclass, startthrows, startequal;
char classname[MAXTOKEN];
char completename[MAXCOMPLETENAME];
int classlevel;
struct {
char *classname;
char *terminate;
int level;
} stack[MAXCLASSSTACK];
const char *interested = "{}=;";
stack[0].terminate = completename;
stack[0].level = 0;
level = classlevel = 0;
target = (sflag) ? SYM : ((rflag) ? REF : DEF);
startclass = startthrows = startequal = 0;
while ((c = nexttoken(interested, reserved)) != EOF) {
switch (c) {
case SYMBOL: /* symbol */
for (; c == SYMBOL && peekc(1) == '.'; c = nexttoken(interested, reserved)) {
if (target == SYM)
PUT(token, lineno, sp);
}
if (c != SYMBOL)
break;
if (startclass || startthrows) {
if (target == REF && defined(token))
PUT(token, lineno, sp);
} else if (peekc(0) == '('/* ) */) {
if (target == DEF && level == stack[classlevel].level && !startequal)
/* ignore constructor */
if (strcmp(stack[classlevel].classname, token))
PUT(token, lineno, sp);
if (target == REF && (level > stack[classlevel].level || startequal) && defined(token))
PUT(token, lineno, sp);
} else {
if (target == SYM)
PUT(token, lineno, sp);
}
break;
case '{': /* } */
DBG_PRINT(level, "{"); /* } */
++level;
if (startclass) {
char *p = stack[classlevel].terminate;
char *q = classname;
if (++classlevel >= MAXCLASSSTACK)
die1("class stack over flow.[%s]", curfile);
if (classlevel > 1)
*p++ = '.';
stack[classlevel].classname = p;
while (*q)
*p++ = *q++;
stack[classlevel].terminate = p;
stack[classlevel].level = level;
*p++ = 0;
}
startclass = startthrows = 0;
break;
/* { */
case '}':
if (--level < 0) {
if (wflag)
fprintf(stderr, "Warning: missing left '{' (at %d).\n", lineno); /* } */
level = 0;
}
if (level < stack[classlevel].level)
*(stack[--classlevel].terminate) = 0;
/* { */
DBG_PRINT(level, "}");
break;
case '=':
startequal = 1;
break;
case ';':
startclass = startthrows = startequal = 0;
break;
case J_CLASS:
case J_INTERFACE:
if ((c = nexttoken(interested, reserved)) == SYMBOL) {
strcpy(classname, token);
startclass = 1;
if (target == DEF)
PUT(token, lineno, sp);
}
break;
case J_NEW:
case J_INSTANCEOF:
while ((c = nexttoken(interested, reserved)) == SYMBOL && peekc(1) == '.')
if (target == SYM)
PUT(token, lineno, sp);
if (c == SYMBOL)
if (target == REF && defined(token))
PUT(token, lineno, sp);
break;
case J_THROWS:
startthrows = 1;
break;
case J_BOOLEAN:
case J_BYTE:
case J_CHAR:
case J_DOUBLE:
case J_FLOAT:
case J_INT:
case J_LONG:
case J_SHORT:
case J_VOID:
if (peekc(1) == '.' && (c = nexttoken(interested, reserved)) != J_CLASS)
pushbacktoken();
break;
default:
}
}
}
/* sorted by alphabet */
static struct words words[] = {
{"abstract", J_ABSTRACT},
{"boolean", J_BOOLEAN},
{"break", J_BREAK},
{"byte", J_BYTE},
{"case", J_CASE},
{"catch", J_CATCH},
{"char", J_CHAR},
{"class", J_CLASS},
{"const", J_CONST},
{"continue", J_CONTINUE},
{"default", J_DEFAULT},
{"do", J_DO},
{"double", J_DOUBLE},
{"else", J_ELSE},
{"extends", J_EXTENDS},
{"false", J_FALSE},
{"final", J_FINAL},
{"finally", J_FINALLY},
{"float", J_FLOAT},
{"for", J_FOR},
{"goto", J_GOTO},
{"if", J_IF},
{"implements", J_IMPLEMENTS},
{"import", J_IMPORT},
{"instanceof", J_INSTANCEOF},
{"int", J_INT},
{"interface", J_INTERFACE},
{"long", J_LONG},
{"native", J_NATIVE},
{"new", J_NEW},
{"null", J_NULL},
{"package", J_PACKAGE},
{"private", J_PRIVATE},
{"protected", J_PROTECTED},
{"public", J_PUBLIC},
{"return", J_RETURN},
{"short", J_SHORT},
{"static", J_STATIC},
{"strictfp", J_STRICTFP},
{"super", J_SUPER},
{"switch", J_SWITCH},
{"synchronized",J_SYNCHRONIZED},
{"this", J_THIS},
{"throw", J_THROW},
{"throws", J_THROWS},
{"union", J_UNION},
{"transient", J_TRANSIENT},
{"true", J_TRUE},
{"try", J_TRY},
{"void", J_VOID},
{"volatile", J_VOLATILE},
{"while", J_WHILE},
{"widefp", J_WIDEFP},
};
static int
reserved(word)
char *word;
{
struct words tmp;
struct words *result;
tmp.name = word;
result = (struct words *)bsearch(&tmp, words, sizeof(words)/sizeof(struct words), sizeof(struct words), cmp);
return (result != NULL) ? result->val : SYMBOL;
}

View File

@ -0,0 +1,91 @@
/*
* Copyright (c) 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
* 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 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.
*
* java.h 20-Aug-98
*/
/*
* java's reserved words.
*/
#define J_ABSTRACT 1001
#define J_BOOLEAN 1002
#define J_BREAK 1003
#define J_BYTE 1004
#define J_CASE 1005
#define J_CATCH 1006
#define J_CHAR 1007
#define J_CLASS 1008
#define J_CONST 1009
#define J_CONTINUE 1010
#define J_DEFAULT 1011
#define J_DO 1012
#define J_DOUBLE 1013
#define J_ELSE 1014
#define J_EXTENDS 1015
#define J_FALSE 1016
#define J_FINAL 1017
#define J_FINALLY 1018
#define J_FLOAT 1019
#define J_FOR 1020
#define J_GOTO 1021
#define J_IF 1022
#define J_IMPLEMENTS 1023
#define J_IMPORT 1024
#define J_INSTANCEOF 1025
#define J_INT 1026
#define J_INTERFACE 1027
#define J_LONG 1028
#define J_NATIVE 1029
#define J_NEW 1030
#define J_NULL 1031
#define J_PACKAGE 1032
#define J_PRIVATE 1033
#define J_PROTECTED 1034
#define J_PUBLIC 1035
#define J_RETURN 1036
#define J_SHORT 1037
#define J_STATIC 1038
#define J_SUPER 1039
#define J_SWITCH 1040
#define J_SYNCHRONIZED 1041
#define J_THIS 1042
#define J_THROW 1043
#define J_THROWS 1044
#define J_UNION 1045
#define J_TRANSIENT 1046
#define J_TRUE 1047
#define J_TRY 1048
#define J_VOID 1049
#define J_VOLATILE 1050
#define J_WHILE 1051
#define J_STRICTFP 1052
#define J_WIDEFP 1053
#define MAXCOMPLETENAME 1024 /* max size of complete name of class */
#define MAXCLASSSTACK 10 /* max size of class stack */

157
contrib/global/global.conf Normal file
View File

@ -0,0 +1,157 @@
#
# Copyright (c) 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
# 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.
#
# Configuration file for GLOBAL source code tag system.
#
# Copy this file as /etc/global.conf or $HOME/.globalrc and GLOBAL system
# use it.
#
# 'default' is default target.
# You can specify target with GTAGSLABEL environment variable.
#
# include:
# It's similar to 'tc=' in termcap but can be used anytime and anywhere.
# 8 level nested usage is allowed.
#
default:\
:include=gctags:include=htags:
#---------------------------------------------------------------------
#
# Configuration for gtags(1)
#
# format:
# Select 'standard' or 'compact'. By default, it assumes 'standard'.
# suffixes:
# Suffixes of target source file. By default, 'c,h,y,s,S,java'.
# skip:
# Skip files among the target files. If the name ends with '/',
# gtags skips all files under the directory.
# By default, 'y.tab.c,y.tab.h,SCCS/,RCS/,CVS/'.
# extractmethod:
# Please see source code of gtags(1).
# GTAGS:
# Tag command for definitions. Non of default value.
# GRTAGS:
# Tag command for references. Non of default value.
# GSYMS:
# Tag command for other symbols. Non of default value.
#
# Htags(1) needs both of GTAGS and GRTAGS. Global(1)'s -s option needs GSYMS.
#
#---------------------------------------------------------------------
common:\
:skip=y.tab.c,y.tab.h,SCCS/,RCS/,CVS/:\
:format=standard:
#
# [gctags]
#
# This command is distributed as part of GLOBAL.
#
gctags|tag command for GLOBAL:\
:include=common:\
:suffixes=c,h,y,s,S,java:\
:GTAGS=gctags %s:\
:GRTAGS=gctags -r %s:\
:GSYMS=gctags -s %s:
#
# [Emacs's ctags]
#
# This ctags is distributed as a part of Emacs editor.
#
# supported suffixes by etags.
#
# lisp: l,el,lsp,lisp,cl,clisp
# scheme: sm,scm,scheme,t,sch,ss,SM,SCM
# assembler: s,a,sa,asm,src,def,ins,inc
# C++: C,H,cpp,cxx,hxx,cc
# C*: cs,hs
# c,yacc: c,h,y
# pl,p,pas: pascal
# fortran: f,for
#
# [Installation]
# % cd <emacs source directory>/lib-src
# % make ctags
# # cp ctags /usr/local/bin/ctags-emacs
#
ctags-emacs|ctags based on etags|GNU Emacs ctags:\
:include=common:\
:suffixes=el,s,a,sa,asm,C,H,cpp,cxx,hxx,cc,c,h,y:\
:skip=ispell.el,canna.el,gnusutil.el:\
:extractmethod:\
:GTAGS=/usr/local/bin/ctags-emacs -x -d -T -w %s:
#
# [Exuberant Ctags]
#
# This ctags is distributed as a part of Vim editor.
#
# [Installation]
# % cd <Vim source directory>/src/ctags
# % make
# # cp ctags /usr/local/bin/ctags-exuberant
#
ctags-exuberant|Exuberant Ctags|ctags by Darren Hiebert:\
:include=common:\
:suffixes=s,a,sa,asm,C,H,cpp,cxx,hxx,cc,c,h,y:\
:extractmethod:\
:GTAGS=/usr/local/bin/ctags-exuberant -x %s | perl -ne '($name, $type, $no, $path, $line) = split(/[ \t]+/, $_, 5); printf(STDOUT "%-16s %4d %-16s %s", $name, $no, $path, $line);':
#---------------------------------------------------------------------
#
# Configuration for htags(1)
# Let's paint hypertext with your favorite colors!
#
# bgcolor,text,link,vlink,alink:
# attribute of <BODY>. (default is not set)
# title_begin,title_end:
# title tag
# comment_begin,comment_end:
# comment tag. (/* ... */, // ...)
# sharp_begin,sharp_end:
# macro tag. (#include, #define, ...)
# brace_begin,brace_end:
# brace tag. ('{', '}')
# reserved_begin,reserved_end:
# reserved word tag. (while, if, char, ...)
# ncol:
# columns of line number. (default = 4)
# tabs:
# tab stop. (default = 8)
# gzipped_suffix:
# suffix of compressed html file.
#
#---------------------------------------------------------------------
htags:\
:bgcolor=silver:text=black:link=blue:vlink=red:alink=cyan:\
:title_begin=<FONT COLOR=#cc0000>:title_end=</FONT>:\
:comment_begin=<I><FONT COLOR=green>:comment_end=</FONT></I>:\
:sharp_begin=<FONT COLOR=darkred>:sharp_end=</FONT>:\
:brace_begin=<FONT COLOR=blue>:brace_end=</FONT>:\
:reserved_begin=<B>:reserved_end=</B>:\
:ncol#4:tabs#8:gzipped_suffix=ghtml:

View File

@ -1,6 +1,3 @@
PROG= global
CFLAGS+=-I${.CURDIR}/../lib
LDADD= $(LIBUTIL)
DPADD= $(LIBUTIL)
.include <bsd.prog.mk>

View File

@ -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.
.\"
.Dd Nov 26, 1997
.Dd Dec 8, 1998
.Dt GLOBAL 1
.Os BSD 4
.Sh NAME
@ -36,26 +36,29 @@
.Nd print the locations of specified object.
.Sh SYNOPSIS
.Nm global
.Op Fl alrvx
.Op Fl alnrtvx
.Ar pattern
.Nm global -c
.Op Ar prefix
.Nm global
.Fl f[arx]
.Ar file
.Fl f[anrtx]
.Ar files
.Nm global
.Fl g[alvx]
.Fl g[alntvx]
.Ar pattern
.Nm global
.Fl i[v]
.Nm global
.Fl p
.Nm global
.Fl s[alvx]
.Fl P[alnt]
.Op Ar pattern
.Nm global
.Fl s[alntvx]
.Ar pattern
.Sh DESCRIPTION
.Nm Global
find the locations of specified object in C and Yacc source files.
find the locations of specified object in C, Yacc and Java source files.
.Nm Global
can treat a source tree, that is, a directory that has subdirectories and
source files.
@ -71,38 +74,53 @@ at the root directory of the source tree to make tag files.
Then you can execute
.Nm
at anywhere in the source tree.
.Pp
The following options are available:
.Sh COMMANDS
The following commands are available:
.Bl -tag -width Ds
.It Ar pattern
object pattern. It can include POSIX 1003.2 regular expression.
.It Fl a
print absolute path name. By default, print relative path name.
print object which match to the
.Ar pattern .
It can include POSIX 1003.2 regular expression.
.It Fl c Op Ar prefix
print candidate function names which start with specified
.Ar prefix .
If
.Ar prefix
is not specified, print all function names.
.It Fl f Ar file
.It Fl f Ar files
print all function definitions in the
.Ar file .
.Ar files .
This option implies -x option.
.It Fl g
print all lines which match to the pattern.
.It Fl g Ar pattern
print all lines which match to the
.Ar pattern .
It is similar to grep(1).
.It Fl i
reconstruct tags files incrementally.
.It Fl l
print objects which exist under the current directory.
.It Fl r
print the locations of function references. By default, print function
definitions.
locate tag files and reconstruct them incrementally.
.It Fl p
print the location of GTAGS.
.It Fl s
.It Fl P Op Ar pattern
print the path which match to the
.Ar pattern .
If no pattern specified, print all.
.It Fl s Ar pattern
print the locations of specified symbol other than function names.
You need GSYMS tags file. See
.Xr gtags 1 .
.Sh OPTIONS
The following options are available:
.Bl -tag -width Ds
.It Fl a
print absolute path name. By default, print relative path name.
.It Fl l
print just objects which exist under the current directory.
.It Fl n
suppress sort filter and path conversion filter.
.It Fl r
print the locations of object references. By default, print object
definitions.
.It Fl t
print with standard ctags format.
.It Fl x
In addition to the default output, produce the line number and
the line contents.
@ -114,6 +132,8 @@ tags file for function definitions.
tags file for function references.
.It Pa GSYMS
tags file for symbols other then functions.
.It Pa GPATH
path index. This is used for incremental updating and compact format.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of global.

View File

@ -2,11 +2,23 @@ XCOMM
XCOMM Imakefile for gozilla
XCOMM
LOCAL_LIBRARIES = XawClientLibs -L../lib -lutil
DEPLIBS = XawClientDepLibs ../lib/libutil.a
DEFINES = -DSTANDALONE -DGLOBAL -I../lib
INC = ../lib
LOCAL_LIBRARIES = XawClientLibs
DEPLIBS = XawClientDepLibs
DEFINES = -DSTANDALONE -DGLOBAL -I$(INC)
SRCS = gozilla.c remote.c
OBJS = gozilla.o remote.o
SRCS = gozilla.c remote.c test.c getdbpath.c strbuf.c conf.c \
mgets.c locatestring.c makepath.c strmake.c
OBJS = gozilla.o remote.o test.o getdbpath.o strbuf.o conf.o \
mgets.o locatestring.o makepath.o strmake.o
LinkSourceFile(test.c,$(INC))
LinkSourceFile(getdbpath.c,$(INC))
LinkSourceFile(strbuf.c,$(INC))
LinkSourceFile(conf.c,$(INC))
LinkSourceFile(mgets.c,$(INC))
LinkSourceFile(locatestring.c,$(INC))
LinkSourceFile(makepath.c,$(INC))
LinkSourceFile(strmake.c,$(INC))
ComplexProgramTarget(gozilla)

View File

@ -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.
*
* gozilla.c 27-Oct-97
* gozilla.c 17-Jul-98
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "global.h"
char *progname = "gozilla"; /* command name */
const char *progname = "gozilla"; /* command name */
static void usage __P((void));
void main __P((int, char **));
int main __P((int, char **));
int issource __P((char *));
int sendcommand __P((char *));
int bflag;
@ -54,17 +57,17 @@ usage()
exit(1);
}
void
int
main(argc, argv)
int argc;
char *argv[];
{
char c, *p, *q;
char *browser = (char *)0;
char *command = (char *)0;
char *arg = (char *)0;
char *browser = NULL;
char *command = NULL;
char *arg = NULL;
char URL[MAXPATHLEN+1];
char com[MAXCOMLINE+1];
char com[MAXFILLEN+1];
int linenumber = 0;
int status;
@ -101,16 +104,19 @@ char *argv[];
}
if (argc == 0)
usage();
if (locatestring(argv[0], "http:", 1) || locatestring(argv[0], "file:", 1))
if (locatestring(argv[0], "http:", MATCH_AT_FIRST) ||
locatestring(argv[0], "ftp:", MATCH_AT_FIRST) ||
locatestring(argv[0], "news:", MATCH_AT_FIRST) ||
locatestring(argv[0], "mail:", MATCH_AT_FIRST) ||
locatestring(argv[0], "file:", MATCH_AT_FIRST))
strcpy(URL, argv[0]);
else {
char *abspath;
char pathbuf[MAXPATHLEN+1];
char htmlpath[MAXPATHLEN+1];
char buf[MAXPATHLEN+1];
if (!test("f", argv[0]) && !test("d", argv[0]))
if (!test("f", argv[0]) && !test("d", NULL))
die1("path '%s' not found.", argv[0]);
if (!(abspath = realpath(argv[0], pathbuf)))
if (!(abspath = realpath(argv[0], buf)))
die1("cannot make absolute path name. realpath(%s) failed.", argv[0]);
if (*abspath != '/')
die("realpath(3) is not compatible with BSD version.");
@ -152,7 +158,7 @@ char *argv[];
/*
* execute generic browser.
*/
if (browser && !locatestring(browser, "netscape", 3)) {
if (browser && !locatestring(browser, "netscape", MATCH_AT_LAST)) {
sprintf(com, "%s '%s'", browser, URL);
system(com);
exit (0);
@ -171,7 +177,7 @@ char *argv[];
if ((pid = fork()) < 0) {
die("cannot execute netscape (fork).");
} else if (pid == 0) {
execlp("netscape", "netscape", URL, (char *)0);
execlp("netscape", "netscape", URL, NULL);
die("loading mozilla failed.");
}
exit(0);
@ -179,6 +185,34 @@ char *argv[];
exit(status);
}
int
issource(path)
char *path;
{
STRBUF *sb = stropen();
char *p;
char suff[MAXPATHLEN+1];
int retval = 0;
if (!getconfs("suffixes", sb)) {
strclose(sb);
return 0;
}
suff[0] = '.';
for (p = strvalue(sb); p; ) {
char *unit = p;
if ((p = locatestring(p, ",", MATCH_FIRST)) != NULL)
*p++ = 0;
strcpy(&suff[1], unit);
if (locatestring(path, suff, MATCH_AT_LAST)) {
retval = 1;
break;
}
}
strclose(sb);
return retval;
}
int
sendcommand(com)
char *com;
{
@ -188,7 +222,7 @@ char *com;
argv[0] = "netscape-remote";
argv[1] = "-remote";
argv[2] = com;
argv[3] = (char *)0;
argv[3] = NULL;
return netscape_remote(argc, argv);
}

View File

@ -139,3 +139,7 @@ can treat not only source file but also normal file, directory, HTML file
and even URL, because it is omnivorous.
.Sh AUTHORS
Shigio Yamaguchi (shigio@wafu.netgate.net)
.Sh HISTORY
The
.Nm
command appeared in FreeBSD 2.2.5.

View File

@ -586,7 +586,7 @@ usage (void)
int
netscape_remote(int argc, char **argv)
#else
void
int
main (int argc, char **argv)
#endif
{

View File

@ -1,6 +1,3 @@
PROG= gtags
CFLAGS+=-I${.CURDIR}/../lib
LDADD= $(LIBUTIL)
DPADD= $(LIBUTIL)
.include <bsd.prog.mk>

View File

@ -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,26 +28,28 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Sep 12, 1997
.Dd Oct 10, 1998
.Dt GTAGS 1
.Os BSD 4
.Sh NAME
.Nm gtags
.Nd create GTAGS, GRTAGS and GSYMS file
.Nd create tag files for global.
.Sh SYNOPSIS
.Nm gtags
.Op Fl c
.Op Fl i
.Op Fl o
.Op Fl w
.Op Fl v
.Op Ar dbpath
.Sh DESCRIPTION
.Nm Gtags
makes GTAGS, GRTAGS and GSYMS file for
makes GTAGS, GRTAGS, GSYMS and GPATH file for
.Xr global 1 .
.Nm Gtags
trace subdirectories, read source files,
locate symbols and save the information into tag files.
C, yacc and assembler source files are supported.
C, yacc, java and assembler source files are supported.
You should execute this command at the root of the source tree.
.Pp
If your source directory is on a read only device like CDROM, specify
@ -55,13 +57,16 @@ If your source directory is on a read only device like CDROM, specify
of the directory on which make tag files.
.Pp
.Bl -tag -width Ds
.It Fl c
make tag files with compact format.
.It Fl i
update tag files incrementally by files which modified after the tag files were
last updated.
update tag files incrementally.
.It Fl o
suppress making GSYMS file.
Use this option if you don't use -s option of
.Xr global 1 .
.It Fl w
print warning messages.
.It Fl v
verbose mode.
.Sh FILES
@ -72,6 +77,8 @@ tag file for function definitions.
tag file for function references.
.It Pa GSYMS
tag file for other symbols.
.It Pa GPATH
path index file which is used for incremental updating and compact format.
.El
.Sh DIAGNOSTICS
.Nm Gtags
@ -85,7 +92,7 @@ exits with a non 0 value if an error occurred, 0 otherwise.
GTAGS, GRTAGS and GSYMS are very large.
In advance of using this command, check the space of your disk.
.br
Assembler support is far from completeness. It extracts only ENTRY()
Assembler support is far from complete. It extracts only ENTRY()
and ALTENTRY() from source file. Probably valid only for FreeBSD and Linux
kernel source.
.br

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,9 @@
LIB= util
SRCS= tag.o tab.o strop.o mgets.o lookup.o gtagsopen.o getdbpath.o \
find.o dbname.o dbio.o test.o makepath.o locatestring.o
NOPROFILE= yes
install:
@echo -n
LIB= gloutil
SRCS= gtagsop.c tab.c strbuf.c mgets.c defined.c getdbpath.c \
find.c dbop.c test.c makepath.c locatestring.c pathop.c \
conf.c strmake.c usable.c token.c
NOPROFILE= noprofile
INTERNALLIB= true
INTERNALSTATICLIB= true
.include <bsd.lib.mk>

308
contrib/global/lib/conf.c Normal file
View File

@ -0,0 +1,308 @@
/*
* 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
* 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.
*
* conf.c 30-Jun-98
*
*/
#include <sys/param.h>
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "conf.h"
#include "die.h"
#include "gparam.h"
#include "locatestring.h"
#include "makepath.h"
#include "mgets.h"
#include "strbuf.h"
#include "strmake.h"
#include "test.h"
/*
* Access library for gtags.conf (.gtagsrc).
* File format is a subset of XXXcap (termcap, printcap) file.
*/
#define GTAGSCONF "/etc/global.conf"
#define GTAGSRC ".globalrc"
#define DEFAULTLABEL "default"
static FILE *fp;
static char *line;
static int allowed_nest_level = 8;
static int opened;
static void trim __P((char *));
static char *readrecord __P((const char *));
static void includelabel __P((STRBUF *, const char *, int));
static void
trim(l)
char *l;
{
char *f, *b;
int colon = 0;
for (f = b = l; *f; f++) {
if (colon && isspace(*f))
continue;
colon = 0;
if ((*b++ = *f) == ':')
colon = 1;
}
*b = 0;
}
static char *
readrecord(label)
const char *label;
{
char *p, *q;
rewind(fp);
while ((p = mgets(fp, NULL, MGETS_CONT|MGETS_SKIPCOM)) != NULL) {
trim(p);
for (;;) {
if ((q = strmake(p, "|:")) == NULL)
die1("illegal configuration file format (%s).", p);
if (!strcmp(label, q)) {
if (!(p = locatestring(p, ":", MATCH_FIRST)))
die("illegal configuration file format.");
p = strdup(p);
if (!p)
die("short of memory.");
return p;
}
p += strlen(q);
if (*p == ':')
break;
else if (*p == '|')
p++;
else
assert(0);
}
}
return NULL;
}
static void
includelabel(sb, label, level)
STRBUF *sb;
const char *label;
int level;
{
char *savep, *p, *q;
if (++level > allowed_nest_level)
die("nested include= (or tc=) over flow.");
if (!(savep = p = readrecord(label)))
die1("label '%s' not found.", label);
while ((q = locatestring(p, ":include=", MATCH_FIRST)) || (q = locatestring(p, ":tc=", MATCH_FIRST))) {
char inclabel[MAXPROPLEN+1], *c = inclabel;
strnputs(sb, p, q - p);
q = locatestring(q, "=", MATCH_FIRST) + 1;
while (*q && *q != ':')
*c++ = *q++;
*c = 0;
includelabel(sb, inclabel, level);
p = q;
}
strputs(sb, p);
free(savep);
}
/*
* configpath: get path of configuration file.
*/
char *
configpath() {
static char config[MAXPATHLEN+1];
char *p;
if ((p = getenv("GTAGSCONF")) != NULL) {
if (!test("r", p))
config[0] = 0;
else
strcpy(config, p);
} else if ((p = getenv("HOME")) && test("r", makepath(p, GTAGSRC)))
strcpy(config, makepath(p, GTAGSRC));
else if (test("r", GTAGSCONF))
strcpy(config, GTAGSCONF);
else
config[0] = 0;
return config;
}
/*
* openconf: load configuration file.
*
* go) line specified entry
*/
void
openconf()
{
const char *label, *config;
STRBUF *sb;
assert(opened == 0);
config = configpath();
/*
* if configuration file is not found, default values are set
* for upper compatibility.
*/
if (*config == 0) {
sb = stropen();
strputs(sb, "suffixes=c,h,y,s,S,java:");
strputs(sb, "skip=y.tab.c,y.tab.h,SCCS/,RCS/,CVS/:");
strputs(sb, "format=standard:");
strputs(sb, "extractmethod:");
strputs(sb, "GTAGS=gctags %s:");
strputs(sb, "GRTAGS=gctags -r %s:");
strputs(sb, "GSYMS=gctags -s %s:");
line = strdup(strvalue(sb));
if (!line)
die("short of memory.");
strclose(sb);
opened = 1;
return;
}
if ((label = getenv("GTAGSLABEL")) == NULL)
label = "default";
if (!(fp = fopen(config, "r")))
die1("cannot open '%s'.", config);
sb = stropen();
includelabel(sb, label, 0);
line = strdup(strvalue(sb));
strclose(sb);
fclose(fp);
opened = 1;
return;
}
/*
* getconfn: get property number
*
* i) name property name
* o) num value (if not NULL)
* r) 1: found, 0: not found
*/
int
getconfn(name, num)
const char *name;
int *num;
{
char *p;
char buf[MAXPROPLEN+1];
if (!opened)
openconf();
sprintf(buf, ":%s#", name);
if ((p = locatestring(line, buf, MATCH_FIRST)) != NULL) {
p += strlen(buf);
if (num != NULL)
*num = atoi(p);
return 1;
}
return 0;
}
/*
* getconfs: get property string
*
* i) name property name
* o) sb string buffer (if not NULL)
* r) 1: found, 0: not found
*/
int
getconfs(name, sb)
const char *name;
STRBUF *sb;
{
char *p;
char buf[MAXPROPLEN+1];
int all = 0;
int exist = 0;
if (!opened)
openconf();
if (!strcmp(name, "suffixes") || !strcmp(name, "skip") || !strcmp(name, "reserved_words"))
all = 1;
sprintf(buf, ":%s=", name);
p = line;
while ((p = locatestring(p, buf, MATCH_FIRST)) != NULL) {
if (exist && sb)
strputc(sb, ',');
exist = 1;
for (p += strlen(buf); *p && *p != ':'; p++)
if (sb)
strputc(sb, *p);
if (!all)
break;
}
/*
* It may be that these code should be moved to applications.
* But nothing cannot start without them.
*/
if (!exist) {
exist = 1;
if (!strcmp(name, "suffixes")) {
if (sb)
strputs(sb, "c,h,y,s,S,java");
} else if (!strcmp(name, "skip")) {
if (sb)
strputs(sb, "y.tab.c,y.tab.h,SCCS/,RCS/,CVS/");
} else
exist = 0;
}
return exist;
}
/*
* getconfb: get property bool value
*
* i) name property name
* r) 1: TRUE, 0: FALSE
*/
int
getconfb(name)
const char *name;
{
char *p;
char buf[MAXPROPLEN+1];
if (!opened)
openconf();
sprintf(buf, ":%s:", name);
if ((p = locatestring(line, buf, MATCH_FIRST)) != NULL)
return 1;
return 0;
}
void
closeconf()
{
if (!opened)
return;
free(line);
opened = 0;
}

54
contrib/global/lib/conf.h Normal file
View File

@ -0,0 +1,54 @@
/*
* 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
* 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.
*
* conf.h 16-Oct-97
*
*/
#ifndef _CONF_H_
#define _CONF_H_
#include "strbuf.h"
#ifndef __P
#if defined(__STDC__)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
char *configpath __P((void));
void openconf __P((void));
int getconfn __P((const char *, int *));
int getconfs __P((const char *, STRBUF *));
int getconfb __P((const char *));
void closeconf __P((void));
#endif /* ! _CONF_H_ */

332
contrib/global/lib/dbop.c Normal file
View File

@ -0,0 +1,332 @@
/*
* Copyright (c) 1996, 1997, 1998 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.
*
* dbop.c 12-Nov-98
*
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "dbop.h"
#include "die.h"
#include "test.h"
static DBT key; /* key of record */
static DBT dat; /* data of record */
/*
* dbop_open: open db database.
*
* i) dbname database name
* i) mode 0: read only, 1: create, 2: modify
* i) perm file permission
* i) flags
* DBOP_DUP: allow duplicate records.
* DBOP_REMOVE: remove on closed.
* r) descripter for dbop_xxx()
*/
DBOP *
dbop_open(dbname, mode, perm, flags)
const char *dbname;
int mode;
int perm;
int flags;
{
DB *db;
int rw = 0;
DBOP *dbop;
BTREEINFO info;
/*
* setup argments.
*/
switch (mode) {
case 0:
rw = O_RDONLY;
break;
case 1:
rw = O_RDWR|O_CREAT|O_TRUNC;
break;
case 2:
rw = O_RDWR;
break;
default:
assert(0);
}
memset(&info, 0, sizeof(info));
if (flags & DBOP_DUP)
info.flags |= R_DUP;
info.cachesize = 500000;
/*
* 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)
return NULL;
if (!(dbop = (DBOP *)malloc(sizeof(DBOP))))
die("short of memory.");
strcpy(dbop->dbname, dbname);
dbop->db = db;
dbop->openflags = flags;
dbop->perm = (mode == 1) ? perm : 0;
dbop->lastkey = NULL;
dbop->lastdat = NULL;
return dbop;
}
/*
* dbop_get: get data by a key.
*
* i) dbop descripter
* i) name name
* r) pointer to data
*/
char *
dbop_get(dbop, name)
DBOP *dbop;
const char *name;
{
DB *db = dbop->db;
int status;
key.data = (char *)name;
key.size = strlen(name)+1;
status = (*db->get)(db, &key, &dat, 0);
dbop->lastkey = (char *)key.data;
dbop->lastdat = (char *)dat.data;
switch (status) {
case RET_SUCCESS:
break;
case RET_ERROR:
die("cannot read from database.");
case RET_SPECIAL:
return (NULL);
}
return((char *)dat.data);
}
/*
* dbop_put: put data by a key.
*
* i) dbop descripter
* i) name key
* i) data data
*/
void
dbop_put(dbop, name, data)
DBOP *dbop;
const char *name;
const char *data;
{
DB *db = dbop->db;
int status;
if (strlen(name) > MAXKEYLEN)
die("primary key too long.");
key.data = (char *)name;
key.size = strlen(name)+1;
dat.data = (char *)data;
dat.size = strlen(data)+1;
status = (*db->put)(db, &key, &dat, 0);
switch (status) {
case RET_SUCCESS:
break;
case RET_ERROR:
case RET_SPECIAL:
die("cannot write to database.");
}
}
/*
* dbop_del: delete record by a key.
*
* i) dbop descripter
* i) name key
*/
void
dbop_del(dbop, name)
DBOP *dbop;
const char *name;
{
DB *db = dbop->db;
int status;
if (name) {
key.data = (char *)name;
key.size = strlen(name)+1;
status = (*db->del)(db, &key, 0);
} else
status = (*db->del)(db, &key, R_CURSOR);
if (status == RET_ERROR)
die("cannot delete record.");
}
/*
* dbop_first: get first record.
*
* i) dbop dbop descripter
* i) name key
* !=NULL: indexed read by key
* ==NULL: sequential read
* i) flags following dbop_next call take over this.
* DBOP_KEY read key part
* DBOP_PREFIX prefix read
* only valied when sequential read
* r) data
*/
char *
dbop_first(dbop, name, flags)
DBOP *dbop;
const char *name;
int flags;
{
DB *db = dbop->db;
int status;
if (flags & DBOP_PREFIX && !name)
flags &= ~DBOP_PREFIX;
if (name) {
if (strlen(name) > MAXKEYLEN)
die("primary key too long.");
strcpy(dbop->key, name);
key.data = (char *)name;
key.size = strlen(name);
/*
* includes NULL character unless prefix read.
*/
if (!(flags & DBOP_PREFIX))
key.size++;
dbop->keylen = key.size;
status = (*db->seq)(db, &key, &dat, R_CURSOR);
} else {
dbop->keylen = dbop->key[0] = 0;
/* skip META records */
for (status = (*db->seq)(db, &key, &dat, R_FIRST);
status == RET_SUCCESS;
status = (*db->seq)(db, &key, &dat, R_NEXT)) {
int c = (flags & DBOP_KEY) ? *((char *)key.data) : *((char *)dat.data);
if (c != ' ')
break;
}
}
dbop->lastkey = (char *)key.data;
dbop->lastdat = (char *)dat.data;
switch (status) {
case RET_SUCCESS:
break;
case RET_ERROR:
die("dbop_first failed.");
case RET_SPECIAL:
return (NULL);
}
dbop->ioflags = flags;
if (flags & DBOP_PREFIX) {
if (strncmp((char *)key.data, dbop->key, dbop->keylen))
return NULL;
} else if (dbop->keylen) {
if (strcmp((char *)key.data, dbop->key))
return NULL;
}
if (flags & DBOP_KEY) {
strcpy(dbop->prev, (char *)key.data);
return (char *)key.data;
}
return ((char *)dat.data);
}
/*
* dbop_next: get next record.
*
* i) dbop dbop descripter
* r) data
*
* Db_next always skip meta records.
*/
char *
dbop_next(dbop)
DBOP *dbop;
{
DB *db = dbop->db;
int flags = dbop->ioflags;
int status;
while ((status = (*db->seq)(db, &key, &dat, R_NEXT)) == RET_SUCCESS) {
assert(dat.data != NULL);
if (flags & DBOP_KEY && *((char *)key.data) == ' ')
continue;
else if (*((char *)dat.data) == ' ')
continue;
if (flags & DBOP_KEY) {
if (!strcmp(dbop->prev, (char *)key.data))
continue;
if (strlen((char *)key.data) > MAXKEYLEN)
die("primary key too long.");
strcpy(dbop->prev, (char *)key.data);
}
dbop->lastkey = (char *)key.data;
dbop->lastdat = (char *)dat.data;
if (flags & DBOP_PREFIX) {
if (strncmp((char *)key.data, dbop->key, dbop->keylen))
return NULL;
} else if (dbop->keylen) {
if (strcmp((char *)key.data, dbop->key))
return NULL;
}
return (flags & DBOP_KEY) ? (char *)key.data : (char *)dat.data;
}
if (status == RET_ERROR)
die("dbop_next failed.");
return NULL;
}
/*
* dbop_close: close db
*
* i) dbop dbop descripter
*/
void
dbop_close(dbop)
DBOP *dbop;
{
DB *db = dbop->db;
(void)db->close(db);
if (dbop->openflags & DBOP_REMOVE)
(void)unlink(dbop->dbname);
else if (dbop->perm && chmod(dbop->dbname, dbop->perm) < 0)
die("cannot change file mode.");
(void)free(dbop);
}

88
contrib/global/lib/dbop.h Normal file
View File

@ -0,0 +1,88 @@
/*
* Copyright (c) 1996, 1997, 1998 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.
*
* dbop.h 12-Nov-98
*
*/
#ifndef _DBOP_H_
#define _DBOP_H_
#include <sys/param.h>
#include <db.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 dbop_open() */
int ioflags; /* flags of dbop_first() */
int perm; /* file permission */
} DBOP;
/*
* openflags
*/
#define DBOP_DUP 1 /* allow duplicate records */
#define DBOP_REMOVE 2 /* remove file when closed */
/*
* ioflags
*/
#define DBOP_KEY 1 /* read key part */
#define DBOP_PREFIX 2 /* prefixed read */
#ifndef __P
#if defined(__STDC__)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
DBOP *dbop_open __P((const char *, int, int, int));
char *dbop_get __P((DBOP *, const char *));
void dbop_put __P((DBOP *, const char *, const char *));
void dbop_del __P((DBOP *, const char *));
char *dbop_first __P((DBOP *, const char *, int));
char *dbop_next __P((DBOP *));
void dbop_close __P((DBOP *));
#endif /* _DBOP_H_ */

View File

@ -0,0 +1,66 @@
/*
* 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
* 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.
*
* defined.c 12-Nov-98
*
*/
#include <stdlib.h>
#include "die.h"
#include "dbop.h"
#include "defined.h"
#include "makepath.h"
static DBOP *dbop = NULL;
/*
* Tag command that supports referenced tag must call this function
* to decide whether or not the tag is defined.
*/
int
defined(name)
const char *name;
{
if (dbop == NULL) {
const char *dbpath;
/*
* gtags(1) set GTAGSDBPATH to the path GTAGS exist.
*/
if (!(dbpath = getenv("GTAGSDBPATH")))
dbpath = ".";
dbop = dbop_open(makepath(dbpath, "GTAGS"), 0, 0, 0);
if (dbop == NULL)
die1("GTAGS not found. (%s)", makepath(dbpath, "GTAGS"));
}
if (dbop_get(dbop, name))
return 1;
return 0;
}

View File

@ -0,0 +1,48 @@
/*
* 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
* 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.
*
* defined.h 2-May-98
*
*/
#ifndef _DEFINED_H_
#define _DEFINED_H_
#ifndef __P
#if defined(__STDC__)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
int defined __P((const char *));
#endif /* ! _DEFINED_H_ */

View File

@ -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
@ -35,7 +35,7 @@
#define _DIE_H_
#include <stdio.h>
extern char *progname;
extern const char *progname;
#define die(a) fprintf(stderr, "%s: ", progname),\
fprintf(stderr, a),\
@ -46,4 +46,8 @@ extern char *progname;
fprintf(stderr, a, b),\
fputs("\n", stderr),\
exit(1)
#define die2(a,b,c) fprintf(stderr, "%s: ", progname),\
fprintf(stderr, a, b, c),\
fputs("\n", stderr),\
exit(1)
#endif /* ! _DIE_H_ */

View File

@ -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

View File

@ -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,27 +28,30 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* global.h 16-Oct-97
* global.h 2-May-98
*
*/
#ifndef _GLOBAL_H_
#define _GLOBAL_H_
#include "gparam.h"
#include "dbname.h"
#include "makepath.h"
#include "dbio.h"
#include "locatestring.h"
#include "mgets.h"
#include "conf.h"
#include "dbop.h"
#include "defined.h"
#include "die.h"
#include "find.h"
#include "getdbpath.h"
#include "strop.h"
#include "gtagsopen.h"
#include "lookup.h"
#include "gparam.h"
#include "gtagsop.h"
#include "locatestring.h"
#include "makepath.h"
#include "mgets.h"
#include "pathop.h"
#include "strbuf.h"
#include "strmake.h"
#include "tab.h"
#include "tag.h"
#include "test.h"
#include "token.h"
#include "usable.h"
#endif /* ! _GLOBAL_H_ */

View File

@ -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,15 +28,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* gparam.h 16-Oct-97
* gparam.h 16-Jul-98
*
*/
#ifndef _GPARAM_H_
#define _GPARAM_H_
#define MAXCOMLINE 1024 /* max length of filter */
#define IDENTLEN 512 /* max length of ident */
#define MAXENVLEN 1024 /* max length of env */
#define MAXBUFLEN 1024 /* max length of buffer */
#define MAXFILLEN 1024 /* max length of filter */
#define IDENTLEN 512 /* max length of ident */
#define MAXENVLEN 1024 /* max length of env */
#define MAXBUFLEN 1024 /* max length of buffer */
#define MAXPROPLEN 1024 /* max length of property */
#define MAXARGLEN 512 /* max length of argment */
#endif /* ! _GPARAM_H_ */

View File

@ -0,0 +1,644 @@
/*
* 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
* 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.
*
* gtagsop.c 12-Nov-98
*
*/
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dbop.h"
#include "die.h"
#include "gtagsop.h"
#include "locatestring.h"
#include "makepath.h"
#include "mgets.h"
#include "pathop.h"
#include "strbuf.h"
#include "strmake.h"
#include "tab.h"
static char *genrecord __P((GTOP *));
static int belongto __P((GTOP *, char *, char *));
static int support_version = 2; /* acceptable format version */
static const char *tagslist[] = {"GTAGS", "GRTAGS", "GSYMS"};
/*
* dbname: return db name
*
* i) db 0: GTAGS, 1: GRTAGS, 2: GSYMS
* r) dbname
*/
const char *
dbname(db)
int db;
{
assert(db >= 0 && db < GTAGLIM);
return tagslist[db];
}
/*
* makecommand: make command line to make global tag file
*
* i) comline skelton command line
* i) path path name
* o) sb command line
*/
void
makecommand(comline, path, sb)
char *comline;
char *path;
STRBUF *sb;
{
char *p;
if (!(p = strmake(comline, "%")))
die1("'%%s' is needed in tag command line. (%s)\n", comline);
strputs(sb, p);
strputs(sb, path);
if (!(p = locatestring(comline, "%s", MATCH_FIRST)))
die1("'%%s' is needed in tag command line. (%s)\n", comline);
strputs(sb, p+2);
}
/*
* formatcheck: check format of tag command's output
*
* i) line input
* i) flags flag
* r) 0: normal
* -1: tag name
* -2: line number
* -3: path
*
* [example of right format]
*
* $1 $2 $3 $4
* ----------------------------------------------------
* main 83 ./ctags.c main(argc, argv)
*/
int
formatcheck(line, flags)
char *line;
int flags;
{
char *p, *q;
/*
* $1 = tagname: allowed any char except sepalator.
*/
p = q = line;
while (*p && !isspace(*p))
p++;
while (*p && isspace(*p))
p++;
if (p == q)
return -1;
/*
* $2 = line number: must be digit.
*/
q = p;
while (*p && !isspace(*p))
if (!isdigit(*p))
return -2;
else
p++;
if (p == q)
return -2;
while (*p && isspace(*p))
p++;
/*
* $3 = path:
* standard format: must start with './'.
* compact format: must be digit.
*/
if (flags & GTAGS_PATHINDEX) {
while (*p && !isspace(*p))
if (!isdigit(*p))
return -3;
else
p++;
} else {
if (!(*p == '.' && *(p + 1) == '/' && *(p + 2)))
return -3;
}
return 0;
}
/*
* gtagsopen: open global tag.
*
* i) dbpath dbpath directory
* i) root root directory (needed when compact format)
* i) db GTAGS, GRTAGS, GSYMS
* i) mode GTAGS_READ: read only
* GTAGS_CREATE: create tag
* GTAGS_MODIFY: modify tag
* i) flags GTAGS_COMPACT
* GTAGS_PATHINDEX
* r) GTOP structure
*
* when error occurred, gtagopen doesn't return.
* GTAGS_PATHINDEX needs GTAGS_COMPACT.
*/
GTOP *
gtagsopen(dbpath, root, db, mode, flags)
char *dbpath;
char *root;
int db;
int mode;
int flags;
{
GTOP *gtop;
int dbmode = 0;
if ((gtop = (GTOP *)calloc(sizeof(GTOP), 1)) == NULL)
die("short of memory.");
gtop->db = db;
gtop->mode = mode;
switch (gtop->mode) {
case GTAGS_READ:
dbmode = 0;
break;
case GTAGS_CREATE:
dbmode = 1;
break;
case GTAGS_MODIFY:
dbmode = 2;
break;
default:
assert(0);
}
/*
* allow duplicate records.
*/
gtop->dbop = dbop_open(makepath(dbpath, dbname(db)), dbmode, 0644, DBOP_DUP);
if (gtop->dbop == NULL) {
if (dbmode == 1)
die1("cannot make %s.", dbname(db));
die1("%s not found.", dbname(db));
}
/*
* decide format version.
*/
gtop->format_version = 1;
gtop->format = GTAGS_STANDARD;
/*
* This is a special case. GSYMS had compact format even if
* format version 1.
*/
if (db == GSYMS)
gtop->format |= GTAGS_COMPACT;
if (gtop->mode == GTAGS_CREATE) {
if (flags & GTAGS_COMPACT) {
char buf[80];
gtop->format_version = 2;
sprintf(buf, "%s %d", VERSIONKEY, gtop->format_version);
dbop_put(gtop->dbop, VERSIONKEY, buf);
gtop->format |= GTAGS_COMPACT;
dbop_put(gtop->dbop, COMPACTKEY, COMPACTKEY);
if (flags & GTAGS_PATHINDEX) {
gtop->format |= GTAGS_PATHINDEX;
dbop_put(gtop->dbop, PATHINDEXKEY, PATHINDEXKEY);
}
}
} 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.
*/
char *p;
if ((p = dbop_get(gtop->dbop, VERSIONKEY)) != NULL) {
for (p += strlen(VERSIONKEY); *p && isspace(*p); p++)
;
gtop->format_version = atoi(p);
}
if (gtop->format_version > support_version)
die("GTAGS seems new format. Please install the latest GLOBAL.");
if (gtop->format_version > 1) {
if (dbop_get(gtop->dbop, COMPACTKEY) != NULL)
gtop->format |= GTAGS_COMPACT;
if (dbop_get(gtop->dbop, PATHINDEXKEY) != NULL)
gtop->format |= GTAGS_PATHINDEX;
}
}
if (gtop->format & GTAGS_PATHINDEX || gtop->mode != GTAGS_READ) {
if (pathopen(dbpath, dbmode) < 0) {
if (dbmode == 1)
die("cannot create GPATH.");
else
die("GPATH not found.");
}
}
/*
* Stuff for compact format.
*/
if (gtop->format & GTAGS_COMPACT) {
assert(root != NULL);
strcpy(gtop->root, root);
if (gtop->mode != GTAGS_READ)
gtop->sb = stropen();
}
return gtop;
}
/*
* gtagsput: put tag record with packing.
*
* i) gtop descripter of GTOP
* i) tag tag name
* i) record ctags -x image
*/
void
gtagsput(gtop, tag, record)
GTOP *gtop;
char *tag;
char *record;
{
char *p, *q;
char lno[10];
char path[MAXPATHLEN+1];
if (gtop->format == GTAGS_STANDARD) {
entab(record);
dbop_put(gtop->dbop, tag, record);
return;
}
/*
* gtop->format & GTAGS_COMPACT
*/
p = record; /* ignore $1 */
while (*p && !isspace(*p))
p++;
while (*p && isspace(*p))
p++;
q = lno; /* lno = $2 */
while (*p && !isspace(*p))
*q++ = *p++;
*q = 0;
while (*p && isspace(*p))
p++;
q = path; /* path = $3 */
while (*p && !isspace(*p))
*q++ = *p++;
*q = 0;
/*
* First time, it occurs, because 'prev_tag' and 'prev_path' are NULL.
*/
if (strcmp(gtop->prev_tag, tag) || strcmp(gtop->prev_path, path)) {
if (gtop->prev_tag[0])
dbop_put(gtop->dbop, gtop->prev_tag, strvalue(gtop->sb));
strcpy(gtop->prev_tag, tag);
strcpy(gtop->prev_path, path);
/*
* Start creating new record.
*/
strstart(gtop->sb);
strputs(gtop->sb, strmake(record, " \t"));
strputc(gtop->sb, ' ');
strputs(gtop->sb, path);
strputc(gtop->sb, ' ');
strputs(gtop->sb, lno);
} else {
strputc(gtop->sb, ',');
strputs(gtop->sb, lno);
}
}
/*
* gtagsadd: add tags belonging to the path into tag file.
*
* i) gtop descripter of GTOP
* i) comline tag command line
* i) path source file
* i) flags GTAGS_UNIQUE, GTAGS_EXTRACTMETHOD
*/
void
gtagsadd(gtop, comline, path, flags)
GTOP *gtop;
char *comline;
char *path;
int flags;
{
char *tagline;
FILE *ip;
STRBUF *sb = stropen();
/*
* add path index if not yet.
*/
pathput(path);
/*
* make command line.
*/
makecommand(comline, path, sb);
/*
* Compact format.
*/
if (gtop->format & GTAGS_PATHINDEX) {
char *pno;
if ((pno = pathget(path)) == NULL)
die1("GPATH is corrupted.('%s' not found)", path);
strputs(sb, "| sed 's!");
strputs(sb, path);
strputs(sb, "!");
strputs(sb, pno);
strputs(sb, "!'");
}
if (gtop->format & GTAGS_COMPACT)
strputs(sb, "| sort +0 -1 +1n -2");
if (flags & GTAGS_UNIQUE)
strputs(sb, "| uniq");
if (!(ip = popen(strvalue(sb), "r")))
die1("cannot execute '%s'.", strvalue(sb));
while ((tagline = mgets(ip, NULL, MGETS_TAILCUT)) != NULL) {
char *tag, *p;
if (formatcheck(tagline, gtop->format) < 0)
die1("illegal parser output.\n'%s'", tagline);
tag = strmake(tagline, " \t"); /* tag = $1 */
/*
* extract method when class method definition.
*
* Ex: Class::method(...)
*
* key = 'method'
* data = 'Class::method 103 ./class.cpp ...'
*/
if (flags & GTAGS_EXTRACTMETHOD) {
if ((p = locatestring(tag, ".", MATCH_LAST)) != NULL)
tag = p + 1;
else if ((p = locatestring(tag, "::", MATCH_LAST)) != NULL)
tag = p + 2;
}
gtagsput(gtop, tag, tagline);
}
pclose(ip);
strclose(sb);
}
/*
* belongto: wheather or not record belongs to the path.
*
* i) gtop GTOP structure
* i) path path name (in standard format)
* path number (in compact format)
* i) p record
* r) 1: belong, 0: not belong
*/
static int
belongto(gtop, path, p)
GTOP *gtop;
char *path;
char *p;
{
char *q;
int length = strlen(path);
/*
* seek to path part.
*/
if (gtop->format & GTAGS_PATHINDEX) {
for (q = p; *q && !isspace(*q); q++)
;
if (*q == 0)
die1("illegal tag format. '%s'", p);
for (; *q && isspace(*q); q++)
;
} else
q = locatestring(p, "./", MATCH_FIRST);
if (*q == 0)
die1("illegal tag format. '%s'", p);
if (!strncmp(q, path, length) && isspace(*(q + length)))
return 1;
return 0;
}
/*
* gtagsdelete: delete records belong to path.
*
* i) gtop GTOP structure
* i) path path name
*/
void
gtagsdelete(gtop, path)
GTOP *gtop;
char *path;
{
char *p, *key;
int length;
/*
* In compact format, a path is saved as a file number.
*/
key = path;
if (gtop->format & GTAGS_PATHINDEX)
if ((key = pathget(path)) == NULL)
die1("GPATH is corrupted.('%s' not found)", path);
length = strlen(key);
/*
* read sequentially, because db(1) has just one index.
*/
for (p = dbop_first(gtop->dbop, NULL, 0); p; p = dbop_next(gtop->dbop))
if (belongto(gtop, key, p))
dbop_del(gtop->dbop, NULL);
/*
* don't delete from path index.
*/
}
/*
* gtagsfirst: return first record
*
* i) gtop GTOP structure
* i) tag tag name
* i) flags GTOP_PREFIX prefix read
* GTOP_KEY read key only
* r) record
*/
char *
gtagsfirst(gtop, tag, flags)
GTOP *gtop;
char *tag;
int flags;
{
int dbflags = 0;
char *line;
gtop->flags = flags;
if (flags & GTOP_PREFIX && tag != NULL)
dbflags |= DBOP_PREFIX;
if (flags & GTOP_KEY)
dbflags |= DBOP_KEY;
if ((line = dbop_first(gtop->dbop, tag, dbflags)) == NULL)
return NULL;
if (gtop->format == GTAGS_STANDARD || gtop->flags & GTOP_KEY)
return line;
/*
* Compact format.
*/
gtop->line = line; /* gtop->line = $0 */
gtop->opened = 0;
return genrecord(gtop);
}
/*
* gtagsnext: return followed record
*
* i) gtop GTOP structure
* r) record
* NULL end of tag
*/
char *
gtagsnext(gtop)
GTOP *gtop;
{
char *line;
/*
* If it is standard format or only key.
* Just return it.
*/
if (gtop->format == GTAGS_STANDARD || gtop->flags & GTOP_KEY)
return dbop_next(gtop->dbop);
/*
* gtop->format & GTAGS_COMPACT
*/
if ((line = genrecord(gtop)) != NULL)
return line;
/*
* read next record.
*/
if ((line = dbop_next(gtop->dbop)) == NULL)
return line;
gtop->line = line; /* gtop->line = $0 */
gtop->opened = 0;
return genrecord(gtop);
}
/*
* gtagsclose: close tag file
*
* i) gtop GTOP structure
*/
void
gtagsclose(gtop)
GTOP *gtop;
{
if (gtop->format & GTAGS_PATHINDEX || gtop->mode != GTAGS_READ)
pathclose();
if (gtop->sb && gtop->prev_tag[0])
dbop_put(gtop->dbop, gtop->prev_tag, strvalue(gtop->sb));
if (gtop->sb)
strclose(gtop->sb);
dbop_close(gtop->dbop);
free(gtop);
}
static char *
genrecord(gtop)
GTOP *gtop;
{
static char output[MAXBUFLEN+1];
char path[MAXPATHLEN+1];
static char buf[1];
char *buffer = buf;
char *lnop;
int tagline;
if (!gtop->opened) {
char *p, *q;
gtop->opened = 1;
p = gtop->line;
q = gtop->tag; /* gtop->tag = $1 */
while (!isspace(*p))
*q++ = *p++;
*q = 0;
for (; isspace(*p) ; p++)
;
if (gtop->format & GTAGS_PATHINDEX) { /* gtop->path = $2 */
char *name;
q = path;
while (!isspace(*p))
*q++ = *p++;
*q = 0;
if ((name = pathget(path)) == NULL)
die1("GPATH is corrupted.('%s' not found)", path);
strcpy(gtop->path, name);
} else {
q = gtop->path;
while (!isspace(*p))
*q++ = *p++;
*q = 0;
}
for (; isspace(*p) ; p++)
;
gtop->lnop = p; /* gtop->lnop = $3 */
if (gtop->root)
sprintf(path, "%s/%s", gtop->root, &gtop->path[2]);
else
sprintf(path, "%s", &gtop->path[2]);
if ((gtop->fp = fopen(path, "r")) != NULL) {
buffer = mgets(gtop->fp, NULL, MGETS_TAILCUT);
gtop->lno = 1;
}
}
lnop = gtop->lnop;
if (*lnop >= '0' && *lnop <= '9') {
/* get line number */
for (tagline = 0; *lnop >= '0' && *lnop <= '9'; lnop++)
tagline = tagline * 10 + *lnop - '0';
if (*lnop == ',')
lnop++;
gtop->lnop = lnop;
if (gtop->fp) {
if (gtop->lno == tagline)
return output;
while (gtop->lno < tagline) {
if (!(buffer = mgets(gtop->fp, NULL, MGETS_TAILCUT)))
die1("unexpected end of file. '%s'", path);
gtop->lno++;
}
}
if (strlen(gtop->tag) >= 16 && tagline >= 1000)
sprintf(output, "%-16s %4d %-16s %s",
gtop->tag, tagline, gtop->path, buffer);
else
sprintf(output, "%-16s%4d %-16s %s",
gtop->tag, tagline, gtop->path, buffer);
return output;
}
if (gtop->opened && gtop->fp != NULL) {
gtop->opened = 0;
fclose(gtop->fp);
}
return NULL;
}

View File

@ -0,0 +1,109 @@
/*
* 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
* 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.
*
* gtagsop.h 23-Dec-97
*
*/
#ifndef _GTOP_H_
#define _GTOP_H_
#include <stdio.h>
#include "dbop.h"
#include "gparam.h"
#include "strbuf.h"
#define VERSIONKEY " __.VERSION"
#define COMPACTKEY " __.COMPACT"
#define PATHINDEXKEY " __.PATHINDEX"
#define GTAGS 0
#define GRTAGS 1
#define GSYMS 2
#define GTAGLIM 3
#define GTAGS_READ 0
#define GTAGS_CREATE 1
#define GTAGS_MODIFY 2
/* gtagsopen() */
#define GTAGS_STANDARD 0 /* standard format */
#define GTAGS_COMPACT 1 /* compact format */
#define GTAGS_PATHINDEX 2 /* use path index */
/* gtagsadd() */
#define GTAGS_UNIQUE 1 /* compress duplicate lines */
#define GTAGS_EXTRACTMETHOD 2 /* extract method from class definition */
/* gtagsfirst() */
#define GTOP_KEY 1 /* read key part */
#define GTOP_PREFIX 2 /* prefixed read */
typedef struct {
DBOP *dbop; /* descripter of DBOP */
int format_version; /* format version */
int format; /* GTAGS_STANDARD, GTAGS_COMPACT */
int mode; /* mode */
int db; /* 0:GTAGS, 1:GRTAGS, 2:GSYMS */
int flags; /* flags */
char root[MAXPATHLEN+1]; /* root directory of source tree */
/*
* Stuff for compact format
*/
int opened; /* wether or not file opened */
char *line; /* current record */
char tag[IDENTLEN+1]; /* current tag */
char prev_tag[IDENTLEN+1]; /* previous tag */
char path[MAXPATHLEN+1]; /* current path */
char prev_path[MAXPATHLEN+1];/* previous path */
STRBUF *sb; /* string buffer */
FILE *fp; /* descriptor of 'path' */
char *lnop; /* current line number */
int lno; /* integer value of 'lnop' */
} GTOP;
#ifndef __P
#if defined(__STDC__)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
const char *dbname __P((int));
void makecommand __P((char *, char *, STRBUF *));
int formatcheck __P((char *, int));
GTOP *gtagsopen __P((char *, char *, int, int, int));
void gtagsput __P((GTOP *, char *, char *));
char *gtagsget __P((GTOP *, char *));
void gtagsadd __P((GTOP *, char *, char *, int));
void gtagsdelete __P((GTOP *, char *));
char *gtagsfirst __P((GTOP *, char *, int));
char *gtagsnext __P((GTOP *));
void gtagsclose __P((GTOP *));
#endif /* ! _GTOP_H_ */

View File

@ -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,13 +28,18 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* locatestring.h 16-Oct-97
* locatestring.h 25-Jul-98
*
*/
#ifndef _LOCATESTRING_H_
#define _LOCATESTRING_H_
#define MATCH_FIRST 0
#define MATCH_AT_FIRST 1
#define MATCH_LAST 2
#define MATCH_AT_LAST 3
#ifndef __P
#if defined(__STDC__)
#define __P(protos) protos
@ -43,6 +48,6 @@
#endif
#endif
char *locatestring __P((char *, char *, int));
char *locatestring __P((const char *, const char *, int));
#endif /* ! _LOCATESTRING_H_ */

View File

@ -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
@ -43,6 +43,6 @@
#endif
#endif
char *makepath __P((char *, char *));
char *makepath __P((const char *, const char *));
#endif /* ! _MAKEPATH_H_ */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
* Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
*
* Redilogibution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -37,6 +37,7 @@
#include <stdio.h>
#define MGETS_CONT 1
#define MGETS_SKIPCOM 2
#define MGETS_TAILCUT 4
#ifndef __P
#if defined(__STDC__)
@ -46,6 +47,6 @@
#endif
#endif
char *mgets __P((FILE *, int, int *));
char *mgets __P((FILE *, int *, int));
#endif /* ! _MGETS_H_ */

155
contrib/global/lib/pathop.c Normal file
View File

@ -0,0 +1,155 @@
/*
* 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
* 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.
*
* pathop.c 12-Nov-98
*
*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "die.h"
#include "dbop.h"
#include "makepath.h"
#include "pathop.h"
static DBOP *dbop;
static const char *gpath = "GPATH";
static int _nextkey;
static int _mode;
static int opened;
static int created;
/*
* pathopen: open path dictionary tag.
*
* i) mode 0: read only
* 1: create
* 2: modify
* r) 0: normal
* -1: error
*/
int
pathopen(dbpath, mode)
char *dbpath;
int mode;
{
char *p;
assert(opened == 0);
/*
* We create GPATH just first time.
*/
_mode = mode;
if (mode == 1 && created)
mode = 0;
dbop = dbop_open(makepath(dbpath, gpath), mode, 0644, 0);
if (dbop == NULL)
return -1;
if (mode == 1)
_nextkey = 0;
else {
if (!(p = dbop_get(dbop, NEXTKEY)))
die("nextkey not found in GPATH.");
_nextkey = atoi(p);
}
opened = 1;
return 0;
}
void
pathput(path)
char *path;
{
char buf[10];
assert(opened == 1);
if (_mode == 1 && created)
return;
if (dbop_get(dbop, path) != NULL)
return;
sprintf(buf, "%d", _nextkey++);
dbop_put(dbop, path, buf);
dbop_put(dbop, buf, path);
}
char *
pathget(key)
char *key;
{
assert(opened == 1);
return dbop_get(dbop, key);
}
char *
pathiget(n)
int n;
{
char key[80];
assert(opened == 1);
sprintf(key, "%d", n);
return dbop_get(dbop, key);
}
void
pathdel(key)
char *key;
{
char *d;
assert(opened == 1);
assert(_mode == 2);
assert(key[0] == '.' && key[1] == '/');
d = dbop_get(dbop, key);
if (d == NULL)
return;
dbop_del(dbop, d);
dbop_del(dbop, key);
}
int
nextkey(void)
{
assert(_mode != 1);
return _nextkey;
}
void
pathclose(void)
{
char buf[10];
assert(opened == 1);
opened = 0;
if (_mode == 1 && created) {
dbop_close(dbop);
return;
}
sprintf(buf, "%d", _nextkey);
if (_mode == 1 || _mode == 2)
dbop_put(dbop, NEXTKEY, buf);
dbop_close(dbop);
if (_mode == 1)
created = 1;
}

View File

@ -0,0 +1,59 @@
/*
* 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
* 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.
*
* pathop.h 14-May-98
*
*/
#ifndef _PATHOP_H_
#define _PATHOP_H_
#include <stdio.h>
#include "dbop.h"
#include "gparam.h"
#define NEXTKEY " __.NEXTKEY"
#ifndef __P
#if defined(__STDC__)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
int pathopen __P((char *, int));
char *pathget __P((char *));
char *pathiget __P((int));
void pathput __P((char *));
void pathdel __P((char *));
void pathclose __P((void));
int nextkey __P((void));
#endif /* ! _PATHOP_H_ */

137
contrib/global/lib/strbuf.c Normal file
View File

@ -0,0 +1,137 @@
/*
* 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
* 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.
*
* strbuf.c 5-Jul-98
*
*/
#include <stdlib.h>
#include <string.h>
#include "die.h"
#include "strbuf.h"
/*
* usage: string buffer
*
* sb = stropen();
* for (s = string; *s; s++)
* strputc(sb, *s);
* s = strvalue(sb);
* strstart(sb);
* strputs(sb, "hello");
* s = strvalue(sb);
* strclose(sb);
*/
/*
* expandbuf: expand buffer so that afford to the length data at least.
*
* i) sb STRBUF structure
* i) length required room
*/
void
expandbuf(sb, length)
STRBUF *sb;
int length;
{
int count = sb->curp - sb->sbuf;
sb->sbufsize += (length > EXPANDSIZE) ? length : EXPANDSIZE;
if (!(sb->sbuf = (char *)realloc(sb->sbuf, sb->sbufsize + 1)))
die("short of memory.");
sb->curp = sb->sbuf + count;
sb->endp = sb->sbuf + sb->sbufsize;
}
/*
* stropen: open string buffer.
*
* r) sb STRBUF structure
*/
STRBUF *
stropen(void)
{
STRBUF *sb = (STRBUF *)calloc(sizeof(STRBUF), 1);
if (sb == NULL)
die("short of memory.");
sb->sbufsize = INITIALSIZE;
if (!(sb->sbuf = (char *)malloc(sb->sbufsize + 1)))
die("short of memory.");
sb->curp = sb->sbuf;
sb->endp = sb->sbuf + sb->sbufsize;
return sb;
}
/*
* strstart: reset string buffer for new string.
*
* i) sb STRBUF structure
*/
void
strstart(sb)
STRBUF *sb;
{
sb->curp = sb->sbuf;
}
/*
* strbuflen: return the length of string buffer.
*
* i) sb STRBUF structure
*/
int
strbuflen(sb)
STRBUF *sb;
{
return sb->curp - sb->sbuf;
}
/*
* strvalue: return the content of string buffer.
*
* i) sb STRBUF structure
* r) string
*/
char *
strvalue(sb)
STRBUF *sb;
{
*sb->curp = 0;
return sb->sbuf;
}
/*
* strclose: close string buffer.
*
* i) sb STRBUF structure
*/
void
strclose(sb)
STRBUF *sb;
{
(void)free(sb->sbuf);
(void)free(sb);
}

View File

@ -0,0 +1,82 @@
/*
* 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
* 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.
*
* strbuf.h 5-Jul-98
*
*/
#ifndef _STRBUF_H
#define _STRBUF_H
#include <string.h>
#define INITIALSIZE 80
#define EXPANDSIZE 80
typedef struct {
char *sbuf;
char *endp;
char *curp;
int sbufsize;
} STRBUF;
#define strputc(sb,c) do {\
if (sb->curp + 1 > sb->endp)\
expandbuf(sb, 0);\
*sb->curp++ = c;\
} while (0)
#define strunputc(sb,c) do {\
if (sb->curp > sb->sbuf && *(sb->curp - 1) == c)\
sb->curp--;\
} while (0)
#define strnputs(sb, s, len) do {\
unsigned int _length = len;\
if (sb->curp + _length > sb->endp)\
expandbuf(sb, _length);\
strncpy(sb->curp, s, _length);\
sb->curp += _length;\
} while (0)
#define strputs(sb, s) strnputs(sb, s, strlen(s))
#ifndef __P
#if defined(__STDC__)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
void expandbuf __P((STRBUF *, int));
STRBUF *stropen __P((void));
void strstart __P((STRBUF *));
int strbuflen __P((STRBUF *));
char *strvalue __P((STRBUF *));
void strclose __P((STRBUF *));
#endif /* ! _STRBUF_H */

View File

@ -0,0 +1,59 @@
/*
* 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
* 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.
*
* strmake.c 15-May-98
*
*/
#include <stdlib.h>
#include "strbuf.h"
#include "strmake.h"
static STRBUF *sb;
char *
strmake(p, lim)
const char *p;
const char *lim;
{
const char *c;
if (sb == NULL)
sb = stropen();
strstart(sb);
for (; *p; p++) {
for (c = lim; *c; c++)
if (*p == *c)
goto end;
strputc(sb,*p);
}
end:
return strvalue(sb);
}

View File

@ -0,0 +1,48 @@
/*
* 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
* 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.
*
* strmake.h 17-Apr-98
*
*/
#ifndef _STRMAKE_H_
#define _STRMAKE_H_
#ifndef __P
#if defined(__STDC__)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
char *strmake __P((const char *, const char *));
#endif /* ! _STRMAKE_H_ */

View File

@ -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.
*
* tab.h 16-Oct-97
* tab.h 8-Oct-98
*
*/
@ -43,6 +43,7 @@
#endif
#endif
void settabs __P((int));
void detab __P((FILE *, char *));
void entab __P((char *));

View File

@ -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
@ -43,6 +43,6 @@
#endif
#endif
int test __P((char *, char *));
int test __P((const char *, const char *));
#endif /* ! _TEST_H_ */

293
contrib/global/lib/token.c Normal file
View File

@ -0,0 +1,293 @@
/*
* Copyright (c) 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
* 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 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.
*
* token.c 14-Aug-98
*/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#include "mgets.h"
#include "token.h"
/*
* File input method.
*/
int lineno;
char *sp, *cp, *lp;
int crflag; /* 1: return '\n', 0: doesn't return */
int cmode; /* allow token which start with '#' */
int ymode; /* allow token which start with '%' */
char token[MAXTOKEN];
char curfile[MAXPATHLEN];
static char ptok[MAXTOKEN];
static int lasttok;
static FILE *ip;
static void pushbackchar __P((void));
/*
* opentoken:
*/
int
opentoken(file)
char *file;
{
if ((ip = fopen(file, "r")) == NULL)
return 0;
strcpy(curfile, file);
sp = cp = lp = NULL; lineno = 0;
return 1;
}
/*
* closetoken:
*/
void
closetoken()
{
fclose(ip);
}
/*
* nexttoken: get next token
*
* i) interested interested special charactor
* if NULL then all charactor.
* i) reserved converter from token to token number
* if this is specified, nexttoken() return
* word number, else return symbol.
* r) EOF(-1) end of file
* ==0 symbol ('tok' has the value.)
* > 255 reserved word
* <=255 interested special charactor
*
* nexttoken() doesn't return followings.
*
* o comment
* o space (' ', '\t', '\f')
* o quoted string ("...", '.')
*/
int
nexttoken(interested, reserved)
const char *interested;
int (*reserved)(char *);
{
int c;
char *p;
int sharp = 0;
int percent = 0;
/* check push back buffer */
if (ptok[0]) {
strcpy(token, ptok);
ptok[0] = 0;
return lasttok;
}
for (;;) {
/* skip spaces */
if (!crflag)
while ((c = nextchar()) != EOF && isspace(c))
;
else
while ((c = nextchar()) != EOF && (c == ' ' || c == '\t' || c == '\f'))
;
if (c == EOF || c == '\n')
break;
if (c == '"' || c == '\'') { /* quoted string */
int quote = c;
while ((c = nextchar()) != EOF) {
if (c == quote)
break;
if (quote == '\'' && c == '\n')
break;
if (c == '\\' && (c = nextchar()) == EOF)
break;
}
} else if (c == '/') { /* comment */
if ((c = nextchar()) == '/') {
while ((c = nextchar()) != EOF)
if (c == '\n')
break;
} else if (c == '*') {
while ((c = nextchar()) != EOF) {
if (c == '*') {
if ((c = nextchar()) == '/')
break;
pushbackchar();
}
}
} else
pushbackchar();
} else if (c == '\\') {
(void)nextchar();
} else if (isdigit(c)) { /* digit */
while ((c = nextchar()) != EOF && (c == '.' || isdigit(c) || isalpha(c)))
;
pushbackchar();
} else if (c == '#' && cmode) {
/* recognize '##' as a token if it is reserved word. */
if (peekc(1) == '#') {
p = token;
*p++ = c;
*p++ = nextchar();
*p = 0;
if (reserved && (c = (*reserved)(token)) == 0)
break;
} else if (atfirst_exceptspace()) {
sharp = 1;
continue;
}
} else if (c == '%' && ymode) {
/* recognize '%%' as a token if it is reserved word. */
if (atfirst) {
p = token;
*p++ = c;
if ((c = peekc(1)) == '%' || c == '{' || c == '}') {
*p++ = nextchar();
*p = 0;
if (reserved && (c = (*reserved)(token)) != 0)
break;
} else if (!isspace(c)) {
percent = 1;
continue;
}
}
} else if (c & 0x80 || isalpha(c) || c == '_') {/* symbol */
p = token;
if (sharp) {
sharp = 0;
*p++ = '#';
} else if (percent) {
percent = 0;
*p++ = '%';
}
for (*p++ = c; (c = nextchar()) != EOF && (c & 0x80 || isalnum(c) || c == '_'); *p++ = c)
;
*p = 0;
if (c != EOF)
pushbackchar();
/* convert token string into token number */
if (reserved)
c = (*reserved)(token);
break;
} else { /* special char */
if (interested == NULL || strchr(interested, c))
break;
/* otherwise ignore it */
}
sharp = percent = 0;
}
return lasttok = c;
}
/*
* pushbacktoken: push back token
*
* following nexttoken() return same token again.
*/
void
pushbacktoken()
{
strcpy(ptok, token);
}
/*
* peekc: peek next char
*
* i) immediate 0: ignore blank, 1: include blank
*
* Peekc() read ahead following blanks but doesn't chage line.
*/
int
peekc(immediate)
int immediate;
{
int c;
long pos;
if (cp != NULL) {
if (immediate)
c = nextchar();
else
while ((c = nextchar()) != EOF && c != '\n' && isspace(c))
;
if (c != EOF)
pushbackchar();
if (c != '\n' || immediate)
return c;
}
pos = ftell(ip);
if (immediate)
c = getc(ip);
else
while ((c = getc(ip)) != EOF && isspace(c))
;
(void)fseek(ip, pos, SEEK_SET);
return c;
}
/*
* atfirst_exceptspace: return if current position is the first column
* except for space.
* | 1 0
* | v v
* | # define
*/
int
atfirst_exceptspace()
{
char *start = sp;
char *end = cp ? cp - 1 : lp;
while (start < end && *start && isspace(*start))
start++;
return (start == end) ? 1 : 0;
}
/*
* pushbackchar: push back charactor.
*
* following nextchar() return same charactor again.
*
*/
static void
pushbackchar()
{
if (sp == NULL)
return; /* nothing to do */
if (cp == NULL)
cp = lp;
else
--cp;
}

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 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
* 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 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.
*
* token.h 14-Aug-98
*/
#ifndef _TOKEN_H_
#define _TOKEN_H_
#include <sys/param.h>
#include "mgets.h"
#define MAXTOKEN 512
#define SYMBOL 0
extern char *sp, *cp, *lp;
extern int lineno;
extern int crflag;
extern int cmode;
extern int ymode;
extern char token[MAXTOKEN];
extern char curfile[MAXPATHLEN];
#define nextchar() \
(cp == NULL ? \
((sp = cp = mgets(ip, NULL, 0)) == NULL ? \
EOF : \
(lineno++, *cp == 0 ? \
lp = cp, cp = NULL, '\n' : \
*cp++)) : \
(*cp == 0 ? (lp = cp, cp = NULL, '\n') : *cp++))
#define atfirst (sp && sp == (cp ? cp - 1 : lp))
#ifndef __P
#if defined(__STDC__)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
int opentoken __P((char *));
void closetoken __P((void));
int nexttoken __P((const char *, int (*)(char *)));
void pushbacktoken __P((void));
int peekc __P((int));
int atfirst_exceptspace __P((void));
#endif /* ! _TOKEN_H_ */

View File

@ -0,0 +1,70 @@
/*
* 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
* 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.
*
* usable.c 22-Jun-98
*
*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "locatestring.h"
#include "gparam.h"
#include "makepath.h"
#include "test.h"
#include "usable.h"
/*
* usable: check executable or not about the command.
*
* i) command
* r) 1: executable
* 0: non executable
*/
int
usable(command)
char *command;
{
char buf[MAXENVLEN+1], *p, *dir;
if (*command == '/' || locatestring(command, "./", MATCH_AT_FIRST) || locatestring(command, "../", MATCH_AT_FIRST))
return test("fx", command);
strcpy(buf, getenv("PATH"));
p = buf;
while (p) {
dir = p;
if ((p = locatestring(p, ":", MATCH_FIRST)) != NULL)
*p++ = 0;
if (test("fx", makepath(dir, command)))
return 1;
}
return 0;
}

View File

@ -0,0 +1,48 @@
/*
* 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
* 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.
*
* usable.h 22-Jul-98
*
*/
#ifndef _USABLE_H_
#define _USABLE_H_
#ifndef __P
#if defined(__STDC__)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
int usable __P((char *));
#endif /* ! _USABLE_H_ */

View File

@ -0,0 +1,673 @@
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/build/Makefile ./build/Makefile
*** /usr/src/usr.bin/nvi-1.66.org/build/Makefile Tue May 5 15:57:21 1998
--- ./build/Makefile Sun Aug 16 03:22:53 1998
***************
*** 3,9 ****
# from: @(#)Makefile.in 8.56 (Berkeley) 5/18/96
WARNS= 0
! CPPFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include
LDADD+= -lcurses -ltermcap
DPADD+= ${LIBCURSES} ${LIBTERMCAP}
--- 3,9 ----
# from: @(#)Makefile.in 8.56 (Berkeley) 5/18/96
WARNS= 0
! CPPFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include -DGTAGS
LDADD+= -lcurses -ltermcap
DPADD+= ${LIBCURSES} ${LIBTERMCAP}
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/common/main.c ./common/main.c
*** /usr/src/usr.bin/nvi-1.66.org/common/main.c Tue May 5 15:57:26 1998
--- ./common/main.c Sun Aug 16 03:27:19 1998
***************
*** 63,68 ****
--- 63,71 ----
size_t len;
u_int flags;
int ch, fd, flagchk, lflag, startup, readonly, rval, silent;
+ #ifdef GTAGS
+ int gtags = 0;
+ #endif
char *tag_f, *wsizearg;
char path[256];
***************
*** 113,123 ****
--- 116,135 ----
/* Set the file snapshot flag. */
F_SET(gp, G_SNAPSHOT);
+ #ifdef GTAGS
+ #ifdef DEBUG
+ while ((ch = getopt(argc, argv, "c:D:eFGlRrsT:t:vw:")) != EOF)
+ #else
+ while ((ch = getopt(argc, argv, "c:eFGlRrst:vw:")) != EOF)
+ #endif
+ #else
#ifdef DEBUG
while ((ch = getopt(argc, argv, "c:D:eFlRrsT:t:vw:")) != EOF)
#else
while ((ch = getopt(argc, argv, "c:eFlRrst:vw:")) != EOF)
#endif
+ #endif
+
switch (ch) {
case 'c': /* Run the command. */
/*
***************
*** 167,172 ****
--- 179,189 ----
case 'F': /* No snapshot. */
F_CLR(gp, G_SNAPSHOT);
break;
+ #ifdef GTAGS
+ case 'G': /* gtags mode. */
+ gtags = 1;
+ break;
+ #endif
case 'l': /* Set lisp, showmatch options. */
lflag = 1;
break;
***************
*** 258,263 ****
--- 275,284 ----
{ int oargs[4], *oargp = oargs;
if (readonly) /* Command-line options. */
*oargp++ = O_READONLY;
+ #ifdef GTAGS
+ if (gtags)
+ *oargp++ = O_GTAGSMODE;
+ #endif
if (lflag) {
*oargp++ = O_LISP;
*oargp++ = O_SHOWMATCH;
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/common/options.c ./common/options.c
*** /usr/src/usr.bin/nvi-1.66.org/common/options.c Tue May 5 15:57:26 1998
--- ./common/options.c Sun Aug 16 03:29:51 1998
***************
*** 80,85 ****
--- 80,89 ----
{"filec", NULL, OPT_STR, 0},
/* O_FLASH HPUX */
{"flash", NULL, OPT_1BOOL, 0},
+ #ifdef GTAGS
+ /* O_GTAGSMODE FreeBSD, NetBSD */
+ {"gtagsmode", NULL, OPT_0BOOL, 0},
+ #endif
/* O_HARDTABS 4BSD */
{"hardtabs", NULL, OPT_NUM, 0},
/* O_ICLOWER 4.4BSD */
***************
*** 240,245 ****
--- 244,252 ----
{"eb", O_ERRORBELLS}, /* 4BSD */
{"ed", O_EDCOMPATIBLE}, /* 4BSD */
{"ex", O_EXRC}, /* System V (undocumented) */
+ #ifdef GTAGS
+ {"gt", O_GTAGSMODE}, /* FreeBSD, NetBSD */
+ #endif
{"ht", O_HARDTABS}, /* 4BSD */
{"ic", O_IGNORECASE}, /* 4BSD */
{"li", O_LINES}, /* 4.4BSD */
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/docs/USD.doc/vi.man/vi.1 ./docs/USD.doc/vi.man/vi.1
*** /usr/src/usr.bin/nvi-1.66.org/docs/USD.doc/vi.man/vi.1 Tue May 5 15:57:31 1998
--- ./docs/USD.doc/vi.man/vi.1 Sun Aug 16 03:34:12 1998
***************
*** 40,46 ****
.SH SYNOPSIS
.B ex
[\c
! .B -eFRrsv\c
] [\c
.BI -c " cmd"\c
] [\c
--- 40,46 ----
.SH SYNOPSIS
.B ex
[\c
! .B -eFGRrsv\c
] [\c
.BI -c " cmd"\c
] [\c
***************
*** 51,57 ****
.br
.B vi
[\c
! .B -eFlRrv\c
] [\c
.BI -c " cmd"\c
] [\c
--- 51,57 ----
.br
.B vi
[\c
! .B -eFGlRrv\c
] [\c
.BI -c " cmd"\c
] [\c
***************
*** 62,68 ****
.br
.B view
[\c
! .B -eFRrv\c
] [\c
.BI -c " cmd"\c
] [\c
--- 62,68 ----
.br
.B view
[\c
! .B -eFGRrv\c
] [\c
.BI -c " cmd"\c
] [\c
***************
*** 135,140 ****
--- 135,143 ----
(The default is to make a copy in case someone else modifies
the file during your edit session.)
.TP
+ .B \-G
+ Start editing in gtags mode, as if the gtagsmode option was set.
+ .TP
.B \-l
Start editing with the lisp and showmatch options set.
.TP
***************
*** 441,446 ****
--- 444,451 ----
.TP
.B "<control-]>"
Push a tag reference onto the tag stack.
+ In gtagsmode, if at the first column of line,
+ locate function references otherwise function definitions.
.TP
.B "<control-^>"
Switch to the most recently edited file.
***************
*** 952,957 ****
--- 957,965 ----
.B "rew[ind][!]"
Rewind the argument list.
.TP
+ .B "rta[g][!] tagstring"
+ Edit the file refering the specified tag. (Only in gtagsmode)
+ .TP
.B "se[t] [option[=[value]] ...] [nooption ...] [option? ...] [all]"
Display or set editor options.
.TP
***************
*** 1121,1126 ****
--- 1129,1137 ----
.TP
.B "flash [on]"
Flash the screen instead of beeping the keyboard on error.
+ .TP
+ .B "gtagsmode, gt [off]"
+ Use GTAGS and GRTAGS instead of tags.
.TP
.B "hardtabs, ht [8]"
Set the spacing between hardware tab settings.
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/ex/ex.h ./ex/ex.h
*** /usr/src/usr.bin/nvi-1.66.org/ex/ex.h Tue May 5 15:57:37 1998
--- ./ex/ex.h Sun Aug 16 03:35:58 1998
***************
*** 162,167 ****
--- 162,170 ----
#define E_NEWLINE 0x00800000 /* Found ending <newline>. */
#define E_USELASTCMD 0x01000000 /* Use the last command. */
#define E_VISEARCH 0x02000000 /* It's really a vi search command. */
+ #ifdef GTAGS
+ #define E_REFERENCE 0x04000000 /* locate function references */
+ #endif
u_int32_t flags; /* Current flags. */
};
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/ex/ex_cmd.c ./ex/ex_cmd.c
*** /usr/src/usr.bin/nvi-1.66.org/ex/ex_cmd.c Tue May 5 15:57:37 1998
--- ./ex/ex_cmd.c Sun Aug 16 03:38:03 1998
***************
*** 302,307 ****
--- 302,314 ----
"!",
"rew[ind][!]",
"re-edit all the files in the file argument list"},
+ #ifdef GTAGS
+ /* C_RTAG */
+ {"rtag", ex_rtag_push, E_NEWSCREEN,
+ "!w1o",
+ "rta[g][!] [string]",
+ "edit the file containing the tag"},
+ #endif
/*
* !!!
* Adding new commands starting with 's' may break the substitute command code
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/ex/ex_tag.c ./ex/ex_tag.c
*** /usr/src/usr.bin/nvi-1.66.org/ex/ex_tag.c Tue May 5 15:57:41 1998
--- ./ex/ex_tag.c Sun Aug 16 03:46:43 1998
***************
*** 46,51 ****
--- 46,55 ----
static int compare __P((char *, char *, char *));
static void ctag_file __P((SCR *, TAGF *, char *, char **, size_t *));
static int ctag_search __P((SCR *, char *, char *));
+ #ifdef GTAGS
+ static int getentry __P((char *, char **, char **, char **));
+ static TAGQ *gtag_slist __P((SCR *, char *, int));
+ #endif
static int ctag_sfile __P((SCR *, TAGF *, TAGQ *, char *));
static TAGQ *ctag_slist __P((SCR *, char *));
static char *linear_search __P((char *, char *, char *));
***************
*** 89,94 ****
--- 93,117 ----
return (0);
}
+ #ifdef GTAGS
+ /*
+ * ex_rtag_push -- ^]
+ * :rtag[!] [string]
+ *
+ * Enter a new TAGQ context based on a ctag string.
+ *
+ * PUBLIC: int ex_rtag_push __P((SCR *, EXCMD *));
+ */
+ int
+ ex_rtag_push(sp, cmdp)
+ SCR *sp;
+ EXCMD *cmdp;
+ {
+ F_SET(cmdp, E_REFERENCE);
+ return ex_tag_push(sp, cmdp);
+ }
+ #endif
+
/*
* ex_tag_push -- ^]
* :tag[!] [string]
***************
*** 138,143 ****
--- 161,172 ----
}
/* Get the tag information. */
+ #ifdef GTAGS
+ if (O_ISSET(sp, O_GTAGSMODE)) {
+ if ((tqp = gtag_slist(sp, exp->tag_last, F_ISSET(cmdp, E_REFERENCE))) == NULL)
+ return (1);
+ } else
+ #endif
if ((tqp = ctag_slist(sp, exp->tag_last)) == NULL)
return (1);
***************
*** 963,969 ****
--- 992,1120 ----
(void)nonblank(sp, sp->lno, &sp->cno);
return (0);
}
+ #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 = buf;
+
+ for (*tag = p; *p && !isspace(*p); p++) /* tag name */
+ ;
+ if (*p == 0)
+ goto err;
+ *p++ = 0;
+ for (; *p && isspace(*p); p++) /* (skip blanks) */
+ ;
+ if (*p == 0)
+ goto err;
+ *line = p; /* line no */
+ for (*line = p; *p && !isspace(*p); p++)
+ ;
+ if (*p == 0)
+ goto err;
+ *p++ = 0;
+ for (; *p && isspace(*p); p++) /* (skip blanks) */
+ ;
+ if (*p == 0)
+ goto err;
+ *file = p; /* file name */
+ for (*file = p; *p && !isspace(*p); p++)
+ ;
+ if (*p == 0)
+ goto err;
+ *p = 0;
+
+ /* value check */
+ if (strlen(*tag) && strlen(*line) && strlen(*file) && atoi(*line) > 0)
+ return 1; /* OK */
+ err:
+ return 0; /* ERROR */
+ }
+
+ /*
+ * gtag_slist --
+ * Search the list of tags files for a tag, and return tag queue.
+ */
+ static TAGQ *
+ gtag_slist(sp, tag, ref)
+ SCR *sp;
+ char *tag;
+ int ref;
+ {
+ EX_PRIVATE *exp;
+ TAGF *tfp;
+ TAGQ *tqp;
+ size_t len;
+ int echk;
+ TAG *tp;
+ char *name, *file, *line;
+ char command[BUFSIZ];
+ char buf[BUFSIZ];
+ FILE *fp;
+
+ /* Allocate and initialize the tag queue structure. */
+ len = strlen(tag);
+ CALLOC_GOTO(sp, tqp, TAGQ *, 1, sizeof(TAGQ) + len + 1);
+ CIRCLEQ_INIT(&tqp->tagq);
+ tqp->tag = tqp->buf;
+ memcpy(tqp->tag, tag, (tqp->tlen = len) + 1);
+
+ /*
+ * Find the tag, only display missing file messages once, and
+ * then only if we didn't find the tag.
+ */
+ snprintf(command, sizeof(command), "global -%s '%s' 2>/dev/null", ref ? "rx" : "x", tag);
+ if (fp = popen(command, "r")) {
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (buf[strlen(buf)-1] == '\n') /* chop(buf) */
+ buf[strlen(buf)-1] = 0;
+ else
+ while (fgetc(fp) != '\n')
+ ;
+ if (getentry(buf, &name, &file, &line) == 0) {
+ echk = 1;
+ F_SET(tfp, TAGF_ERR);
+ break;
+ }
+ CALLOC_GOTO(sp, tp,
+ TAG *, 1, sizeof(TAG) + strlen(file) + 1 + strlen(line) + 1);
+ tp->fname = tp->buf;
+ strcpy(tp->fname, file);
+ tp->fnlen = strlen(file);
+ tp->search = tp->fname + tp->fnlen + 1;
+ strcpy(tp->search, line);
+ CIRCLEQ_INSERT_TAIL(&tqp->tagq, tp, q);
+ }
+ pclose(fp);
+ }
+
+ /* Check to see if we found anything. */
+ if (tqp->tagq.cqh_first == (void *)&tqp->tagq) {
+ msgq_str(sp, M_ERR, tag, "162|%s: tag not found");
+ free(tqp);
+ return (NULL);
+ }
+ tqp->current = tqp->tagq.cqh_first;
+ return (tqp);
+
+ alloc_err:
+ return (NULL);
+ }
+ #endif
/*
* ctag_slist --
* Search the list of tags files for a tag, and return tag queue.
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/include/ex_def.h ./include/ex_def.h
*** /usr/src/usr.bin/nvi-1.66.org/include/ex_def.h Tue May 5 15:57:42 1998
--- ./include/ex_def.h Sun Aug 16 03:49:40 1998
***************
*** 47,78 ****
#define C_RECOVER 46
#define C_RESIZE 47
#define C_REWIND 48
! #define C_SUBSTITUTE 49
! #define C_SCRIPT 50
! #define C_SET 51
! #define C_SHELL 52
! #define C_SOURCE 53
! #define C_STOP 54
! #define C_SUSPEND 55
! #define C_T 56
! #define C_TAG 57
! #define C_TAGNEXT 58
! #define C_TAGPOP 59
! #define C_TAGPREV 60
! #define C_TAGTOP 61
! #define C_TCLCMD 62
! #define C_UNDO 63
! #define C_UNABBREVIATE 64
! #define C_UNMAP 65
! #define C_V 66
! #define C_VERSION 67
! #define C_VISUAL_EX 68
! #define C_VISUAL_VI 69
! #define C_VIUSAGE 70
! #define C_WRITE 71
! #define C_WN 72
! #define C_WQ 73
! #define C_XIT 74
! #define C_YANK 75
! #define C_Z 76
! #define C_SUBTILDE 77
--- 47,79 ----
#define C_RECOVER 46
#define C_RESIZE 47
#define C_REWIND 48
! #define C_RTAG 49
! #define C_SUBSTITUTE 50
! #define C_SCRIPT 51
! #define C_SET 52
! #define C_SHELL 53
! #define C_SOURCE 54
! #define C_STOP 55
! #define C_SUSPEND 56
! #define C_T 57
! #define C_TAG 58
! #define C_TAGNEXT 59
! #define C_TAGPOP 60
! #define C_TAGPREV 61
! #define C_TAGTOP 62
! #define C_TCLCMD 63
! #define C_UNDO 64
! #define C_UNABBREVIATE 65
! #define C_UNMAP 66
! #define C_V 67
! #define C_VERSION 68
! #define C_VISUAL_EX 69
! #define C_VISUAL_VI 70
! #define C_VIUSAGE 71
! #define C_WRITE 72
! #define C_WN 73
! #define C_WQ 74
! #define C_XIT 75
! #define C_YANK 76
! #define C_Z 77
! #define C_SUBTILDE 78
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/include/ex_extern.h ./include/ex_extern.h
*** /usr/src/usr.bin/nvi-1.66.org/include/ex_extern.h Tue May 5 15:57:42 1998
--- ./include/ex_extern.h Sun Aug 16 03:50:24 1998
***************
*** 92,97 ****
--- 92,100 ----
char *, char **, size_t *, regex_t *, u_int));
void re_error __P((SCR *, int, regex_t *));
int ex_tag_first __P((SCR *, char *));
+ #ifdef GTAGS
+ int ex_rtag_push __P((SCR *, EXCMD *));
+ #endif
int ex_tag_push __P((SCR *, EXCMD *));
int ex_tag_next __P((SCR *, EXCMD *));
int ex_tag_prev __P((SCR *, EXCMD *));
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/include/options_def.h ./include/options_def.h
*** /usr/src/usr.bin/nvi-1.66.org/include/options_def.h Tue May 5 15:57:42 1998
--- ./include/options_def.h Sun Aug 16 03:54:45 1998
***************
*** 16,77 ****
#define O_EXTENDED 15
#define O_FILEC 16
#define O_FLASH 17
! #define O_HARDTABS 18
! #define O_ICLOWER 19
! #define O_IGNORECASE 20
! #define O_KEYTIME 21
! #define O_LEFTRIGHT 22
! #define O_LINES 23
! #define O_LISP 24
! #define O_LIST 25
! #define O_LOCKFILES 26
! #define O_MAGIC 27
! #define O_MATCHTIME 28
! #define O_MESG 29
! #define O_MODELINE 30
! #define O_MSGCAT 31
! #define O_NOPRINT 32
! #define O_NUMBER 33
! #define O_OCTAL 34
! #define O_OPEN 35
! #define O_OPTIMIZE 36
! #define O_PARAGRAPHS 37
! #define O_PRINT 38
! #define O_PROMPT 39
! #define O_READONLY 40
! #define O_RECDIR 41
! #define O_REDRAW 42
! #define O_REMAP 43
! #define O_REPORT 44
! #define O_RULER 45
! #define O_SCROLL 46
! #define O_SEARCHINCR 47
! #define O_SECTIONS 48
! #define O_SECURE 49
! #define O_SHELL 50
! #define O_SHELLMETA 51
! #define O_SHIFTWIDTH 52
! #define O_SHOWMATCH 53
! #define O_SHOWMODE 54
! #define O_SIDESCROLL 55
! #define O_SLOWOPEN 56
! #define O_SOURCEANY 57
! #define O_TABSTOP 58
! #define O_TAGLENGTH 59
! #define O_TAGS 60
! #define O_TERM 61
! #define O_TERSE 62
! #define O_TILDEOP 63
! #define O_TIMEOUT 64
! #define O_TTYWERASE 65
! #define O_VERBOSE 66
! #define O_W1200 67
! #define O_W300 68
! #define O_W9600 69
! #define O_WARN 70
! #define O_WINDOW 71
! #define O_WRAPLEN 72
! #define O_WRAPMARGIN 73
! #define O_WRAPSCAN 74
! #define O_WRITEANY 75
! #define O_OPTIONCOUNT 76
--- 16,78 ----
#define O_EXTENDED 15
#define O_FILEC 16
#define O_FLASH 17
! #define O_GTAGSMODE 18
! #define O_HARDTABS 19
! #define O_ICLOWER 20
! #define O_IGNORECASE 21
! #define O_KEYTIME 22
! #define O_LEFTRIGHT 23
! #define O_LINES 24
! #define O_LISP 25
! #define O_LIST 26
! #define O_LOCKFILES 27
! #define O_MAGIC 28
! #define O_MATCHTIME 29
! #define O_MESG 30
! #define O_MODELINE 31
! #define O_MSGCAT 32
! #define O_NOPRINT 33
! #define O_NUMBER 34
! #define O_OCTAL 35
! #define O_OPEN 36
! #define O_OPTIMIZE 37
! #define O_PARAGRAPHS 38
! #define O_PRINT 39
! #define O_PROMPT 40
! #define O_READONLY 41
! #define O_RECDIR 42
! #define O_REDRAW 43
! #define O_REMAP 44
! #define O_REPORT 45
! #define O_RULER 46
! #define O_SCROLL 47
! #define O_SEARCHINCR 48
! #define O_SECTIONS 49
! #define O_SECURE 50
! #define O_SHELL 51
! #define O_SHELLMETA 52
! #define O_SHIFTWIDTH 53
! #define O_SHOWMATCH 54
! #define O_SHOWMODE 55
! #define O_SIDESCROLL 56
! #define O_SLOWOPEN 57
! #define O_SOURCEANY 58
! #define O_TABSTOP 59
! #define O_TAGLENGTH 60
! #define O_TAGS 61
! #define O_TERM 62
! #define O_TERSE 63
! #define O_TILDEOP 64
! #define O_TIMEOUT 65
! #define O_TTYWERASE 66
! #define O_VERBOSE 67
! #define O_W1200 68
! #define O_W300 69
! #define O_W9600 70
! #define O_WARN 71
! #define O_WINDOW 72
! #define O_WRAPLEN 73
! #define O_WRAPMARGIN 74
! #define O_WRAPSCAN 75
! #define O_WRITEANY 76
! #define O_OPTIONCOUNT 77
diff -c -r -N /usr/src/usr.bin/nvi-1.66.org/vi/v_ex.c ./vi/v_ex.c
*** /usr/src/usr.bin/nvi-1.66.org/vi/v_ex.c Tue May 5 15:57:45 1998
--- ./vi/v_ex.c Sun Aug 16 03:55:38 1998
***************
*** 221,226 ****
--- 221,231 ----
ARGS *ap[2], a;
EXCMD cmd;
+ #ifdef GTAGS
+ if (O_ISSET(sp, O_GTAGSMODE) && vp->m_start.cno == 0)
+ ex_cinit(&cmd, C_RTAG, 0, OOBLNO, 0, 0, ap);
+ else
+ #endif
ex_cinit(&cmd, C_TAG, 0, OOBLNO, 0, 0, ap);
ex_cadd(&cmd, &a, VIP(sp)->keyw, strlen(VIP(sp)->keyw));
return (v_exec_ex(sp, vp, &cmd));

View File

@ -1,6 +1,6 @@
diff -c -r -N /usr/local/src/nvi-1.79/build/Makefile.in ./build/Makefile.in
*** /usr/local/src/nvi-1.79/build/Makefile.in Wed Oct 23 22:43:38 1996
--- ./build/Makefile.in Wed Apr 16 21:20:09 1997
--- ./build/Makefile.in Fri Aug 14 01:41:14 1998
***************
*** 3,9 ****
srcdir= @srcdir@/..
@ -20,7 +20,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/build/Makefile.in ./build/Makefile.in
PERLLIB=@vi_cv_perllib@
diff -c -r -N /usr/local/src/nvi-1.79/common/main.c ./common/main.c
*** /usr/local/src/nvi-1.79/common/main.c Sat Oct 12 07:28:28 1996
--- ./common/main.c Wed Apr 16 21:20:09 1997
--- ./common/main.c Fri Aug 14 01:41:14 1998
***************
*** 64,69 ****
--- 64,72 ----
@ -84,7 +84,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/common/main.c ./common/main.c
*oargp = -1; /* Options initialization. */
diff -c -r -N /usr/local/src/nvi-1.79/common/options.c ./common/options.c
*** /usr/local/src/nvi-1.79/common/options.c Tue Oct 15 03:56:29 1996
--- ./common/options.c Wed Apr 16 21:20:09 1997
--- ./common/options.c Fri Aug 14 01:41:14 1998
***************
*** 80,85 ****
--- 80,89 ----
@ -112,7 +112,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/common/options.c ./common/options.c
{"li", O_LINES}, /* 4.4BSD */
diff -c -r -N /usr/local/src/nvi-1.79/docs/USD.doc/vi.man/vi.1 ./docs/USD.doc/vi.man/vi.1
*** /usr/local/src/nvi-1.79/docs/USD.doc/vi.man/vi.1 Fri Oct 11 10:34:05 1996
--- ./docs/USD.doc/vi.man/vi.1 Wed Apr 16 21:20:09 1997
--- ./docs/USD.doc/vi.man/vi.1 Fri Aug 14 01:41:14 1998
***************
*** 17,23 ****
.SH SYNOPSIS
@ -213,7 +213,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/docs/USD.doc/vi.man/vi.1 ./docs/USD.doc/vi
Set the spacing between hardware tab settings.
diff -c -r -N /usr/local/src/nvi-1.79/ex/ex.h ./ex/ex.h
*** /usr/local/src/nvi-1.79/ex/ex.h Tue Aug 13 09:24:00 1996
--- ./ex/ex.h Wed Apr 16 21:20:09 1997
--- ./ex/ex.h Fri Aug 14 01:41:14 1998
***************
*** 152,157 ****
--- 152,160 ----
@ -228,7 +228,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/ex/ex.h ./ex/ex.h
diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_cmd.c ./ex/ex_cmd.c
*** /usr/local/src/nvi-1.79/ex/ex_cmd.c Wed Oct 23 22:31:01 1996
--- ./ex/ex_cmd.c Wed Apr 16 21:20:09 1997
--- ./ex/ex_cmd.c Fri Aug 14 01:41:14 1998
***************
*** 302,307 ****
--- 302,314 ----
@ -239,7 +239,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_cmd.c ./ex/ex_cmd.c
+ /* C_RTAG */
+ {"rtag", ex_rtag_push, E_NEWSCREEN,
+ "!w1o",
+ "[Rr]ta[g][!] [string]",
+ "rta[g][!] [string]",
+ "edit the file containing the tag"},
+ #endif
/*
@ -247,7 +247,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_cmd.c ./ex/ex_cmd.c
* Adding new commands starting with 's' may break the substitute command code
diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_tag.c ./ex/ex_tag.c
*** /usr/local/src/nvi-1.79/ex/ex_tag.c Mon Sep 16 05:02:43 1996
--- ./ex/ex_tag.c Wed Apr 16 21:20:09 1997
--- ./ex/ex_tag.c Fri Aug 14 01:53:35 1998
***************
*** 46,51 ****
--- 46,55 ----
@ -255,7 +255,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_tag.c ./ex/ex_tag.c
static void ctag_file __P((SCR *, TAGF *, char *, char **, size_t *));
static int ctag_search __P((SCR *, char *, size_t, char *));
+ #ifdef GTAGS
+ static int getentry __P((char *, char *, char *, char *));
+ static int getentry __P((char *, char **, char **, char **));
+ static TAGQ *gtag_slist __P((SCR *, char *, int));
+ #endif
static int ctag_sfile __P((SCR *, TAGF *, TAGQ *, char *));
@ -306,7 +306,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_tag.c ./ex/ex_tag.c
***************
*** 969,974 ****
--- 998,1116 ----
--- 998,1126 ----
return (0);
}
@ -325,30 +325,40 @@ diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_tag.c ./ex/ex_tag.c
+ */
+ static int
+ getentry(buf, tag, file, line)
+ char *buf, *tag, *file, *line;
+ char *buf, **tag, **file, **line;
+ {
+ char *p;
+ char *p = buf;
+
+ 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++;
+ for (*tag = p; *p && !isspace(*p); p++) /* tag name */
+ ;
+ if (*p == 0)
+ goto err;
+ *p++ = 0;
+ for (; *p && isspace(*p); p++) /* (skip blanks) */
+ ;
+ if (*p == 0)
+ goto err;
+ *line = p; /* line no */
+ for (*line = p; *p && !isspace(*p); p++)
+ ;
+ if (*p == 0)
+ goto err;
+ *p++ = 0;
+ for (; *p && isspace(*p); p++) /* (skip blanks) */
+ ;
+ if (*p == 0)
+ goto err;
+ *file = p; /* file name */
+ for (*file = p; *p && !isspace(*p); p++)
+ ;
+ if (*p == 0)
+ goto err;
+ *p = 0;
+
+ /* value check */
+ if (strlen(tag) && strlen(line) && strlen(file) && atoi(line) > 0)
+ if (strlen(*tag) && strlen(*line) && strlen(*file) && atoi(*line) > 0)
+ return 1; /* OK */
+ err:
+ return 0; /* ERROR */
+ }
+
@ -368,9 +378,9 @@ diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_tag.c ./ex/ex_tag.c
+ size_t len;
+ int echk;
+ TAG *tp;
+ static char name[80], file[200], line[10];
+ char command[200];
+ char buf[BUFSIZ+1];
+ char *name, *file, *line;
+ char command[BUFSIZ];
+ char buf[BUFSIZ];
+ FILE *fp;
+
+ /* Allocate and initialize the tag queue structure. */
@ -384,7 +394,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_tag.c ./ex/ex_tag.c
+ * Find the tag, only display missing file messages once, and
+ * then only if we didn't find the tag.
+ */
+ sprintf(command, "global -%s '%s'", ref ? "rx" : "x", tag);
+ snprintf(command, sizeof(command), "global -%s '%s' 2>/dev/null", ref ? "rx" : "x", tag);
+ if (fp = popen(command, "r")) {
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (buf[strlen(buf)-1] == '\n') /* chop(buf) */
@ -392,7 +402,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_tag.c ./ex/ex_tag.c
+ else
+ while (fgetc(fp) != '\n')
+ ;
+ if (getentry(buf, name, file, line) == 0) {
+ if (getentry(buf, &name, &file, &line) == 0) {
+ echk = 1;
+ F_SET(tfp, TAGF_ERR);
+ break;
@ -428,7 +438,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/ex/ex_tag.c ./ex/ex_tag.c
* Search the list of tags files for a tag, and return tag queue.
diff -c -r -N /usr/local/src/nvi-1.79/include/ex_def.h ./include/ex_def.h
*** /usr/local/src/nvi-1.79/include/ex_def.h Wed Oct 23 22:53:09 1996
--- ./include/ex_def.h Wed Apr 16 21:20:09 1997
--- ./include/ex_def.h Fri Aug 14 01:41:14 1998
***************
*** 47,78 ****
#define C_RECOVER 46
@ -499,7 +509,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/include/ex_def.h ./include/ex_def.h
! #define C_SUBTILDE 78
diff -c -r -N /usr/local/src/nvi-1.79/include/ex_extern.h ./include/ex_extern.h
*** /usr/local/src/nvi-1.79/include/ex_extern.h Wed Oct 23 22:53:10 1996
--- ./include/ex_extern.h Wed Apr 16 21:20:09 1997
--- ./include/ex_extern.h Fri Aug 14 01:41:14 1998
***************
*** 89,94 ****
--- 89,95 ----
@ -512,7 +522,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/include/ex_extern.h ./include/ex_extern.h
int ex_tag_prev __P((SCR *, EXCMD *));
diff -c -r -N /usr/local/src/nvi-1.79/include/options_def.h ./include/options_def.h
*** /usr/local/src/nvi-1.79/include/options_def.h Wed Oct 23 22:53:10 1996
--- ./include/options_def.h Wed Apr 16 21:20:09 1997
--- ./include/options_def.h Fri Aug 14 01:41:14 1998
***************
*** 16,79 ****
#define O_EXTENDED 15
@ -647,7 +657,7 @@ diff -c -r -N /usr/local/src/nvi-1.79/include/options_def.h ./include/options_de
! #define O_OPTIONCOUNT 79
diff -c -r -N /usr/local/src/nvi-1.79/vi/v_ex.c ./vi/v_ex.c
*** /usr/local/src/nvi-1.79/vi/v_ex.c Mon Sep 16 05:03:02 1996
--- ./vi/v_ex.c Wed Apr 16 21:20:09 1997
--- ./vi/v_ex.c Fri Aug 14 01:41:14 1998
***************
*** 226,231 ****
--- 226,236 ----

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 1997 Shigio Yamaguchi. All rights reserved.
# Copyright (c) 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
@ -29,59 +29,219 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# systags.sh 7-Jul-97
# systags.sh 17-Aug-98
#
# script to make hypertext of kernel source.
# supporting FreeBSD and Linux.
# support OS: FreeBSD, NetBSD, OpenBSD, Linux, GNUmach, GNUhurd
#
case $1 in
-n) nflag=1; shift;;
esac
while case $1 in
-*)
if grep '[^-cfgn]' <<! >/dev/null 2>&1; then
$1
!
echo "usage: systags [-c][-f][-g][-n][dir]"
exit 1
fi
case $1 in
*c*) cflag=c;;
esac
case $1 in
*f*) fflag=f;;
esac
case $1 in
*g*) gflag=g;;
esac
case $1 in
*n*) nflag=n;;
esac
;;
*) false;;
esac
do
shift
done
case $1 in
"") dir=.;;
*) dir=$1;;
esac
if [ ! -d $dir -o ! -w $dir ]; then
echo "systags: '$dir' is not a directory or not writable."
exit 1
fi
tmpdir=$dir/systags_tmpdir_$$
#
# get release number from source tree.
#
if [ -f conf/newvers.sh ]; then
os=FreeBSD
release=`awk -F= '/^RELEASE=/ {print $2}' < conf/newvers.sh`
# (Free|Net|Open)BSD?
if ! mkdir $tmpdir 2>/dev/null; then
echo "systags: '$dir' is not writable."
exit 1
fi
cwd=`pwd`
(cd $tmpdir; sh $cwd/conf/newvers.sh)
os=`awk -F\" '/char[ \t]+ostype\[\][ \t]*=[ \t]*\"[^"]+\"/ {print $2}' < $tmpdir/vers.c`;
release=`awk -F\" '/char[ \t]+osrelease\[\][ \t]*=[ \t]*\"[^"]+\"/ {print $2}' < $tmpdir/vers.c`;
rm -rf $tmpdir
elif [ -f Makefile ] && grep '^vmlinux:' Makefile >/dev/null; then
# Linux?
os=Linux
version=`awk -F= '/^VERSION *=/ {print $2}' < Makefile`
patchlevel=`awk -F= '/^PATCHLEVEL *=/ {print $2}' < Makefile`
sublevel=`awk -F= '/^SUBLEVEL *=/ {print $2}' < Makefile`
release=`echo "$version.$patchlevel.$sublevel" | tr -d ' '`
elif [ -f version.c ]; then
# GNU mach?
version=`awk -F\" '/char[ \t]+version\[\][ \t]*=[ \t]*\"[^"]+\"/ {print $2}' < version.c`
os=`echo $version | awk '{print $1}'`
release=`echo $version | awk '{print $2}'`
elif [ -f version.h ]; then
# GNU hurd?
release=`awk -F\" '/^#define[ \t]+HURD_VERSION[ \t]+"[^"]+\"/ {print $2}' < version.h`
if [ ${release}X != X ]; then
os=GNUhurd
fi
fi
#
# remove old files
#
files=
for f in htags.log gtags.log GTAGS GRTAGS GSYMS GPATH HTML; do
files="$files $dir/$f";
done
com="rm -rf $files"
case $nflag in
1) echo "rm -rf $dir/htags.log $dir/gtags.log $dir/GTAGS $dir/GRTAGS $dir/GSYMS $dir/HTML";;
*) rm -rf $dir/htags.log $dir/gtags.log $dir/GTAGS $dir/GRTAGS $dir/GSYMS $dir/HTML;;
n) echo $com;;
*) eval $com;;
esac
#
# make global database(GTAGS, GRTAGS, GSYMS).
# FreeBSD System macros.
#
# These macros with argument are used out of function.
# gctags(1) knows these are not function by '.notfunction' list.
#
# kernel.h MAKE_SET,TEXT_SET,DATA_SET,BSS_SET,ABS_SET,
# SYSINIT,SYSINIT_KT,SYSINIT_KP,PSEUDO_SET
# sysctl.h SYSCTL_OID,SYSCTL_NODE,SYSCTL_STRING,SYSCTL_INT,SYSCTL_OPAQUE,
# SYSCTL_STRUCT,SYSCTL_PROC
# domain.h DOMAIN_SET
# mount.h VFS_SET
# lkm.h MOD_DECL,MOD_SYSCALL,MOD_VFS,MOD_DEV,MOD_EXEC,MOD_MISC
# vnode.h VNODEOP_SET
# spl.h GENSPL
# queue.h SLIST_HEAD,SLIST_ENTRY,SLIST_INIT,SLIST_INSERT_AFTER,
# SLIST_INSERT_HEAD,SLIST_REMOVE_HEAD,SLIST_REMOVE,STAILQ_HEAD,
# STAILQ_ENTRY,STAILQ_INIT,STAILQ_INSERT_HEAD,STAILQ_INSERT_TAIL,
# STAILQ_INSERT_AFTER,STAILQ_REMOVE_HEAD,STAILQ_REMOVE,
# LIST_HEAD,LIST_ENTRY,LIST_INIT,LIST_INSERT_AFTER,LIST_INSERT_BEFORE,
# LIST_INSERT_HEAD,LIST_REMOVE,TAILQ_HEAD,TAILQ_ENTRY,
# TAILQ_EMPTY,TAILQ_FIRST,TAILQ_LAST,TAILQ_NEXT,TAILQ_PREV,
# TAILQ_INIT,TAILQ_INSERT_HEAD,TAILQ_INSERT_TAIL,TAILQ_INSERT_AFTER,
# TAILQ_INSERT_BEFORE,TAILQ_REMOVE,CIRCLEQ_HEAD,CIRCLEQ_ENTRY,
# CIRCLEQ_INIT,CIRCLEQ_INSERT_AFTER,CIRCLEQ_INSERT_BEFORE,
# CIRCLEQ_INSERT_HEAD,CIRCLEQ_INSERT_TAIL,CIRCLEQ_REMOVE
#
case $os in
FreeBSD)
cat <<-! >.notfunction
MAKE_SET
TEXT_SET
DATA_SET
BSS_SET
ABS_SET
SYSINIT
SYSINIT_KT
SYSINIT_KP
PSEUDO_SET
SYSCTL_OID
SYSCTL_NODE
SYSCTL_STRING
SYSCTL_INT
SYSCTL_OPAQUE
SYSCTL_STRUCT
SYSCTL_PROC
DOMAIN_SET
VFS_SET
MOD_DECL
MOD_SYSCALL
MOD_VFS
MOD_DEV
MOD_EXEC
MOD_MISC
VNODEOP_SET
GENSPL
SLIST_HEAD
SLIST_ENTRY
SLIST_INIT
SLIST_INSERT_AFTER
SLIST_INSERT_HEAD
SLIST_REMOVE_HEAD
SLIST_REMOVE
STAILQ_HEAD
STAILQ_ENTRY
STAILQ_INIT
STAILQ_INSERT_HEAD
STAILQ_INSERT_TAIL
STAILQ_INSERT_AFTER
STAILQ_REMOVE_HEAD
STAILQ_REMOVE
LIST_HEAD
LIST_ENTRY
LIST_INIT
LIST_INSERT_AFTER
LIST_INSERT_BEFORE
LIST_INSERT_HEAD
LIST_REMOVE
TAILQ_HEAD
TAILQ_ENTRY
TAILQ_EMPTY
TAILQ_FIRST
TAILQ_LAST
TAILQ_NEXT
TAILQ_PREV
TAILQ_INIT
TAILQ_INSERT_HEAD
TAILQ_INSERT_TAIL
TAILQ_INSERT_AFTER
TAILQ_INSERT_BEFORE
TAILQ_REMOVE
CIRCLEQ_HEAD
CIRCLEQ_ENTRY
CIRCLEQ_INIT
CIRCLEQ_INSERT_AFTER
CIRCLEQ_INSERT_BEFORE
CIRCLEQ_INSERT_HEAD
CIRCLEQ_INSERT_TAIL
CIRCLEQ_REMOVE
!
esac
#
# make global database(GTAGS, GRTAGS).
#
com="gtags -owv $dir > $dir/gtags.log 2>&1"
case $nflag in
1) echo "gtags -v $dir > $dir/gtags.log 2>&1";;
*) gtags -v $dir > $dir/gtags.log 2>&1;;
n) echo $com;;
*) eval $com;;
esac
case $? in
0) ;;
*) exit 1;;
esac
case $gflag in
g) exit 0;;
esac
#
# make hypertext.
# (please replace this title with a suitable one.)
#
case $os$release in
"") program=`/bin/pwd | sed 's/.*\///'`
title="Welcome to $program source tour!";;
*) title="Welcome to $os $release kernel source tour!";;
esac
if [ ${os}X != X -a ${release}X != X ]; then
title="Welcome to $os $release kernel source tour!"
else
program=`/bin/pwd | sed 's/.*\///'`
title="Welcome to $program source tour!"
fi
com="htags -${cflag}${fflag}lhnvat '$title' -d $dir $dir > $dir/htags.log 2>&1"
case $nflag in
1) echo "htags -fnvat '$title' -d $dir $dir > $dir/htags.log 2>&1";;
*) htags -fnvat "$title" -d $dir $dir> $dir/htags.log 2>&1;;
n) echo $com;;
*) eval $com;;
esac