Skip to content

Commit

Permalink
Merge pull request #2125 from clausmoltkeleth/master
Browse files Browse the repository at this point in the history
readtags should be able to read tag files generated for the excmd "combine"
  • Loading branch information
masatake committed Jul 5, 2019
2 parents b9bde3d + 6e445fe commit 20ae3f5
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 0 deletions.
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

0 comments on commit 20ae3f5

Please sign in to comment.