Skip to content

Instantly share code, notes, and snippets.

@mattn
Created April 29, 2015 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/5f388e4fdba9a69a49a2 to your computer and use it in GitHub Desktop.
Save mattn/5f388e4fdba9a69a49a2 to your computer and use it in GitHub Desktop.
diff -r 18d84ed365a5 src/search.c
--- a/src/search.c Wed Apr 22 22:18:22 2015 +0200
+++ b/src/search.c Thu Apr 30 00:43:26 2015 +0900
@@ -2154,6 +2154,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 "\\".
@@ -2162,10 +2163,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;
}
@@ -2295,6 +2298,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