Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readtags should be able to read tag files generated for the excmd "combine" #2125

Merged
merged 2 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Tmain/readtags-combine.d/backward.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 0.0.0 /6e3f1aa1/
foo input.c 2;?^int foo (void)$?;" f typeref:typename:int
1 change: 1 addition & 0 deletions Tmain/readtags-combine.d/exit-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
8 changes: 8 additions & 0 deletions Tmain/readtags-combine.d/forward.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 0.0.0 /6e3f1aa1/
foo input.c 0;/^int foo (void)$/;" f typeref:typename:int
18 changes: 18 additions & 0 deletions Tmain/readtags-combine.d/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# Copyright: 2019 CCI Europe. Author: Claus Moltke-Leth
# License: GPL-2

READTAGS=$3

. ../utils.sh

#V="valgrind --leak-check=full -v"
V=

if ! [ -x "${READTAGS}" ]; then
skip "no readtags"
fi

${V} ${READTAGS} -e -t forward.tags -l &&
${V} ${READTAGS} -e -t backward.tags -l
Empty file.
2 changes: 2 additions & 0 deletions Tmain/readtags-combine.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
foo input.c 0;/^int foo (void)$/;" kind:f typeref:typename:int
foo input.c 2;?^int foo (void)$?;" kind:f typeref:typename:int
25 changes: 25 additions & 0 deletions read/readtags.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ static void parseTagLine (tagFile *file, tagEntry *const entry)
if (tab != NULL)
{
int fieldsPresent;
int combinedPattern;
*tab = '\0';
p = tab + 1;
if (*p == '/' || *p == '?')
Expand Down Expand Up @@ -471,6 +472,30 @@ static void parseTagLine (tagFile *file, tagEntry *const entry)
entry->address.lineNumber = atol (p);
while (isdigit ((int) *(unsigned char*) p))
++p;
if (p)
{
combinedPattern = (strncmp (p, ";/", 2) == 0) ||
(strncmp (p, ";?", 2) == 0);
if (combinedPattern)
{
++p;
/* parse pattern */
int delimiter = *(unsigned char*) p;
do
{
p = strchr (p + 1, delimiter);
} while (p != NULL
&& isOdd (countContinuousBackslashesBackward (p - 1,
entry->address.pattern)));

if (p == NULL)
{
/* invalid pattern */
}
else
++p;
}
}
}
else
{
Expand Down