Path: usenet.cis.ufl.edu!usenet.eel.ufl.edu!spool.mu.edu!howland.reston.ans.net!news.sprintlink.net!psgrain!nntp.teleport.com!usenet
From:
[email protected] (Bart Robinson)
Newsgroups: comp.lang.perl.announce,comp.lang.perl.misc,comp.lang.perl
Subject: etags fix wrt perl
Followup-To: gnu.emacs.help
Date: 13 Jun 1995 05:54:21 GMT
Organization: Source only, discussion and requests in gnu.emacs.help
Lines: 214
Approved:
[email protected] (comp.lang.perl.announce)
Message-ID: <
[email protected]>
NNTP-Posting-Host: linda.teleport.com
X-Disclaimer: The "Approved" header verifies header information for article transmission and does not imply approval of content.
Xref: usenet.cis.ufl.edu comp.lang.perl.announce:33 comp.lang.perl.misc:582 comp.lang.perl:51964
I added some stuff to etags so it will make tags for perl subs.
I used to use a perl script to do it but came to dislike that
paradigm. Here are patches for the XEmacs19.11 etags.[c1]. It
would be easy cut/paste to add them to the Emacs one (who knows
why they differ).
[followups to gnu.emacs.help]
- - - - - - - - - - - - - - - tear here - - - - - - - - - - - - - - -
--- /afs/cs.utah.edu/home/lomew/src/xemacs-19.11/lib-src/etags.c Mon Jun 12 15:46:55 1995
+++ lib-src/etags.c Mon Jun 12 18:24:01 1995
@@ -24,6 +24,7 @@
* Ed Pelegri-Llopart added C typedefs.
* Gnu Emacs TAGS format and modifications by RMS?
* Sam Kendall added C++.
+ * Perl support by Bart Robinson <
[email protected]>
*/
#include "../src/config.h"
@@ -186,6 +187,8 @@
long readline ();
void Asm_funcs ();
void C_entries ();
+void perl_funcs ();
+void perl_getit();
void L_funcs ();
void L_getit ();
void PS_funcs ();
@@ -224,6 +227,8 @@
long readline (struct linebuffer *, FILE *);
void Asm_funcs (FILE *);
void C_entries (int);
+void perl_funcs (FILE *);
+void perl_getit();
void L_funcs (FILE *);
void L_getit (void);
void PS_funcs (FILE *);
@@ -421,6 +426,7 @@
int no_warnings; /* -w: suppress warnings */
int cxref_style; /* -x: create cxref style output */
int cplusplus; /* .[hc] means C++, not C */
+int perl; /* .p[lm] or no match ==> perl */
int noindentypedefs; /* -S: ignore indentation in C */
/* Name this program was invoked with. */
@@ -439,6 +445,7 @@
{ "no-defines", no_argument, NULL, 'D' },
{ "no-warn", no_argument, NULL, 'w' },
{ "output", required_argument, NULL, 'o' },
+ { "perl", no_argument, NULL, 'p' },
{ "typedefs", no_argument, NULL, 't' },
{ "typedefs-and-c++", no_argument, NULL, 'T' },
{ "update", no_argument, NULL, 'u' },
@@ -499,9 +506,11 @@
Treat files with `.c' and `.h' extensions as C++ code, not C\n\
code. Files with `.C', `.H', `.cxx', `.hxx', or `.cc'\n\
extensions are always assumed to be C++ code.");
+ puts ("-p, --perl\n\
+ Files with no matching extension will be considered perl instead\n\
+ of C. Also, .pl will be treated as perl instead of as prolog.");
fputs ("-d, --defines\n\
Create tag entries for #defines, too.", stdout);
-
#ifdef ETAGS
fputs (" This is the default\n\
behavior.", stdout);
@@ -610,7 +619,7 @@
for (;;)
{
int opt;
- opt = getopt_long (argc, argv, "aCdDo:f:StTi:BFuvxwVH", longopts, 0);
+ opt = getopt_long (argc, argv, "aCdDo:f:StTi:BFuvxwVHp", longopts, 0);
if (opt == EOF)
break;
@@ -645,6 +654,9 @@
}
outfile = optarg;
break;
+ case 'p':
+ perl = 1;
+ break;
case 'S':
noindentypedefs++;
break;
@@ -1005,12 +1017,19 @@
C_entries (YACC);
goto close_and_return;
}
- /* .pl implies prolog source code */
+ /* .pl implies either perl or prolog source code */
if (cp && streq (cp + 1, "pl"))
{
- prolog_funcs (inf);
+ perl? perl_funcs (inf) : prolog_funcs (inf);
goto close_and_return;
}
+ /* .pm or .perl implies perl src */
+ if (cp && (streq (cp + 1, "pm")
+ || streq (cp + 1, "perl")))
+ {
+ perl_funcs (inf);
+ goto close_and_return;
+ }
/* .ps implies postscript source code */
if (cp && (streq (cp + 1, "ps")))
{
@@ -1046,7 +1065,8 @@
goto close_and_return;
rewind (inf); /* no fortran tags found, try C */
}
- C_entries (cplusplus ? C_PLPL : 0);
+ /* No extension match, default to c/c++ or perl */
+ perl? perl_funcs (inf) : C_entries (cplusplus ? C_PLPL : 0);
close_and_return:
(void) fclose (inf);
@@ -2397,6 +2417,59 @@
}
} /* while not e-o-f */
}
+
+
+/*
+ * perl tag functions
+ * Just look for "sub foo ... {"
+ */
+
+void
+perl_funcs (fi)
+ FILE *fi;
+{
+ lineno = 0;
+ charno = 0;
+ pfcnt = 0;
+
+ while (!feof (fi))
+ {
+ lineno++;
+ linecharno = charno;
+ charno += readline (&lb, fi);
+ dbp = lb.buffer;
+ if (dbp[0] == 's' && dbp[1] == 'u' && dbp[2] == 'b' && isspace(dbp[3]))
+ {
+ dbp += 4;
+ while (*dbp && isspace(*dbp))
+ dbp++;
+ perl_getit();
+ }
+ }
+}
+
+void
+perl_getit()
+{
+ register char *cp;
+ char c;
+ char nambuf[BUFSIZ];
+
+ if (*dbp == 0)
+ return;
+
+ for (cp = dbp+1; *cp && !isspace(*cp); cp++)
+ continue;
+
+ c = cp[0];
+ cp[0] = 0;
+ strcpy(nambuf, dbp);
+ cp[0] = c;
+
+ pfnote (nambuf, TRUE, FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
+ pfcnt++;
+}
+
/*
* lisp tag functions
--- /afs/cs.utah.edu/home/lomew/src/xemacs-19.11/etc/etags.1 Thu Jul 29 15:07:44 1993
+++ etc/etags.1 Mon Jun 12 18:19:00 1995
@@ -14,17 +14,17 @@
.SH SYNOPSIS
.hy 0
.na
-.B etags [\|\-CDSTVHadt\|] [\|\-i \fIfile\fP\|] [\|\-o \fIoutfile\fP\|]
+.B etags [\|\-CDSTVHadpt\|] [\|\-i \fIfile\fP\|] [\|\-o \fIoutfile\fP\|]
.br
-[\|\-\-defines\|] [\|\-\-no\-defines\|] [\|\-\-c++\|] [\|\-\-typedefs\|] [\|\-\-typedefs\-and\-c++\|] [\|\-\-ignore\-indentation\|]
+[\|\-\-defines\|] [\|\-\-no\-defines\|] [\|\-\-c++\|] [\|\-\-typedefs\|] [\|\-\-typedefs\-and\-c++\|] [\|\-\-ignore\-indentation\|] [\|\-\-perl\|]
.br
[\|\-\-help\|] [\|\-\-version\|]
.br
[\|\-\-include=\fIfile\fP\|] [\|\-\-output=\fIoutfile\fP\|] [\|\-\-append\|] \fIfile\fP .\|.\|.
-.B ctags [\|\-CDSTVHadt\|] [\|\-BFuvwx\|] [\|\-o \fIoutfile\fP\|]
+.B ctags [\|\-CDSTVHadpt\|] [\|\-BFuvwx\|] [\|\-o \fIoutfile\fP\|]
.br
-[\|\-\-defines\|] [\|\-\-no\-defines\|] [\|\-\-c++\|] [\|\-\-typedefs\|] [\|\-\-typedefs\-and\-c++\|] [\|\-\-ignore\-indentation\|] [\|\-\-no\-warn\|]
+[\|\-\-defines\|] [\|\-\-no\-defines\|] [\|\-\-c++\|] [\|\-\-typedefs\|] [\|\-\-typedefs\-and\-c++\|] [\|\-\-ignore\-indentation\|] [\|\-\-no\-warn\|] [\|\-\-perl\|]
.br
[\|\-\-backward\-search\|] [\|\-\-forward\-search\|] [\|\-\-vgrind\|] [\|\-\-cxref\|]
.br
@@ -63,6 +63,10 @@
Treat files with `\|.c\|' and `\|.h\|' extensions as C++ code, not C
code. Files with `\|.C\|', `\|.H\|', `\|.cxx\|', `\|.hxx\|', or
`\|.cc\|' extensions are always assumed to be C++ code.
+.TP
+.B \-p, \-\-perl
+Files with no matching extension will be considered perl instead
+of C. Also, `\|.pl\|' will be treated as perl instead of as prolog.
.TP
.B \-t, \-\-typedefs
Record typedefs in C code as tags.