pedz@megamax.UUCP (The Pedz Thing) (01/19/87)
I prefer that a program like etags/ctags (which comes as part of the
GNU emacs distribution) be the exact same program and the choice of
how to operate is based upon the name it is executed by. I have made
these changes to etags.c and to the Makefile. Thus the same program
is linked as ctags and as etags and will operate as desired based upon
argv[0]. This saves disk space and makes life much easier. BTW,
there was some sort of "feature" that reverted the program back to
ctags mode if there were any parameters. I did not see the point in
this so I removed it. Below are the diffs.
Perry Smith
Pedz Consultants
pedz@megamax, pedz@ctvax, pedz@pollux
*** etags.c.old Fri Jan 16 19:53:30 1987
--- etags.c Fri Jan 16 19:34:51 1987
***************
*** 50,59
#include <stdio.h>
#include <ctype.h>
! /* Define the symbol ETAGS to make the program "etags",
! which makes emacs-style tag tables by default.
! Define CTAGS to make the program "ctags" compatible with the usual one.
! Default is ETAGS. */
#ifndef CTAGS
#ifndef ETAGS
--- 50,57 -----
#include <stdio.h>
#include <ctype.h>
! /* link the executable from this file to ctags and etags. argv[0] is
! * used to determine how the program should behave. */
#define reg register
#define logical char
***************
*** 55,66
Define CTAGS to make the program "ctags" compatible with the usual one.
Default is ETAGS. */
- #ifndef CTAGS
- #ifndef ETAGS
- #define ETAGS 1
- #endif
- #endif
-
#define reg register
#define logical char
--- 53,58 -----
/* link the executable from this file to ctags and etags. argv[0] is
* used to determine how the program should behave. */
#define reg register
#define logical char
***************
*** 126,131
int vflag; /* -v: create vgrind style index output */
int xflag; /* -x: create cxref style output */
int eflag; /* -e: emacs style output */
FILE *inf, /* ioptr for current input file */
*outf; /* ioptr for tags file */
--- 118,124 -----
int vflag; /* -v: create vgrind style index output */
int xflag; /* -x: create cxref style output */
int eflag; /* -e: emacs style output */
+ char *progname; /* name of the program */
FILE *inf, /* ioptr for current input file */
*outf; /* ioptr for tags file */
***************
*** 177,185
char cmd[100];
int i;
! #ifdef ETAGS
! eflag = 1;
! #endif
while (ac > 1 && av[1][0] == '-')
{
--- 170,180 -----
char cmd[100];
int i;
! if (progname = index(av[0], '/'))
! progname++;
! else
! progname = av[0];
! eflag = strcmp(progname, "etags") == 0;
while (ac > 1 && av[1][0] == '-')
{
***************
*** 183,189
while (ac > 1 && av[1][0] == '-')
{
- eflag = 0;
for (i=1; av[1][i]; i++)
{
switch(av[1][i])
--- 178,183 -----
while (ac > 1 && av[1][0] == '-')
{
for (i=1; av[1][i]; i++)
{
switch(av[1][i])
***************
*** 226,232
if (ac <= 1)
{
usage:
! printf("Usage: ctags [-BFaetuwvx] file ...\n");
exit(1);
}
--- 220,226 -----
if (ac <= 1)
{
usage:
! printf("Usage: %s [-BFaetuwvx] file ...\n", progname);
exit(1);
}
***************
*** 406,412
if ((np = (NODE *) malloc (sizeof (NODE))) == NULL)
{
! fprintf(stderr, "ctags: too many entries to sort\n");
put_entries(head);
free_tree(head);
head = NULL;
--- 400,406 -----
if ((np = (NODE *) malloc (sizeof (NODE))) == NULL)
{
! fprintf(stderr, "%s: too many entries to sort\n", progname);
put_entries(head);
free_tree(head);
head = NULL;
***************
*** 1387,1397
error (s1, s2)
char *s1, *s2;
{
! #ifdef CTAGS
! printf ("ctags: ");
! #else
! printf ("etags: ");
! #endif
printf (s1, s2);
printf ("\n");
}
--- 1381,1387 -----
error (s1, s2)
char *s1, *s2;
{
! printf ("%s: ", progname);
printf (s1, s2);
printf ("\n");
}
*** Makefile.old Mon Jan 12 22:53:30 1987
--- Makefile Fri Jan 16 19:27:02 1987
***************
*** 14,20
./test-distrib
etags: etags.c
! cc -o etags ${CFLAGS} -DETAGS etags.c
ctags: etags.c
cc -o ctags ${CFLAGS} -DCTAGS etags.c
--- 14,20 -----
./test-distrib
etags: etags.c
! cc -o etags ${CFLAGS} etags.c
ctags: etags
rm -f ctags
***************
*** 16,23
etags: etags.c
cc -o etags ${CFLAGS} -DETAGS etags.c
! ctags: etags.c
! cc -o ctags ${CFLAGS} -DCTAGS etags.c
loadst: loadst.c
cc -o loadst ${CFLAGS} loadst.c
--- 16,24 -----
etags: etags.c
cc -o etags ${CFLAGS} etags.c
! ctags: etags
! rm -f ctags
! ln etags ctags
loadst: loadst.c
cc -o loadst ${CFLAGS} loadst.c
--
Perry Smith
Pedz Consultants
pedz@megamax, pedz@ctvax, pedz@pollux
--
Perry Smith
Pedz Consultants
pedz@megamax, pedz@ctvax, pedz@pollux