Skip to content

Instantly share code, notes, and snippets.

@mattn
Created September 2, 2014 12:21
Show Gist options
  • Save mattn/f5ce1b320f1761c14164 to your computer and use it in GitHub Desktop.
Save mattn/f5ce1b320f1761c14164 to your computer and use it in GitHub Desktop.
diff -r dde8ff798ed9 src/search.c
--- a/src/search.c Sat Aug 30 18:10:19 2014 +0200
+++ b/src/search.c Tue Sep 02 21:20:57 2014 +0900
@@ -2153,6 +2153,7 @@
do_quotes = 0;
else if (do_quotes == -1)
{
+ int do_squotes = -1;
/*
* Count the number of quotes in the line, skipping \" and '"'.
* Watch out for "\\".
@@ -2161,10 +2162,12 @@
for (ptr = linep; *ptr; ++ptr)
{
if (ptr == linep + pos.col + backwards)
- at_start = (do_quotes & 1);
+ at_start = (do_quotes & 1) || (do_squotes & 1);
if (*ptr == '"'
&& (ptr == linep || ptr[-1] != '\'' || ptr[1] != '\''))
++do_quotes;
+ else if (*ptr == '\'' && (do_quotes & 1))
+ ++do_squotes;
if (*ptr == '\\' && ptr[1] != NUL)
++ptr;
}
@@ -2294,6 +2297,11 @@
pos.col += 2;
break;
}
+ else
+ {
+ inquote = !inquote;
+ start_in_quotes = FALSE;
+ }
}
}
/* FALLTHROUGH */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment