bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] Combining of Exuberant Ctags and GNU GLOBAL


From: Aneesh Kumar K.V
Subject: Re: [RFC] Combining of Exuberant Ctags and GNU GLOBAL
Date: Mon, 10 Sep 2012 17:06:43 +0530
User-agent: Notmuch/0.13.2+63~g548a9bf (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu)

Shigio YAMAGUCHI <address@hidden> writes:

>> But if i use the existing ctags integration, i won't be able to use
>> references right ?
>
> Right.
> What do you think we should do about the --regex option?

It would really nice if we could support that as a gtags command line
option. Right now I run a patched gtags to make it work on linux kernel
Linux kernel have code as below

SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)

That is actually sys_open(const chat __user *filename, ....)

A really ugly hack it is :)

diff --git a/libparser/C.c b/libparser/C.c
index 40069c0..fa9fc5b 100644
--- a/libparser/C.c
+++ b/libparser/C.c
@@ -27,6 +27,7 @@
 #else
 #include <strings.h>
 #endif
+#include <stdlib.h>
 
 #include "internal.h"
 #include "die.h"
@@ -127,6 +128,7 @@ C_family(const struct parser_param *param, int type)
                                } else if (level == 0 && !startmacro && 
!startsharp) {
                                        char arg1[MAXTOKEN], savetok[MAXTOKEN], 
*saveline;
                                        int savelineno = lineno;
+                                       char *linux_kernel;
 
                                        strlimcpy(savetok, token, 
sizeof(savetok));
                                        strbuf_reset(sb);
@@ -150,6 +152,12 @@ C_family(const struct parser_param *param, int type)
                                        if (function_definition(param, arg1)) {
                                                if (!strcmp(savetok, 
"SCM_DEFINE") && *arg1)
                                                        strlimcpy(savetok, 
arg1, sizeof(savetok));
+                                               linux_kernel = 
getenv("LINUX_KERNEL_SOURCE");
+                                               if (linux_kernel && 
!strcmp(linux_kernel, "yes") &&
+                                                       !strncmp(savetok, 
"SYSCALL_DEFINE", 14 ) && *arg1) {
+                                                       strcpy(savetok, "sys_");
+                                                       strncat(savetok, arg1, 
sizeof(savetok) - 4);
+                                               }
                                                PUT(PARSER_DEF, savetok, 
savelineno, saveline);
                                        } else {
                                                PUT(PARSER_REF_SYM, savetok, 
savelineno, saveline);
@@ -541,7 +549,7 @@ function_definition(const struct parser_param *param, char 
arg1[MAXTOKEN])
        if (c == EOF)
                return 0;
        brace_level = 0;
-       while ((c = nexttoken(",;[](){}=", c_reserved_word)) != EOF) {
+       while ((c = nexttoken(";[](){}=", c_reserved_word)) != EOF) {
                switch (c) {
                case SHARP_IFDEF:
                case SHARP_IFNDEF:


The ctags way of doing this is 

    --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \

So if i can get gtags to take --regex that would be really nice.
-aneesh




reply via email to

[Prev in Thread] Current Thread [Next in Thread]