]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Work around bugs in older versions of the OS/2 conversion library by trying to minimi...
authorpweilbacher <pweilbacher@noemail.net>
Tue, 15 Jul 2008 22:59:04 +0000 (22:59 +0000)
committerpweilbacher <pweilbacher@noemail.net>
Tue, 15 Jul 2008 22:59:04 +0000 (22:59 +0000)
FossilOrigin-Name: 80e42183066b53129778ae8cbb16e495f7a82990

manifest
manifest.uuid
src/os_os2.c

index db117b7e440649bfdc0d4b4c2847c49bc8981ca1..9c6bf363fa33d28dbbb80b87fbd32fb5267a6275 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Implement\soptimize()\sfunction.\s\sThis\smerges\sall\ssegments\sin\sthe\sfts\nindex\sinto\sa\ssingle\ssegment,\sincluding\sdropping\sdelete\scookies.\s(CVS\s5417)
-D 2008-07-15T21:32:07
+C Work\saround\sbugs\sin\solder\sversions\sof\sthe\sOS/2\sconversion\slibrary\sby\strying\sto\sminimize\scalls\sto\sUniCreateUconvObject()\setc.\sUse\sglobal\suconv\sobjects\sinstead.\s(CVS\s5418)
+D 2008-07-15T22:59:05
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in a03f7cb4f7ad50bc53a788c6c544430e81f95de4
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -131,7 +131,7 @@ F src/mutex_w32.c f0d21ff1f6981e5aedc56796adf3a347423ef736
 F src/os.c 292b3b4a49fe5bf6cf2f1cf0af186ebd334e80b8
 F src/os.h ef8abeb9afc694b82dbd169a91c9b7e26db3c892
 F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
-F src/os_os2.c 6c33e61f0fab256b0136650cdee35c3eaab2fa04
+F src/os_os2.c b16aee2f727842f758140641835a46caad322f5d
 F src/os_unix.c 1df6108efdb7957a9f28b9700600e58647c9c12d
 F src/os_win.c 2bf2f8cd700299564cc236262c2668e1e02c626a
 F src/pager.c bb286b2fc0c7c87d0a8cbfee96a3e953da1e53dd
@@ -608,7 +608,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 61f6e19755b85bcb065f85fc425c2172badea308
-R 801d6f0acc1dc5b802184549b77ec890
-U shess
-Z 136d2d664a48bc67bfa7ab0ac78c0104
+P b22e187bc2b38bd219dd0feba19b97279bd83089
+R 3e4111cc48212173ac6c652db5b424aa
+U pweilbacher
+Z 2bd5796475610dfaaebbcccc19839580
index 37da664a7f04d008bff3dd08295fe04ab60df8c2..4f45fba0457f93bfc30c0d13c9eae8e723cc0124 100644 (file)
@@ -1 +1 @@
-b22e187bc2b38bd219dd0feba19b97279bd83089
\ No newline at end of file
+80e42183066b53129778ae8cbb16e495f7a82990
\ No newline at end of file
index 5a09d70d5c0cec6b2df9b4412d7e0a9bd9250d44..29628a4664265f571df20faa268404c2f370461a 100644 (file)
@@ -12,7 +12,7 @@
 **
 ** This file contains code that is specific to OS/2.
 **
-** $Id: os_os2.c,v 1.49 2008/07/08 22:34:07 pweilbacher Exp $
+** $Id: os_os2.c,v 1.50 2008/07/15 22:59:05 pweilbacher Exp $
 */
 
 #include "sqliteInt.h"
@@ -547,33 +547,62 @@ static int os2DeviceCharacteristics(sqlite3_file *id){
   return 0;
 }
 
+
+/*
+** Character set conversion objects used by conversion routines.
+*/
+static UconvObject ucUtf8 = NULL; /* convert between UTF-8 and UCS-2 */
+static UconvObject uclCp = NULL;  /* convert between local codepage and UCS-2 */
+
+/*
+** Helper function to initialize the conversion objects from and to UTF-8.
+*/
+static void initUconvObjects( void ){
+       printf("init them\n");
+  if( UniCreateUconvObject( UTF_8, &ucUtf8 ) != ULS_SUCCESS )
+    ucUtf8 = NULL;
+  if ( UniCreateUconvObject( (UniChar *)L"@path=yes", &uclCp ) != ULS_SUCCESS )
+    uclCp = NULL;
+}
+
+/*
+** Helper function to free the conversion objects from and to UTF-8.
+*/
+static void freeUconvObjects( void ){
+       printf("free them\n");
+  if ( ucUtf8 )
+    UniFreeUconvObject( ucUtf8 );
+  if ( uclCp )
+    UniFreeUconvObject( uclCp );
+  ucUtf8 = NULL;
+  uclCp = NULL;
+}
+
 /*
 ** Helper function to convert UTF-8 filenames to local OS/2 codepage.
 ** The two-step process: first convert the incoming UTF-8 string
 ** into UCS-2 and then from UCS-2 to the current codepage.
 ** The returned char pointer has to be freed.
 */
-static char *convertUtf8PathToCp(const char *in)
-{
-  UconvObject uconv;
-  UniChar ucsUtf8Cp[12],
-          tempPath[CCHMAXPATH];
-  char *out;
-  int rc = 0;
+static char *convertUtf8PathToCp( const char *in ){
+  UniChar tempPath[CCHMAXPATH];
+  char *out = (char *)calloc( CCHMAXPATH, 1 );
+printf("convertUtf8PathToCp(%s)\n", in);
 
-  out = (char *)calloc(CCHMAXPATH, 1);
+  if( !out )
+    return NULL;
+
+  if( !ucUtf8 || !uclCp )
+    initUconvObjects();
 
   /* determine string for the conversion of UTF-8 which is CP1208 */
-  rc = UniMapCpToUcsCp(1208, ucsUtf8Cp, 12);
-  rc = UniCreateUconvObject(ucsUtf8Cp, &uconv);
-  rc = UniStrToUcs(uconv, tempPath, (char *)in, CCHMAXPATH);
-  rc = UniFreeUconvObject(uconv);
+  if( UniStrToUcs( ucUtf8, tempPath, (char *)in, CCHMAXPATH ) != ULS_SUCCESS )
+    return out; /* if conversion fails, return the empty string */
 
   /* conversion for current codepage which can be used for paths */
-  rc = UniCreateUconvObject((UniChar *)L"@path=yes", &uconv);
-  rc = UniStrFromUcs(uconv, out, tempPath, CCHMAXPATH);
-  rc = UniFreeUconvObject(uconv);
+  UniStrFromUcs( uclCp, out, tempPath, CCHMAXPATH );
 
+       printf("%s -> Cp = %s\n", in, out);
   return out;
 }
 
@@ -582,28 +611,29 @@ static char *convertUtf8PathToCp(const char *in)
 ** The two-step process: first convert the incoming codepage-specific
 ** string into UCS-2 and then from UCS-2 to the codepage of UTF-8.
 ** The returned char pointer has to be freed.
+**
+** This function is non-static to be able to use this in shell.c and
+** similar applications that take command line arguments.
 */
-static char *convertCpPathToUtf8(const char *in)
-{
-  UconvObject uconv;
-  UniChar ucsUtf8Cp[12],
-          tempPath[CCHMAXPATH];
-  char *out;
-  int rc = 0;
+char *convertCpPathToUtf8( const char *in ){
+  UniChar tempPath[CCHMAXPATH];
+  char *out = (char *)calloc( CCHMAXPATH, 1 );
+printf("convertCpPathToUtf8(%s)\n", in);
 
-  out = (char *)calloc(CCHMAXPATH, 1);
+  if( !out )
+    return NULL;
+
+  if( !ucUtf8 || !uclCp )
+    initUconvObjects();
 
   /* conversion for current codepage which can be used for paths */
-  rc = UniCreateUconvObject((UniChar *)L"@path=yes", &uconv);
-  rc = UniStrToUcs(uconv, tempPath, (char *)in, CCHMAXPATH);
-  rc = UniFreeUconvObject(uconv);
+  if( UniStrToUcs( uclCp, tempPath, (char *)in, CCHMAXPATH ) != ULS_SUCCESS )
+    return out; /* if conversion fails, return the empty string */
 
   /* determine string for the conversion of UTF-8 which is CP1208 */
-  rc = UniMapCpToUcsCp(1208, ucsUtf8Cp, 12);
-  rc = UniCreateUconvObject(ucsUtf8Cp, &uconv);
-  rc = UniStrFromUcs(uconv, out, tempPath, CCHMAXPATH);
-  rc = UniFreeUconvObject(uconv);
+  UniStrFromUcs( ucUtf8, out, tempPath, CCHMAXPATH );
 
+       printf("%s -> Utf8 = %s\n", in, out);
   return out;
 }
 
@@ -651,9 +681,9 @@ static int getTempname(int nBuf, char *zBuf ){
     if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){
       if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){
         if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){
-             ULONG ulDriveNum = 0, ulDriveMap = 0;
-             DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
-             sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) );
+           ULONG ulDriveNum = 0, ulDriveMap = 0;
+           DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
+           sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) );
         }
       }
     }
@@ -1059,6 +1089,8 @@ static int os2GetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
 ** Initialize and deinitialize the operating system interface.
 */
 int sqlite3_os_init(void){
+  initUconvObjects();
+
   static sqlite3_vfs os2Vfs = {
     1,                 /* iVersion */
     sizeof(os2File),   /* szOsFile */
@@ -1084,6 +1116,7 @@ int sqlite3_os_init(void){
   return SQLITE_OK;
 }
 int sqlite3_os_end(void){
+  freeUconvObjects();
   return SQLITE_OK;
 }