| Index: third_party/sqlite/src/src/test_hexio.c
|
| diff --git a/third_party/sqlite/src/src/test_hexio.c b/third_party/sqlite/src/src/test_hexio.c
|
| index 9e1e8de80d021b0f3d6deff62019e4195b2117d6..02bd60c8aadc265a69fd12b52ceba2dd30f264ae 100644
|
| --- a/third_party/sqlite/src/src/test_hexio.c
|
| +++ b/third_party/sqlite/src/src/test_hexio.c
|
| @@ -16,8 +16,6 @@
|
| ** command of TCL to do a lot of this, but there are some issues
|
| ** with historical versions of the "binary" command. So it seems
|
| ** easier and safer to build our own mechanism.
|
| -**
|
| -** $Id: test_hexio.c,v 1.7 2008/05/12 16:17:42 drh Exp $
|
| */
|
| #include "sqliteInt.h"
|
| #include "tcl.h"
|
| @@ -318,6 +316,48 @@ static int utf8_to_utf8(
|
| return TCL_OK;
|
| }
|
|
|
| +static int getFts3Varint(const char *p, sqlite_int64 *v){
|
| + const unsigned char *q = (const unsigned char *) p;
|
| + sqlite_uint64 x = 0, y = 1;
|
| + while( (*q & 0x80) == 0x80 ){
|
| + x += y * (*q++ & 0x7f);
|
| + y <<= 7;
|
| + }
|
| + x += y * (*q++);
|
| + *v = (sqlite_int64) x;
|
| + return (int) (q - (unsigned char *)p);
|
| +}
|
| +
|
| +
|
| +/*
|
| +** USAGE: read_fts3varint BLOB VARNAME
|
| +**
|
| +** Read a varint from the start of BLOB. Set variable VARNAME to contain
|
| +** the interpreted value. Return the number of bytes of BLOB consumed.
|
| +*/
|
| +static int read_fts3varint(
|
| + void * clientData,
|
| + Tcl_Interp *interp,
|
| + int objc,
|
| + Tcl_Obj *CONST objv[]
|
| +){
|
| + int nBlob;
|
| + unsigned char *zBlob;
|
| + sqlite3_int64 iVal;
|
| + int nVal;
|
| +
|
| + if( objc!=3 ){
|
| + Tcl_WrongNumArgs(interp, 1, objv, "BLOB VARNAME");
|
| + return TCL_ERROR;
|
| + }
|
| + zBlob = Tcl_GetByteArrayFromObj(objv[1], &nBlob);
|
| +
|
| + nVal = getFts3Varint((char*)zBlob, (sqlite3_int64 *)(&iVal));
|
| + Tcl_ObjSetVar2(interp, objv[2], 0, Tcl_NewWideIntObj(iVal), 0);
|
| + Tcl_SetObjResult(interp, Tcl_NewIntObj(nVal));
|
| + return TCL_OK;
|
| +}
|
| +
|
|
|
| /*
|
| ** Register commands with the TCL interpreter.
|
| @@ -333,6 +373,7 @@ int Sqlitetest_hexio_Init(Tcl_Interp *interp){
|
| { "hexio_render_int16", hexio_render_int16 },
|
| { "hexio_render_int32", hexio_render_int32 },
|
| { "utf8_to_utf8", utf8_to_utf8 },
|
| + { "read_fts3varint", read_fts3varint },
|
| };
|
| int i;
|
| for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
|
|
|