#define streq(s,t) (strcmp (s, t) == 0)
#define strneq(s,t,n) (strncmp (s, t, n) == 0)
+#define lowcase(c) ((c) | ' ')
+
#define iswhite(arg) (_wht[arg]) /* T if char is white */
#define begtoken(arg) (_btk[arg]) /* T if char can start token */
#define intoken(arg) (_itk[arg]) /* T if char can be in token */
Lang_function just_read_file;
#else /* so let's write it this way */
void Asm_labels ();
-void default_C_entries ();
void C_entries ();
+void default_C_entries ();
+void plain_C_entries ();
void Cplusplus_entries ();
void Cstar_entries ();
void Fortran_functions ();
/* Language stuff. */
struct lang_entry
{
- char *extension;
+ char *suffix;
Lang_function *function;
};
{ NULL, NULL }
};
-/* Table of file extensions and corresponding language functions. */
-struct lang_entry lang_extensions[] =
+/* Table of file name suffixes and corresponding language functions. */
+struct lang_entry lang_suffixes[] =
{
/* Assume that ".s" or ".a" is assembly code. -wolfgang.
Or even ".sa". */
{ "t", Scheme_functions },
/* FIXME Can't do the `SCM' or `scm' prefix with a version number */
- /* Note that ".c" and ".h" can be considered C++, if the --c++
- flag was given. That is why default_C_entries is called here. */
+ /* Note that .c and .h can be considered C++, if the --c++ flag was
+ given. That is why default_C_entries is called here. */
{ "c", default_C_entries },
{ "h", default_C_entries },
+ /* .pc is a Pro*C file. */
+ { "pc", plain_C_entries },
+
/* .C or .H or .c++ or .cc or .cpp or .cxx or .h++ or .hh or .hxx:
a C++ file */
{ "C", Cplusplus_entries },
struct lang_entry *name, *ext;
puts ("\nThese are the currently supported languages, along with the\n\
-default extensions for files:");
- for (name = lang_names; name->extension; ++name)
+default file name suffixes:");
+ for (name = lang_names; name->suffix; ++name)
{
- printf ("\t%s\t", name->extension);
- for (ext = lang_extensions; ext->extension; ++ext)
+ printf ("\t%s\t", name->suffix);
+ for (ext = lang_suffixes; ext->suffix; ++ext)
if (name->function == ext->function)
- printf (" .%s", ext->extension);
+ printf (" .%s", ext->suffix);
puts ("");
}
- puts ("Where `auto' means use default language for files based on filename\n\
-extension, and `none' means only do regexp processing on files.\n\
-If no language is specified and no extension is found for some file,\n\
+ puts ("Where `auto' means use default language for files based on file\n\
+name suffix, and `none' means only do regexp processing on files.\n\
+If no language is specified and no matching suffix is found,\n\
Fortran is tried first; if no tags are found, C is tried next.");
}
backward-search command instead of '/', the forward-search command.");
puts ("-C, --c++\n\
- Treat files whose extension defaults to C language as C++ files.");
+ Treat files whose name suffix defaults to C language as C++ files.");
if (CTAGS)
puts ("-d, --defines\n\
{
struct lang_entry *lang;
- for (lang = lang_names; lang->extension; ++lang)
+ for (lang = lang_names; lang->suffix; ++lang)
{
- if (streq (language, lang->extension))
+ if (streq (language, lang->suffix))
{
*func = lang->function;
return TRUE;
if (cp)
{
++cp;
- for (lang = lang_extensions; lang->extension; ++lang)
+ for (lang = lang_suffixes; lang->suffix; ++lang)
{
- if (streq (cp, lang->extension))
+ if (streq (cp, lang->suffix))
{
lang->function (inf);
fclose (inf);
/* Detect GNU macros. */
if (definedef == dnone)
- if (strneq (str, "DEFUN", 5) /* Used in emacs */
+ if (strneq (str, "DEFUN", len) /* Used in emacs */
#if FALSE
These are defined inside C functions, so currently they
are not met anyway.
- || strneq (str, "EXFUN", 5) /* Used in glibc */
+ || strneq (str, "EXFUN", len) /* Used in glibc */
|| strneq (str, "DEFVAR_", 7) /* Used in emacs */
#endif
- || strneq (str, "SYSCALL", 7) /* Used in glibc (mach) */
- || strneq (str, "ENTRY", 5) /* Used in glibc */
- || strneq (str, "PSEUDO", 6)) /* Used in glibc */
+ || strneq (str, "SYSCALL", len) /* Used in glibc (mach) */
+ || strneq (str, "ENTRY", len) /* Used in glibc */
+ || strneq (str, "PSEUDO", len)) /* Used in glibc */
{
next_token_is_func = TRUE;
C_entries (cplusplus ? C_PLPL : 0, inf);
}
+/* Always do plain ANSI C. */
+void
+plain_C_entries (inf)
+ FILE *inf;
+{
+ C_entries (0, inf);
+}
+
/* Always do C++. */
void
Cplusplus_entries (inf)
{
register int len = 0;
- while (*cp && (*cp | ' ') == (dbp[len] | ' '))
+ while (*cp && lowcase(*cp) == lowcase(dbp[len]))
cp++, len++;
- if (*cp == 0)
+ if (*cp == 0 && !intoken(dbp[len]))
{
dbp += len;
return TRUE;
dbp++;
while (isspace (*dbp))
dbp++;
- if (tail ("(*)"))
- return;
+ if (strneq (dbp, "(*)", 3))
+ {
+ dbp += 3;
+ return;
+ }
if (!isdigit (*dbp))
{
--dbp; /* force failure */
dbp++;
if (*dbp == 0)
continue;
- switch (*dbp | ' ')
+ switch (lowcase (*dbp))
{
case 'i':
if (tail ("integer"))
dbp++;
if (*dbp == 0)
continue;
- switch (*dbp | ' ')
+ switch (lowcase (*dbp))
{
case 'f':
if (tail ("function"))
else if (!incomment && !inquote && !found_tag)
{
/* check for proc/fn keywords */
- switch (c | ' ')
+ switch (lowcase (c))
{
case 'p':
if (tail ("rocedure")) /* c = 'p', dbp has advanced */