mirror of
https://github.com/sqlite/sqlite.git
synced 2025-10-21 11:13:54 +03:00
Consolidate two different UTF8 encoders into a single subroutine.
FossilOrigin-Name: 6208e494858b9d362efc7db4e8aac6f8e93fe51d2e038c94dfa97c55a74688a0
This commit is contained in:
18
manifest
18
manifest
@@ -1,5 +1,5 @@
|
||||
C Fix\sthe\snew\sshellA.test\stest\sscript\sso\sthat\sit\sworks\swith\sValgrind.
|
||||
D 2025-02-24T23:34:50.874
|
||||
C Consolidate\stwo\sdifferent\sUTF8\sencoders\sinto\sa\ssingle\ssubroutine.
|
||||
D 2025-02-25T11:47:34.550
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
|
||||
@@ -735,7 +735,7 @@ F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42
|
||||
F src/expr.c 6769d3f0ca9b1792e883e3ff21fdc5ca0033cece65571ebbf9d8b8fe2f47cd27
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f
|
||||
F src/func.c 9d352aee28d64e0b1e48fd7a4606d6700cce443055c6369f69bfcadbb9bd7adb
|
||||
F src/func.c dfd3d099d2381f034185457f2181cadc7c86e226578ebf85b158878e294a69c0
|
||||
F src/global.c a19e4b1ca1335f560e9560e590fc13081e21f670643367f99cb9e8f9dc7d615b
|
||||
F src/hash.c 73934a7f7ab1cb110614a9388cb516893b0cf5b7b69e4fd1a0780ac4ce166be7
|
||||
F src/hash.h 46b92795a95bfefb210f52f0c316e9d7cdbcdd7e7fcfb0d8be796d3a5767cddf
|
||||
@@ -777,7 +777,7 @@ F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5
|
||||
F src/pcache1.c 78d4935e510f7bed0fdd1a3f742c0e663b36a795f9dc7411161dc22bdae1245e
|
||||
F src/pragma.c c7ada272232e1182c4536d9637fa7b955a10bc1bd8d5a87d4dc9309dab827791
|
||||
F src/prepare.c 1832be043fce7d489959aae6f994c452d023914714c4d5457beaed51c0f3d126
|
||||
F src/printf.c 743e31d168ad01ecc93a7303c07ef5ac741c4b8342b88e7cda428dbd2b4d9844
|
||||
F src/printf.c b6056bd2818523255255af34d370e2665b4895e50476955de797368d92f8f31f
|
||||
F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
|
||||
F src/resolve.c 626c24b258b111f75c22107aa5614ad89810df3026f5ca071116d3fe75925c75
|
||||
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
|
||||
@@ -786,7 +786,7 @@ F src/shell.c.in 19cde2832968fff4d26a75b40b3af1ad7744dfeb0023467f4100849e23a81ce
|
||||
F src/sqlite.h.in 8d4486fb28a90de818ac1e8c6206ea458e7de6bd8e0dfa3d554494f155be8c01
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
|
||||
F src/sqliteInt.h 587be8a6047992f44590bc255ea43ba7f2a46fbbf80da77c1eead07b31cf8a42
|
||||
F src/sqliteInt.h 674ba4569567f1773f0e4b84fa1c766d497da4e43c68aa2647755a5e61b7bacc
|
||||
F src/sqliteLimit.h 6d817c28a8f19af95e6f4921933b7fbbca48a962bce0eb0ec81e8bb3ef38e68b
|
||||
F src/status.c 0e72e4f6be6ccfde2488eb63210297e75f569f3ce9920f6c3d77590ec6ce5ffd
|
||||
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
|
||||
@@ -847,7 +847,7 @@ F src/treeview.c d85ce76e6d1498d781957c07cb234da6d77ce0ed2d196480d516f54dabc6227
|
||||
F src/trigger.c da3c25786870d8bf97cd46b493374c2375d1abaf20a9b0f5f8629a3f2f2ce383
|
||||
F src/update.c 3e5e7ff66fa19ebe4d1b113d480639a24cc1175adbefabbd1a948a07f28e37cf
|
||||
F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1
|
||||
F src/utf.c 8b29d9a5956569ea2700f869669b8ef67a9662ee5e724ff77ab3c387e27094ba
|
||||
F src/utf.c d4d55ca95106a2029ec1cdbd2497a34e69ea1d338f1a9d80ef15ebf4ff01690d
|
||||
F src/util.c 9ff6470dabcf943fd796d2da766c98bd328c8f6fe036a31e5b338e628603f989
|
||||
F src/vacuum.c b763b6457bd058d2072ef9364832351fd8d11e8abf70cbb349657360f7d55c40
|
||||
F src/vdbe.c e7567bed441a53c4ceb48d2bdf3d1747677fc296a91e8d2a0fe8facdb9b890ce
|
||||
@@ -2211,8 +2211,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
|
||||
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
||||
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 4c56cd7392f114e27b43d8fcc79444c3078cd65285ba7dd3338a414e2a9f5392
|
||||
R 13d013de3c78981833017ee209b07ff8
|
||||
P c3949852cee320c2e02123b99c33155c459b10b2ac8e4fe80b1b7624c9ce0817
|
||||
R 783f95f7f826d114483ba4d9a5fea8e7
|
||||
U drh
|
||||
Z 457892f8d9951398e0ae7676d77bfb1c
|
||||
Z 0a01b2d715a4d18665f9611e7764aecb
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@@ -1 +1 @@
|
||||
c3949852cee320c2e02123b99c33155c459b10b2ac8e4fe80b1b7624c9ce0817
|
||||
6208e494858b9d362efc7db4e8aac6f8e93fe51d2e038c94dfa97c55a74688a0
|
||||
|
36
src/func.c
36
src/func.c
@@ -1149,34 +1149,6 @@ void sqlite3QuoteValue(StrAccum *pStr, sqlite3_value *pValue, int bEscape){
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Write a single UTF8 character whose value if v into the
|
||||
** buffer starting at zOut. Return the number of bytes needed
|
||||
** to encode that character.
|
||||
*/
|
||||
static int appendOneUtf8Char(char *zOut, u32 v){
|
||||
if( v<0x00080 ){
|
||||
zOut[0] = (u8)(v & 0xff);
|
||||
return 1;
|
||||
}
|
||||
if( v<0x00800 ){
|
||||
zOut[0] = 0xc0 + (u8)((v>>6) & 0x1f);
|
||||
zOut[1] = 0x80 + (u8)(v & 0x3f);
|
||||
return 2;
|
||||
}
|
||||
if( v<0x10000 ){
|
||||
zOut[0] = 0xe0 + (u8)((v>>12) & 0x0f);
|
||||
zOut[1] = 0x80 + (u8)((v>>6) & 0x3f);
|
||||
zOut[2] = 0x80 + (u8)(v & 0x3f);
|
||||
return 3;
|
||||
}
|
||||
zOut[0] = 0xf0 + (u8)((v>>18) & 0x07);
|
||||
zOut[1] = 0x80 + (u8)((v>>12) & 0x3f);
|
||||
zOut[2] = 0x80 + (u8)((v>>6) & 0x3f);
|
||||
zOut[3] = 0x80 + (u8)(v & 0x3f);
|
||||
return 4;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return true if z[] begins with N hexadecimal digits, and write
|
||||
** a decoding of those digits into *pVal. Or return false if any
|
||||
@@ -1248,19 +1220,19 @@ static void unistrFunc(
|
||||
}else if( sqlite3Isxdigit(zIn[i+1]) ){
|
||||
if( !isNHex(&zIn[i+1], 4, &v) ) goto unistr_error;
|
||||
i += 5;
|
||||
j += appendOneUtf8Char(&zOut[j], v);
|
||||
j += sqlite3AppendOneUtf8Character(&zOut[j], v);
|
||||
}else if( zIn[i+1]=='+' ){
|
||||
if( !isNHex(&zIn[i+2], 6, &v) ) goto unistr_error;
|
||||
i += 8;
|
||||
j += appendOneUtf8Char(&zOut[j], v);
|
||||
j += sqlite3AppendOneUtf8Character(&zOut[j], v);
|
||||
}else if( zIn[i+1]=='u' ){
|
||||
if( !isNHex(&zIn[i+2], 4, &v) ) goto unistr_error;
|
||||
i += 6;
|
||||
j += appendOneUtf8Char(&zOut[j], v);
|
||||
j += sqlite3AppendOneUtf8Character(&zOut[j], v);
|
||||
}else if( zIn[i+1]=='U' ){
|
||||
if( !isNHex(&zIn[i+2], 8, &v) ) goto unistr_error;
|
||||
i += 10;
|
||||
j += appendOneUtf8Char(&zOut[j], v);
|
||||
j += sqlite3AppendOneUtf8Character(&zOut[j], v);
|
||||
}else{
|
||||
goto unistr_error;
|
||||
}
|
||||
|
20
src/printf.c
20
src/printf.c
@@ -673,25 +673,7 @@ void sqlite3_str_vappendf(
|
||||
}
|
||||
}else{
|
||||
unsigned int ch = va_arg(ap,unsigned int);
|
||||
if( ch<0x00080 ){
|
||||
buf[0] = ch & 0xff;
|
||||
length = 1;
|
||||
}else if( ch<0x00800 ){
|
||||
buf[0] = 0xc0 + (u8)((ch>>6)&0x1f);
|
||||
buf[1] = 0x80 + (u8)(ch & 0x3f);
|
||||
length = 2;
|
||||
}else if( ch<0x10000 ){
|
||||
buf[0] = 0xe0 + (u8)((ch>>12)&0x0f);
|
||||
buf[1] = 0x80 + (u8)((ch>>6) & 0x3f);
|
||||
buf[2] = 0x80 + (u8)(ch & 0x3f);
|
||||
length = 3;
|
||||
}else{
|
||||
buf[0] = 0xf0 + (u8)((ch>>18) & 0x07);
|
||||
buf[1] = 0x80 + (u8)((ch>>12) & 0x3f);
|
||||
buf[2] = 0x80 + (u8)((ch>>6) & 0x3f);
|
||||
buf[3] = 0x80 + (u8)(ch & 0x3f);
|
||||
length = 4;
|
||||
}
|
||||
length = sqlite3AppendOneUtf8Character(buf, ch);
|
||||
}
|
||||
if( precision>1 ){
|
||||
i64 nPrior = 1;
|
||||
|
@@ -5143,6 +5143,7 @@ FuncDef *sqlite3FunctionSearch(int,const char*);
|
||||
void sqlite3InsertBuiltinFuncs(FuncDef*,int);
|
||||
FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
|
||||
void sqlite3QuoteValue(StrAccum*,sqlite3_value*,int);
|
||||
int sqlite3AppendOneUtf8Character(char*, u32);
|
||||
void sqlite3RegisterBuiltinFunctions(void);
|
||||
void sqlite3RegisterDateTimeFunctions(void);
|
||||
void sqlite3RegisterJsonFunctions(void);
|
||||
|
29
src/utf.c
29
src/utf.c
@@ -105,6 +105,35 @@ static const unsigned char sqlite3Utf8Trans1[] = {
|
||||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
** Write a single UTF8 character whose value is v into the
|
||||
** buffer starting at zOut. zOut must be sized to hold at
|
||||
** least for bytes. Return the number of bytes needed
|
||||
** to encode the new character.
|
||||
*/
|
||||
int sqlite3AppendOneUtf8Character(char *zOut, u32 v){
|
||||
if( v<0x00080 ){
|
||||
zOut[0] = (u8)(v & 0xff);
|
||||
return 1;
|
||||
}
|
||||
if( v<0x00800 ){
|
||||
zOut[0] = 0xc0 + (u8)((v>>6) & 0x1f);
|
||||
zOut[1] = 0x80 + (u8)(v & 0x3f);
|
||||
return 2;
|
||||
}
|
||||
if( v<0x10000 ){
|
||||
zOut[0] = 0xe0 + (u8)((v>>12) & 0x0f);
|
||||
zOut[1] = 0x80 + (u8)((v>>6) & 0x3f);
|
||||
zOut[2] = 0x80 + (u8)(v & 0x3f);
|
||||
return 3;
|
||||
}
|
||||
zOut[0] = 0xf0 + (u8)((v>>18) & 0x07);
|
||||
zOut[1] = 0x80 + (u8)((v>>12) & 0x3f);
|
||||
zOut[2] = 0x80 + (u8)((v>>6) & 0x3f);
|
||||
zOut[3] = 0x80 + (u8)(v & 0x3f);
|
||||
return 4;
|
||||
}
|
||||
|
||||
/*
|
||||
** Translate a single UTF-8 character. Return the unicode value.
|
||||
**
|
||||
|
Reference in New Issue
Block a user