Add two latest distribution patches
Correct the erroneous brace count caused by the unbalanced { }
Make it possible to add the new keywords
Resolves: RHEL-158207
Signed-off-by: Vladislav Dronov <vdronov@redhat.com>
This commit is contained in:
parent
b8463d40c8
commit
8808f9c66c
@ -7,7 +7,7 @@
|
||||
Summary: C source code tree search and browse tool
|
||||
Name: cscope
|
||||
Version: 15.9
|
||||
Release: 26%{?dist}
|
||||
Release: 31%{?dist}
|
||||
Source0: https://downloads.sourceforge.net/project/%{name}/%{name}/v%{version}/%{name}-%{version}.tar.gz
|
||||
URL: http://cscope.sourceforge.net
|
||||
License: BSD-3-Clause AND GPL-2.0-or-later
|
||||
@ -36,6 +36,8 @@ Patch12: dist-2-cscope-indexer-help.patch
|
||||
Patch13: dist-3-add-selftests.patch
|
||||
Patch14: dist-4-fix-printf.patch
|
||||
Patch15: dist-5-fix-signal-handler.patch
|
||||
Patch16: dist-6-fix-brace-count.patch
|
||||
Patch17: dist-7-add-new-keywords.patch
|
||||
|
||||
%define cscope_share_path %{_datadir}/cscope
|
||||
%if %{with xemacs}
|
||||
@ -116,6 +118,11 @@ rm -f %{emacs_lisp_path}/xcscope.el
|
||||
rm -f %{vim_plugin_path}/cctree.vim
|
||||
|
||||
%changelog
|
||||
* Wed Mar 25 2026 Vladislav Dronov <vdronov@redhat.com> - 15.9-31
|
||||
- Add two latest distribution patches (RHEL-158207)
|
||||
- Correct the erroneous brace count caused by the unbalanced { }
|
||||
- Make it possible to add the new keywords
|
||||
|
||||
* Thu Oct 31 2024 Vladis Dronov <vdronov@redhat.com> - 15.9-26
|
||||
- Update cscope to 15.9-26 from Fedora (RHEL-65464)
|
||||
- Fix signal handling at exit
|
||||
|
||||
141
dist-6-fix-brace-count.patch
Normal file
141
dist-6-fix-brace-count.patch
Normal file
@ -0,0 +1,141 @@
|
||||
From: Oleg Nesterov <oleg@redhat.com>
|
||||
Subject: cscope: correct the erroneous brace count caused by the unbalanced { }
|
||||
Content-Type: text/plain; charset=us-ascii
|
||||
|
||||
cscope can't parse kernel/trace/trace_events.c (and some other files)
|
||||
in the linux kernel tree because this file has
|
||||
|
||||
#define do_for_each_event_file(tr, file) \
|
||||
list_for_each_entry(tr, &ftrace_trace_arrays, list) { \
|
||||
list_for_each_entry(file, &tr->events, list)
|
||||
|
||||
#define do_for_each_event_file_safe(tr, file) \
|
||||
list_for_each_entry(tr, &ftrace_trace_arrays, list) { \
|
||||
struct trace_event_file *___n; \
|
||||
list_for_each_entry_safe(file, ___n, &tr->events, list)
|
||||
|
||||
#define while_for_each_event_file() \
|
||||
}
|
||||
|
||||
at the top and thus the 2nd '{' in do_for_each_event_file_safe() above
|
||||
is not balanced.
|
||||
|
||||
Simple example:
|
||||
|
||||
$ cat -n test.c
|
||||
1 #define open1 {
|
||||
2 #define open2 {
|
||||
3 #define close }
|
||||
4
|
||||
5 void func(void)
|
||||
6 {
|
||||
7 }
|
||||
|
||||
Without this patch:
|
||||
|
||||
$ ./src/cscope -bu test.c
|
||||
$ ./src/cscope -dL -1 func
|
||||
|
||||
With this patch:
|
||||
|
||||
$ ./src/cscope -bu test.c
|
||||
$ ./src/cscope -dL -1 func
|
||||
test.c func 5 void func(void )
|
||||
|
||||
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
|
||||
---
|
||||
src/fscanner.l | 70 ++++++++++++++++++++++++++------------------------
|
||||
1 file changed, 37 insertions(+), 33 deletions(-)
|
||||
|
||||
diff --git a/src/fscanner.l b/src/fscanner.l
|
||||
index 43880bf..46734ea 100644
|
||||
--- a/src/fscanner.l
|
||||
+++ b/src/fscanner.l
|
||||
@@ -178,19 +178,21 @@ wsnl [ \t\r\v\f\n]|{comment}
|
||||
}
|
||||
|
||||
\{ { /* count unmatched left braces for fcn def detection */
|
||||
- ++braces;
|
||||
-
|
||||
- /* mark an untagged enum/struct/union so its beginning
|
||||
- can be found */
|
||||
- if (tagdef) {
|
||||
- if (braces == 1) {
|
||||
- esudef = YES;
|
||||
+ if (ppdefine == NO) {
|
||||
+ ++braces;
|
||||
+
|
||||
+ /* mark an untagged enum/struct/union so its beginning
|
||||
+ can be found */
|
||||
+ if (tagdef) {
|
||||
+ if (braces == 1) {
|
||||
+ esudef = YES;
|
||||
+ }
|
||||
+ token = tagdef;
|
||||
+ tagdef = '\0';
|
||||
+ last = first;
|
||||
+ my_yymore();
|
||||
+ return(token);
|
||||
}
|
||||
- token = tagdef;
|
||||
- tagdef = '\0';
|
||||
- last = first;
|
||||
- my_yymore();
|
||||
- return(token);
|
||||
}
|
||||
goto more;
|
||||
/* NOTREACHED */
|
||||
@@ -326,28 +328,30 @@ wsnl [ \t\r\v\f\n]|{comment}
|
||||
}
|
||||
|
||||
\} {
|
||||
- /* could be the last enum member initializer */
|
||||
- if (braces == initializerbraces) {
|
||||
- initializerbraces = -1;
|
||||
- initializer = NO;
|
||||
- }
|
||||
- if (--braces <= 0) {
|
||||
- endstate:
|
||||
- braces = 0;
|
||||
- classdef = NO;
|
||||
- }
|
||||
- if (braces == 0 || (braces == 1 && classdef == YES)) {
|
||||
-
|
||||
- /* if the end of an enum/struct/union definition */
|
||||
- if (esudef == YES) {
|
||||
- esudef = NO;
|
||||
+ if (ppdefine == NO) {
|
||||
+ /* could be the last enum member initializer */
|
||||
+ if (braces == initializerbraces) {
|
||||
+ initializerbraces = -1;
|
||||
+ initializer = NO;
|
||||
}
|
||||
- /* if the end of the function */
|
||||
- else if (fcndef == YES) {
|
||||
- fcndef = NO;
|
||||
- last = first;
|
||||
- my_yymore();
|
||||
- return(FCNEND);
|
||||
+ if (--braces <= 0) {
|
||||
+ endstate:
|
||||
+ braces = 0;
|
||||
+ classdef = NO;
|
||||
+ }
|
||||
+ if (braces == 0 || (braces == 1 && classdef == YES)) {
|
||||
+
|
||||
+ /* if the end of an enum/struct/union definition */
|
||||
+ if (esudef == YES) {
|
||||
+ esudef = NO;
|
||||
+ }
|
||||
+ /* if the end of the function */
|
||||
+ else if (fcndef == YES) {
|
||||
+ fcndef = NO;
|
||||
+ last = first;
|
||||
+ my_yymore();
|
||||
+ return(FCNEND);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
goto more;
|
||||
--
|
||||
2.25.1.362.g51ebf55
|
||||
151
dist-7-add-new-keywords.patch
Normal file
151
dist-7-add-new-keywords.patch
Normal file
@ -0,0 +1,151 @@
|
||||
From: Oleg Nesterov <oleg@redhat.com>
|
||||
Subject: cscope: make it possible to add the new keywords
|
||||
Content-Type: text/plain; charset=us-ascii
|
||||
|
||||
The linux kernel uses a lot of annotations which confuse cscope.
|
||||
Simple example:
|
||||
|
||||
$ cat -n test.c
|
||||
1 void func1(void) __acquires(RCU)
|
||||
2 {
|
||||
3 X = 1;
|
||||
4 }
|
||||
5
|
||||
6 void func2(void) __releases(RCU)
|
||||
7 {
|
||||
8 X = 1;
|
||||
9 }
|
||||
|
||||
Without this patch:
|
||||
|
||||
$ ./src/cscope -bu test.c
|
||||
$ ./src/cscope -dL -0 X
|
||||
test.c __acquires 3 X = 1;
|
||||
test.c __releases 8 X = 1;
|
||||
|
||||
With this patch:
|
||||
|
||||
$ ./src/cscope -bu -K __acquires,__releases test.c
|
||||
$ ./src/cscope -dL -0 X
|
||||
test.c func1 3 X = 1;
|
||||
test.c func2 8 X = 1;
|
||||
|
||||
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
|
||||
---
|
||||
src/global.h | 1 +
|
||||
src/lookup.c | 35 +++++++++++++++++++++++++++++++----
|
||||
src/main.c | 5 ++++-
|
||||
3 files changed, 36 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/global.h b/src/global.h
|
||||
index a6f1486..5f75b68 100644
|
||||
--- a/src/global.h
|
||||
+++ b/src/global.h
|
||||
@@ -342,6 +342,7 @@ char *read_block(void);
|
||||
char *scanpast(char c);
|
||||
|
||||
|
||||
+void add_keyword(char *csk);
|
||||
void addcmd(int f, char *s);
|
||||
void addsrcfile(char *path);
|
||||
void askforchar(void);
|
||||
diff --git a/src/lookup.c b/src/lookup.c
|
||||
index d8595db..71e4aac 100644
|
||||
--- a/src/lookup.c
|
||||
+++ b/src/lookup.c
|
||||
@@ -51,7 +51,9 @@ char uniontext[] = "union";
|
||||
* without changing the database file version and adding compatibility code
|
||||
* for old databases.
|
||||
*/
|
||||
-struct keystruct keyword[] = {
|
||||
+#define KEYWORDS 64
|
||||
+
|
||||
+struct keystruct keyword[KEYWORDS] = {
|
||||
{"", '\0', NULL}, /* dummy entry */
|
||||
{"#define", ' ', NULL}, /* must be table entry 1 */
|
||||
{"#include", ' ', NULL}, /* must be table entry 2 */
|
||||
@@ -93,7 +95,32 @@ struct keystruct keyword[] = {
|
||||
{"signed", ' ', NULL},
|
||||
{"volatile", ' ', NULL},
|
||||
};
|
||||
-#define KEYWORDS (sizeof(keyword) / sizeof(keyword[0]))
|
||||
+
|
||||
+static int keyword_nr = 38;
|
||||
+
|
||||
+void add_keyword(char *csk)
|
||||
+{
|
||||
+ for (;;) {
|
||||
+ char *eok = strchrnul(csk, ',');
|
||||
+ int last = !*eok;
|
||||
+
|
||||
+ *eok = 0;
|
||||
+ if (*csk) {
|
||||
+ if (keyword_nr == KEYWORDS) {
|
||||
+ fprintf(stderr, "KEYWORDS overflow\n");
|
||||
+ myexit(1);
|
||||
+ }
|
||||
+ keyword[keyword_nr].text = csk;
|
||||
+ keyword[keyword_nr].delim = '(';
|
||||
+ keyword_nr++;
|
||||
+ }
|
||||
+
|
||||
+ if (last)
|
||||
+ break;
|
||||
+ csk = eok + 1;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
|
||||
#define HASHMOD (KEYWORDS * 2 + 1)
|
||||
|
||||
@@ -106,8 +133,8 @@ initsymtab(void)
|
||||
{
|
||||
unsigned int i, j;
|
||||
struct keystruct *p;
|
||||
-
|
||||
- for (i = 1; i < KEYWORDS; ++i) {
|
||||
+
|
||||
+ for (i = 1; i < keyword_nr; ++i) {
|
||||
p = keyword + i;
|
||||
j = hash(p->text) % HASHMOD;
|
||||
p->next = hashtab[j];
|
||||
diff --git a/src/main.c b/src/main.c
|
||||
index 2ffabc3..055b222 100644
|
||||
--- a/src/main.c
|
||||
+++ b/src/main.c
|
||||
@@ -153,7 +153,7 @@ char ** parse_options(int *argc, char **argv)
|
||||
|
||||
|
||||
while ((opt = getopt_long(argcc, argv,
|
||||
- "hVbcCdeF:f:I:i:kLl0:1:2:3:4:5:6:7:8:9:P:p:qRs:TUuvX",
|
||||
+ "hVbcCdeF:f:I:i:kLl0:1:2:3:4:5:6:7:8:9:P:p:qRs:TUuvXK:",
|
||||
lopts, &longind)) != -1) {
|
||||
switch(opt) {
|
||||
|
||||
@@ -273,6 +273,9 @@ char ** parse_options(int *argc, char **argv)
|
||||
case 's': /* additional source file directory */
|
||||
sourcedir(optarg);
|
||||
break;
|
||||
+ case 'K':
|
||||
+ add_keyword(optarg);
|
||||
+ break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
diff --git a/doc/cscope.1 b/doc/cscope.1
|
||||
--- a/doc/cscope.1
|
||||
+++ b/doc/cscope.1
|
||||
@@ -121,6 +121,11 @@ whitespace have to be enclosed in "doubl
|
||||
filenames, any double-quote and backslash characters have to be
|
||||
escaped by backslashes.
|
||||
.TP
|
||||
+.BI -K keyword[,keyword[,...]]
|
||||
+Add an additional user-defined keyword(s). This is useful for example
|
||||
+for the kernel sources with non-standard keywords like ``__acquires''
|
||||
+and ``__releases''. The limit is 26 new keywords.
|
||||
+.TP
|
||||
.B -k
|
||||
``Kernel Mode'', turns off the use of the default include dir
|
||||
(usually /usr/include) when building the database, since kernel
|
||||
--
|
||||
2.25.1.362.g51ebf55
|
||||
@ -1,6 +0,0 @@
|
||||
--- !Policy
|
||||
product_versions:
|
||||
- rhel-10
|
||||
decision_context: osci_compose_gate
|
||||
rules:
|
||||
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
|
||||
Loading…
Reference in New Issue
Block a user