Skip to content

Commit

Permalink
Merge pull request #1611 from masatake/convert-slash-to-backslash-in-…
Browse files Browse the repository at this point in the history
…exclude-option

Convert slash to backslash in exclude option
  • Loading branch information
masatake authored Dec 19, 2017
2 parents c17ec18 + 8254c60 commit d161653
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Tmain/ptag-kind-desc.d/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

CTAGS=$1

source ../utils.sh
. ../utils.sh

{
echo '# BUILTIN'
Expand Down
5 changes: 5 additions & 0 deletions Tmain/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ exit_if_win32()
is_feature_available $1 '!' win32
}

exit_unless_win32()
{
is_feature_available $1 win32
}

exit_if_no_case_insensitive_filenames()
{
is_feature_available $1 case-insensitive-filenames
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int capture_me_1(void)
{
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int dont_capture_me(void)
{
return 0;
}
4 changes: 4 additions & 0 deletions Tmain/w32-slash-in-exclude-option.d/input.d/input.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int capture_me_0(void)
{
return 0;
}
11 changes: 11 additions & 0 deletions Tmain/w32-slash-in-exclude-option.d/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright: 2017 Masatake YAMATO
# License: GPL-2

CTAGS=$1

. ../utils.sh

exit_unless_win32 "$CTAGS"

MSYS2_ARG_CONV_EXCL=dont_capture_me/input.c ${CTAGS} --quiet --options=NONE -R -o - \
--exclude='input.d/dont_capture_me/input.c' input.d
2 changes: 2 additions & 0 deletions Tmain/w32-slash-in-exclude-option.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
capture_me_0 input.d\\input.c /^int capture_me_0(void)$/;" f typeref:typename:int
capture_me_1 input.d\\capture_me\\input.c /^int capture_me_1(void)$/;" f typeref:typename:int
3 changes: 3 additions & 0 deletions main/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,9 @@ static void processExcludeOption (
else
{
vString *const item = vStringNewInit (parameter);
#if defined (WIN32)
vStringTranslate(item, '\\', '/');
#endif
if (Excluded == NULL)
Excluded = stringListNew ();
stringListAdd (Excluded, item);
Expand Down
15 changes: 14 additions & 1 deletion main/strlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,24 @@ extern vString* stringListFileFinds (
vString* vstr = NULL;
bool matched = false;
unsigned int i;
const char * normalized = fileName;

#if defined (WIN32)
vString *tmp = vStringNewInit (fileName);
vStringTranslate (tmp, '\\', '/');
normalized = vStringValue (tmp);
#endif

for (i = 0 ; ! matched && i < stringListCount (current) ; ++i)
{
vstr = stringListItem (current, i);
matched = fileNameMatched (vstr, fileName);
matched = fileNameMatched (vstr, normalized);
}

#if defined (WIN32) && defined (UNIX_PATH_SEPARATOR)
vStringDelete (tmp);
#endif

return matched? vstr: NULL;
}

Expand Down
9 changes: 9 additions & 0 deletions main/vstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,12 @@ extern vString *vStringNewOrClearWithAutoRelease (vString *const string)

return r;
}

extern void vStringTranslate(vString *const string, char fromC, char toC)
{
for (int i = 0; i < vStringLength(string); i++)
{
if (string->buffer[i] == fromC)
string->buffer[i] = toC;
}
}
1 change: 1 addition & 0 deletions main/vstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ extern void vStringNCopyS (vString *const string, const char *const s, const siz
extern void vStringCopyToLower (vString *const dest, const vString *const src);
extern void vStringSetLength (vString *const string);
extern void vStringTruncate (vString *const string, const size_t length);
extern void vStringTranslate(vString *const string, char fromC, char toC);

extern vString *vStringNewOrClear (vString *const string);
extern vString *vStringNewOrClearWithAutoRelease (vString *const string);
Expand Down

0 comments on commit d161653

Please sign in to comment.