1
0
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:
pweilbacher
2007-07-01 15:41:02 +00:00
parent 2b9ca8d3e4
commit 503028d61a
3 changed files with 21 additions and 15 deletions

View File

@@ -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;
}