]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a bug in the spellfix extension causing it to compute suboptimal answers.
authordrh <drh@noemail.net>
Fri, 30 Mar 2018 16:34:04 +0000 (16:34 +0000)
committerdrh <drh@noemail.net>
Fri, 30 Mar 2018 16:34:04 +0000 (16:34 +0000)
The problem was introduced by check-in [afd6fbc01052ccfc9].

FossilOrigin-Name: 3bf28fd9a70ebefc464dceda124d6ed342dd83f71eeeb0568f79e34e731a073e

ext/misc/spellfix.c
manifest
manifest.uuid

index e2364fe5b89f718b9293284f29c8eecd224b4a57..faceea189cebdca777104c9e41f6deb90544b5ad 100644 (file)
@@ -835,6 +835,7 @@ static int utf8Len(unsigned char c, int N){
 ** the given string.
 */
 static int matchTo(EditDist3Cost *p, const char *z, int n){
+  assert( n>0 );
   if( p->a[p->nFrom]!=z[0] ) return 0;
   if( p->nTo>n ) return 0;
   if( strncmp(p->a+p->nFrom, z, p->nTo)!=0 ) return 0;
@@ -847,8 +848,10 @@ static int matchTo(EditDist3Cost *p, const char *z, int n){
 */
 static int matchFrom(EditDist3Cost *p, const char *z, int n){
   assert( p->nFrom<=n );
-  if( p->a[0]!=z[0] ) return 0;
-  if( strncmp(p->a, z, p->nFrom)!=0 ) return 0;
+  if( p->nFrom ){
+    if( p->a[0]!=z[0] ) return 0;
+    if( strncmp(p->a, z, p->nFrom)!=0 ) return 0;
+  }
   return 1;
 }
 
@@ -864,6 +867,7 @@ static int matchFromTo(
 ){
   int b1 = pStr->a[n1].nByte;
   if( b1>n2 ) return 0;
+  assert( b1>0 );
   if( pStr->z[n1]!=z2[0] ) return 0;
   if( strncmp(pStr->z+n1, z2, b1)!=0 ) return 0;
   return 1;
index db56171bcfc336349dcdff02ed3f7f67241b1be2..cdce8d1e9376fec347e531790ed284699fb7eb2a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\soff-by-one\serror\sin\sthe\sdist3\salgorithm\sof\sthe\sspellfix\sextension.
-D 2018-03-30T15:59:54.149
+C Fix\sa\sbug\sin\sthe\sspellfix\sextension\scausing\sit\sto\scompute\ssuboptimal\sanswers.\nThe\sproblem\swas\sintroduced\sby\scheck-in\s[afd6fbc01052ccfc9].
+D 2018-03-30T16:34:04.007
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F Makefile.in 7016fc56c6b9bfe5daac4f34be8be38d8c0b5fab79ccbfb764d3b23bf1c6fff3
@@ -294,7 +294,7 @@ F ext/misc/series.c f3c0dba5c5c749ce1782b53076108f87cf0b71041eb6023f727a9c50681d
 F ext/misc/sha1.c 0b9e9b855354910d3ca467bf39099d570e73db56
 F ext/misc/shathree.c 9e960ba50483214c6a7a4b1517f8d8cef799e9db381195178c3fd3ad207e10c0
 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
-F ext/misc/spellfix.c 28faad8be801b36926cee7f74e8fffcddc2f6c4b56c699f7501ca2eeae316dfb
+F ext/misc/spellfix.c 54d650f44f3a69a851814791bd4d304575cdbbf78d96d4f0801b44a8f31a58c5
 F ext/misc/sqlar.c 57d5bc45cd5492208e451f697404be88f8612527d64c9d42f96b325b64983d74
 F ext/misc/stmt.c 6f16443abb3551e3f5813bb13ba19a30e7032830015b0f92fe0c0453045c0a11
 F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512
@@ -1717,7 +1717,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b6252feb125db16dabf6ce07568159f0002f9053df1b7b600e2614cc9da24873
-R 5bb4c3e3e3df1583429be04eb3b092b3
+P 5c34af7b975598bbe20751dfdd346f43031cb2bcb6b78f1bbdb2b51b398de182
+R 32840bd2fcaf07eb6e9e19cb2e0114c1
 U drh
-Z 347174e588628be1221ab4287f906f72
+Z c20632532889bc7014eaf94ce0826931
index 9fa5e60408509802823c2edd5a85e444b6090439..318e5a3de15b9174de7b4afbe2e4a8606d08bd1e 100644 (file)
@@ -1 +1 @@
-5c34af7b975598bbe20751dfdd346f43031cb2bcb6b78f1bbdb2b51b398de182
\ No newline at end of file
+3bf28fd9a70ebefc464dceda124d6ed342dd83f71eeeb0568f79e34e731a073e
\ No newline at end of file