From 070b018e2b973e64aa7f53ed0e0b53bca2a3f942 Mon Sep 17 00:00:00 2001 From: OpenSource Compile and Link Date: Fri, 28 Jun 2019 15:04:50 +0200 Subject: [PATCH 1/2] Make tag reader able to read tag files created with the option --excmd=combine. Previously the reader would discard everything beyond the first semicolon in the search expression. This was unfortunate because when using the 'combine' option the full search expression has the form ;. --- read/readtags.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/read/readtags.c b/read/readtags.c index 4814ab6b02..abe29ebf37 100644 --- a/read/readtags.c +++ b/read/readtags.c @@ -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 == '?') @@ -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 { From 6e445fe638d8c4fe1a631c9fe65d767346cacec1 Mon Sep 17 00:00:00 2001 From: Claus Moltke-Leth Date: Thu, 4 Jul 2019 22:37:46 +0200 Subject: [PATCH 2/2] Provide test cases for readtabs-combine --- Tmain/readtags-combine.d/backward.tags | 8 ++++++++ Tmain/readtags-combine.d/exit-expected.txt | 1 + Tmain/readtags-combine.d/forward.tags | 8 ++++++++ Tmain/readtags-combine.d/run.sh | 18 ++++++++++++++++++ Tmain/readtags-combine.d/stderr-expected.txt | 0 Tmain/readtags-combine.d/stdout-expected.txt | 2 ++ 6 files changed, 37 insertions(+) create mode 100644 Tmain/readtags-combine.d/backward.tags create mode 100644 Tmain/readtags-combine.d/exit-expected.txt create mode 100644 Tmain/readtags-combine.d/forward.tags create mode 100644 Tmain/readtags-combine.d/run.sh create mode 100644 Tmain/readtags-combine.d/stderr-expected.txt create mode 100644 Tmain/readtags-combine.d/stdout-expected.txt diff --git a/Tmain/readtags-combine.d/backward.tags b/Tmain/readtags-combine.d/backward.tags new file mode 100644 index 0000000000..80954941ba --- /dev/null +++ b/Tmain/readtags-combine.d/backward.tags @@ -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 diff --git a/Tmain/readtags-combine.d/exit-expected.txt b/Tmain/readtags-combine.d/exit-expected.txt new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/Tmain/readtags-combine.d/exit-expected.txt @@ -0,0 +1 @@ +0 diff --git a/Tmain/readtags-combine.d/forward.tags b/Tmain/readtags-combine.d/forward.tags new file mode 100644 index 0000000000..1a66255d6a --- /dev/null +++ b/Tmain/readtags-combine.d/forward.tags @@ -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 diff --git a/Tmain/readtags-combine.d/run.sh b/Tmain/readtags-combine.d/run.sh new file mode 100644 index 0000000000..4ff5e4dffc --- /dev/null +++ b/Tmain/readtags-combine.d/run.sh @@ -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 diff --git a/Tmain/readtags-combine.d/stderr-expected.txt b/Tmain/readtags-combine.d/stderr-expected.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tmain/readtags-combine.d/stdout-expected.txt b/Tmain/readtags-combine.d/stdout-expected.txt new file mode 100644 index 0000000000..0423fd0fc4 --- /dev/null +++ b/Tmain/readtags-combine.d/stdout-expected.txt @@ -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