mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-06 15:49:35 +03:00
Work around bugs in older versions of the OS/2 conversion library by trying to minimize calls to UniCreateUconvObject() etc. Use global uconv objects instead. (CVS 5418)
FossilOrigin-Name: 80e42183066b53129778ae8cbb16e495f7a82990
This commit is contained in:
14
manifest
14
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)
|
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-15T21:32:07
|
D 2008-07-15T22:59:05
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in a03f7cb4f7ad50bc53a788c6c544430e81f95de4
|
F Makefile.in a03f7cb4f7ad50bc53a788c6c544430e81f95de4
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@@ -131,7 +131,7 @@ F src/mutex_w32.c f0d21ff1f6981e5aedc56796adf3a347423ef736
|
|||||||
F src/os.c 292b3b4a49fe5bf6cf2f1cf0af186ebd334e80b8
|
F src/os.c 292b3b4a49fe5bf6cf2f1cf0af186ebd334e80b8
|
||||||
F src/os.h ef8abeb9afc694b82dbd169a91c9b7e26db3c892
|
F src/os.h ef8abeb9afc694b82dbd169a91c9b7e26db3c892
|
||||||
F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
|
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_unix.c 1df6108efdb7957a9f28b9700600e58647c9c12d
|
||||||
F src/os_win.c 2bf2f8cd700299564cc236262c2668e1e02c626a
|
F src/os_win.c 2bf2f8cd700299564cc236262c2668e1e02c626a
|
||||||
F src/pager.c bb286b2fc0c7c87d0a8cbfee96a3e953da1e53dd
|
F src/pager.c bb286b2fc0c7c87d0a8cbfee96a3e953da1e53dd
|
||||||
@@ -608,7 +608,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
|||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||||
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
P 61f6e19755b85bcb065f85fc425c2172badea308
|
P b22e187bc2b38bd219dd0feba19b97279bd83089
|
||||||
R 801d6f0acc1dc5b802184549b77ec890
|
R 3e4111cc48212173ac6c652db5b424aa
|
||||||
U shess
|
U pweilbacher
|
||||||
Z 136d2d664a48bc67bfa7ab0ac78c0104
|
Z 2bd5796475610dfaaebbcccc19839580
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
b22e187bc2b38bd219dd0feba19b97279bd83089
|
80e42183066b53129778ae8cbb16e495f7a82990
|
||||||
101
src/os_os2.c
101
src/os_os2.c
@@ -12,7 +12,7 @@
|
|||||||
**
|
**
|
||||||
** This file contains code that is specific to OS/2.
|
** 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"
|
#include "sqliteInt.h"
|
||||||
@@ -547,33 +547,62 @@ static int os2DeviceCharacteristics(sqlite3_file *id){
|
|||||||
return 0;
|
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.
|
** Helper function to convert UTF-8 filenames to local OS/2 codepage.
|
||||||
** The two-step process: first convert the incoming UTF-8 string
|
** The two-step process: first convert the incoming UTF-8 string
|
||||||
** into UCS-2 and then from UCS-2 to the current codepage.
|
** into UCS-2 and then from UCS-2 to the current codepage.
|
||||||
** The returned char pointer has to be freed.
|
** The returned char pointer has to be freed.
|
||||||
*/
|
*/
|
||||||
static char *convertUtf8PathToCp(const char *in)
|
static char *convertUtf8PathToCp( const char *in ){
|
||||||
{
|
UniChar tempPath[CCHMAXPATH];
|
||||||
UconvObject uconv;
|
char *out = (char *)calloc( CCHMAXPATH, 1 );
|
||||||
UniChar ucsUtf8Cp[12],
|
printf("convertUtf8PathToCp(%s)\n", in);
|
||||||
tempPath[CCHMAXPATH];
|
|
||||||
char *out;
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
out = (char *)calloc(CCHMAXPATH, 1);
|
if( !out )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if( !ucUtf8 || !uclCp )
|
||||||
|
initUconvObjects();
|
||||||
|
|
||||||
/* determine string for the conversion of UTF-8 which is CP1208 */
|
/* determine string for the conversion of UTF-8 which is CP1208 */
|
||||||
rc = UniMapCpToUcsCp(1208, ucsUtf8Cp, 12);
|
if( UniStrToUcs( ucUtf8, tempPath, (char *)in, CCHMAXPATH ) != ULS_SUCCESS )
|
||||||
rc = UniCreateUconvObject(ucsUtf8Cp, &uconv);
|
return out; /* if conversion fails, return the empty string */
|
||||||
rc = UniStrToUcs(uconv, tempPath, (char *)in, CCHMAXPATH);
|
|
||||||
rc = UniFreeUconvObject(uconv);
|
|
||||||
|
|
||||||
/* conversion for current codepage which can be used for paths */
|
/* conversion for current codepage which can be used for paths */
|
||||||
rc = UniCreateUconvObject((UniChar *)L"@path=yes", &uconv);
|
UniStrFromUcs( uclCp, out, tempPath, CCHMAXPATH );
|
||||||
rc = UniStrFromUcs(uconv, out, tempPath, CCHMAXPATH);
|
|
||||||
rc = UniFreeUconvObject(uconv);
|
|
||||||
|
|
||||||
|
printf("%s -> Cp = %s\n", in, out);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,28 +611,29 @@ static char *convertUtf8PathToCp(const char *in)
|
|||||||
** The two-step process: first convert the incoming codepage-specific
|
** 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.
|
** string into UCS-2 and then from UCS-2 to the codepage of UTF-8.
|
||||||
** The returned char pointer has to be freed.
|
** 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)
|
char *convertCpPathToUtf8( const char *in ){
|
||||||
{
|
UniChar tempPath[CCHMAXPATH];
|
||||||
UconvObject uconv;
|
char *out = (char *)calloc( CCHMAXPATH, 1 );
|
||||||
UniChar ucsUtf8Cp[12],
|
printf("convertCpPathToUtf8(%s)\n", in);
|
||||||
tempPath[CCHMAXPATH];
|
|
||||||
char *out;
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
out = (char *)calloc(CCHMAXPATH, 1);
|
if( !out )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if( !ucUtf8 || !uclCp )
|
||||||
|
initUconvObjects();
|
||||||
|
|
||||||
/* conversion for current codepage which can be used for paths */
|
/* conversion for current codepage which can be used for paths */
|
||||||
rc = UniCreateUconvObject((UniChar *)L"@path=yes", &uconv);
|
if( UniStrToUcs( uclCp, tempPath, (char *)in, CCHMAXPATH ) != ULS_SUCCESS )
|
||||||
rc = UniStrToUcs(uconv, tempPath, (char *)in, CCHMAXPATH);
|
return out; /* if conversion fails, return the empty string */
|
||||||
rc = UniFreeUconvObject(uconv);
|
|
||||||
|
|
||||||
/* determine string for the conversion of UTF-8 which is CP1208 */
|
/* determine string for the conversion of UTF-8 which is CP1208 */
|
||||||
rc = UniMapCpToUcsCp(1208, ucsUtf8Cp, 12);
|
UniStrFromUcs( ucUtf8, out, tempPath, CCHMAXPATH );
|
||||||
rc = UniCreateUconvObject(ucsUtf8Cp, &uconv);
|
|
||||||
rc = UniStrFromUcs(uconv, out, tempPath, CCHMAXPATH);
|
|
||||||
rc = UniFreeUconvObject(uconv);
|
|
||||||
|
|
||||||
|
printf("%s -> Utf8 = %s\n", in, out);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -651,9 +681,9 @@ static int getTempname(int nBuf, char *zBuf ){
|
|||||||
if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){
|
if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){
|
||||||
if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){
|
if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){
|
||||||
if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){
|
if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){
|
||||||
ULONG ulDriveNum = 0, ulDriveMap = 0;
|
ULONG ulDriveNum = 0, ulDriveMap = 0;
|
||||||
DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
|
DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
|
||||||
sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) );
|
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.
|
** Initialize and deinitialize the operating system interface.
|
||||||
*/
|
*/
|
||||||
int sqlite3_os_init(void){
|
int sqlite3_os_init(void){
|
||||||
|
initUconvObjects();
|
||||||
|
|
||||||
static sqlite3_vfs os2Vfs = {
|
static sqlite3_vfs os2Vfs = {
|
||||||
1, /* iVersion */
|
1, /* iVersion */
|
||||||
sizeof(os2File), /* szOsFile */
|
sizeof(os2File), /* szOsFile */
|
||||||
@@ -1084,6 +1116,7 @@ int sqlite3_os_init(void){
|
|||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
int sqlite3_os_end(void){
|
int sqlite3_os_end(void){
|
||||||
|
freeUconvObjects();
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user