Copyright (C) 1984, 1987, 1988, 1989, 1993, 1994, 1995, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is not considered part of GNU Emacs.
/*
* Authors:
- * 1983 Ctags originally by Ken Arnold.
- * 1984 Fortran added by Jim Kleckner.
- * 1984 Ed Pelegri-Llopart added C typedefs.
- * 1985 Emacs TAGS format by Richard Stallman.
- * 1989 Sam Kendall added C++.
+ * 1983 Ctags originally by Ken Arnold.
+ * 1984 Fortran added by Jim Kleckner.
+ * 1984 Ed Pelegri-Llopart added C typedefs.
+ * 1985 Emacs TAGS format by Richard Stallman.
+ * 1989 Sam Kendall added C++.
* 1992 Joseph B. Wells improved C and C++ parsing.
- * 1993 Francesco Potortì reorganized C and C++.
- * 1994 Line-by-line regexp tags by Tom Tromey.
+ * 1993 Francesco Potortì reorganized C and C++.
+ * 1994 Line-by-line regexp tags by Tom Tromey.
* 2001 Nested classes by Francesco Potortì (concept by Mykola Dzyuba).
* 2002 #line directives by Francesco Potortì.
*
/*
* If you want to add support for a new language, start by looking at the LUA
- * language, which is the simplest. Alternatively, consider shipping a
- * configuration file containing regexp definitions for etags.
+ * language, which is the simplest. Alternatively, consider distributing etags
+ * together with a configuration file containing regexp definitions for etags.
*/
-char pot_etags_version[] = "@(#) pot revision number is 17.38";
+char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
#define TRUE 1
#define FALSE 0
# define EMACS_NAME "standalone"
#endif
#ifndef VERSION
-# define VERSION "17.38"
+# define VERSION "17.38.1.4"
#endif
static void
print_version ()
{
/* Makes it easier to update automatically. */
- char emacs_copyright[] = "Copyright (C) 2008 Free Software Foundation, Inc.";
+ char emacs_copyright[] = "Copyright (C) 2009 Free Software Foundation, Inc.";
printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION);
puts (emacs_copyright);
}
if (tagfile == NULL)
- tagfile = CTAGS ? "tags" : "TAGS";
+ tagfile = savestr (CTAGS ? "tags" : "TAGS");
cwd = etags_getcwd (); /* the current working directory */
if (cwd[strlen (cwd) - 1] != '/')
{
cwd = concat (oldcwd, "/", "");
free (oldcwd);
}
- /* Relative file names are made relative to the current directory. */
+
+ /* Compute base directory for relative file names. */
if (streq (tagfile, "-")
|| strneq (tagfile, "/dev/", 5))
- tagfiledir = cwd;
+ tagfiledir = cwd; /* relative file names are relative to cwd */
else
- tagfiledir = absolute_dirname (tagfile, cwd);
+ {
+ canonicalize_filename (tagfile);
+ tagfiledir = absolute_dirname (tagfile, cwd);
+ }
init (); /* set up boolean "functions" */
compressor *compr;
char *slash, *suffix;
- /* This relies on FN to be after canonicalize_filename,
+ /* File has been processed by canonicalize_filename,
so we don't need to consider backslashes on DOS_NT. */
slash = etags_strrchr (file, '/');
suffix = etags_strrchr (file, '.');
else
re_set_syntax (RE_SYNTAX_EMACS);
- err = re_compile_pattern (pat, strlen (regexp_pattern), patbuf);
+ err = re_compile_pattern (pat, strlen (pat), patbuf);
if (multi_line)
free (pat);
if (err != NULL)
discard_until_line_directive = FALSE; /* found it */
name = lbp->buffer + start;
*endp = '\0';
- canonicalize_filename (name); /* for DOS */
+ canonicalize_filename (name);
taggedabsname = absolute_filename (name, tagfiledir);
if (filename_is_absolute (name)
|| filename_is_absolute (curfdp->infname))
/* Build a sequence of "../" strings for the resulting relative file name. */
i = 0;
- while (*dp == '/')
- ++dp;
while ((dp = etags_strchr (dp + 1, '/')) != NULL)
- {
- i += 1;
- while (*dp == '/')
- ++dp;
- }
+ i += 1;
res = xnew (3*i + strlen (fp + 1) + 1, char);
res[0] = '\0';
while (i-- > 0)
char *slashp, *res;
char save;
- canonicalize_filename (file);
slashp = etags_strrchr (file, '/');
if (slashp == NULL)
return savestr (dir);
);
}
-/* Translate backslashes into slashes. Works in place. */
+/* Upcase DOS drive letter and collapse separators into single slashes.
+ Works in place. */
static void
canonicalize_filename (fn)
register char *fn;
{
+ register char* cp;
+ char sep = '/';
+
#ifdef DOS_NT
/* Canonicalize drive letter case. */
if (fn[0] != '\0' && fn[1] == ':' && ISLOWER (fn[0]))
fn[0] = upcase (fn[0]);
- /* Convert backslashes to slashes. */
- for (; *fn != '\0'; fn++)
- if (*fn == '\\')
- *fn = '/';
-#else
- /* No action. */
- fn = NULL; /* shut up the compiler */
+
+ sep = '\\';
#endif
+
+ /* Collapse multiple separators into a single slash. */
+ for (cp = fn; *cp != '\0'; cp++, fn++)
+ if (*cp == sep)
+ {
+ *fn = '/';
+ while (cp[1] == sep)
+ cp++;
+ }
+ else
+ *fn = *cp;
+ *fn = '\0';
}
\f
-/* Initialize a linebuffer for use */
+/* Initialize a linebuffer for use. */
static void
linebuffer_init (lbp)
linebuffer *lbp;