aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-12-03 20:42:28 +0000
committerdrh <drh@noemail.net>2015-12-03 20:42:28 +0000
commit90e5dda217b4d939d8609d8728dc7c3015f9c164 (patch)
tree20550ad830697f33859085501575f170b64b9e90 /src/os_unix.c
parent7be53fe441c128deff7f8f130a3833488e08d06d (diff)
downloadsqlite-90e5dda217b4d939d8609d8728dc7c3015f9c164.tar.gz
sqlite-90e5dda217b4d939d8609d8728dc7c3015f9c164.zip
Cleaner code and additional comments on the handling of 8+3 filenames when
trying to find the name of a database file based on its journal filename, in the unix VFS. FossilOrigin-Name: 9e489a71f2aeb1f13f9ca6f106b9144d07ca25aa
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 5f4cbca2a..beaac0d15 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5521,16 +5521,19 @@ static int findCreateFileMode(
** used by the test_multiplex.c module.
*/
nDb = sqlite3Strlen30(zPath) - 1;
-#ifdef SQLITE_ENABLE_8_3_NAMES
- while( nDb>0 && sqlite3Isalnum(zPath[nDb]) ) nDb--;
- if( nDb==0 || zPath[nDb]!='-' ) return SQLITE_OK;
-#else
while( zPath[nDb]!='-' ){
+#ifndef SQLITE_ENABLE_8_3_NAMES
+ /* In the normal case (8+3 filenames disabled) the journal filename
+ ** is guaranteed to contain a '-' character. */
assert( nDb>0 );
- assert( zPath[nDb]!='\n' );
+ assert( sqlite3Isalnum(zPath[nDb]) );
+#else
+ /* If 8+3 names are possible, then the journal file might not contain
+ ** a '-' character. So check for that case and return early. */
+ if( nDb==0 || zPath[nDb]=='.' ) return SQLITE_OK;
+#endif
nDb--;
}
-#endif
memcpy(zDb, zPath, nDb);
zDb[nDb] = '\0';