Skip to content

Commit 931a12f

Browse files
committed
main,win32: introduce an option replacing backslashes in input file names with slashes
(TODO: documentation) Suggested by @k-takata in #1325. Signed-off-by: Masatake YAMATO <[email protected]>
1 parent 126781c commit 931a12f

File tree

6 files changed

+42
-0
lines changed

6 files changed

+42
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright: 2019 Masatake YAMATO
2+
# License: GPL-2
3+
4+
CTAGS=$1
5+
OPT=--use-slash-as-filename-separator
6+
7+
. ../utils.sh
8+
9+
exit_unless_win32 $CTAGS
10+
11+
$CTAGS --quiet --options=NONE -o - 'src\input.c'
12+
$CTAGS --quiet --options=NONE -o - $OPT 'src\input.c'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int n;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
n src\\input.c /^int n;$/;" v typeref:typename:int
2+
n src/input.c /^int n;$/;" v typeref:typename:int

main/entry.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,20 @@ static void writeTagEntry (const tagEntryInfo *const tag, bool checkingNeeded)
12361236

12371237
DebugStatement ( debugEntry (tag); )
12381238

1239+
#ifdef WIN32
1240+
if (Option.useSlashAsFilenameSeparator)
1241+
{
1242+
Assert (((const tagEntryInfo *)tag)->inputFileName);
1243+
char *c = (char *)(((tagEntryInfo *const)tag)->inputFileName);
1244+
while (*c)
1245+
{
1246+
if (*c == '\\')
1247+
*c = '/';
1248+
c++;
1249+
}
1250+
}
1251+
#endif
1252+
12391253
if (includeExtensionFlags ()
12401254
&& isXtagEnabled (XTAG_QUALIFIED_TAGS)
12411255
&& doesInputLanguageRequestAutomaticFQTag ()

main/options.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ optionValues Option = {
172172
.putFieldPrefix = false,
173173
.maxRecursionDepth = 0xffffffff,
174174
.interactive = false,
175+
#ifdef WIN32
176+
.useSlashAsFilenameSeparator = false,
177+
#endif
175178
#ifdef DEBUG
176179
.breakLine = 0,
177180
#endif
@@ -416,6 +419,10 @@ static optionDescription LongOptionDescription [] = {
416419
{0," never: be absolute even if input files are passed in with relative paths" },
417420
{1," --totals=[yes|no|extra]"},
418421
{1," Print statistics about input and tag files [no]."},
422+
#ifdef WIN32
423+
{1," --use-slash-as-filename-separator"},
424+
{1," Use slash as filename separator [no]."},
425+
#endif
419426
{1," --verbose=[yes|no]"},
420427
{1," Enable verbose messages describing actions on each input file."},
421428
{1," --version"},
@@ -2786,6 +2793,9 @@ static booleanOption BooleanOptions [] = {
27862793
{ "recurse", &Option.recurse, false, STAGE_ANY },
27872794
#endif
27882795
{ "verbose", &ctags_verbose, false, STAGE_ANY },
2796+
#ifdef WIN32
2797+
{ "use-slash-as-filename-separator", &Option.useSlashAsFilenameSeparator, false, STAGE_ANY },
2798+
#endif
27892799
{ "with-list-header", &localOption.withListHeader, true, STAGE_ANY },
27902800
{ "_fatal-warnings",&Option.fatalWarnings, false, STAGE_ANY },
27912801
};

main/options_p.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ typedef struct sOptionValues {
120120
enum interactiveMode { INTERACTIVE_NONE = 0,
121121
INTERACTIVE_DEFAULT,
122122
INTERACTIVE_SANDBOX, } interactive; /* --interactive */
123+
#ifdef WIN32
124+
bool useSlashAsFilenameSeparator; /* --use-slash-as-filename-separator */
125+
#endif
123126
#ifdef DEBUG
124127
unsigned long breakLine;/* -b input line at which to call lineBreak() */
125128
#endif

0 commit comments

Comments
 (0)