mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-05 04:30:38 +03:00
Change OS/2 version of sqlite3Os2FullPathname() for cross-compiler compatibility:
- allocate zBuff on demand (restricted stack space on old compilers) - 2 bytes in zDrive in include '\0' - pass drive number to DosQueryCurrentDir() instead of 0 to make EMX work - zFull does not need to be preallocated (CVS 4149) FossilOrigin-Name: cc2105176563c352a6dccef89a429a76b6f3adf5
This commit is contained in:
22
src/os_os2.c
22
src/os_os2.c
@@ -682,16 +682,22 @@ char *sqlite3Os2FullPathname( const char *zRelative ){
|
||||
if( strchr(zRelative, ':') ){
|
||||
sqlite3SetString( &zFull, zRelative, (char*)0 );
|
||||
}else{
|
||||
char zBuff[SQLITE_TEMPNAME_SIZE - 2] = {0};
|
||||
char zDrive[1] = {0};
|
||||
ULONG cbzFullLen = SQLITE_TEMPNAME_SIZE;
|
||||
ULONG ulDriveNum = 0;
|
||||
ULONG ulDriveMap = 0;
|
||||
DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
|
||||
DosQueryCurrentDir( 0L, zBuff, &cbzFullLen );
|
||||
zFull = sqliteMalloc( cbzFullLen );
|
||||
sprintf( zDrive, "%c", (char)('A' + ulDriveNum - 1) );
|
||||
sqlite3SetString( &zFull, zDrive, ":\\", zBuff, "\\", zRelative, (char*)0 );
|
||||
ULONG cbzBufLen = SQLITE_TEMPNAME_SIZE;
|
||||
char zDrive[2];
|
||||
char *zBuff;
|
||||
|
||||
zBuff = sqliteMalloc( cbzBufLen );
|
||||
if( zBuff != 0 ){
|
||||
DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
|
||||
if( DosQueryCurrentDir( ulDriveNum, zBuff, &cbzBufLen ) == NO_ERROR ){
|
||||
sprintf( zDrive, "%c", (char)('A' + ulDriveNum - 1) );
|
||||
sqlite3SetString( &zFull, zDrive, ":\\", zBuff,
|
||||
"\\", zRelative, (char*)0 );
|
||||
}
|
||||
sqliteFree( zBuff );
|
||||
}
|
||||
}
|
||||
return zFull;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user