Index: src/expr.c ================================================================== --- src/expr.c +++ src/expr.c @@ -10,11 +10,11 @@ ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.148 2004/06/23 12:15:55 danielk1977 Exp $ +** $Id: expr.c,v 1.149 2004/06/23 12:35:15 danielk1977 Exp $ */ #include "sqliteInt.h" #include char const *sqlite3AffinityString(char affinity){ @@ -1762,11 +1762,11 @@ ** prefers UTF-16LE when UTF-16BE is requested, or vice versa. ** 6: An exact match. ** ** A larger value of 'matchqual' indicates a more desirable match. */ - if( (p->xStep||p->xFunc ) && (p->nArg==-1||p->nArg==nArg||nArg==-1) ){ + if( p->nArg==-1 || p->nArg==nArg || nArg==-1 ){ int match = 1; /* Quality of this match */ if( p->nArg==nArg || nArg==-1 ){ match = 4; } if( enc==p->iPrefEnc ){ Index: src/test1.c ================================================================== --- src/test1.c +++ src/test1.c @@ -11,11 +11,11 @@ ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.85 2004/06/23 12:15:55 danielk1977 Exp $ +** $Id: test1.c,v 1.86 2004/06/23 12:35:15 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include @@ -1089,18 +1089,24 @@ if( objc!=5 ) goto bad_args; if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR; - sqlite3_create_function(db, "test_function", 1, SQLITE_UTF8, - interp, val?test_function_utf8:0, 0, 0); + if( val ){ + sqlite3_create_function(db, "test_function", 1, SQLITE_UTF8, + interp, test_function_utf8, 0, 0); + } if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[3], &val) ) return TCL_ERROR; - sqlite3_create_function(db, "test_function", 1, SQLITE_UTF16LE, - interp, val?test_function_utf16le:0, 0, 0); + if( val ){ + sqlite3_create_function(db, "test_function", 1, SQLITE_UTF16LE, + interp, test_function_utf16le, 0, 0); + } if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[4], &val) ) return TCL_ERROR; - sqlite3_create_function(db, "test_function", 1, SQLITE_UTF16BE, - interp, val?test_function_utf16be:0, 0, 0); + if( val ){ + sqlite3_create_function(db, "test_function", 1, SQLITE_UTF16BE, + interp, test_function_utf16be, 0, 0); + } return TCL_OK; bad_args: Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " ", 0); Index: test/enc2.test ================================================================== --- test/enc2.test +++ test/enc2.test @@ -11,11 +11,11 @@ # This file implements regression tests for SQLite library. The focus of # this file is testing the SQLite routines used for converting between the # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # UTF-16be). # -# $Id: enc2.test,v 1.13 2004/06/23 12:15:55 danielk1977 Exp $ +# $Id: enc2.test,v 1.14 2004/06/23 12:35:16 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # The rough organisation of tests in this file is: @@ -283,17 +283,20 @@ add_test_function $DB 1 1 1 execsql { SELECT test_function('sqlite') } } {{UTF-8 sqlite}} - +db close +set DB [sqlite3 db test.db] do_test enc2-6.2 { add_test_function $DB 0 1 0 execsql { SELECT test_function('sqlite') } } {{UTF-16LE sqlite}} +db close +set DB [sqlite3 db test.db] do_test enc2-6.3 { add_test_function $DB 0 0 1 execsql { SELECT test_function('sqlite') } @@ -312,17 +315,20 @@ add_test_function $DB 1 1 1 execsql { SELECT test_function('sqlite') } } {{UTF-16LE sqlite}} - +db close +set DB [sqlite3 db test.db] do_test enc2-6.5 { add_test_function $DB 0 1 0 execsql { SELECT test_function('sqlite') } } {{UTF-16LE sqlite}} +db close +set DB [sqlite3 db test.db] do_test enc2-6.6 { add_test_function $DB 0 0 1 execsql { SELECT test_function('sqlite') } @@ -341,17 +347,20 @@ add_test_function $DB 1 1 1 execsql { SELECT test_function('sqlite') } } {{UTF-16BE sqlite}} - +db close +set DB [sqlite3 db test.db] do_test enc2-6.9 { add_test_function $DB 0 1 0 execsql { SELECT test_function('sqlite') } } {{UTF-16LE sqlite}} +db close +set DB [sqlite3 db test.db] do_test enc2-6.10 { add_test_function $DB 0 0 1 execsql { SELECT test_function('sqlite') }