View | Details | Raw Unified | Return to bug 7954
Collapse All | Expand All

(-)ctags-5.5.4-orig/entry.c (-2 / +16 lines)
Lines 547-554 Link Here
547
extern void endEtagsFile (const char *const name)
547
extern void endEtagsFile (const char *const name)
548
{
548
{
549
    const char *line;
549
    const char *line;
550
    const char *file = name;
551
    size_t buildRootLen = Option.buildRoot ? strlen (Option.buildRoot) : 0;
550
552
551
    fprintf (TagFile.fp, "\f\n%s,%ld\n", name, (long) TagFile.etags.byteCount);
553
    if (Option.buildRoot &&
554
	strncmp (file, Option.buildRoot, buildRootLen) == 0 &&
555
	isPathSeparator (name[buildRootLen]))
556
	file += buildRootLen;
557
558
    fprintf (TagFile.fp, "\f\n%s,%ld\n", file, (long) TagFile.etags.byteCount);
552
    if (TagFile.etags.fp != NULL)
559
    if (TagFile.etags.fp != NULL)
553
    {
560
    {
554
	rewind (TagFile.etags.fp);
561
	rewind (TagFile.etags.fp);
Lines 825-837 Link Here
825
832
826
extern void initTagEntry (tagEntryInfo *const e, const char *const name)
833
extern void initTagEntry (tagEntryInfo *const e, const char *const name)
827
{
834
{
835
    const char *file = getSourceFileTagPath ();
836
    size_t buildRootLen = Option.buildRoot ? strlen (Option.buildRoot) : 0;
837
828
    Assert (File.source.name != NULL);
838
    Assert (File.source.name != NULL);
829
    memset (e, 0, sizeof (tagEntryInfo));
839
    memset (e, 0, sizeof (tagEntryInfo));
830
    e->lineNumberEntry	= (boolean) (Option.locate == EX_LINENUM);
840
    e->lineNumberEntry	= (boolean) (Option.locate == EX_LINENUM);
831
    e->lineNumber	= getSourceLineNumber ();
841
    e->lineNumber	= getSourceLineNumber ();
832
    e->language		= getSourceLanguageName ();
842
    e->language		= getSourceLanguageName ();
833
    e->filePosition	= getInputFilePosition ();
843
    e->filePosition	= getInputFilePosition ();
834
    e->sourceFileName	= getSourceFileTagPath ();
844
    if (Option.buildRoot &&
845
	strncmp (file, Option.buildRoot, buildRootLen) == 0 &&
846
	isPathSeparator (file[buildRootLen]))
847
	file += buildRootLen;
848
    e->sourceFileName	= file;
835
    e->name		= name;
849
    e->name		= name;
836
}
850
}
837
851
(-)ctags-5.5.4-orig/options.c (+14 lines)
Lines 147-152 Link Here
147
    FALSE,		/* --tag-relative */
147
    FALSE,		/* --tag-relative */
148
    FALSE,		/* --totals */
148
    FALSE,		/* --totals */
149
    FALSE,		/* --line-directives */
149
    FALSE,		/* --line-directives */
150
    NULL,		/* --buildroot */
150
#ifdef DEBUG
151
#ifdef DEBUG
151
    0, 0		/* -D, -b */
152
    0, 0		/* -D, -b */
152
#endif
153
#endif
Lines 267-272 Link Here
267
 {0,"       Should paths be relative to location of tag file [no; yes when -e]?"},
268
 {0,"       Should paths be relative to location of tag file [no; yes when -e]?"},
268
 {1,"  --totals=[yes|no]"},
269
 {1,"  --totals=[yes|no]"},
269
 {1,"       Print statistics about source and tag files [no]."},
270
 {1,"       Print statistics about source and tag files [no]."},
271
 {1,"  --buildroot=path"},
272
 {1,"       Base directory to strip from file names."},
270
 {1,"  --verbose=[yes|no]"},
273
 {1,"  --verbose=[yes|no]"},
271
 {1,"       Enable verbose messages describing actions on each source file."},
274
 {1,"       Enable verbose messages describing actions on each source file."},
272
 {1,"  --version"},
275
 {1,"  --version"},
Lines 859-864 Link Here
859
    }
862
    }
860
}
863
}
861
864
865
static void processBuildrootOption (
866
	const char *const option, const char *const parameter)
867
{
868
    freeString (&Option.buildRoot);
869
    if (! isAbsolutePath(parameter))
870
	error (FATAL, "Value for \"%s\" must be absolute path",option);
871
    Option.buildRoot = stringCopy (parameter);
872
}
873
862
static void processFilterTerminatorOption (
874
static void processFilterTerminatorOption (
863
	const char *const option __unused__, const char *const parameter)
875
	const char *const option __unused__, const char *const parameter)
864
{
876
{
Lines 1362-1367 Link Here
1362
 */
1374
 */
1363
1375
1364
static parametricOption ParametricOptions [] = {
1376
static parametricOption ParametricOptions [] = {
1377
    { "buildroot",		processBuildrootOption,		TRUE	},
1365
    { "etags-include",		processEtagsInclude,		FALSE	},
1378
    { "etags-include",		processEtagsInclude,		FALSE	},
1366
    { "exclude",		processExcludeOption,		FALSE	},
1379
    { "exclude",		processExcludeOption,		FALSE	},
1367
    { "excmd",			processExcmdOption,		FALSE	},
1380
    { "excmd",			processExcmdOption,		FALSE	},
Lines 1767-1772 Link Here
1767
    freeString (&Option.tagFileName);
1780
    freeString (&Option.tagFileName);
1768
    freeString (&Option.fileList);
1781
    freeString (&Option.fileList);
1769
    freeString (&Option.filterTerminator);
1782
    freeString (&Option.filterTerminator);
1783
    freeString (&Option.buildRoot);
1770
1784
1771
    freeList (&Excluded);
1785
    freeList (&Excluded);
1772
    freeList (&Option.ignore);
1786
    freeList (&Option.ignore);
(-)ctags-5.5.4-orig/options.h (+1 lines)
Lines 107-112 Link Here
107
    boolean tagRelative;    /* --tag-relative file paths relative to tag file */
107
    boolean tagRelative;    /* --tag-relative file paths relative to tag file */
108
    boolean printTotals;    /* --totals  print cumulative statistics */
108
    boolean printTotals;    /* --totals  print cumulative statistics */
109
    boolean lineDirectives; /* --linedirectives  process #line directives */
109
    boolean lineDirectives; /* --linedirectives  process #line directives */
110
    char *buildRoot;        /* --buildroot  file prefix */
110
#ifdef DEBUG
111
#ifdef DEBUG
111
    long debugLevel;	    /* -D  debugging output */
112
    long debugLevel;	    /* -D  debugging output */
112
    unsigned long breakLine;/* -b  source line at which to call lineBreak() */
113
    unsigned long breakLine;/* -b  source line at which to call lineBreak() */
(-)ctags-5.5.4-orig/routines.c (-1 / +1 lines)
Lines 504-510 Link Here
504
 *  Pathname manipulation (O/S dependent!!!)
504
 *  Pathname manipulation (O/S dependent!!!)
505
 */
505
 */
506
506
507
static boolean isPathSeparator (const int c)
507
extern boolean isPathSeparator (const int c)
508
{
508
{
509
    boolean result;
509
    boolean result;
510
#if defined (MSDOS_STYLE_PATH) || defined (VMS)
510
#if defined (MSDOS_STYLE_PATH) || defined (VMS)
(-)ctags-5.5.4-orig/routines.h (+1 lines)
Lines 118-123 Link Here
118
extern int fgetpos  (FILE *stream, fpos_t *pos);
118
extern int fgetpos  (FILE *stream, fpos_t *pos);
119
extern int fsetpos  (FILE *stream, fpos_t *pos);
119
extern int fsetpos  (FILE *stream, fpos_t *pos);
120
#endif
120
#endif
121
extern boolean isPathSeparator (const int c);
121
extern const char *baseFilename (const char *const filePath);
122
extern const char *baseFilename (const char *const filePath);
122
extern const char *fileExtension (const char *const fileName);
123
extern const char *fileExtension (const char *const fileName);
123
extern boolean isAbsolutePath (const char *const path);
124
extern boolean isAbsolutePath (const char *const path);

Return to bug 7954