From d34d8d828fad8a919b669006d549d4d3ed6e71cd Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sun, 30 Apr 2023 10:52:44 +0900 Subject: [PATCH 1/7] docs(man): fix a typo Signed-off-by: Masatake YAMATO --- docs/man/ctags-lang-asm.7.rst | 2 +- man/ctags-lang-asm.7.rst.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/man/ctags-lang-asm.7.rst b/docs/man/ctags-lang-asm.7.rst index bacf021460..f88868b209 100644 --- a/docs/man/ctags-lang-asm.7.rst +++ b/docs/man/ctags-lang-asm.7.rst @@ -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 diff --git a/man/ctags-lang-asm.7.rst.in b/man/ctags-lang-asm.7.rst.in index 43610fa2a6..0d493db396 100644 --- a/man/ctags-lang-asm.7.rst.in +++ b/man/ctags-lang-asm.7.rst.in @@ -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 From c982b5e5c5c6c652b6520a778bd7639fb4af4a5c Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sun, 30 Apr 2023 10:55:41 +0900 Subject: [PATCH 2/7] gitignore: add files related to man pages in section 5 Signed-off-by: Masatake YAMATO --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index ebf524aec2..74c5f422df 100644 --- a/.gitignore +++ b/.gitignore @@ -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 @@ -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 From 318d4683551709537101163c05999ffeb7d8b8dc Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Mon, 25 Oct 2021 09:59:40 +0900 Subject: [PATCH 3/7] main,refactor: reduce the number of calling getNamedLanguage Signed-off-by: Masatake YAMATO --- main/options.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/main/options.c b/main/options.c index 3f6f3d1d64..e2e42f5a95 100644 --- a/main/options.c +++ b/main/options.c @@ -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); @@ -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); @@ -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) From 18843616e74f805c3b9f415e42e4df9a4dc4dbbf Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Thu, 4 May 2023 05:34:54 +0900 Subject: [PATCH 4/7] optlib2c: limit the chars acceptable as parts of a table name in --_mtable-extend option Signed-off-by: Masatake YAMATO --- misc/optlib2c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/optlib2c b/misc/optlib2c index 7feddda30b..b5c79a3eb2 100755 --- a/misc/optlib2c +++ b/misc/optlib2c @@ -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-= option before defining the language" if (! defined $_[0]->{'langdef'}); die "Extending a multitable regex is allowed only to the language specified with --langdef: $1" From 3bb7b35db973c3d59ae8fc29712b288510c3b8db Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Thu, 4 May 2023 06:51:35 +0900 Subject: [PATCH 5/7] prelude: add _chop and _chop_space procs Signed-off-by: Masatake YAMATO --- Tmain/common-prelude.d/chop.expected | 6 ++++++ Tmain/common-prelude.d/chop.ps | Bin 0 -> 122 bytes Tmain/common-prelude.d/stdout-expected.txt | 1 + main/CommonPrelude.c | 21 +++++++++++++++++++++ main/CommonPrelude.ps | Bin 4912 -> 5344 bytes 5 files changed, 28 insertions(+) create mode 100644 Tmain/common-prelude.d/chop.expected create mode 100644 Tmain/common-prelude.d/chop.ps diff --git a/Tmain/common-prelude.d/chop.expected b/Tmain/common-prelude.d/chop.expected new file mode 100644 index 0000000000..48d740c93d --- /dev/null +++ b/Tmain/common-prelude.d/chop.expected @@ -0,0 +1,6 @@ +(abcx) +(abc) +(abc ) +(abc) +(abcx) +(abcx) diff --git a/Tmain/common-prelude.d/chop.ps b/Tmain/common-prelude.d/chop.ps new file mode 100644 index 0000000000000000000000000000000000000000..bf440a32327a4e0290705538198dbcbeea6535c9 GIT binary patch literal 122 zcmdN$OiHfMRIs(>(txnylQZ%Q6bgz<5|gtPl5_CRyPVoqy~;*z4wymWLH^@oju!Zfb5)Y7vq{L5>0k4a@>Ng<6HoG%&9gNgXJ7umM$Y Uz?EdALVY^fmrZi>V$NPp00wGrY5)KL delta 12 TcmaE$xj}8iV$RLM+`XItB) Date: Thu, 4 May 2023 07:28:14 +0900 Subject: [PATCH 6/7] optscript: reject negative numbers for specifying rolling objects Signed-off-by: Masatake YAMATO --- Tmain/optscript.d/stack.expected | 1 + Tmain/optscript.d/stack.ps | Bin 343 -> 467 bytes dsl/optscript.c | 2 ++ 3 files changed, 3 insertions(+) diff --git a/Tmain/optscript.d/stack.expected b/Tmain/optscript.d/stack.expected index c3cf9f618d..29a61f2c0e 100644 --- a/Tmain/optscript.d/stack.expected +++ b/Tmain/optscript.d/stack.expected @@ -34,3 +34,4 @@ 3 3 /A +/rangecheck diff --git a/Tmain/optscript.d/stack.ps b/Tmain/optscript.d/stack.ps index 2bc7e17fa78c110ac14bbed3fd9e784a0b1850e5..b245679b8b4e133f8e4aa54b118ad48f13064e0b 100644 GIT binary patch delta 132 zcmcc4beVZWIAcwiq zeo)}Mv4{%*H1H?z delta 7 Ocmcc2e4S}SI3oZI*aEl! diff --git a/dsl/optscript.c b/dsl/optscript.c index 32adcb1705..b17780a8c2 100644 --- a/dsl/optscript.c +++ b/dsl/optscript.c @@ -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; From 9d034a41c616a01661d99eeee8ba9518435a813c Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Thu, 4 May 2023 13:19:50 +0900 Subject: [PATCH 7/7] CPreProcessor: don't use isTagExtra() to pick up tags for adding them to a signature string The original code scanned corkQueue to pick up tags for making signature string. To avoid adding unwanted tags to the signature string, isTagExtra was used (522de3f2c08b2663d60b0de38129a3e421c27f5c). However, filtering with isTagExtra was too aggressive; tags extracted by the CPreProcessor parser running as a part of guest parser were rejected. This change uses an intArray. Instead of filtering candidate items in the corkQueue, the CPreProcessor collects tags for parameters to the intArray. The parameters are parts of a signature, not candidates. Therefore we don't need "filtering" anymore. Signed-off-by: Masatake YAMATO --- parsers/cpreprocessor.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/parsers/cpreprocessor.c b/parsers/cpreprocessor.c index 7a2fdd7bcc..7342a559e9 100644 --- a/parsers/cpreprocessor.c +++ b/parsers/cpreprocessor.c @@ -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); @@ -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, ','); @@ -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 { @@ -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 == '\\') @@ -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)