--- ctags-5.5.4-orig/entry.c 2004-03-24 05:28:52 +0300 +++ ctags-5.5.4-orig/entry.c 2005-09-14 14:13:24 +0400 @@ -547,8 +547,15 @@ extern void endEtagsFile (const char *const name) { const char *line; + const char *file = name; + size_t buildRootLen = Option.buildRoot ? strlen (Option.buildRoot) : 0; - fprintf (TagFile.fp, "\f\n%s,%ld\n", name, (long) TagFile.etags.byteCount); + if (Option.buildRoot && + strncmp (file, Option.buildRoot, buildRootLen) == 0 && + isPathSeparator (name[buildRootLen])) + file += buildRootLen; + + fprintf (TagFile.fp, "\f\n%s,%ld\n", file, (long) TagFile.etags.byteCount); if (TagFile.etags.fp != NULL) { rewind (TagFile.etags.fp); @@ -825,13 +832,20 @@ extern void initTagEntry (tagEntryInfo *const e, const char *const name) { + const char *file = getSourceFileTagPath (); + size_t buildRootLen = Option.buildRoot ? strlen (Option.buildRoot) : 0; + Assert (File.source.name != NULL); memset (e, 0, sizeof (tagEntryInfo)); e->lineNumberEntry = (boolean) (Option.locate == EX_LINENUM); e->lineNumber = getSourceLineNumber (); e->language = getSourceLanguageName (); e->filePosition = getInputFilePosition (); - e->sourceFileName = getSourceFileTagPath (); + if (Option.buildRoot && + strncmp (file, Option.buildRoot, buildRootLen) == 0 && + isPathSeparator (file[buildRootLen])) + file += buildRootLen; + e->sourceFileName = file; e->name = name; } --- ctags-5.5.4-orig/options.c 2004-02-28 18:19:45 +0300 +++ ctags-5.5.4-orig/options.c 2005-09-14 13:57:12 +0400 @@ -147,6 +147,7 @@ FALSE, /* --tag-relative */ FALSE, /* --totals */ FALSE, /* --line-directives */ + NULL, /* --buildroot */ #ifdef DEBUG 0, 0 /* -D, -b */ #endif @@ -267,6 +268,8 @@ {0," Should paths be relative to location of tag file [no; yes when -e]?"}, {1," --totals=[yes|no]"}, {1," Print statistics about source and tag files [no]."}, + {1," --buildroot=path"}, + {1," Base directory to strip from file names."}, {1," --verbose=[yes|no]"}, {1," Enable verbose messages describing actions on each source file."}, {1," --version"}, @@ -859,6 +862,15 @@ } } +static void processBuildrootOption ( + const char *const option, const char *const parameter) +{ + freeString (&Option.buildRoot); + if (! isAbsolutePath(parameter)) + error (FATAL, "Value for \"%s\" must be absolute path",option); + Option.buildRoot = stringCopy (parameter); +} + static void processFilterTerminatorOption ( const char *const option __unused__, const char *const parameter) { @@ -1362,6 +1374,7 @@ */ static parametricOption ParametricOptions [] = { + { "buildroot", processBuildrootOption, TRUE }, { "etags-include", processEtagsInclude, FALSE }, { "exclude", processExcludeOption, FALSE }, { "excmd", processExcmdOption, FALSE }, @@ -1767,6 +1780,7 @@ freeString (&Option.tagFileName); freeString (&Option.fileList); freeString (&Option.filterTerminator); + freeString (&Option.buildRoot); freeList (&Excluded); freeList (&Option.ignore); --- ctags-5.5.4-orig/options.h 2003-07-21 05:09:08 +0400 +++ ctags-5.5.4-orig/options.h 2005-09-14 13:57:12 +0400 @@ -107,6 +107,7 @@ boolean tagRelative; /* --tag-relative file paths relative to tag file */ boolean printTotals; /* --totals print cumulative statistics */ boolean lineDirectives; /* --linedirectives process #line directives */ + char *buildRoot; /* --buildroot file prefix */ #ifdef DEBUG long debugLevel; /* -D debugging output */ unsigned long breakLine;/* -b source line at which to call lineBreak() */ --- ctags-5.5.4-orig/routines.c 2003-10-31 07:15:35 +0300 +++ ctags-5.5.4-orig/routines.c 2005-09-14 14:12:05 +0400 @@ -504,7 +504,7 @@ * Pathname manipulation (O/S dependent!!!) */ -static boolean isPathSeparator (const int c) +extern boolean isPathSeparator (const int c) { boolean result; #if defined (MSDOS_STYLE_PATH) || defined (VMS) --- ctags-5.5.4-orig/routines.h 2003-10-13 06:35:45 +0400 +++ ctags-5.5.4-orig/routines.h 2005-09-14 14:12:08 +0400 @@ -118,6 +118,7 @@ extern int fgetpos (FILE *stream, fpos_t *pos); extern int fsetpos (FILE *stream, fpos_t *pos); #endif +extern boolean isPathSeparator (const int c); extern const char *baseFilename (const char *const filePath); extern const char *fileExtension (const char *const fileName); extern boolean isAbsolutePath (const char *const path);