summaryrefslogtreecommitdiff
path: root/pico
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2013-07-15 14:40:46 -0600
committerEduardo Chappa <chappa@washington.edu>2013-07-15 14:40:46 -0600
commit6f187653ec9cc2122670cd67d01bf8394dc62fe2 (patch)
tree1d153b764fd6bbc5d7e30906f98417de2cc32ed4 /pico
parentd0f63f5130c5024bead498ea8a0ebf26d8b72478 (diff)
downloadalpine-6f187653ec9cc2122670cd67d01bf8394dc62fe2.tar.xz
* Fix support for quote strings that have trailing spaces.
Diffstat (limited to 'pico')
-rw-r--r--pico/word.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/pico/word.c b/pico/word.c
index a46bf3ef..e5b361b7 100644
--- a/pico/word.c
+++ b/pico/word.c
@@ -510,7 +510,7 @@ quote_match(UCS *q, LINE *gl, UCS *bufl, size_t buflen)
LINE *nl = gl != curbp->b_linep ? lforw(gl) : NULL;
LINE *pl = lback(gl) != curbp->b_linep ? lback(gl) : NULL;
UCS bufp[NSTRING], bufn[NSTRING];
- int i, j;
+ int i, j, qstart, qend;
int quoted_line = 0;
do_quote_match(q, pl, bufp, sizeof(bufp)); /* previous line */
@@ -522,8 +522,15 @@ quote_match(UCS *q, LINE *gl, UCS *bufl, size_t buflen)
/* is this line quoted? */
if(q && *q){
- for(i = 0; i < llength(gl) && q[i] && lgetc(gl, i).c == q[i]; i++);
- if(!q[i])
+ /* pare down q so it contains no leading or trailing whitespace */
+ for(i = 0; q[i] == ' '; i++);
+ qstart = i;
+ for(i = ucs4_strlen(q); i > 0 && q[i-1] == ' '; i--);
+ qend = i;
+ for(i = 0; i < llength(gl)
+ && i + qstart < qend
+ && lgetc(gl, i).c == q[i+qstart]; i++);
+ if(i + qstart == qend)
quoted_line = 1;
}