/ Check-in [f31c84a6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a bug in the previous checkin. (CVS 1677)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f31c84a64f53cf2e75a5e988fbb6ad82537f2403
User & Date: danielk1977 2004-06-23 12:35:15
Context
2004-06-23
13:46
Improve test coverage of utf.c. (CVS 1678) check-in: 53c553c7 user: danielk1977 tags: trunk
12:35
Fix a bug in the previous checkin. (CVS 1677) check-in: f31c84a6 user: danielk1977 tags: trunk
12:15
Add some tests for user functions that prefer various text encodings. (CVS 1676) check-in: db6bab57 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used for analyzing expressions and
    13     13   ** for generating VDBE code that evaluates expressions in SQLite.
    14     14   **
    15         -** $Id: expr.c,v 1.148 2004/06/23 12:15:55 danielk1977 Exp $
           15  +** $Id: expr.c,v 1.149 2004/06/23 12:35:15 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   char const *sqlite3AffinityString(char affinity){
    21     21     switch( affinity ){
    22     22       case SQLITE_AFF_INTEGER: return "i";
................................................................................
  1760   1760       **    prefers UTF-8 when a UTF-16 encoding is requested, or vice versa.
  1761   1761       ** 5: A function with the exact number of arguments requested that
  1762   1762       **    prefers UTF-16LE when UTF-16BE is requested, or vice versa.
  1763   1763       ** 6: An exact match.
  1764   1764       **
  1765   1765       ** A larger value of 'matchqual' indicates a more desirable match.
  1766   1766       */
  1767         -    if( (p->xStep||p->xFunc ) && (p->nArg==-1||p->nArg==nArg||nArg==-1) ){
         1767  +    if( p->nArg==-1 || p->nArg==nArg || nArg==-1 ){
  1768   1768         int match = 1;          /* Quality of this match */
  1769   1769         if( p->nArg==nArg || nArg==-1 ){
  1770   1770           match = 4;
  1771   1771         }
  1772   1772         if( enc==p->iPrefEnc ){
  1773   1773           match += 2;
  1774   1774         }

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the printf() interface to SQLite.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.85 2004/06/23 12:15:55 danielk1977 Exp $
           16  +** $Id: test1.c,v 1.86 2004/06/23 12:35:15 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include "os.h"
    21     21   #include <stdlib.h>
    22     22   #include <string.h>
    23     23   
................................................................................
  1087   1087     sqlite3 *db;
  1088   1088     int val;
  1089   1089   
  1090   1090     if( objc!=5 ) goto bad_args;
  1091   1091     if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
  1092   1092   
  1093   1093     if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR;
  1094         -  sqlite3_create_function(db, "test_function", 1, SQLITE_UTF8, 
  1095         -      interp, val?test_function_utf8:0, 0, 0);
         1094  +  if( val ){
         1095  +    sqlite3_create_function(db, "test_function", 1, SQLITE_UTF8, 
         1096  +        interp, test_function_utf8, 0, 0);
         1097  +  }
  1096   1098     if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[3], &val) ) return TCL_ERROR;
  1097         -  sqlite3_create_function(db, "test_function", 1, SQLITE_UTF16LE, 
  1098         -      interp, val?test_function_utf16le:0, 0, 0);
         1099  +  if( val ){
         1100  +    sqlite3_create_function(db, "test_function", 1, SQLITE_UTF16LE, 
         1101  +        interp, test_function_utf16le, 0, 0);
         1102  +  }
  1099   1103     if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[4], &val) ) return TCL_ERROR;
  1100         -  sqlite3_create_function(db, "test_function", 1, SQLITE_UTF16BE, 
  1101         -      interp, val?test_function_utf16be:0, 0, 0);
         1104  +  if( val ){
         1105  +    sqlite3_create_function(db, "test_function", 1, SQLITE_UTF16BE, 
         1106  +        interp, test_function_utf16be, 0, 0);
         1107  +  }
  1102   1108   
  1103   1109     return TCL_OK;
  1104   1110   bad_args:
  1105   1111     Tcl_AppendResult(interp, "wrong # args: should be \"",
  1106   1112         Tcl_GetStringFromObj(objv[0], 0), " <DB> <utf8> <utf16le> <utf16be>", 0);
  1107   1113     return TCL_ERROR;
  1108   1114   }

Changes to test/enc2.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The focus of
    12     12   # this file is testing the SQLite routines used for converting between the
    13     13   # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
    14     14   # UTF-16be).
    15     15   #
    16         -# $Id: enc2.test,v 1.13 2004/06/23 12:15:55 danielk1977 Exp $
           16  +# $Id: enc2.test,v 1.14 2004/06/23 12:35:16 danielk1977 Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # The rough organisation of tests in this file is:
    22     22   #
    23     23   # enc2.1.*: Simple tests with a UTF-8 db.
................................................................................
   281    281   } {}
   282    282   do_test enc2-6.1 {
   283    283     add_test_function $DB 1 1 1
   284    284     execsql {
   285    285       SELECT test_function('sqlite')
   286    286     }
   287    287   } {{UTF-8 sqlite}}
   288         -
          288  +db close
          289  +set DB [sqlite3 db test.db]
   289    290   do_test enc2-6.2 {
   290    291     add_test_function $DB 0 1 0
   291    292     execsql {
   292    293       SELECT test_function('sqlite')
   293    294     }
   294    295   } {{UTF-16LE sqlite}}
          296  +db close
          297  +set DB [sqlite3 db test.db]
   295    298   do_test enc2-6.3 {
   296    299     add_test_function $DB 0 0 1
   297    300     execsql {
   298    301       SELECT test_function('sqlite')
   299    302     }
   300    303   } {{UTF-16BE sqlite}}
   301    304   
................................................................................
   310    313   } {}
   311    314   do_test enc2-6.4 {
   312    315     add_test_function $DB 1 1 1
   313    316     execsql {
   314    317       SELECT test_function('sqlite')
   315    318     }
   316    319   } {{UTF-16LE sqlite}}
   317         -
          320  +db close
          321  +set DB [sqlite3 db test.db]
   318    322   do_test enc2-6.5 {
   319    323     add_test_function $DB 0 1 0
   320    324     execsql {
   321    325       SELECT test_function('sqlite')
   322    326     }
   323    327   } {{UTF-16LE sqlite}}
          328  +db close
          329  +set DB [sqlite3 db test.db]
   324    330   do_test enc2-6.6 {
   325    331     add_test_function $DB 0 0 1
   326    332     execsql {
   327    333       SELECT test_function('sqlite')
   328    334     }
   329    335   } {{UTF-16BE sqlite}}
   330    336   
................................................................................
   339    345   } {}
   340    346   do_test enc2-6.8 {
   341    347     add_test_function $DB 1 1 1
   342    348     execsql {
   343    349       SELECT test_function('sqlite')
   344    350     }
   345    351   } {{UTF-16BE sqlite}}
   346         -
          352  +db close
          353  +set DB [sqlite3 db test.db]
   347    354   do_test enc2-6.9 {
   348    355     add_test_function $DB 0 1 0
   349    356     execsql {
   350    357       SELECT test_function('sqlite')
   351    358     }
   352    359   } {{UTF-16LE sqlite}}
          360  +db close
          361  +set DB [sqlite3 db test.db]
   353    362   do_test enc2-6.10 {
   354    363     add_test_function $DB 0 0 1
   355    364     execsql {
   356    365       SELECT test_function('sqlite')
   357    366     }
   358    367   } {{UTF-16BE sqlite}}
   359    368