From 944bffb9673660b4d0b37fee2037541b148f0627 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 9 Jun 2015 15:06:12 +0200 Subject: [PATCH] json: Fix handling of tags containing a dot X-Universal-CTags-Commit-ID: 7ae28a3d8a7ad5f8a9d6399a4e357fcf19ad2b2e --- tagmanager/ctags/json.c | 10 +--------- tests/ctags/Makefile.am | 1 + tests/ctags/dotted-names.json | 25 +++++++++++++++++++++++++ tests/ctags/dotted-names.json.tags | 20 ++++++++++++++++++++ 4 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 tests/ctags/dotted-names.json create mode 100644 tests/ctags/dotted-names.json.tags diff --git a/tagmanager/ctags/json.c b/tagmanager/ctags/json.c index 8c87476d..52350275 100644 --- a/tagmanager/ctags/json.c +++ b/tagmanager/ctags/json.c @@ -227,15 +227,7 @@ static void pushScope (tokenInfo *const token, static void popScope (tokenInfo *const token, const tokenInfo *const parent) { - char *dot = strrchr (token->scope->buffer, '.'); - - if (! dot) - vStringClear (token->scope); - else - { - *dot = 0; - token->scope->length = dot - token->scope->buffer; - } + vStringTruncate (token->scope, vStringLength (parent->scope)); token->scopeKind = parent->scopeKind; } diff --git a/tests/ctags/Makefile.am b/tests/ctags/Makefile.am index 16e4af76..86590ed6 100644 --- a/tests/ctags/Makefile.am +++ b/tests/ctags/Makefile.am @@ -134,6 +134,7 @@ test_sources = \ debian_432872.f90 \ directives.c \ dopbl2.f \ + dotted-names.json \ enum.c \ enum.f90 \ enum.java \ diff --git a/tests/ctags/dotted-names.json b/tests/ctags/dotted-names.json new file mode 100644 index 00000000..f4e8cffb --- /dev/null +++ b/tests/ctags/dotted-names.json @@ -0,0 +1,25 @@ +{ + "first.name": "John", + "last.name": "Smith", + "is.alive": true, + "age": 25, + "height_cm": 167.6, + "address": { + "street.address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal.code": "10021-3100" + }, + "phone.numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [], + "spouse": null +} diff --git a/tests/ctags/dotted-names.json.tags b/tests/ctags/dotted-names.json.tags new file mode 100644 index 00000000..e6d79b9e --- /dev/null +++ b/tests/ctags/dotted-names.json.tags @@ -0,0 +1,20 @@ +# format=tagmanager +0Ì64Îphone.numbersÖ0 +1Ì64Îphone.numbersÖ0 +addressÌ64Ö0 +ageÌ64Ö0 +childrenÌ64Ö0 +cityÌ64ÎaddressÖ0 +first.nameÌ64Ö0 +height_cmÌ64Ö0 +is.aliveÌ64Ö0 +last.nameÌ64Ö0 +numberÌ64Îphone.numbers.0Ö0 +numberÌ64Îphone.numbers.1Ö0 +phone.numbersÌ64Ö0 +postal.codeÌ64ÎaddressÖ0 +spouseÌ64Ö0 +stateÌ64ÎaddressÖ0 +street.addressÌ64ÎaddressÖ0 +typeÌ64Îphone.numbers.0Ö0 +typeÌ64Îphone.numbers.1Ö0