Last active
August 29, 2015 13:56
-
-
Save arnested/8971896 to your computer and use it in GitHub Desktop.
GNU Global experimental patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: libutil/conf.c | |
| =================================================================== | |
| RCS file: /sources/global/global/libutil/conf.c,v | |
| retrieving revision 1.61 | |
| diff -c -r1.61 conf.c | |
| *** libutil/conf.c 18 Dec 2013 03:39:41 -0000 1.61 | |
| --- libutil/conf.c 18 Feb 2014 23:21:24 -0000 | |
| *************** | |
| *** 358,365 **** | |
| if (exist && sb) | |
| strbuf_putc(sb, ','); | |
| exist = 1; | |
| ! for (p += strlen(buf); *p && *p != ':'; p++) { | |
| ! if (*p == '\\') /* quoted character */ | |
| p++; | |
| if (sb) | |
| strbuf_putc(sb, *p); | |
| --- 358,367 ---- | |
| if (exist && sb) | |
| strbuf_putc(sb, ','); | |
| exist = 1; | |
| ! for (p += strlen(buf); *p; p++) { | |
| ! if (*p == ':') | |
| ! break; | |
| ! if (*p == '\\' && *(p + 1) == ':') /* quoted character */ | |
| p++; | |
| if (sb) | |
| strbuf_putc(sb, *p); | |
| Index: libutil/find.c | |
| =================================================================== | |
| RCS file: /sources/global/global/libutil/find.c,v | |
| retrieving revision 1.91 | |
| diff -c -r1.91 find.c | |
| *** libutil/find.c 13 Oct 2012 07:01:33 -0000 1.91 | |
| --- libutil/find.c 18 Feb 2014 23:21:24 -0000 | |
| *************** | |
| *** 1,6 **** | |
| /* | |
| * Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2005, 2006, 2008, | |
| ! * 2009, 2011, 2012 Tama Communications Corporation | |
| * | |
| * This file is part of GNU GLOBAL. | |
| * | |
| --- 1,6 ---- | |
| /* | |
| * Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2005, 2006, 2008, | |
| ! * 2009, 2011, 2012, 2014 Tama Communications Corporation | |
| * | |
| * This file is part of GNU GLOBAL. | |
| * | |
| *************** | |
| *** 109,117 **** | |
| static char *find_read_filelist(void); | |
| extern int qflag; | |
| - #ifdef DEBUG | |
| extern int debug; | |
| - #endif | |
| static const int allow_blank = 1; | |
| static const int check_looplink = 1; | |
| static int accept_dotfiles = 0; | |
| --- 109,115 ---- | |
| *************** | |
| *** 244,250 **** | |
| return NULL; | |
| } | |
| skiplist = check_strdup(strbuf_value(reg)); | |
| ! trim(skiplist); | |
| strbuf_reset(reg); | |
| /* | |
| * construct regular expression. | |
| --- 242,250 ---- | |
| return NULL; | |
| } | |
| skiplist = check_strdup(strbuf_value(reg)); | |
| ! if (debug) | |
| ! fprintf(stderr, "original skip list: %s\n", skiplist); | |
| ! /* trim(skiplist);*/ | |
| strbuf_reset(reg); | |
| /* | |
| * construct regular expression. | |
| *************** | |
| *** 265,287 **** | |
| strbuf_puts(reg, "/GRTAGS$|"); | |
| strbuf_puts(reg, "/GSYMS$|"); | |
| strbuf_puts(reg, "/GPATH$|"); | |
| ! for (p = skiplist; p; ) { | |
| ! char *skipf = p; | |
| ! if ((p = locatestring(p, ",", MATCH_FIRST)) != NULL) | |
| ! *p++ = 0; | |
| if (*skipf == '/') { | |
| list_count++; | |
| strbuf_puts0(list, skipf); | |
| } else { | |
| strbuf_putc(reg, '/'); | |
| for (q = skipf; *q; q++) { | |
| ! if (isregexchar(*q)) | |
| strbuf_putc(reg, '\\'); | |
| ! strbuf_putc(reg, *q); | |
| } | |
| if (*(q - 1) != '/') | |
| strbuf_putc(reg, '$'); | |
| ! if (p) | |
| strbuf_putc(reg, '|'); | |
| } | |
| } | |
| --- 265,353 ---- | |
| strbuf_puts(reg, "/GRTAGS$|"); | |
| strbuf_puts(reg, "/GSYMS$|"); | |
| strbuf_puts(reg, "/GPATH$|"); | |
| ! for (p = skiplist; *p; ) { | |
| ! STATIC_STRBUF(sb); | |
| ! strbuf_clear(sb); | |
| ! char *skipf; | |
| ! | |
| ! while (*p && *p == ',') | |
| ! p++; | |
| ! if (*p == '\0') | |
| ! break; | |
| ! for (; *p; p++) { | |
| ! if (*p == ',') | |
| ! break; | |
| ! if (*p == '\\' && *(p + 1) == ',') | |
| ! p++; | |
| ! strbuf_putc(sb, *p); | |
| ! } | |
| ! skipf = strbuf_value(sb); | |
| if (*skipf == '/') { | |
| list_count++; | |
| strbuf_puts0(list, skipf); | |
| } else { | |
| strbuf_putc(reg, '/'); | |
| for (q = skipf; *q; q++) { | |
| ! /* | |
| ! * replaces wild cards into regular expressions. | |
| ! * | |
| ! * '*' -> '.*' | |
| ! * '?' -> '.' | |
| ! * '[...]' -> '[...]' | |
| ! * '[!...]' -> '[^...]' | |
| ! */ | |
| ! if (*q == '[') { | |
| ! char *c = q; | |
| ! STATIC_STRBUF(class); | |
| ! int isclass = 1; | |
| ! | |
| ! strbuf_clear(class); | |
| ! strbuf_putc(class, *c++); /* '[' */ | |
| ! if (*c == '\0') | |
| ! isclass = 0; | |
| ! else if (*c == ']') | |
| ! strbuf_putc(class, *c++); | |
| ! else if (*c == '!') { | |
| ! strbuf_putc(class, '^'); | |
| ! c++; | |
| ! } else | |
| ! strbuf_putc(class, *c++); | |
| ! if (isclass) { | |
| ! while (*c && *c != ']') | |
| ! strbuf_putc(class, *c++); | |
| ! if (*c == ']') | |
| ! strbuf_putc(class, *c); /* ']' */ | |
| ! else | |
| ! isclass = 0; | |
| ! } | |
| ! if (isclass) { | |
| ! strbuf_puts(reg, strbuf_value(class)); | |
| ! q = c; | |
| ! } else { | |
| ! /* 'class' is thrown away */ | |
| ! strbuf_putc(reg, '\\'); | |
| ! strbuf_putc(reg, *q); | |
| ! } | |
| ! } else if (*q == '*') | |
| ! strbuf_puts(reg, ".*"); | |
| ! else if (*q == '?') | |
| ! strbuf_putc(reg, '.'); | |
| ! else if (*q == '\\' && *(q + 1) == ',') | |
| ! strbuf_putc(reg, *++q); | |
| ! else if (isregexchar(*q)) { | |
| strbuf_putc(reg, '\\'); | |
| ! strbuf_putc(reg, *q); | |
| ! } else { | |
| ! if (*q == '\\' && *(q + 1) != '\0') { | |
| ! strbuf_putc(reg, *q++); | |
| ! strbuf_putc(reg, *q); | |
| ! } else | |
| ! strbuf_putc(reg, *q); | |
| ! } | |
| } | |
| if (*(q - 1) != '/') | |
| strbuf_putc(reg, '$'); | |
| ! if (*p == ',') | |
| strbuf_putc(reg, '|'); | |
| } | |
| } | |
| *************** | |
| *** 290,295 **** | |
| --- 356,363 ---- | |
| /* | |
| * compile regular expression. | |
| */ | |
| + if (debug) | |
| + fprintf(stderr, "converted skip list:\n%s\n", strbuf_value(reg)); | |
| if (regcomp(&skip_area, strbuf_value(reg), flags) != 0) | |
| die("cannot compile regular expression."); | |
| if (list_count > 0) { | |
| *************** | |
| *** 349,356 **** | |
| if (skip == NULL) | |
| die("prepare_skip failed."); | |
| } | |
| ! if (regexec(skip, path, 0, 0, 0) == 0) | |
| return 1; | |
| /* | |
| * list check. | |
| */ | |
| --- 417,427 ---- | |
| if (skip == NULL) | |
| die("prepare_skip failed."); | |
| } | |
| ! if (regexec(skip, path, 0, 0, 0) == 0) { | |
| ! if (debug) | |
| ! fprintf(stderr, "File '%s' is skipped by skip variable (type 1).\n", path); | |
| return 1; | |
| + } | |
| /* | |
| * list check. | |
| */ | |
| *************** | |
| *** 364,373 **** | |
| --- 435,448 ---- | |
| */ | |
| if (*(last - 1) == '/') { /* it's a directory */ | |
| if (!STRNCMP(path + 1, first, last - first)) { | |
| + if (debug) | |
| + fprintf(stderr, "File '%s' is skipped by skip variable (type 2).\n", path); | |
| return 1; | |
| } | |
| } else { | |
| if (!STRCMP(path + 1, first)) { | |
| + if (debug) | |
| + fprintf(stderr, "File '%s' is skipped by skip variable (type 3).\n", path); | |
| return 1; | |
| } | |
| } |
Author
Author
Emacs's flymake-mode creates temporary files by adding adding _flymake before the extension (i.e. my-code.php → my-code_flymake.php).
So now I can add *_flymake.* to my skip lists.
Author
For Homebrew users I have created a formula in my own tap: https://github.com/arnested/homebrew-emacs/blob/master/Formula/global-patched.rb.
Author
Shigio YAMAGUCHI has created a new patch including more glob characters: http://permalink.gmane.org/gmane.comp.gnu.global.bugs/1653
I updated this Gist with Shigio YAMAGUCHIs patch and changed the brew formula to use that patch as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This patch allows you to put a
*in your skip lists.The
*is converted to the regular expression.*.