Skip to content

Commit

Permalink
main,win32: introduce an option replacing backslashes in input file n…
Browse files Browse the repository at this point in the history
…ames with slashes

(TODO: documentation)

Suggested by @k-takata in universal-ctags#1325.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Sep 18, 2019
1 parent 126781c commit 151fce1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Tmain/option-use-slash-as-filename-separator.d/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright: 2019 Masatake YAMATO
# License: GPL-2

CTAGS=$1
OPT=--use-slash-as-filename-separator

. ../utils.sh

exit_unless_win32 $CTAGS

$CTAGS --quiet --options=NONE -o - 'src\input.c'
$CTAGS --quiet --options=NONE -o - $OPT 'src\input.c'
1 change: 1 addition & 0 deletions Tmain/option-use-slash-as-filename-separator.d/src/input.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int n;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
n src\\input.c /^int n;$/;" v typeref:typename:int
n src/input.c /^int n;$/;" v typeref:typename:int
14 changes: 14 additions & 0 deletions main/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,20 @@ static void writeTagEntry (const tagEntryInfo *const tag, bool checkingNeeded)

DebugStatement ( debugEntry (tag); )

#ifdef WIN32
if (Option.useSlashAsFilenameSeparator)
{
Assert (((const tagEntryInfo *)tag)->inputFileName);
char *c = ((const tagEntryInfo *)tag)->inputFileName;
while (*c)
{
if (*c == '\\')
*c = '/';
c++;
}
}
#endif

if (includeExtensionFlags ()
&& isXtagEnabled (XTAG_QUALIFIED_TAGS)
&& doesInputLanguageRequestAutomaticFQTag ()
Expand Down
10 changes: 10 additions & 0 deletions main/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ optionValues Option = {
.putFieldPrefix = false,
.maxRecursionDepth = 0xffffffff,
.interactive = false,
#ifdef WIN32
.useSlashAsFilenameSeparator = false,
#endif
#ifdef DEBUG
.breakLine = 0,
#endif
Expand Down Expand Up @@ -416,6 +419,10 @@ static optionDescription LongOptionDescription [] = {
{0," never: be absolute even if input files are passed in with relative paths" },
{1," --totals=[yes|no|extra]"},
{1," Print statistics about input and tag files [no]."},
#ifdef WIN32
{1," --use-slash-as-filename-separator"},
{1," Use slash as filename separator [no]."},
#endif
{1," --verbose=[yes|no]"},
{1," Enable verbose messages describing actions on each input file."},
{1," --version"},
Expand Down Expand Up @@ -2786,6 +2793,9 @@ static booleanOption BooleanOptions [] = {
{ "recurse", &Option.recurse, false, STAGE_ANY },
#endif
{ "verbose", &ctags_verbose, false, STAGE_ANY },
#ifdef WIN32
{ "use-slash-as-filename-separator", &Option.useSlashAsFilenameSeparator, false, STAGE_ANY },
#endif
{ "with-list-header", &localOption.withListHeader, true, STAGE_ANY },
{ "_fatal-warnings",&Option.fatalWarnings, false, STAGE_ANY },
};
Expand Down
3 changes: 3 additions & 0 deletions main/options_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ typedef struct sOptionValues {
enum interactiveMode { INTERACTIVE_NONE = 0,
INTERACTIVE_DEFAULT,
INTERACTIVE_SANDBOX, } interactive; /* --interactive */
#ifdef WIN32
bool useSlashAsFilenameSeparator; /* --use-slash-as-filename-separator */
#endif
#ifdef DEBUG
unsigned long breakLine;/* -b input line at which to call lineBreak() */
#endif
Expand Down

0 comments on commit 151fce1

Please sign in to comment.