From: drh Date: Sun, 14 Mar 2004 22:11:59 +0000 (+0000) Subject: Make sqlite_encode_binary() and sqlite_decode_binary() an official part of X-Git-Tag: version-3.6.10~4773 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6da834a8b4081d29d2152f8fab23af93ffc5ff47;p=thirdparty%2Fsqlite.git Make sqlite_encode_binary() and sqlite_decode_binary() an official part of the library. (CVS 1295) FossilOrigin-Name: 786fe545560ec6c42bb0e344345031f425bf177a --- diff --git a/main.mk b/main.mk index 840b336981..2d9f0be502 100644 --- a/main.mk +++ b/main.mk @@ -72,6 +72,7 @@ SRC = \ $(TOP)/src/copy.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ + $(TOP)/src/encode.c \ $(TOP)/src/expr.c \ $(TOP)/src/func.c \ $(TOP)/src/hash.c \ @@ -268,6 +269,9 @@ date.o: $(TOP)/src/date.c $(HDR) delete.o: $(TOP)/src/delete.c $(HDR) $(TCCX) -c $(TOP)/src/delete.c +encode.o: $(TOP)/src/encode.c + $(TCCX) -c $(TOP)/src/encode.c + expr.o: $(TOP)/src/expr.c $(HDR) $(TCCX) -c $(TOP)/src/expr.c diff --git a/manifest b/manifest index c3b56b6dc7..3e768c03bf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updates\sto\sthe\sarchitecture\sdocument.\s(CVS\s1294) -D 2004-03-14T11:57:58 +C Make\ssqlite_encode_binary()\sand\ssqlite_decode_binary()\san\sofficial\spart\sof\nthe\slibrary.\s(CVS\s1295) +D 2004-03-14T22:12:00 F Makefile.in 46788b65500865e3fd965f7617d41697da8a11a1 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -15,8 +15,8 @@ F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538 F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh f6b283068efa69f06eb8aa1fe4bddfdbdeb35826 -F main.mk d88d460c46a12ceb33daad7a7a8725e4bc2dbaad -F publish.sh d413bc45500e6d76db0535e46628fa5c88df1c6f +F main.mk 1b27efb94be53a96c4333584a00a59fcc87ddc37 +F publish.sh 1cd5c982388560fa91eedf6a338e210f713b35c8 F spec.template a38492f1c1dd349fc24cb0565e08afc53045304b F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea F sqlite.def a4d2ada1c3667fd1bc18a37bf2ff9dcf138e0d51 @@ -30,7 +30,7 @@ F src/build.c c8ab8b467d9a64254b0d4d42083f6313b3a980d1 F src/copy.c 750e13828c3e4a293123e36aaa7cf0f22466248a F src/date.c f055419d602bde622c70f831350b6b52f2235de0 F src/delete.c 82001c74882319f94dab5f6b92a27311b31092ae -F src/encode.c 9e70ea1e4e746f23f18180949e94f1bb1c2220d3 +F src/encode.c e6518a1e3326a07539a88d2082cbaa3389cdf6e0 F src/expr.c 95ea5d47d11b5085aaeeb77d60b17c2cba13383a F src/func.c 34fead7a33e82095f6412d3fafd379d47864b3be F src/hash.c 9b56ef3b291e25168f630d5643a4264ec011c70e @@ -188,7 +188,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P 31c94acc72d318b5dec0fef1485621943add45c8 -R 4444a9fae45099d79266fa1def7dab13 +P c661cc81b6981c536c107f40525ad9783b11ea82 +R 53b6160aa94d763507d1d66642e02dba U drh -Z 8aa570decc2b64f7981738dac3c42536 +Z 751dfdf95f809133e2f24efbf8215847 diff --git a/manifest.uuid b/manifest.uuid index e3c4aa5528..f4677ec2cb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c661cc81b6981c536c107f40525ad9783b11ea82 \ No newline at end of file +786fe545560ec6c42bb0e344345031f425bf177a \ No newline at end of file diff --git a/publish.sh b/publish.sh index 4691dee6e5..d15e9bf703 100644 --- a/publish.sh +++ b/publish.sh @@ -122,6 +122,8 @@ sqlite_finalize sqlite_reset sqlite_bind sqlite_last_statement_changes +sqlite_encode_binary +sqlite_decode_binary END_OF_FILE i386-mingw32msvc-dllwrap \ --def sqlite.def -v --export-all \ diff --git a/src/encode.c b/src/encode.c index 925995d190..712619c4c7 100644 --- a/src/encode.c +++ b/src/encode.c @@ -15,9 +15,10 @@ ** data in an SQLite database. The code in this file is not used by any other ** part of the SQLite library. ** -** $Id: encode.c,v 1.10 2004/01/14 21:59:23 drh Exp $ +** $Id: encode.c,v 1.11 2004/03/14 22:12:00 drh Exp $ */ #include +#include /* ** How This Encoder Works @@ -114,13 +115,19 @@ ** ** The return value is the number of characters in the encoded ** string, excluding the "\000" terminator. +** +** If out==NULL then no output is generated but the routine still returns +** the number of characters that would have been generated if out had +** not been NULL. */ int sqlite_encode_binary(const unsigned char *in, int n, unsigned char *out){ int i, j, e, m; int cnt[256]; if( n<=0 ){ - out[0] = 'x'; - out[1] = 0; + if( out ){ + out[0] = 'x'; + out[1] = 0; + } return 1; } memset(cnt, 0, sizeof(cnt)); @@ -136,16 +143,16 @@ int sqlite_encode_binary(const unsigned char *in, int n, unsigned char *out){ if( m==0 ) break; } } + if( out==0 ){ + return n+m+1; + } out[0] = e; j = 1; for(i=0; i%d (max %d)", n, strlen(out)+1, m); if( strlen(out)+1>m ){ @@ -244,6 +255,9 @@ int main(int argc, char **argv){ } printf(" OK\n"); } - fprintf(stderr, "Finished. Total encoding: %d bytes\n", nByte); + fprintf(stderr,"Finished. Total encoding: %d->%d bytes\n", + nByteIn, nByteOut); + fprintf(stderr,"Avg size increase: %.3f%%\n", + (nByteOut-nByteIn)*100.0/(double)nByteIn); } #endif /* ENCODER_TEST */