diff options
| author | Hans-Christoph Steiner <hans@eds.org> | 2014-10-16 22:51:43 -0400 | 
|---|---|---|
| committer | Hans-Christoph Steiner <hans@eds.org> | 2014-10-16 22:51:43 -0400 | 
| commit | 9f67c0520ea0d5f11a190197cdf746c512db4ce4 (patch) | |
| tree | c88a33f01f20a3d13a09594f114fffacebd0d1a4 /ext/fts3/fts3_test.c | |
| parent | ee20336e9c78d2e3782c8d096b9ab4f6ca8ce95f (diff) | |
| parent | 569c6676a6ddb0ff73821d7693b5e18ddef809b9 (diff) | |
Merge tag 'upstream/3.2.0'
Upstream version 3.2.0
# gpg: Signature made Thu 16 Oct 2014 10:51:39 PM EDT using RSA key ID 374BBE81
# gpg: Good signature from "Hans-Christoph Steiner <hans@guardianproject.info>"
# gpg:                 aka "Hans-Christoph Steiner <hans@eds.org>"
# gpg:                 aka "Hans-Christoph Steiner <hans@at.or.at>"
# gpg:                 aka "[jpeg image of size 5408]"
Diffstat (limited to 'ext/fts3/fts3_test.c')
| -rw-r--r-- | ext/fts3/fts3_test.c | 49 | 
1 files changed, 49 insertions, 0 deletions
| diff --git a/ext/fts3/fts3_test.c b/ext/fts3/fts3_test.c index 75ec6bd..36dcc94 100644 --- a/ext/fts3/fts3_test.c +++ b/ext/fts3/fts3_test.c @@ -517,6 +517,51 @@ static int fts3_test_tokenizer_cmd(    return TCL_OK;  } +static int fts3_test_varint_cmd( +  ClientData clientData, +  Tcl_Interp *interp, +  int objc, +  Tcl_Obj *CONST objv[] +){ +#ifdef SQLITE_ENABLE_FTS3 +  char aBuf[24]; +  int rc; +  Tcl_WideInt w, w2; +  int nByte, nByte2; + +  if( objc!=2 ){ +    Tcl_WrongNumArgs(interp, 1, objv, "INTEGER"); +    return TCL_ERROR; +  } + +  rc = Tcl_GetWideIntFromObj(interp, objv[1], &w); +  if( rc!=TCL_OK ) return rc; + +  nByte = sqlite3Fts3PutVarint(aBuf, w); +  nByte2 = sqlite3Fts3GetVarint(aBuf, &w2); +  if( w!=w2 || nByte!=nByte2 ){ +    char *zErr = sqlite3_mprintf("error testing %lld", w); +    Tcl_ResetResult(interp); +    Tcl_AppendResult(interp, zErr, 0); +    return TCL_ERROR; +  } + +  if( w<=2147483647 && w>=0 ){ +    int i; +    nByte2 = fts3GetVarint32(aBuf, &i); +    if( (int)w!=i || nByte!=nByte2 ){ +      char *zErr = sqlite3_mprintf("error testing %lld (32-bit)", w); +      Tcl_ResetResult(interp); +      Tcl_AppendResult(interp, zErr, 0); +      return TCL_ERROR; +    } +  } + +#endif +  UNUSED_PARAMETER(clientData); +  return TCL_OK; +} +  /*   ** End of tokenizer code.  **************************************************************************/  @@ -529,6 +574,10 @@ int Sqlitetestfts3_Init(Tcl_Interp *interp){    Tcl_CreateObjCommand(        interp, "fts3_test_tokenizer", fts3_test_tokenizer_cmd, 0, 0    ); + +  Tcl_CreateObjCommand( +      interp, "fts3_test_varint", fts3_test_varint_cmd, 0, 0 +  );    return TCL_OK;  }  #endif                  /* SQLITE_ENABLE_FTS3 || SQLITE_ENABLE_FTS4 */ | 
