[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lib-src/etags.c
From: |
Francesco Potortì |
Subject: |
[Emacs-diffs] Changes to emacs/lib-src/etags.c |
Date: |
Wed, 26 Dec 2001 17:11:21 -0500 |
Index: emacs/lib-src/etags.c
diff -c emacs/lib-src/etags.c:3.6 emacs/lib-src/etags.c:3.7
*** emacs/lib-src/etags.c:3.6 Sat Dec 15 11:07:31 2001
--- emacs/lib-src/etags.c Wed Dec 26 17:11:21 2001
***************
*** 1,5 ****
/* Tags file maker to go with GNU Emacs -*- coding: latin-1 -*-
! Copyright (C) 1984, 87, 88, 89, 93, 94, 95, 98, 99, 2000, 2001
Free Software Foundation, Inc. and Ken Arnold
This file is not considered part of GNU Emacs.
--- 1,5 ----
/* Tags file maker to go with GNU Emacs -*- coding: latin-1 -*-
! Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2001
Free Software Foundation, Inc. and Ken Arnold
This file is not considered part of GNU Emacs.
***************
*** 25,38 ****
* Ed Pelegri-Llopart added C typedefs.
* Gnu Emacs TAGS format and modifications by RMS?
* 1989 Sam Kendall added C++.
! * 1993 Francesco Potortì reorganised C and C++ based on work by Joe
Wells.
* 1994 Regexp tags by Tom Tromey.
! * 2001 Nested classes by Francesco Potortì based on work by Mykola Dzyuba.
*
* Francesco Potortì <address@hidden> has maintained it since 1993.
*/
! char pot_etags_version[] = "@(#) pot revision number is 14.26";
#define TRUE 1
#define FALSE 0
--- 25,39 ----
* Ed Pelegri-Llopart added C typedefs.
* Gnu Emacs TAGS format and modifications by RMS?
* 1989 Sam Kendall added C++.
! * 1992 Joseph B. Wells improved C and C++ parsing.
! * 1993 Francesco Potortì reorganised C and C++.
* 1994 Regexp tags by Tom Tromey.
! * 2001 Nested classes by Francesco Potortì (ideas by Mykola Dzyuba).
*
* Francesco Potortì <address@hidden> has maintained it since 1993.
*/
! char pot_etags_version[] = "@(#) pot revision number is 14.35";
#define TRUE 1
#define FALSE 0
***************
*** 45,56 ****
# define NDEBUG /* disable assert */
#endif
- #if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C))
- # define P_(proto) proto
- #else
- # define P_(proto) ()
- #endif
-
#ifdef HAVE_CONFIG_H
# include <config.h>
/* On some systems, Emacs defines static as nothing for the sake
--- 46,51 ----
***************
*** 58,67 ****
# undef static
# define ETAGS_REGEXPS /* use the regexp features */
# define LONG_OPTIONS /* accept long options */
#else
! # ifndef __STDC__
! # define static /* remove static for old compilers' sake */
! # define const /* same for const */
# endif
#endif /* !HAVE_CONFIG_H */
--- 53,72 ----
# undef static
# define ETAGS_REGEXPS /* use the regexp features */
# define LONG_OPTIONS /* accept long options */
+ # ifndef PTR /* for Xemacs */
+ # define PTR void *
+ # endif
+ # ifndef __P /* for Xemacs */
+ # define __P(args) args
+ # endif
#else
! # if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C))
! # define __P(args) args /* use prototypes */
! # define PTR void * /* for generic pointers */
! # else
! # define __P(args) () /* no prototypes */
! # define const /* remove const for old compilers' sake */
! # define PTR long * /* don't use void* */
# endif
#endif /* !HAVE_CONFIG_H */
***************
*** 217,225 ****
(char *) (op), (n) * sizeof (Type)))
#endif
! typedef int bool;
! typedef void Lang_function P_((FILE *));
typedef struct
{
--- 222,230 ----
(char *) (op), (n) * sizeof (Type)))
#endif
! #define bool int
! typedef void Lang_function __P((FILE *));
typedef struct
{
***************
*** 265,347 ****
/* Many compilers barf on this:
Lang_function Ada_funcs;
so let's write it this way */
! static void Ada_funcs P_((FILE *));
! static void Asm_labels P_((FILE *));
! static void C_entries P_((int c_ext, FILE *));
! static void default_C_entries P_((FILE *));
! static void plain_C_entries P_((FILE *));
! static void Cjava_entries P_((FILE *));
! static void Cobol_paragraphs P_((FILE *));
! static void Cplusplus_entries P_((FILE *));
! static void Cstar_entries P_((FILE *));
! static void Erlang_functions P_((FILE *));
! static void Fortran_functions P_((FILE *));
! static void Yacc_entries P_((FILE *));
! static void Lisp_functions P_((FILE *));
! static void Makefile_targets P_((FILE *));
! static void Pascal_functions P_((FILE *));
! static void Perl_functions P_((FILE *));
! static void PHP_functions P_((FILE *));
! static void Postscript_functions P_((FILE *));
! static void Prolog_functions P_((FILE *));
! static void Python_functions P_((FILE *));
! static void Scheme_functions P_((FILE *));
! static void TeX_commands P_((FILE *));
! static void Texinfo_nodes P_((FILE *));
! static void just_read_file P_((FILE *));
!
! static void print_language_names P_((void));
! static void print_version P_((void));
! static void print_help P_((void));
! int main P_((int, char **));
! static int number_len P_((long));
!
! static compressor *get_compressor_from_suffix P_((char *, char **));
! static language *get_language_from_langname P_((char *));
! static language *get_language_from_interpreter P_((char *));
! static language *get_language_from_filename P_((char *));
! static int total_size_of_entries P_((node *));
! static long readline P_((linebuffer *, FILE *));
! static long readline_internal P_((linebuffer *, FILE *));
! static void get_tag P_((char *));
#ifdef ETAGS_REGEXPS
! static void analyse_regex P_((char *, bool));
! static void add_regex P_((char *, bool, language *));
! static void free_patterns P_((void));
#endif /* ETAGS_REGEXPS */
! static void error P_((const char *, const char *));
! static void suggest_asking_for_help P_((void));
! void fatal P_((char *, char *));
! static void pfatal P_((char *));
! static void add_node P_((node *, node **));
!
! static void init P_((void));
! static void initbuffer P_((linebuffer *));
! static void find_entries P_((char *, FILE *));
! static void free_tree P_((node *));
! static void pfnote P_((char *, bool, char *, int, int, long));
! static void new_pfnote P_((char *, int, bool, char *, int, int, long));
! static void process_file P_((char *));
! static void put_entries P_((node *));
! static void takeprec P_((void));
!
! static char *concat P_((char *, char *, char *));
! static char *skip_spaces P_((char *));
! static char *skip_non_spaces P_((char *));
! static char *savenstr P_((char *, int));
! static char *savestr P_((char *));
! static char *etags_strchr P_((const char *, int));
! static char *etags_strrchr P_((const char *, int));
! static char *etags_getcwd P_((void));
! static char *relative_filename P_((char *, char *));
! static char *absolute_filename P_((char *, char *));
! static char *absolute_dirname P_((char *, char *));
! static bool filename_is_absolute P_((char *f));
! static void canonicalize_filename P_((char *));
! static void linebuffer_setlen P_((linebuffer *, int));
! long *xmalloc P_((unsigned int));
! long *xrealloc P_((char *, unsigned int));
char searchar = '/'; /* use /.../ searches */
--- 270,352 ----
/* Many compilers barf on this:
Lang_function Ada_funcs;
so let's write it this way */
! static void Ada_funcs __P((FILE *));
! static void Asm_labels __P((FILE *));
! static void C_entries __P((int c_ext, FILE *));
! static void default_C_entries __P((FILE *));
! static void plain_C_entries __P((FILE *));
! static void Cjava_entries __P((FILE *));
! static void Cobol_paragraphs __P((FILE *));
! static void Cplusplus_entries __P((FILE *));
! static void Cstar_entries __P((FILE *));
! static void Erlang_functions __P((FILE *));
! static void Fortran_functions __P((FILE *));
! static void Yacc_entries __P((FILE *));
! static void Lisp_functions __P((FILE *));
! static void Makefile_targets __P((FILE *));
! static void Pascal_functions __P((FILE *));
! static void Perl_functions __P((FILE *));
! static void PHP_functions __P((FILE *));
! static void Postscript_functions __P((FILE *));
! static void Prolog_functions __P((FILE *));
! static void Python_functions __P((FILE *));
! static void Scheme_functions __P((FILE *));
! static void TeX_commands __P((FILE *));
! static void Texinfo_nodes __P((FILE *));
! static void just_read_file __P((FILE *));
!
! static void print_language_names __P((void));
! static void print_version __P((void));
! static void print_help __P((void));
! int main __P((int, char **));
! static int number_len __P((long));
!
! static compressor *get_compressor_from_suffix __P((char *, char **));
! static language *get_language_from_langname __P((const char *));
! static language *get_language_from_interpreter __P((char *));
! static language *get_language_from_filename __P((char *));
! static int total_size_of_entries __P((node *));
! static long readline __P((linebuffer *, FILE *));
! static long readline_internal __P((linebuffer *, FILE *));
! static bool nocase_tail __P((char *));
! static char *get_tag __P((char *));
#ifdef ETAGS_REGEXPS
! static void analyse_regex __P((char *, bool));
! static void add_regex __P((char *, bool, language *));
! static void free_patterns __P((void));
#endif /* ETAGS_REGEXPS */
! static void error __P((const char *, const char *));
! static void suggest_asking_for_help __P((void));
! void fatal __P((char *, char *));
! static void pfatal __P((char *));
! static void add_node __P((node *, node **));
!
! static void init __P((void));
! static void initbuffer __P((linebuffer *));
! static void find_entries __P((char *, FILE *));
! static void free_tree __P((node *));
! static void pfnote __P((char *, bool, char *, int, int, long));
! static void new_pfnote __P((char *, int, bool, char *, int, int, long));
! static void process_file __P((char *));
! static void put_entries __P((node *));
!
! static char *concat __P((char *, char *, char *));
! static char *skip_spaces __P((char *));
! static char *skip_non_spaces __P((char *));
! static char *savenstr __P((char *, int));
! static char *savestr __P((char *));
! static char *etags_strchr __P((const char *, int));
! static char *etags_strrchr __P((const char *, int));
! static char *etags_getcwd __P((void));
! static char *relative_filename __P((char *, char *));
! static char *absolute_filename __P((char *, char *));
! static char *absolute_dirname __P((char *, char *));
! static bool filename_is_absolute __P((char *f));
! static void canonicalize_filename __P((char *));
! static void linebuffer_setlen __P((linebuffer *, int));
! PTR xmalloc __P((unsigned int));
! PTR xrealloc __P((char *, unsigned int));
char searchar = '/'; /* use /.../ searches */
***************
*** 370,376 ****
/* white chars */
*white = " \f\t\n\r\v",
/* not in a name */
! *nonam = " \f\t\n\r(=,[;",
/* token ending chars */
*endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
/* token starting chars */
--- 375,381 ----
/* white chars */
*white = " \f\t\n\r\v",
/* not in a name */
! *nonam = " \f\t\n\r()=,;",
/* token ending chars */
*endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
/* token starting chars */
***************
*** 440,448 ****
typedef struct pattern
{
struct pattern *p_next;
! language *language;
char *regex;
! struct re_pattern_buffer *pattern;
struct re_registers regs;
char *name_pattern;
bool error_signaled;
--- 445,453 ----
typedef struct pattern
{
struct pattern *p_next;
! language *lang;
char *regex;
! struct re_pattern_buffer *pat;
struct re_registers regs;
char *name_pattern;
bool error_signaled;
***************
*** 1289,1295 ****
*/
static language *
get_language_from_langname (name)
! char *name;
{
language *lang;
--- 1294,1300 ----
*/
static language *
get_language_from_langname (name)
! const char *name;
{
language *lang;
***************
*** 1702,1708 ****
* also be one of the characters " \t(),;".
*
* The real implementation uses the notinname() macro, which recognises
! * characters slightly different form " \t\r\n(),;". See the variable
* `nonam'.
*/
#define traditional_tag_style TRUE
--- 1707,1713 ----
* also be one of the characters " \t(),;".
*
* The real implementation uses the notinname() macro, which recognises
! * characters slightly different from " \t\r\n(),;". See the variable
* `nonam'.
*/
#define traditional_tag_style TRUE
***************
*** 1965,1973 ****
st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef,
st_C_typespec
};
! static unsigned int hash P_((const char *, unsigned int));
! static struct C_stab_entry * in_word_set P_((const char *, unsigned int));
! static enum sym_type C_symtype P_((char *, int, int));
/* Feed stuff between (but not including) %[ and %] lines to:
gperf -c -k 1,3 -o -p -r -t
--- 1970,1978 ----
st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef,
st_C_typespec
};
! static unsigned int hash __P((const char *, unsigned int));
! static struct C_stab_entry * in_word_set __P((const char *, unsigned int));
! static enum sym_type C_symtype __P((char *, int, int));
/* Feed stuff between (but not including) %[ and %] lines to:
gperf -c -k 1,3 -o -p -r -t
***************
*** 2315,2323 ****
* Variables and functions for dealing with nested structures.
* Idea by Mykola Dzyuba <address@hidden> (2001)
*/
! static void pushclass_above P_((int, char *, int));
! static void popclass_above P_((int));
! static void write_classname P_((linebuffer *, char *qualifier));
struct {
char **cname; /* nested class names */
--- 2320,2328 ----
* Variables and functions for dealing with nested structures.
* Idea by Mykola Dzyuba <address@hidden> (2001)
*/
! static void pushclass_above __P((int, char *, int));
! static void popclass_above __P((int));
! static void write_classname __P((linebuffer *, char *qualifier));
struct {
char **cname; /* nested class names */
***************
*** 2406,2413 ****
}
! static bool consider_token P_((char *, int, int, int *, int, int, bool *));
! static void make_C_tag P_((bool));
/*
* consider_token ()
--- 2411,2418 ----
}
! static bool consider_token __P((char *, int, int, int *, int, int, bool *));
! static void make_C_tag __P((bool));
/*
* consider_token ()
***************
*** 3607,3615 ****
TRUE); \
)
#define LOOKING_AT(cp, keyword) /* keyword is a constant string */
\
! (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at kyword */
\
! && iswhite((cp)[sizeof(keyword)-1]) /* followed by a blank */
\
! && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip blanks */
/*
* Read a file, but do no processing. This is used to do regexp
--- 3612,3620 ----
TRUE); \
)
#define LOOKING_AT(cp, keyword) /* keyword is a constant string */
\
! (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at keyword */
\
! && notinname ((cp)[sizeof(keyword)-1]) /* end of keyword */ \
! && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip spaces */
/*
* Read a file, but do no processing. This is used to do regexp
***************
*** 3628,3655 ****
/* Fortran parsing */
! static bool tail P_((char *));
! static void takeprec P_((void));
! static void getit P_((FILE *));
!
! static bool
! tail (cp)
! char *cp;
! {
! register int len = 0;
!
! while (*cp != '\0' && lowcase (*cp) == lowcase (dbp[len]))
! cp++, len++;
! if (*cp == '\0' && !intoken (dbp[len]))
! {
! dbp += len;
! return TRUE;
! }
! return FALSE;
! }
static void
! takeprec ()
{
dbp = skip_spaces (dbp);
if (*dbp != '*')
--- 3633,3643 ----
/* Fortran parsing */
! static void F_takeprec __P((void));
! static void F_getit __P((FILE *));
static void
! F_takeprec ()
{
dbp = skip_spaces (dbp);
if (*dbp != '*')
***************
*** 3672,3678 ****
}
static void
! getit (inf)
FILE *inf;
{
register char *cp;
--- 3660,3666 ----
}
static void
! F_getit (inf)
FILE *inf;
{
register char *cp;
***************
*** 3712,3739 ****
switch (lowcase (*dbp))
{
case 'i':
! if (tail ("integer"))
! takeprec ();
break;
case 'r':
! if (tail ("real"))
! takeprec ();
break;
case 'l':
! if (tail ("logical"))
! takeprec ();
break;
case 'c':
! if (tail ("complex") || tail ("character"))
! takeprec ();
break;
case 'd':
! if (tail ("double"))
{
dbp = skip_spaces (dbp);
if (*dbp == '\0')
continue;
! if (tail ("precision"))
break;
continue;
}
--- 3700,3727 ----
switch (lowcase (*dbp))
{
case 'i':
! if (nocase_tail ("integer"))
! F_takeprec ();
break;
case 'r':
! if (nocase_tail ("real"))
! F_takeprec ();
break;
case 'l':
! if (nocase_tail ("logical"))
! F_takeprec ();
break;
case 'c':
! if (nocase_tail ("complex") || nocase_tail ("character"))
! F_takeprec ();
break;
case 'd':
! if (nocase_tail ("double"))
{
dbp = skip_spaces (dbp);
if (*dbp == '\0')
continue;
! if (nocase_tail ("precision"))
break;
continue;
}
***************
*** 3745,3770 ****
switch (lowcase (*dbp))
{
case 'f':
! if (tail ("function"))
! getit (inf);
continue;
case 's':
! if (tail ("subroutine"))
! getit (inf);
continue;
case 'e':
! if (tail ("entry"))
! getit (inf);
continue;
case 'b':
! if (tail ("blockdata") || tail ("block data"))
{
dbp = skip_spaces (dbp);
if (*dbp == '\0') /* assume un-named */
pfnote (savestr ("blockdata"), TRUE,
lb.buffer, dbp - lb.buffer, lineno, linecharno);
else
! getit (inf); /* look for name */
}
continue;
}
--- 3733,3758 ----
switch (lowcase (*dbp))
{
case 'f':
! if (nocase_tail ("function"))
! F_getit (inf);
continue;
case 's':
! if (nocase_tail ("subroutine"))
! F_getit (inf);
continue;
case 'e':
! if (nocase_tail ("entry"))
! F_getit (inf);
continue;
case 'b':
! if (nocase_tail ("blockdata") || nocase_tail ("block data"))
{
dbp = skip_spaces (dbp);
if (*dbp == '\0') /* assume un-named */
pfnote (savestr ("blockdata"), TRUE,
lb.buffer, dbp - lb.buffer, lineno, linecharno);
else
! F_getit (inf); /* look for name */
}
continue;
}
***************
*** 3774,3788 ****
/*
* Ada parsing
* Philippe Waroquiers <address@hidden> (1998)
*/
! static void adagetit P_((FILE *, char *));
/* Once we are positioned after an "interesting" keyword, let's get
the real tag value necessary. */
static void
! adagetit (inf, name_qualifier)
FILE *inf;
char *name_qualifier;
{
--- 3762,3777 ----
/*
* Ada parsing
+ * Original code by
* Philippe Waroquiers <address@hidden> (1998)
*/
! static void Ada_getit __P((FILE *, char *));
/* Once we are positioned after an "interesting" keyword, let's get
the real tag value necessary. */
static void
! Ada_getit (inf, name_qualifier)
FILE *inf;
char *name_qualifier;
{
***************
*** 3801,3811 ****
charno += readline (&lb, inf);
dbp = lb.buffer;
}
! switch (*dbp)
{
case 'b':
! case 'B':
! if (tail ("body"))
{
/* Skipping body of procedure body or package body or ....
resetting qualifier to body instead of spec. */
--- 3790,3799 ----
charno += readline (&lb, inf);
dbp = lb.buffer;
}
! switch (lowcase(*dbp))
{
case 'b':
! if (nocase_tail ("body"))
{
/* Skipping body of procedure body or package body or ....
resetting qualifier to body instead of spec. */
***************
*** 3814,3822 ****
}
break;
case 't':
- case 'T':
/* Skipping type of task type or protected type ... */
! if (tail ("type"))
continue;
break;
}
--- 3802,3809 ----
}
break;
case 't':
/* Skipping type of task type or protected type ... */
! if (nocase_tail ("type"))
continue;
break;
}
***************
*** 3897,3929 ****
}
/* We are at the beginning of a token. */
! switch (*dbp)
{
case 'f':
! case 'F':
! if (!packages_only && tail ("function"))
! adagetit (inf, "/f");
else
break; /* from switch */
continue; /* advance char */
case 'p':
! case 'P':
! if (!packages_only && tail ("procedure"))
! adagetit (inf, "/p");
! else if (tail ("package"))
! adagetit (inf, "/s");
! else if (tail ("protected")) /* protected type */
! adagetit (inf, "/t");
else
break; /* from switch */
continue; /* advance char */
case 't':
! case 'T':
! if (!packages_only && tail ("task"))
! adagetit (inf, "/k");
! else if (typedefs && !packages_only && tail ("type"))
{
! adagetit (inf, "/t");
while (*dbp != '\0')
dbp += 1;
}
--- 3884,3913 ----
}
/* We are at the beginning of a token. */
! switch (lowcase(*dbp))
{
case 'f':
! if (!packages_only && nocase_tail ("function"))
! Ada_getit (inf, "/f");
else
break; /* from switch */
continue; /* advance char */
case 'p':
! if (!packages_only && nocase_tail ("procedure"))
! Ada_getit (inf, "/p");
! else if (nocase_tail ("package"))
! Ada_getit (inf, "/s");
! else if (nocase_tail ("protected")) /* protected type */
! Ada_getit (inf, "/t");
else
break; /* from switch */
continue; /* advance char */
case 't':
! if (!packages_only && nocase_tail ("task"))
! Ada_getit (inf, "/k");
! else if (typedefs && !packages_only && nocase_tail ("type"))
{
! Ada_getit (inf, "/t");
while (*dbp != '\0')
dbp += 1;
}
***************
*** 3942,3950 ****
/*
- * Bob Weiner, Motorola Inc., 4/3/94
* Unix and microcontroller assembly tag handling
! * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]'
*/
static void
Asm_labels (inf)
--- 3926,3934 ----
/*
* Unix and microcontroller assembly tag handling
! * Labels: /^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]/
! * Idea by Bob Weiner, Motorola Inc. (1994)
*/
static void
Asm_labels (inf)
***************
*** 3975,4014 ****
/*
* Perl support
! * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/
* Perl variable names: /^(my|local).../
! * Bart Robinson <address@hidden> (1995)
! * Michael Ernst <address@hidden> (1997)
*/
static void
Perl_functions (inf)
FILE *inf;
{
register char *cp;
LOOP_ON_INPUT_LINES (inf, lb, cp)
{
! if (LOOKING_AT (cp, "sub"))
{
! if (*cp != '\0')
! {
! char *sp = cp;
! while (*cp != '\0'
! && !iswhite (*cp) && *cp != '{' && *cp != '(')
! cp++;
! pfnote (savenstr (sp, cp-sp), TRUE,
! lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
! }
}
else if (globals /* only if tagging global vars is
enabled */
! && ((strneq (cp, "my", 2) && (cp+=2))
! || (strneq (cp, "local", 5) && (cp+=5)))
! && (*cp == '(' || iswhite (*cp)))
{
/* After "my" or "local", but before any following paren or space. */
char *varname = NULL;
- cp = skip_spaces (cp);
if (*cp == '$' || *cp == '@' || *cp == '%')
{
char* varstart = ++cp;
--- 3959,4015 ----
/*
* Perl support
! * Perl sub names: /^sub[ \t\n]+[^ \t\n{]+/
* Perl variable names: /^(my|local).../
! * Original code by Bart Robinson <address@hidden> (1995)
! * Additions by Michael Ernst <address@hidden> (1997)
! * Ideas by Kai Großjohann <address@hidden> (2001)
*/
static void
Perl_functions (inf)
FILE *inf;
{
+ char *package = savestr ("main"); /* current package name */
register char *cp;
LOOP_ON_INPUT_LINES (inf, lb, cp)
{
! skip_spaces(cp);
!
! if (LOOKING_AT (cp, "package"))
{
! free (package);
! package = get_tag (cp);
! if (package == NULL) /* can't parse package name */
! package = savestr ("");
! else
! package = savestr(package); /* make a copy */
! }
! else if (LOOKING_AT (cp, "sub"))
! {
! char *name, *fullname, *pos;
! char *sp = cp;
!
! while (!notinname (*cp))
! cp++;
! if (cp == sp)
! continue;
! name = savenstr (sp, cp-sp);
! if ((pos = etags_strchr (name, ':')) != NULL && pos[1] == ':')
! fullname = name;
! else
! fullname = concat (package, "::", name);
! pfnote (fullname, TRUE,
! lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
! if (name != fullname)
! free (name);
}
else if (globals /* only if tagging global vars is
enabled */
! && (LOOKING_AT (cp, "my") || LOOKING_AT (cp, "local")))
{
/* After "my" or "local", but before any following paren or space. */
char *varname = NULL;
if (*cp == '$' || *cp == '@' || *cp == '%')
{
char* varstart = ++cp;
***************
*** 4036,4042 ****
/*
* Python support
* Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
! * Eric S. Raymond <address@hidden> (1997)
*/
static void
Python_functions (inf)
--- 4037,4043 ----
/*
* Python support
* Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
! * Idea by Eric S. Raymond <address@hidden> (1997)
*/
static void
Python_functions (inf)
***************
*** 4047,4053 ****
LOOP_ON_INPUT_LINES (inf, lb, cp)
if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class"))
{
! while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':')
cp++;
pfnote (NULL, TRUE,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
--- 4048,4054 ----
LOOP_ON_INPUT_LINES (inf, lb, cp)
if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class"))
{
! while (!notinname (*cp) && *cp != ':')
cp++;
pfnote (NULL, TRUE,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
***************
*** 4063,4069 ****
* - /^[ \t]*define\(\"[^\"]+/
* Only with --members:
* - /^[ \t]*var[ \t\n]+\$[^ \t\n=;]/
! * originally by Diez B. Roggisch 2001-06-06
*/
static void
PHP_functions (inf)
--- 4064,4070 ----
* - /^[ \t]*define\(\"[^\"]+/
* Only with --members:
* - /^[ \t]*var[ \t\n]+\$[^ \t\n=;]/
! * Idea by Diez B. Roggisch (2001)
*/
static void
PHP_functions (inf)
***************
*** 4078,4084 ****
if (search_identifier
&& *cp != '\0')
{
! while (*cp != '\0' && !iswhite (*cp) && *cp != '(')
cp++;
pfnote (NULL, TRUE,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
--- 4079,4085 ----
if (search_identifier
&& *cp != '\0')
{
! while (!notinname (*cp))
cp++;
pfnote (NULL, TRUE,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
***************
*** 4090,4096 ****
cp = skip_spaces (cp+1);
if(*cp != '\0')
{
! while (*cp != '\0' && !iswhite (*cp) && *cp != '(')
cp++;
pfnote (NULL, TRUE,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
--- 4091,4097 ----
cp = skip_spaces (cp+1);
if(*cp != '\0')
{
! while (!notinname (*cp))
cp++;
pfnote (NULL, TRUE,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
***************
*** 4125,4131 ****
&& LOOKING_AT (cp, "var")
&& *cp == '$')
{
! while (*cp != '=' && *cp != ';' && *cp != '\0' && !iswhite(*cp))
cp++;
pfnote (NULL, FALSE,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
--- 4126,4132 ----
&& LOOKING_AT (cp, "var")
&& *cp == '$')
{
! while (!notinname(*cp))
cp++;
pfnote (NULL, FALSE,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
***************
*** 4134,4143 ****
}
! /* Idea by Corny de Souza
* Cobol tag functions
* We could look for anything that could be a paragraph name.
* i.e. anything that starts in column 8 is one word and ends in a full stop.
*/
static void
Cobol_paragraphs (inf)
--- 4135,4145 ----
}
! /*
* Cobol tag functions
* We could look for anything that could be a paragraph name.
* i.e. anything that starts in column 8 is one word and ends in a full stop.
+ * Idea by Corny de Souza (1993)
*/
static void
Cobol_paragraphs (inf)
***************
*** 4187,4196 ****
}
- /* Added by Mosur Mohan, 4/22/88 */
- /* Pascal parsing */
-
/*
* Locates tags for procedures & functions. Doesn't do any type- or
* var-definitions. It does look for the keyword "extern" or
* "forward" immediately following the procedure statement; if found,
--- 4189,4198 ----
}
/*
+ * Pascal parsing
+ * Original code by Mosur K. Mohan (1989)
+ *
* Locates tags for procedures & functions. Doesn't do any type- or
* var-definitions. It does look for the keyword "extern" or
* "forward" immediately following the procedure statement; if found,
***************
*** 4303,4309 ****
continue;
if (lowcase (*dbp == 'e'))
{
! if (tail ("extern")) /* superfluous, really! */
{
found_tag = FALSE;
verify_tag = FALSE;
--- 4305,4311 ----
continue;
if (lowcase (*dbp == 'e'))
{
! if (nocase_tail ("extern")) /* superfluous, really! */
{
found_tag = FALSE;
verify_tag = FALSE;
***************
*** 4311,4317 ****
}
else if (lowcase (*dbp) == 'f')
{
! if (tail ("forward")) /* check for forward reference */
{
found_tag = FALSE;
verify_tag = FALSE;
--- 4313,4319 ----
}
else if (lowcase (*dbp) == 'f')
{
! if (nocase_tail ("forward")) /* check for forward reference */
{
found_tag = FALSE;
verify_tag = FALSE;
***************
*** 4355,4365 ****
switch (lowcase (c))
{
case 'p':
! if (tail ("rocedure")) /* c = 'p', dbp has advanced */
get_tagname = TRUE;
continue;
case 'f':
! if (tail ("unction"))
get_tagname = TRUE;
continue;
}
--- 4357,4367 ----
switch (lowcase (c))
{
case 'p':
! if (nocase_tail ("rocedure")) /* c = 'p', dbp has advanced */
get_tagname = TRUE;
continue;
case 'f':
! if (nocase_tail ("unction"))
get_tagname = TRUE;
continue;
}
***************
*** 4375,4430 ****
* look for (def or (DEF, quote or QUOTE
*/
! static int L_isdef P_((char *));
! static int L_isquote P_((char *));
! static void L_getit P_((void));
!
! static int
! L_isdef (strp)
! register char *strp;
! {
! return ((strp[1] == 'd' || strp[1] == 'D')
! && (strp[2] == 'e' || strp[2] == 'E')
! && (strp[3] == 'f' || strp[3] == 'F'));
! }
!
! static int
! L_isquote (strp)
! register char *strp;
! {
! return ((*++strp == 'q' || *strp == 'Q')
! && (*++strp == 'u' || *strp == 'U')
! && (*++strp == 'o' || *strp == 'O')
! && (*++strp == 't' || *strp == 'T')
! && (*++strp == 'e' || *strp == 'E')
! && iswhite (*++strp));
! }
static void
L_getit ()
{
- register char *cp;
-
if (*dbp == '\'') /* Skip prefix quote */
dbp++;
else if (*dbp == '(')
{
! if (L_isquote (dbp))
! dbp += 7; /* Skip "(quote " */
! else
! dbp += 1; /* Skip "(" before name in (defstruct
(foo)) */
! dbp = skip_spaces (dbp);
}
!
! for (cp = dbp /*+1*/;
! *cp != '\0' && *cp != '(' && !iswhite(*cp) && *cp != ')';
! cp++)
! continue;
! if (cp == dbp)
! return;
!
! pfnote (savenstr (dbp, cp-dbp), TRUE,
! lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
}
static void
--- 4377,4398 ----
* look for (def or (DEF, quote or QUOTE
*/
! static void L_getit __P((void));
static void
L_getit ()
{
if (*dbp == '\'') /* Skip prefix quote */
dbp++;
else if (*dbp == '(')
{
! dbp++;
! /* Try to skip "(quote " */
! if (!LOOKING_AT (dbp, "quote") && !LOOKING_AT (dbp, "QUOTE"))
! /* Ok, then skip "(" before name in (defstruct (foo)) */
! dbp = skip_spaces (dbp);
}
! get_tag (dbp);
}
static void
***************
*** 4433,4465 ****
{
LOOP_ON_INPUT_LINES (inf, lb, dbp)
{
! if (dbp[0] == '(')
{
! if (L_isdef (dbp))
! {
! dbp = skip_non_spaces (dbp);
! dbp = skip_spaces (dbp);
! L_getit ();
! }
! else
{
- /* Check for (foo::defmumble name-defined ... */
do
dbp++;
! while (*dbp != '\0' && !iswhite (*dbp)
! && *dbp != ':' && *dbp != '(' && *dbp != ')');
! if (*dbp == ':')
! {
! do
! dbp++;
! while (*dbp == ':');
! if (L_isdef (dbp - 1))
! {
! dbp = skip_non_spaces (dbp);
! dbp = skip_spaces (dbp);
! L_getit ();
! }
}
}
}
--- 4401,4432 ----
{
LOOP_ON_INPUT_LINES (inf, lb, dbp)
{
! if (dbp[0] != '(')
! continue;
!
! if (strneq (dbp+1, "def", 3) || strneq (dbp+1, "DEF", 3))
{
! dbp = skip_non_spaces (dbp);
! dbp = skip_spaces (dbp);
! L_getit ();
! }
! else
! {
! /* Check for (foo::defmumble name-defined ... */
! do
! dbp++;
! while (!notinname (*dbp) && *dbp != ':');
! if (*dbp == ':')
{
do
dbp++;
! while (*dbp == ':');
! if (strneq (dbp, "def", 3) || strneq (dbp, "DEF", 3))
! {
! dbp = skip_non_spaces (dbp);
! dbp = skip_spaces (dbp);
! L_getit ();
}
}
}
***************
*** 4471,4478 ****
* Postscript tag functions
* Just look for lines where the first character is '/'
* Also look at "defineps" for PSWrap
! * Richard Mlynarik <address@hidden> (1997)
! * Ideas by Masatake Yamato <address@hidden> (1999)
*/
static void
Postscript_functions (inf)
--- 4438,4446 ----
* Postscript tag functions
* Just look for lines where the first character is '/'
* Also look at "defineps" for PSWrap
! * Ideas by:
! * Richard Mlynarik <address@hidden> (1997)
! * Masatake Yamato <address@hidden> (1999)
*/
static void
Postscript_functions (inf)
***************
*** 4491,4502 ****
pfnote (savenstr (bp, ep-bp), TRUE,
lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
}
! else if (strneq (bp, "defineps", 8))
! {
! bp = skip_non_spaces (bp);
! bp = skip_spaces (bp);
! get_tag (bp);
! }
}
}
--- 4459,4466 ----
pfnote (savenstr (bp, ep-bp), TRUE,
lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
}
! else if (LOOKING_AT (bp, "defineps"))
! get_tag (bp);
}
}
***************
*** 4504,4512 ****
/*
* Scheme tag functions
* look for (def... xyzzy
! * look for (def... (xyzzy
! * look for (def ... ((...(xyzzy ....
! * look for (set! xyzzy
*/
static void
--- 4468,4477 ----
/*
* Scheme tag functions
* look for (def... xyzzy
! * (def... (xyzzy
! * (def ... ((...(xyzzy ....
! * (set! xyzzy
! * Original code by Ken Haase (1985?)
*/
static void
***************
*** 4517,4530 ****
LOOP_ON_INPUT_LINES (inf, lb, bp)
{
! if (bp[0] == '('
! && (bp[1] == 'D' || bp[1] == 'd')
! && (bp[2] == 'E' || bp[2] == 'e')
! && (bp[3] == 'F' || bp[3] == 'f'))
{
! bp = skip_non_spaces (bp);
/* Skip over open parens and white space */
! while (iswhite (*bp) || *bp == '(')
bp++;
get_tag (bp);
}
--- 4482,4492 ----
LOOP_ON_INPUT_LINES (inf, lb, bp)
{
! if (strneq (bp, "(def", 4) || strneq (bp, "(DEF", 4))
{
! bp = skip_non_spaces (bp+4);
/* Skip over open parens and white space */
! while (notinname (*bp))
bp++;
get_tag (bp);
}
***************
*** 4554,4562 ****
:chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
:part:appendix:entry:index";
! static void TEX_mode P_((FILE *));
! static struct TEX_tabent *TEX_decode_env P_((char *, char *));
! static int TEX_Token P_((char *));
char TEX_esc = '\\';
char TEX_opgrp = '{';
--- 4516,4524 ----
:chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
:part:appendix:entry:index";
! static void TEX_mode __P((FILE *));
! static struct TEX_tabent *TEX_decode_env __P((char *, char *));
! static int TEX_Token __P((char *));
char TEX_esc = '\\';
char TEX_opgrp = '{';
***************
*** 4736,4749 ****
/*
! * Prolog support (rewritten) by Anders Lindgren, Mar. 96
*
! * Assumes that the predicate starts at column 0.
! * Only the first clause of a predicate is added.
! */
! static int prolog_pr P_((char *, char *));
! static void prolog_skip_comment P_((linebuffer *, FILE *));
! static int prolog_atom P_((char *, int));
static void
Prolog_functions (inf)
--- 4698,4713 ----
/*
! * Prolog support
*
! * Assumes that the predicate or rule starts at column 0.
! * Only the first clause of a predicate or rule is added.
! * Original code by Sunichirou Sugou (1989)
! * Rewritten by Anders Lindgren (1996)
! */
! static int prolog_pr __P((char *, char *));
! static void prolog_skip_comment __P((linebuffer *, FILE *));
! static int prolog_atom __P((char *, int));
static void
Prolog_functions (inf)
***************
*** 4767,4774 ****
prolog_skip_comment (&lb, inf);
else if ((len = prolog_pr (cp, last)) > 0)
{
! /* Predicate. Store the function name so that we only
! generate a tag for the first clause. */
if (last == NULL)
last = xnew(len + 1, char);
else if (len + 1 > allocated)
--- 4731,4738 ----
prolog_skip_comment (&lb, inf);
else if ((len = prolog_pr (cp, last)) > 0)
{
! /* Predicate or rule. Store the function name so that we
! only generate a tag for the first clause. */
if (last == NULL)
last = xnew(len + 1, char);
else if (len + 1 > allocated)
***************
*** 4900,4914 ****
/*
! * Support for Erlang -- Anders Lindgren, Feb 1996.
*
* Generates tags for functions, defines, and records.
- *
* Assumes that Erlang functions start at column 0.
*/
! static int erlang_func P_((char *, char *));
! static void erlang_attribute P_((char *));
! static int erlang_atom P_((char *, int));
static void
Erlang_functions (inf)
--- 4864,4878 ----
/*
! * Support for Erlang
*
* Generates tags for functions, defines, and records.
* Assumes that Erlang functions start at column 0.
+ * Original code by Anders Lindgren (1996)
*/
! static int erlang_func __P((char *, char *));
! static void erlang_attribute __P((char *));
! static int erlang_atom __P((char *, int));
static void
Erlang_functions (inf)
***************
*** 5010,5018 ****
int pos;
int len;
! if (strneq (s, "-define", 7) || strneq (s, "-record", 7))
{
- pos = skip_spaces (s + 7) - s;
if (s[pos++] == '(')
{
pos = skip_spaces (s + pos) - s;
--- 4974,4981 ----
int pos;
int len;
! if (LOOKING_AT (s, "-define") || LOOKING_AT (s, "-record"))
{
if (s[pos++] == '(')
{
pos = skip_spaces (s + pos) - s;
***************
*** 5079,5088 ****
#ifdef ETAGS_REGEXPS
! static char *scan_separators P_((char *));
! static void analyse_regex P_((char *, bool));
! static void add_regex P_((char *, bool, language *));
! static char *substitute P_((char *, char *, struct re_registers *));
/* Take a string like "/blah/" and turn it into "blah", making sure
that the first and last characters are the same, and handling
--- 5042,5051 ----
#ifdef ETAGS_REGEXPS
! static char *scan_separators __P((char *));
! static void analyse_regex __P((char *, bool));
! static void add_regex __P((char *, bool, language *));
! static char *substitute __P((char *, char *, struct re_registers *));
/* Take a string like "/blah/" and turn it into "blah", making sure
that the first and last characters are the same, and handling
***************
*** 5244,5251 ****
p_head = xnew (1, pattern);
p_head->regex = savestr (regexp_pattern);
p_head->p_next = pp;
! p_head->language = lang;
! p_head->pattern = patbuf;
p_head->name_pattern = savestr (name);
p_head->error_signaled = FALSE;
}
--- 5207,5214 ----
p_head = xnew (1, pattern);
p_head->regex = savestr (regexp_pattern);
p_head->p_next = pp;
! p_head->lang = lang;
! p_head->pat = patbuf;
p_head->name_pattern = savestr (name);
p_head->error_signaled = FALSE;
}
***************
*** 5318,5338 ****
#endif /* ETAGS_REGEXPS */
! static void
get_tag (bp)
register char *bp;
{
! register char *cp;
if (*bp == '\0')
! return;
/* Go till you get to white space or a syntactic break */
! for (cp = bp + 1;
! *cp != '\0' && *cp != '(' && *cp != ')' && !iswhite (*cp);
! cp++)
continue;
! pfnote (savenstr (bp, cp-bp), TRUE,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
}
/* Initialize a linebuffer for use */
--- 5281,5317 ----
#endif /* ETAGS_REGEXPS */
! static bool
! nocase_tail (cp)
! char *cp;
! {
! register int len = 0;
!
! while (*cp != '\0' && lowcase (*cp) == lowcase (dbp[len]))
! cp++, len++;
! if (*cp == '\0' && !intoken (dbp[len]))
! {
! dbp += len;
! return TRUE;
! }
! return FALSE;
! }
!
! static char *
get_tag (bp)
register char *bp;
{
! register char *cp, *name;
if (*bp == '\0')
! return NULL;
/* Go till you get to white space or a syntactic break */
! for (cp = bp + 1; !notinname (*cp); cp++)
continue;
! name = savenstr (bp, cp-bp);
! pfnote (name, TRUE,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
+ return name;
}
/* Initialize a linebuffer for use */
***************
*** 5436,5445 ****
for (pp = p_head; pp != NULL; pp = pp->p_next)
{
/* Only use generic regexps or those for the current language. */
! if (pp->language != NULL && pp->language != curlang)
continue;
! match = re_match (pp->pattern, lbp->buffer, lbp->len, 0, &pp->regs);
switch (match)
{
case -2:
--- 5415,5424 ----
for (pp = p_head; pp != NULL; pp = pp->p_next)
{
/* Only use generic regexps or those for the current language. */
! if (pp->lang != NULL && pp->lang != curlang)
continue;
! match = re_match (pp->pat, lbp->buffer, lbp->len, 0, &pp->regs);
switch (match)
{
case -2:
***************
*** 5847,5868 ****
}
/* Like malloc but get fatal error if memory is exhausted. */
! long *
xmalloc (size)
unsigned int size;
{
! long *result = (long *) malloc (size);
if (result == NULL)
fatal ("virtual memory exhausted", (char *)NULL);
return result;
}
! long *
xrealloc (ptr, size)
char *ptr;
unsigned int size;
{
! long *result = (long *) realloc (ptr, size);
if (result == NULL)
fatal ("virtual memory exhausted", (char *)NULL);
return result;
--- 5826,5847 ----
}
/* Like malloc but get fatal error if memory is exhausted. */
! PTR
xmalloc (size)
unsigned int size;
{
! PTR result = (PTR) malloc (size);
if (result == NULL)
fatal ("virtual memory exhausted", (char *)NULL);
return result;
}
! PTR
xrealloc (ptr, size)
char *ptr;
unsigned int size;
{
! PTR result = (PTR) realloc (ptr, size);
if (result == NULL)
fatal ("virtual memory exhausted", (char *)NULL);
return result;
***************
*** 5873,5878 ****
* c-indentation-style: gnu
* indent-tabs-mode: t
* tab-width: 8
! * c-font-lock-extra-types: ("FILE" "bool" "linebuffer")
* End:
*/
--- 5852,5857 ----
* c-indentation-style: gnu
* indent-tabs-mode: t
* tab-width: 8
! * c-font-lock-extra-types: ("FILE" "bool" "language" "linebuffer")
* End:
*/