forked from universal-ctags/ctags
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'libreadtags/' changes from 53b7e27ab..4eee45ec6
4eee45ec6 Merge pull request universal-ctags#48 from masatake/unescaping-input-field-only-when-slash 15b9503ba Read the input field with unescaping if TAG_OUTPUT_MODE is "u-ctags" and TAG_OUTPUT_FILESEP is "slash" 93e0c73d4 Merge pull request universal-ctags#47 from masatake/unescaping-input-field 687f3d9ad Read the input field with unescaping if TAG_OUTPUT_MODE is "u-ctags" 3517d2e68 Use smaller data types for some members in tagFile 93bdb3226 Add a helper function for unescaping 3fb676fde Make macros for comparing field values reusable git-subtree-dir: libreadtags git-subtree-split: 4eee45ec6f4fedb506a9a14b33e97904ec1f09d8
- Loading branch information
Showing
16 changed files
with
768 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 2022, Masatake YAMATO | ||
* | ||
* This source code is released into the public domain. | ||
* | ||
* Testing the fix for handling unescaping | ||
*/ | ||
|
||
#ifndef TEST_FIELDS_H | ||
#define TEST_FIELDS_H | ||
|
||
#define NEXT() \ | ||
r = tagsNext (t, &e); \ | ||
if (r != TagSuccess) \ | ||
{ \ | ||
fprintf (stderr, "error in tagsNext\n"); \ | ||
return 1; \ | ||
} \ | ||
do {} while (0) | ||
|
||
#define CHECK(EXP,FIELD) \ | ||
if (strcmp (EXP, e.FIELD) != 0) \ | ||
{ \ | ||
fprintf (stderr, "unexpected " #FIELD "(expected: %s, actual: %s) in tagsFirst\n", \ | ||
EXP, e.FIELD); \ | ||
return 1; \ | ||
} \ | ||
do {} while (0) | ||
|
||
#define CHECK_X(FIELD,EXP) \ | ||
{ \ | ||
unsigned short i; \ | ||
for (i = 0; i < e.fields.count; i++) \ | ||
{ \ | ||
if (strcmp (e.fields.list [i].key, FIELD) == 0) \ | ||
{ \ | ||
if (strcmp(e.fields.list [i].value, EXP) == 0) \ | ||
break; \ | ||
else \ | ||
{ \ | ||
fprintf (stderr, "unexpected " #FIELD "(expected: %s, actual: %s) in tagsFirst\n", \ | ||
EXP, e.fields.list [i].value); \ | ||
return 1; \ | ||
} \ | ||
} \ | ||
} \ | ||
if (i >= e.fields.count) \ | ||
{ \ | ||
fprintf (stderr, "unexpected " #FIELD " field is not found in tagsFirst (count: %u)\n", \ | ||
e.fields.count); \ | ||
return 1; \ | ||
} \ | ||
} | ||
|
||
#define CHECK3(NAME,FILE,PAT) \ | ||
CHECK ((NAME), name); \ | ||
CHECK ((FILE), file); \ | ||
CHECK ((PAT), address.pattern) | ||
|
||
#define NEXT_CHECK3(NAME,FILE,PAT) \ | ||
NEXT (); \ | ||
CHECK3 (NAME,FILE,PAT) | ||
|
||
#endif /* !TEST_FIELDS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (c) 2022, Masatake YAMATO | ||
* | ||
* This source code is released into the public domain. | ||
* | ||
* Testing the fix for handling unescaping | ||
*/ | ||
|
||
#include "readtags.h" | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
#include "test-fields.h" | ||
|
||
|
||
#define CHECK3(NAME,FILE,PAT) \ | ||
CHECK ((NAME), name); \ | ||
CHECK ((FILE), file); \ | ||
CHECK ((PAT), address.pattern) | ||
|
||
#define NEXT_CHECK3(NAME,FILE,PAT) \ | ||
NEXT (); \ | ||
CHECK3 (NAME,FILE,PAT) | ||
|
||
int | ||
main (void) | ||
{ | ||
char *srcdir = getenv ("srcdir"); | ||
if (srcdir) | ||
{ | ||
if (chdir (srcdir) == -1) | ||
{ | ||
perror ("chdir"); | ||
return 99; | ||
} | ||
} | ||
|
||
tagFile *t; | ||
tagFileInfo info; | ||
|
||
const char *tags0 = "./unescaping-input-fields-backslash.tags"; | ||
t = tagsOpen (tags0, &info); | ||
if (t == NULL | ||
|| info.status.opened == 0) | ||
{ | ||
fprintf (stderr, "unexpected result (t: %p, opened: %d)\n", | ||
t, info.status.opened); | ||
return 1; | ||
} | ||
fprintf (stderr, "ok\n"); | ||
|
||
tagEntry e; | ||
tagResult r; | ||
|
||
r = tagsFirst (t, &e); | ||
if (r != TagSuccess) | ||
{ | ||
fprintf (stderr, "error in tagsFirst\n"); | ||
return 1; | ||
} | ||
|
||
CHECK3 ("tab0", "\\tabc", "/^tab0$/"); | ||
NEXT_CHECK3 ("tab1", "a\\tbc", "/^tab1$/"); | ||
NEXT_CHECK3 ("tab2", "ab\\tc", "/^tab2$/"); | ||
NEXT_CHECK3 ("tab3", "abc\\t", "/^tab3$/"); | ||
NEXT_CHECK3 ("tab4", "\\\\abc", "/^tab4$/"); | ||
NEXT_CHECK3 ("tab5", "a\\\\bc", "/^tab5$/"); | ||
NEXT_CHECK3 ("tab6", "ab\\\\c", "/^tab6$/"); | ||
NEXT_CHECK3 ("tab7", "abc\\\\", "/^tab7$/"); | ||
NEXT_CHECK3 ("tab8", "\\nabc", "/^tab8$/"); | ||
NEXT_CHECK3 ("tab9", "a\\nbc", "/^tab9$/"); | ||
NEXT_CHECK3 ("taba", "ab\\nc", "/^taba$/"); | ||
NEXT_CHECK3 ("tabb", "abc\\n", "/^tabb$/"); | ||
NEXT_CHECK3 ("tabc", "\\n\\\\abc", "/^tabc$/"); | ||
NEXT_CHECK3 ("tabd", "\\\\\\nabc", "/^tabd$/"); | ||
NEXT_CHECK3 ("tabe", "a\\n\\\\bc", "/^tabe$/"); | ||
NEXT_CHECK3 ("tabf", "a\\\\\\nbc", "/^tabf$/"); | ||
NEXT_CHECK3 ("tabg", "abc\\n\\\\", "/^tabg$/"); | ||
NEXT_CHECK3 ("tabh", "abc\\\\\\n", "/^tabh$/"); | ||
NEXT_CHECK3 ("tabi", "\\t\\\\\\n", "/^tabi$/"); | ||
NEXT_CHECK3 ("tabj", "ab\\t\\\\\\nc", "/^tabj$/"); | ||
|
||
r = tagsClose(t); | ||
if (r != TagSuccess) | ||
{ | ||
fprintf (stderr, "error in tagsClose\n"); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.