On 2/04/2015 22:16, Pavel Nedev wrote:

> 1 - I didn't know that global reference and definition search is actually 
> using regexp. Is that on purpose?

Attached is a patch to recognise `--literal`.

> 2 - Are the global search results supposed to be ordered by file name?

Try piping to `sort -V` (if your sort supports version sorting).

-- 
Jason.
diff -urp global-6.4/global/global.c global-6-4/global/global.c
--- global-6.4/global/global.c  2015-03-24 21:37:16 +1000
+++ global-6-4/global/global.c  2015-04-03 16:47:43 +1000
@@ -1709,7 +1709,9 @@ search(const char *pattern, const char *
         */
        if (nofilter & SORT_FILTER)
                flags |= GTOP_NOSORT;
-       if (Gflag)
+       if (literal)
+               flags |= GTOP_NOREGEX;
+       else if (Gflag)
                flags |= GTOP_BASICREGEX;
        if (format == FORMAT_PATH)
                flags |= GTOP_PATH;
diff -urp global-6.4/libutil/gtagsop.c global-6-4/libutil/gtagsop.c
--- global-6.4/libutil/gtagsop.c        2015-03-24 12:59:54 +1000
+++ global-6-4/libutil/gtagsop.c        2015-04-03 17:31:15 +1000
@@ -598,7 +598,7 @@ get_prefix(const char *pattern, int flag
 
        if (pattern == NULL || pattern[0] == 0) {
                prefix = NULL;
-       } else if (!isregex(pattern)) {
+       } else if (flags & GTOP_NOREGEX || !isregex(pattern)) {
                if (flags & GTOP_IGNORECASE) {
                        buffer[0] = toupper(*pattern);
                        buffer[1] = 0;
@@ -725,7 +725,7 @@ gtags_first(GTOP *gtop, const char *patt
                gtop->preg = NULL;
        } else if (flags & GTOP_IGNORECASE) {
                regflags |= REG_ICASE;
-               if (!isregex(pattern) || flags & GTOP_NOREGEX) {
+               if (flags & GTOP_NOREGEX || !isregex(pattern)) {
                        gtop->prefix = get_prefix(pattern, flags);
                        if (gtop->openflags & GTAGS_DEBUG)
                                if (gtop->prefix != NULL)
@@ -733,7 +733,7 @@ gtags_first(GTOP *gtop, const char *patt
                        if (gtop->prefix == NULL)
                                die("gtags_first: impossible (1).");
                        strbuf_putc(regex, '^');
-                       strbuf_puts(regex, pattern);
+                       strbuf_puts(regex, quote_string(pattern));
                        if (!(flags & GTOP_PREFIX))
                                strbuf_putc(regex, '$');
                } else if (*pattern == '^' && (gtop->prefix = 
get_prefix(pattern, flags)) != NULL) {
@@ -744,7 +744,7 @@ gtags_first(GTOP *gtop, const char *patt
                        strbuf_puts(regex, pattern);
                }
        } else {
-               if (!isregex(pattern) || flags & GTOP_NOREGEX) {
+               if (flags & GTOP_NOREGEX || !isregex(pattern)) {
                        if (flags & GTOP_PREFIX)
                                gtop->dbflags |= DBOP_PREFIX;
                        gtop->key = pattern;
_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global

Reply via email to