diff --git a/ext/fts1/fts1.c b/ext/fts1/fts1.c index 47ce5f8591..4ebe95660f 100644 --- a/ext/fts1/fts1.c +++ b/ext/fts1/fts1.c @@ -2298,11 +2298,32 @@ static int wordBoundary( return iBreak; } +/* +** If the StringBuffer does not end in white space, add a single +** space character to the end. +*/ +static void appendWhiteSpace(StringBuffer *p){ + if( p->len==0 ) return; + if( isspace(p->s[p->len-1]) ) return; + append(p, " "); +} + +/* +** Remove white space from teh end of the StringBuffer +*/ +static void trimWhiteSpace(StringBuffer *p){ + while( p->len>0 && isspace(p->s[p->len-1]) ){ + p->len--; + } +} + + + /* ** Allowed values for Snippet.aMatch[].snStatus */ #define SNIPPET_IGNORE 0 /* It is ok to omit this match from the snippet */ -#define SNIPPET_DESIRED 1 /* We want to include this match in the snippet */ +#define SNIPPET_DESIRED 1 /* We want to include this match in the snippet */ /* ** Generate the text of a snippet. @@ -2369,8 +2390,12 @@ static void snippetText( wantEllipsis = 0; tailEllipsis = 0; } + if( iCol!=tailCol || iStart!=tailOffset ){ + appendWhiteSpace(&sb); + } if( wantEllipsis || tailEllipsis ){ append(&sb, zEllipsis); + appendWhiteSpace(&sb); } iEnd = aMatch[i].iStart + aMatch[i].nByte + 40; iEnd = wordBoundary(iEnd, zDoc, nDoc, aMatch, nMatch, iCol); @@ -2382,8 +2407,12 @@ static void snippetText( } while( iMatchsnippet.zSnippet = sb.s; diff --git a/manifest b/manifest index 3a46379121..91923b1cc1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\ssegfaults\swhen\sinserted\sNULL\svalues\sinto\sFTS1.\s(CVS\s3447) -D 2006-09-28T11:41:41 +C Bug\sfix\sin\sthe\sFTS1\ssnippet\sgenerator.\s\sImprovements\sin\sthe\sway\sthe\ssnippet\ngenerator\shandles\swhitespace.\s(CVS\s3448) +D 2006-09-28T18:37:16 F Makefile.in cabd42d34340f49260bc2a7668c38eba8d4cfd99 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -21,7 +21,7 @@ F ext/README.txt 913a7bd3f4837ab14d7e063304181787658b14e1 F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e F ext/fts1/ft_hash.c 3927bd880e65329bdc6f506555b228b28924921b F ext/fts1/ft_hash.h 1a35e654a235c2c662d3ca0dfc3138ad60b8b7d5 -F ext/fts1/fts1.c 5cb7829d331502a3151d6648cadd358ac97b5161 +F ext/fts1/fts1.c 8531a2a86cc9a29d0b47762243e04f8e45655d33 F ext/fts1/fts1.h 6060b8f62c1d925ea8356cb1a6598073eb9159a6 F ext/fts1/fts1_hash.c 3196cee866edbebb1c0521e21672e6d599965114 F ext/fts1/fts1_hash.h 957d378355ed29f672cd5add012ce8b088a5e089 @@ -192,7 +192,7 @@ F test/fkey1.test 153004438d51e6769fb1ce165f6313972d6263ce F test/format4.test bf3bed3b13c63abfb3cfec232597a319a31d0bcc F test/fts1a.test 8fa66282a2a297faebdab76279c1693eb7920a3b F test/fts1b.test 5d8a01aefbecc8b7442b36c94c05eb7a845462d5 -F test/fts1c.test a57cb192d59ddacba64d17c326ff99393c181dc6 +F test/fts1c.test 3e1ad5a8b9118ba2970e6e4572cbc0f0d952d184 F test/func.test 0ed54b5aeaad319f68016c033acfebef56f5874a F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d @@ -399,7 +399,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 944d5f812004e2dc0065fce267accf8907235a50 -R a3b9f1ec905300375312507d7a2e50ec +P 165645d30115f3171fc45489823f85639fe2bfcd +R 02e1bfc3de0db0fdbc150a5e5d77d065 U drh -Z e44db4ed3c8a0588eb2a24973c8a730d +Z 838ab44cedca04109db513f0d883f765 diff --git a/manifest.uuid b/manifest.uuid index 3144d7b27c..2288e204ed 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -165645d30115f3171fc45489823f85639fe2bfcd \ No newline at end of file +d3f4ae827582bd0aac54ae3211d272a1429b6523 \ No newline at end of file diff --git a/test/fts1c.test b/test/fts1c.test index 3003f5fc64..dc88ddb140 100644 --- a/test/fts1c.test +++ b/test/fts1c.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is testing the FTS1 module. # -# $Id: fts1c.test,v 1.7 2006/09/21 02:03:11 drh Exp $ +# $Id: fts1c.test,v 1.8 2006/09/28 18:37:16 drh Exp $ # set testdir [file dirname $argv0] @@ -1131,31 +1131,31 @@ do_test fts1c-4.2 { SELECT snippet(email) FROM email WHERE email MATCH 'christmas candlelight' } -} {{...place.? What do you think about going here Christmas +} {{... place.? What do you think about going here Christmas eve?? They have an 11:00 a.m. service and a candlelight service at 5:00 p.m., -among others. - -...}} +among others. ...}} do_test fts1c-4.3 { execsql { SELECT snippet(email) FROM email WHERE email MATCH 'deal sheet potential reuse' } -} {{EOL-Accenture Deal Sheet...intent +} {{EOL-Accenture Deal Sheet ... intent Review Enron asset base for potential reuse/ licensing - Contract negotiations - -...}} + Contract negotiations ...}} do_test fts1c-4.4 { execsql { SELECT snippet(email,'<<<','>>>',' ') FROM email WHERE email MATCH 'deal sheet potential reuse' } -} {{EOL-Accenture <<>> <<>> intent +} {{EOL-Accenture <<>> <<>> intent Review Enron asset base for <<>> <<>>/ licensing - Contract negotiations - - }} + Contract negotiations }} +do_test fts1c-4.5 { + execsql { + SELECT snippet(email,'<<<','>>>',' ') FROM email + WHERE email MATCH 'first things' + } +} {{Re: <<>> Polish Deal! Congrats! <<>> seem to be building rapidly now on the }} finish_test