Merge branch 'nd/icase' into maint
"git grep -i" has been taught to fold case in non-ascii locales correctly. * nd/icase: grep.c: reuse "icase" variable diffcore-pickaxe: support case insensitive match on non-ascii diffcore-pickaxe: Add regcomp_or_die() grep/pcre: support utf-8 gettext: add is_utf8_locale() grep/pcre: prepare locale-dependent tables for icase matching grep: rewrite an if/else condition to avoid duplicate expression grep/icase: avoid kwsset when -F is specified grep/icase: avoid kwsset on literal non-ascii strings test-regex: expose full regcomp() to the command line test-regex: isolate the bug test code grep: break down an "if" stmt in preparation for next changes
This commit is contained in:
37
quote.c
37
quote.c
@ -453,3 +453,40 @@ void tcl_quote_buf(struct strbuf *sb, const char *src)
|
||||
}
|
||||
strbuf_addch(sb, '"');
|
||||
}
|
||||
|
||||
void basic_regex_quote_buf(struct strbuf *sb, const char *src)
|
||||
{
|
||||
char c;
|
||||
|
||||
if (*src == '^') {
|
||||
/* only beginning '^' is special and needs quoting */
|
||||
strbuf_addch(sb, '\\');
|
||||
strbuf_addch(sb, *src++);
|
||||
}
|
||||
if (*src == '*')
|
||||
/* beginning '*' is not special, no quoting */
|
||||
strbuf_addch(sb, *src++);
|
||||
|
||||
while ((c = *src++)) {
|
||||
switch (c) {
|
||||
case '[':
|
||||
case '.':
|
||||
case '\\':
|
||||
case '*':
|
||||
strbuf_addch(sb, '\\');
|
||||
strbuf_addch(sb, c);
|
||||
break;
|
||||
|
||||
case '$':
|
||||
/* only the end '$' is special and needs quoting */
|
||||
if (*src == '\0')
|
||||
strbuf_addch(sb, '\\');
|
||||
strbuf_addch(sb, c);
|
||||
break;
|
||||
|
||||
default:
|
||||
strbuf_addch(sb, c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user