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

Misc fix #3713

Merged
merged 7 commits into from
May 5, 2023
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ _build
man/ctags.1
man/ctags.1.html
man/ctags.1.rst
man/ctags-*.5
man/ctags-*.5.rst
man/ctags-*.5.html
man/ctags-*.7
man/ctags-*.7.rst
man/ctags-*.7.html
Expand All @@ -93,6 +96,7 @@ man/readtags.1
man/readtags.1.rst
man/readtags.1.html
man/tags.5
man/tags.5.rst
man/tags.5.html
man/*.[157].in
ManTest
Expand Down
6 changes: 6 additions & 0 deletions Tmain/common-prelude.d/chop.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(abcx)
(abc)
(abc )
(abc)
(abcx)
(abcx)
Binary file added Tmain/common-prelude.d/chop.ps
Binary file not shown.
1 change: 1 addition & 0 deletions Tmain/common-prelude.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
aindex.ps...0
amember.ps...0
buildstring.ps...0
chop.ps...0
dedup.ps...0
dedup_spaces.ps...0
ndup.ps...0
Expand Down
1 change: 1 addition & 0 deletions Tmain/optscript.d/stack.expected
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
3
3
/A
/rangecheck
Binary file modified Tmain/optscript.d/stack.ps
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/man/ctags-lang-asm.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The main effects of running the CPreProcessor parser;

* lines started from `//` are stripped as comments,
* areas surrounded by the pair of `/*` and `*/` are
started as comments, and
stripped as comments, and
* macros defined with `#define` are extracted as tags.

Set ``runCPreProcessor`` to ``false`` for disabling the CPreProcessor
Expand Down
2 changes: 2 additions & 0 deletions dsl/optscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -2772,6 +2772,8 @@ op_roll (OptVM *vm, EsObject *name)
if (!es_integer_p (nobj))
return OPT_ERR_TYPECHECK;
int n = es_integer_get (nobj);
if (n < 0)
return OPT_ERR_RANGECHECK;

if ((((int)c) - 2) < n)
return OPT_ERR_UNDERFLOW;
Expand Down
21 changes: 21 additions & 0 deletions main/CommonPrelude.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,27 @@ const char ctagsCommonPrelude []=
" exch copy pop\n"
"} __bddef\n"
"\n"
"(string _CHOP string)\n"
"/_chop {\n"
" mark exch {} forall pop _buildstring\n"
"} __bddef\n"
"\n"
"(string _CHOP_SPACE string)\n"
"/_chop_space {\n"
" dup length dup 0 gt {\n"
" % string length\n"
" 1 sub\n"
" % string `length - 1`\n"
" 1 index exch\n"
" % string string `length - 1`\n"
" get (\\n\\t\\r\\f\\v ) exch _amember {\n"
" _chop\n"
" } if\n"
" } {\n"
" pop % pop the length\n"
" } ifelse\n"
"} __bddef\n"
"\n"
"% /x mark 40 (a) 32 32 10 (b) 10 10 9 9 (xyz) 9 9 41 _buildstring def\n"
"% x _normalize_spaces! x pstack\n"
"\n"
Expand Down
Binary file modified main/CommonPrelude.ps
Binary file not shown.
13 changes: 5 additions & 8 deletions main/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -2564,9 +2564,8 @@ static void processHeaderListOption (const int option, const char *parameter)
/*
* Token ignore processing
*/
static void readIgnoreList (const char *const list)
static void readIgnoreList (langType lang, const char *const list)
{
langType lang = getNamedLanguage ("CPreProcessor", 0);
char* newList = stringCopy (list);
const char *token = strtok (newList, IGNORE_SEPARATORS);

Expand All @@ -2578,10 +2577,8 @@ static void readIgnoreList (const char *const list)
eFree (newList);
}

static void addIgnoreListFromFile (const char *const fileName)
static void addIgnoreListFromFile (langType lang, const char *const fileName)
{
langType lang = getNamedLanguage ("CPreProcessor", 0);

stringList* tokens = stringListNewFromFile (fileName);
if (tokens == NULL)
error (FATAL | PERROR, "cannot open \"%s\"", fileName);
Expand All @@ -2607,16 +2604,16 @@ static void processIgnoreOption (const char *const list, int IgnoreOrDefine)
else if (strchr ("@./\\", list [0]) != NULL)
{
const char* fileName = (*list == '@') ? list + 1 : list;
addIgnoreListFromFile (fileName);
addIgnoreListFromFile (lang, fileName);
}
#if defined (WIN32)
else if (isalpha (list [0]) && list [1] == ':')
addIgnoreListFromFile (list);
addIgnoreListFromFile (lang, list);
#endif
else if (strcmp (list, "-") == 0)
applyLanguageParam (lang, "ignore", NULL);
else
readIgnoreList (list);
readIgnoreList (lang, list);
}

static void processAnonHashOption (const char *const option CTAGS_ATTR_UNUSED, const char *const parameter CTAGS_ATTR_UNUSED)
Expand Down
2 changes: 1 addition & 1 deletion man/ctags-lang-asm.7.rst.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The main effects of running the CPreProcessor parser;

* lines started from `//` are stripped as comments,
* areas surrounded by the pair of `/*` and `*/` are
started as comments, and
stripped as comments, and
* macros defined with `#define` are extracted as tags.

Set ``runCPreProcessor`` to ``false`` for disabling the CPreProcessor
Expand Down
2 changes: 1 addition & 1 deletion misc/optlib2c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ my $options =
unless ($_[0]->{'langdef'} eq $1);
return parse_regex ($3, $_[0], 1, $2);
} ],
[ qr/^--_mtable-extend-([^=]*)=(.*)\+(.*)/, sub {
[ qr/^--_mtable-extend-([^=]*)=([a-zA-Z_0-9]+)\+([a-zA-Z_0-9]+)/, sub {
die "Don't use --_mline-extend-<LANG>= option before defining the language"
if (! defined $_[0]->{'langdef'});
die "Extending a multitable regex is allowed only to the language specified with --langdef: $1"
Expand Down
17 changes: 11 additions & 6 deletions parsers/cpreprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ static void makeIncludeTag (const char *const name, bool systemHeader)
}
}

static void makeParamTag (vString *name, short nth, bool placeholder)
static int makeParamTag (vString *name, short nth, bool placeholder)
{
bool standing_alone = doesCPreProRunAsStandaloneParser(CPREPRO_MACRO);

Expand All @@ -890,15 +890,17 @@ static void makeParamTag (vString *name, short nth, bool placeholder)
if (placeholder)
markTagAsPlaceholder (e, placeholder);
}
return r;
}

static void regenreateSignatureFromParameters (vString * buffer, int from, int to)
static void makeSignatureStringFromParameters (vString * buffer, intArray *parameters)
{
vStringPut(buffer, '(');
for (int pindex = from; pindex < to; pindex++)
for (size_t i = 0; i < intArrayCount (parameters); i++)
{
int pindex = intArrayItem (parameters, i);
tagEntryInfo *e = getEntryInCorkQueue (pindex);
if (e && !isTagExtra (e))
if (e)
{
vStringCatS (buffer, e->name);
vStringPut (buffer, ',');
Expand Down Expand Up @@ -939,6 +941,7 @@ static int directiveDefine (const int c, bool undef)

if (p == '(')
{
intArray *params = intArrayNew ();
vString *param = vStringNew ();
int param_start = (int)countEntryInCorkQueue();
do {
Expand All @@ -953,7 +956,8 @@ static int directiveDefine (const int c, bool undef)

if (vStringLength (param) > 0)
{
makeParamTag (param, nth++, vStringChar(param, 0) == '.');
int r = makeParamTag (param, nth++, vStringChar(param, 0) == '.');
intArrayAdd (params, r);
vStringClear (param);
}
if (p == '\\')
Expand All @@ -965,12 +969,13 @@ static int directiveDefine (const int c, bool undef)
if (p == ')')
{
vString *signature = vStringNew ();
regenreateSignatureFromParameters (signature, param_start, param_end);
makeSignatureStringFromParameters (signature, params);
r = makeDefineTag (vStringValue (Cpp.directive.name), vStringValue (signature), undef);
vStringDelete (signature);
}
else
r = makeDefineTag (vStringValue (Cpp.directive.name), NULL, undef);
intArrayDelete (params);

tagEntryInfo *e = getEntryInCorkQueue (r);
if (e)
Expand Down