Hi everybody

If the option --from-here is specified, the resulting search by context is
always case-sensitive even if the option --ignore-case is present.

Example:

// will find your main function
global --from-here=25:/path/to/file.c main

// won't find your main function
global --from-here=25:/path/to/file.c -i Main

The attached patch fixes this issue.

Thank you & best regards
fabian
--- a/global/global.c	2017-03-02 23:30:18.632268436 +0100
+++ b/global/global.c	2017-03-02 22:59:17.867998651 +0100
@@ -841,6 +841,23 @@
 		if (isregex(av))
 			die_with_code(2, "regular expression is not allowed with the --from-here option.");
 		db = decide_tag_by_context(av, context_file, atoi(context_lineno));
+		/*
+		 * If we are in case-insensitive mode and have not found
+		 * anything yet, we try to find a matching definition and
+		 * try again.
+		 */
+		if (iflag && db == GSYMS) {
+			GTOP *gtop = gtags_open(dbpath, root, GTAGS, GTAGS_READ, 0);
+			GTP *gtp;
+			char edit[IDENTLEN];
+
+			snprintf(edit, sizeof(edit), "^%s$", av);
+			gtp = gtags_first(gtop, edit, GTOP_KEY | GTOP_BASICREGEX | GTOP_IGNORECASE);
+			gtags_close(gtop);
+			if (gtp) {
+				db = decide_tag_by_context(gtp->tag, context_file, atoi(context_lineno));
+			}
+		}
 	} else {
 		if (dflag)
 			db = GTAGS;
_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global

Reply via email to