From 6f187653ec9cc2122670cd67d01bf8394dc62fe2 Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Mon, 15 Jul 2013 14:40:46 -0600 Subject: * Fix support for quote strings that have trailing spaces. --- pico/word.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'pico') 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; } -- cgit v1.2.3-54-g00ecf