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.
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);
}
while( iMatch<nMatch && aMatch[iMatch].iCol<iCol ){ iMatch++; }
while( iStart<iEnd ){
- while( iMatch<nMatch && aMatch[iMatch].iStart<iStart ){ iMatch++; }
- if( iMatch<nMatch && aMatch[iMatch].iStart<iEnd ){
+ while( iMatch<nMatch && aMatch[iMatch].iStart<iStart
+ && aMatch[iMatch].iCol<=iCol ){
+ iMatch++;
+ }
+ if( iMatch<nMatch && aMatch[iMatch].iStart<iEnd
+ && aMatch[iMatch].iCol==iCol ){
nappend(&sb, &zDoc[iStart], aMatch[iMatch].iStart - iStart);
iStart = aMatch[iMatch].iStart;
append(&sb, zStartMark);
tailCol = iCol;
tailOffset = iEnd;
}
+ trimWhiteSpace(&sb);
if( tailEllipsis ){
+ appendWhiteSpace(&sb);
append(&sb, zEllipsis);
}
pCursor->snippet.zSnippet = sb.s;
-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
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
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
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
-165645d30115f3171fc45489823f85639fe2bfcd
\ No newline at end of file
+d3f4ae827582bd0aac54ae3211d272a1429b6523
\ No newline at end of file
# 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]
SELECT snippet(email) FROM email
WHERE email MATCH 'christmas candlelight'
}
-} {{<b>...</b>place.? What do you think about going here <b>Christmas</b>
+} {{<b>...</b> place.? What do you think about going here <b>Christmas</b>
eve?? They have an 11:00 a.m. service and a <b>candlelight</b> service at 5:00 p.m.,
-among others.
-
-<b>...</b>}}
+among others. <b>...</b>}}
do_test fts1c-4.3 {
execsql {
SELECT snippet(email) FROM email
WHERE email MATCH 'deal sheet potential reuse'
}
-} {{EOL-Accenture <b>Deal</b> <b>Sheet</b><b>...</b>intent
+} {{EOL-Accenture <b>Deal</b> <b>Sheet</b> <b>...</b> intent
Review Enron asset base for <b>potential</b> <b>reuse</b>/ licensing
- Contract negotiations
-
-<b>...</b>}}
+ Contract negotiations <b>...</b>}}
do_test fts1c-4.4 {
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.5 {
+ execsql {
+ SELECT snippet(email,'<<<','>>>',' ') FROM email
+ WHERE email MATCH 'first things'
+ }
+} {{Re: <<<First>>> Polish Deal! Congrats! <<<Things>>> seem to be building rapidly now on the }}
finish_test