]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the char() function so that it works even if SQLITE_OMIT_UTF16 is defined.
authordrh <drh@noemail.net>
Thu, 7 Mar 2013 14:00:04 +0000 (14:00 +0000)
committerdrh <drh@noemail.net>
Thu, 7 Mar 2013 14:00:04 +0000 (14:00 +0000)
FossilOrigin-Name: af542c82e8e7f0415530b639fa397429c5f377f6

manifest
manifest.uuid
src/func.c
test/func.test

index afc16ed0301d26a2a6fa22f8609fbfea2f6e76bf..7edb73ef7ff27d3c893c71d4bbc733926e47cb48 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Skip\stests\sthat\srequire\sUTF-16\ssupport\swhen\scompiled\swith\sSQLITE_OMIT_UTF16.
-D 2013-03-07T09:39:18.757
+C Fix\sthe\schar()\sfunction\sso\sthat\sit\sworks\seven\sif\sSQLITE_OMIT_UTF16\sis\sdefined.
+D 2013-03-07T14:00:04.830
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -133,7 +133,7 @@ F src/delete.c 9b8d308979114991e5dc7cee958316e07186941d
 F src/expr.c a23b4aac2a455b2e76b55bef5dcfbe62b665375c
 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
 F src/fkey.c e16942bd5c8a868ac53287886464a5ed0e72b179
-F src/func.c f829e79fe7c7150659bee6d521b1edbda4a97dc3
+F src/func.c 48987c025d69399f59a1c2a553cea5da41bf105d
 F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a
 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4
 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970
@@ -508,7 +508,7 @@ F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891
 F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7
 F test/fts4unicode.test 25ccad45896f8e50f6a694cff738a35f798cdb40
 F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d
-F test/func.test 2d243cc61d11f1a8b984bdf5ac8a44683836b5dd
+F test/func.test b058483c17952eff7797b837bbb61e27e6b05606
 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
 F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a
 F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74
@@ -1037,7 +1037,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P 10ace06be7fbe9a76a201c418b2af453c7a69043
-R 4a6c0696fed39506ac10ad23e245be27
-U mistachkin
-Z 2203d346668b3376e187a4b6cb595762
+P e39391422e748407d74853d3de297dc1ea6b991d
+R 822f408c1766b55e00934d75132877ff
+U drh
+Z 4bfedc097a3e5f9aa5da630099d07ac8
index 85dc3bfa38941e23ad0e9bf9b7941f4fe3090f75..8c5637fab111605d09dbcde83fb50f5d78f90a91 100644 (file)
@@ -1 +1 @@
-e39391422e748407d74853d3de297dc1ea6b991d
\ No newline at end of file
+af542c82e8e7f0415530b639fa397429c5f377f6
\ No newline at end of file
index de75ff6e7ffd0d67c5d303367d3134a539cdd645..0fce95904fca451d54eb53117a8e48c4489340d6 100644 (file)
@@ -981,7 +981,6 @@ static void unicodeFunc(
 ** an integer.  It constructs a string where each character of the string
 ** is the unicode character for the corresponding integer argument.
 */
-#ifndef SQLITE_OMIT_UTF16
 static void charFunc(
   sqlite3_context *context,
   int argc,
@@ -1000,20 +999,24 @@ static void charFunc(
     x = sqlite3_value_int64(argv[i]);
     if( x<0 || x>0x10ffff ) x = 0xfffd;
     c = (unsigned)(x & 0x1fffff);
-    if( c<=0xFFFF ){
-      if( c>=0xd800 && c<=0xdfff ) c = 0xfffd;
-      *zOut++ = (u8)(c&0x00FF);
-      *zOut++ = (u8)((c>>8)&0x00FF);
+    if( c<0x00080 ){
+      *zOut++ = (u8)(c&0xFF);
+    }else if( c<0x00800 ){
+      *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);
+      *zOut++ = 0x80 + (u8)(c & 0x3F);
+    }else if( c<0x10000 ){
+      *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);
+      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);
+      *zOut++ = 0x80 + (u8)(c & 0x3F);
     }else{
-      *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));
-      *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));
-      *zOut++ = (u8)(c&0x00FF);
-      *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));
-    }
+      *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);
+      *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);
+      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);
+      *zOut++ = 0x80 + (u8)(c & 0x3F);
+    }                                                    \
   }
-  sqlite3_result_text16le(context, (char*)z, (int)(zOut-z), sqlite3_free);
+  sqlite3_result_text(context, (char*)z, (int)(zOut-z), sqlite3_free);
 }
-#endif
 
 /*
 ** The hex() function.  Interpret the argument as a blob.  Return
@@ -1643,9 +1646,7 @@ void sqlite3RegisterGlobalFunctions(void){
     FUNCTION(substr,             2, 0, 0, substrFunc       ),
     FUNCTION(substr,             3, 0, 0, substrFunc       ),
     FUNCTION(unicode,            1, 0, 0, unicodeFunc      ),
-#ifndef SQLITE_OMIT_UTF16
     FUNCTION(char,              -1, 0, 0, charFunc         ),
-#endif
     FUNCTION(abs,                1, 0, 0, absFunc          ),
 #ifndef SQLITE_OMIT_FLOATING_POINT
     FUNCTION(round,              1, 0, 0, roundFunc        ),
index 3df0cb16c04d5e7b0170591146c0813be85e7921..f09ff49805332c90cf7e7ea972c4a6cd734ce5f9 100644 (file)
@@ -1293,12 +1293,6 @@ do_test func-29.6 {
 do_execsql_test func-30.1 {SELECT unicode('$');} 36
 do_execsql_test func-30.2 [subst {SELECT unicode('\u00A2');}] 162
 do_execsql_test func-30.3 [subst {SELECT unicode('\u20AC');}] 8364
-
-ifcapable !utf16 {
-  finish_test
-  return
-}
-
 do_execsql_test func-30.4 {SELECT char(36,162,8364);} [subst {$\u00A2\u20AC}]
 
 for {set i 1} {$i<0xd800} {incr i 13} {