Menu ▾ ▴

#307 find text has one issue for linux kernel code with "tab"

open
nobody
None
5
2 days ago
3 days ago
mark zhang
No

I encountered following problem for kernel code reading:
~~~
Cscope tag: icsk_timeout
# line filename / context / line
1 60 include/net/inet_connection_sock.h <<<unknown>>></unknown>

          * @icsk_timeout:

2 86 include/net/inet_connection_sock.h <<<unknown>>>
unsigned long
3 230 include/net/inet_connection_sock.h <<<unknown>>>
icsk->icsk_timeout = jiffies + when;
~~~</unknown></unknown>

In the second item, the keyword "icsk_timeout" is not showing.
By AI assisted, following patch could solve the issue, make the tab with space:
~~~
$ diff -Naur src/egrep.c.src src/egrep.c
--- src/egrep.c.src 2017-11-07 00:16:24.000000000 +0000
+++ src/egrep.c 2026-10-09 05:03:41.951290242 +0000
@@ -2076,6 +2076,15 @@
return fread(p, sizeof(p), buf_end - p, fptr);
}

+/ Match display.c: tabs in source lines confuse cscope -L clients. /
+static void
+putc_line_char(FILE *output, int c)
+{

  • if (c == '\t')
  • c = ' ';
  • putc(c, output);
    +}
    +
    int
    egrep(char file, FILE output, char *format)
    {
    @@ -2120,11 +2129,11 @@
    fprintf(output, format, file, lnum);
    if (p <= nlp) {
    while (nlp < buf_end)
  • putc(*nlp++, output);
  • putc_line_char(output, *nlp++);
    nlp = buf;
    }
    while (nlp < p)
  • putc(*nlp++, output);
  • putc_line_char(output, nlp++);
    lnum++;
    nlp = p;
    if (out[cstat = istat] == 0)
    @@ -2189,3 +2198,4 @@
    {
    iflag = i; /
    simulate "egrep -i" */
    }
    +

~~~

Thanks,
Mark

Discussion

  • mark zhang

    mark zhang - 3 days ago

    patch in file.

     
  • Hans-Bernhard Broeker

    The report is a bit unclear on what, exactly, you asked cscope to do, and what you were using to look at its output. Which -L mode client was that, and why woud its potential failure to cope with tab characters, which are perfectly fine in C source code, have to be seen as cscope's problem?

    The way the output was mangled by SF's markdown processing also makes it quite hard to judge what might be wrong here. I'm pretty sure there were not two <unknown> tags in cscope's actual output.

    It also doesn't reproduce for me in stock cscope 15.9, searching Ubuntu's linux source 6.8.0. Both line modes, and interactive mode, correctly display all of that line, including the tabs and all the way to its closing semicolon.

     

    Last edit: Hans-Bernhard Broeker 2 days ago

Log in to post a comment.