[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[BUG]
From: |
Hideki IWAMOTO |
Subject: |
[BUG] |
Date: |
Sat, 14 Sep 2013 01:22:12 +0900 |
Hi. Yamaguchi san.
There are some problems in searching using the pattern
which contains '^' at the head.
======== example 1 ========
$ cat a.c
vsprintf
sprintf
asprintf
$ global -sx '^v?sprintf'
vsprintf 1 a.c vsprintf
$ global -sx '^(v)?sprintf'
sprintf 2 a.c sprintf
vsprintf 1 a.c vsprintf
===========================
Although '^v?sprintf should be equivalent to '^(v)?sprintf',
the former does not match 'sprintf'.
I think that the following code in gtags_first() is broken
and it should be removed.
617 const char *p;
618 /*
619 * If the pattern include '^' + some non regular
expression
620 * characters like '^aaa[0-9]', we take prefix read method
621 * with the non regular expression part as the prefix.
622 */
623 if (!(flags & GTOP_IGNORECASE) && *pattern == '^' && *(p
= pattern + 1) && !isregexchar(*p)) {
624 int i = 0;
625
626 while (*p && !isregexchar(*p) && i < IDENTLEN)
627 prefix[i++] = *p++;
628 prefix[i] = '\0';
629 key = prefix;
630 dbflags |= DBOP_PREFIX;
631 } else {
Reducing the length of the string copied to prefix[] by 1 byte
does not solve the following problem.
======== example 2 ========
$ cat b.c
geta
seta
$ global -sx '^get|^set'
get 1 b.c geta
$ global -sx '(^get)|(^set)'
get 1 b.c geta
set 2 b.c seta
===========================
--
Hideki IWAMOTO <address@hidden>