From 5f8cdac620fbf61fbdebd173f18b06b7f6f1906f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 14 Oct 2013 21:14:42 +0000 Subject: Move the tointeger() and toreal() functions out of core and make them into a run-time loadable extension. FossilOrigin-Name: 9f66dd7e3790c04f0ab724419f5381bd21f9ebad --- src/func.c | 141 ------------------------------------------------------------- 1 file changed, 141 deletions(-) (limited to 'src/func.c') diff --git a/src/func.c b/src/func.c index 73b6c3bb2..e2ab68f03 100644 --- a/src/func.c +++ b/src/func.c @@ -965,145 +965,6 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ } } -/* -** tointeger(X): If X is any value (integer, double, blob, or string) that -** can be losslessly converted into an integer, then make the conversion and -** return the result. Otherwise, return NULL. -*/ -static void tointegerFunc( - sqlite3_context *context, - int argc, - sqlite3_value **argv -){ - assert( argc==1 ); - UNUSED_PARAMETER(argc); - switch( sqlite3_value_type(argv[0]) ){ - case SQLITE_FLOAT: { - double rVal = sqlite3_value_double(argv[0]); - i64 iVal = (i64)rVal; - if( rVal==(double)iVal ){ - sqlite3_result_int64(context, iVal); - } - break; - } - case SQLITE_INTEGER: { - sqlite3_result_int64(context, sqlite3_value_int64(argv[0])); - break; - } - case SQLITE_BLOB: { - const unsigned char *zBlob = sqlite3_value_blob(argv[0]); - if( zBlob ){ - int nBlob = sqlite3_value_bytes(argv[0]); - if( nBlob==sizeof(i64) ){ - i64 iVal; - if( SQLITE_BIGENDIAN ){ - int i; - unsigned char *zBlobRev = contextMalloc(context, nBlob); - if( !zBlobRev ) break; - for(i=0; i