]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Allow underscores to occur in hex literals.
authordan <Dan Kennedy>
Mon, 22 Jan 2024 19:38:55 +0000 (19:38 +0000)
committerdan <Dan Kennedy>
Mon, 22 Jan 2024 19:38:55 +0000 (19:38 +0000)
FossilOrigin-Name: 81a56229460cc5b6acfd3c3729fcf89ea3cccb546ca2b4f4035b140c60911e18

manifest
manifest.uuid
src/tokenize.c
src/util.c
test/literal2.tcl
test/literal2.test
test/misc1.test

index c1b974d23a62eb6c522a641b120c5cbc836d9d11..77f3ca0ff6811bce5f64abf10ae7acf8464f1e27 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sextra\stests\sfor\sthe\scode\son\sthis\sbranch.
-D 2024-01-22T19:00:50.821
+C Allow\sunderscores\sto\soccur\sin\shex\sliterals.
+D 2024-01-22T19:38:55.172
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -800,13 +800,13 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7
 F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f
 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
-F src/tokenize.c f283d8017b57d8be74218f6a820fb72f72ee7e05267083b4ac3b1ed456e0a290
+F src/tokenize.c 3ea60fcd98a0eb1391592a080fb8871b0026eaffbdb5795ef3b19bb7d48e702a
 F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee
 F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81
 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92
 F src/upsert.c fa125a8d3410ce9a97b02cb50f7ae68a2476c405c76aa692d3acf6b8586e9242
 F src/utf.c f23165685a67b4caf8ec08fb274cb3f319103decfb2a980b7cfd55d18dfa855e
-F src/util.c 2b274b03f0d4fd1bf253f160d6b399bc5265338b043c078045c5e32298891ec8
+F src/util.c 25e0b776d5bb326d6009fbd8705c5ab332318b0f1c213dab4a717524defb9a7d
 F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104
 F src/vdbe.c 92910d536e0b77505599cd6ae5d9d449e4a5d31ada61da4c0bb84f6ccb2c3189
 F src/vdbe.h 88e19a982df9027ec1c177c793d1a5d34dc23d8f06e3b2d997f43688b05ee0eb
@@ -1356,8 +1356,8 @@ F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de9874
 F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf
 F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e
 F test/literal.test e3d65d4091126cb008f31f57a324364511a83dd9461df31f60b5df6bd1f1f846
-F test/literal2.tcl 10713fed76885d43ada4161c0edf18fdc06e4405094e7baad888c6a1a29141b9
-F test/literal2.test 2e3ad4bc8cb019169d4f43400658fdc35acdcde7f79322c952b61ca07ac27ba6
+F test/literal2.tcl 70cf73b43f09396a4ba3ba7462b107a32866bb77deaa991c3296aa978edcdfdd
+F test/literal2.test dd6b763feb086fa34b4229c527b35099020e7f5d588089fff9e4434c71695f60
 F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04
 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7
 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db
@@ -1410,7 +1410,7 @@ F test/minmax.test fe638b55d77d2375531a8f549b338eafcd9adfbd2f72df37ed77d9b26ca0a
 F test/minmax2.test cf9311babb6f0518d04e42fd6a42c619531c4309a9dd790a2c4e9b3bc595e0de
 F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354
 F test/minmax4.test 272ca395257f05937dc96441c9dde4bc9fbf116a8d4fa02baeb0d13d50e36c87
-F test/misc1.test 8d138a4926ab90617c1aa29ce26e7785ae2b83a4d3a195d543b7374e05589dd1
+F test/misc1.test e3e36262aff1bd9b8b9bf1eeb3af04adb3fc1e23f0a92dbff708bba9e939ace1
 F test/misc2.test 71e746af479119386ac2ed7ab7d81d99970e75b49ffd3e8efffee100b4b5f350
 F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d
 F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db0e
@@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 5bbc378a3022e2013048c8e296d95de21d15a8d7c1b62e8ffb64782f952cfe12
-R 5ae47ec02f1c44e5b63d2c7bab26a43e
+P b15bbb201a7727806b9fd6c02f2579b01e0e38155a8f9e24c5d6f487fe3e8b6c
+R d0d892d569c1b9650e2494b0fb9379db
 U dan
-Z 067422c390415b433adad2a7d339896e
+Z 87a049db1576d41d80b78f3d72e95d0a
 # Remove this line to create a well-formed Fossil manifest.
index 0b49600412b36b898d4136af6e837cb4d8ef22f0..bec89eba1be4fcca5d26ae0745d2b8a2666529a0 100644 (file)
@@ -1 +1 @@
-b15bbb201a7727806b9fd6c02f2579b01e0e38155a8f9e24c5d6f487fe3e8b6c
\ No newline at end of file
+81a56229460cc5b6acfd3c3729fcf89ea3cccb546ca2b4f4035b140c60911e18
\ No newline at end of file
index 7a30512ec6ed2003ca86bd2c566b8bb4e89e50c0..f01548d4cb56424dbc6ffa4dfd117d5f26489961 100644 (file)
@@ -437,30 +437,11 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
       *tokenType = TK_INTEGER;
 #ifndef SQLITE_OMIT_HEX_INTEGER
       if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){
-        for(i=3; sqlite3Isxdigit(z[i]); i++){}
-        return i;
-      }
-#endif
-      for(i=0; 1; i++){
-        if( sqlite3Isdigit(z[i])==0 ){
-          if( z[i]==SQLITE_DIGIT_SEPARATOR
-           && sqlite3Isdigit(z[i-1])
-           && sqlite3Isdigit(z[i+1])
-          ){
-            *tokenType = TK_QNUMBER;
-          }else{
-            break;
-          }
-        }
-      }
-#ifndef SQLITE_OMIT_FLOATING_POINT
-      if( z[i]=='.' ){
-        if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT;
-        for(i++; 1; i++){
-          if( sqlite3Isdigit(z[i])==0 ){
+        for(i=3; 1; i++){
+          if( sqlite3Isxdigit(z[i])==0 ){
             if( z[i]==SQLITE_DIGIT_SEPARATOR
-             && sqlite3Isdigit(z[i-1])
-             && sqlite3Isdigit(z[i+1])
+             && sqlite3Isxdigit(z[i-1])
+             && sqlite3Isxdigit(z[i+1])
             ){
               *tokenType = TK_QNUMBER;
             }else{
@@ -468,14 +449,10 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
             }
           }
         }
-      }
-      if( (z[i]=='e' || z[i]=='E') &&
-           ( sqlite3Isdigit(z[i+1]) 
-            || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))
-           )
-      ){
-        if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT;
-        for(i+=2; 1; i++){
+      }else
+#endif
+        {
+        for(i=0; 1; i++){
           if( sqlite3Isdigit(z[i])==0 ){
             if( z[i]==SQLITE_DIGIT_SEPARATOR
              && sqlite3Isdigit(z[i-1])
@@ -487,8 +464,43 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
             }
           }
         }
-      }
+#ifndef SQLITE_OMIT_FLOATING_POINT
+        if( z[i]=='.' ){
+          if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT;
+          for(i++; 1; i++){
+            if( sqlite3Isdigit(z[i])==0 ){
+              if( z[i]==SQLITE_DIGIT_SEPARATOR
+               && sqlite3Isdigit(z[i-1])
+               && sqlite3Isdigit(z[i+1])
+              ){
+                *tokenType = TK_QNUMBER;
+              }else{
+                break;
+              }
+            }
+          }
+        }
+        if( (z[i]=='e' || z[i]=='E') &&
+             ( sqlite3Isdigit(z[i+1]) 
+              || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))
+             )
+        ){
+          if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT;
+          for(i+=2; 1; i++){
+            if( sqlite3Isdigit(z[i])==0 ){
+              if( z[i]==SQLITE_DIGIT_SEPARATOR
+               && sqlite3Isdigit(z[i-1])
+               && sqlite3Isdigit(z[i+1])
+              ){
+                *tokenType = TK_QNUMBER;
+              }else{
+                break;
+              }
+            }
+          }
+        }
 #endif
+      }
       while( IdChar(z[i]) ){
         *tokenType = TK_ILLEGAL;
         i++;
index 24eff14e9f8699d3433aee072f7495bf8131d35a..9a2ea9e9019e7d197bdd66472a995d5af0ea10f8 100644 (file)
@@ -312,10 +312,9 @@ void sqlite3DequoteExpr(Expr *p){
 }
 
 /*
-** Expression p is a QINTEGER or QFLOAT (quoted integer or float). Dequote
-** the value in p->u.zToken and set the type to INTEGER or FLOAT. "Quoted"
-** integers or floats are those that contain '_' characters that must
-** be removed before further processing.
+** Expression p is a QNUMBER (quoted number). Dequote the value in p->u.zToken
+** and set the type to INTEGER or FLOAT. "Quoted" integers or floats are those
+** that contain '_' characters that must be removed before further processing.
 */
 void sqlite3DequoteNumber(Expr *p){
   if( p ){
@@ -329,6 +328,9 @@ void sqlite3DequoteNumber(Expr *p){
         if( *pIn=='e' || *pIn=='E' || *pIn=='.' ) p->op = TK_FLOAT;
       }
     }while( *pIn++ );
+    if( p->u.zToken[0]=='0' && p->u.zToken[1]=='x' ){
+      p->op = TK_INTEGER;
+    }
   }
 }
 
index 2c97150b0cb09b675fa4958cd3afc476ee9fe6b9..029d33f51a867c8ab9971175cf9e97640d6782f3 100644 (file)
@@ -22,6 +22,14 @@ errorsql_test 1.1 { SELECT 123__456 }
 
 execsql_float_test 2.1 { SELECT 1.0e1_2 }
 
+
+execsql_test  3.0 { SELECT 0xFF_FF }
+execsql_test  3.1 { SELECT 0xFF_EF }
+
+errorsql_test  3.2 { SELECT 0xFF__EF }
+# errorsql_test   3.3 { SELECT 0x_FFEF }
+errorsql_test  3.4 { SELECT 0xFFEF_ }
+
 finish_test
 
 
index 743df44eb7cf69eb33b43db86c67ffe1e7819446..eda526fcef8fcaecb9f3c144ab1cbd821efa1c99 100644 (file)
@@ -45,4 +45,22 @@ do_test 2.1 {
   set {} {}
 } {}
 
+do_execsql_test 3.0 {
+  SELECT 0xFF_FF
+} {65535}
+
+do_execsql_test 3.1 {
+  SELECT 0xFF_EF
+} {65519}
+
+# PG says ERROR:  trailing junk after numeric literal at or near "0xFF_"
+do_test 3.2 { catch { execsql {
+  SELECT 0xFF__EF
+} } } 1
+
+# PG says ERROR:  trailing junk after numeric literal at or near "0xFFEF_"
+do_test 3.4 { catch { execsql {
+  SELECT 0xFFEF_
+} } } 1
+
 finish_test
index 83acc752af74c5b3d4c4cdf2aa98ba7b2566e617..8110d38678de1d789d76652becc67344c308c033 100644 (file)
@@ -654,7 +654,7 @@ do_catchsql_test misc1-21.1 {
 } {1 {near "#0": syntax error}}
 do_catchsql_test misc1-21.2 {
   VALUES(0,0x0MATCH#0;
-} {1 {near ";": syntax error}}
+} {1 {unrecognized token: "0x0MATCH"}}
 
 # 2015-04-15
 do_execsql_test misc1-22.1 {