Fossil SCM

Fixed file_extension() to behave like its docs say it does, which would have made [5a9ac6ca3e] unnecessary.

stephan 2020-08-16 16:49 trunk
Commit f95e47b611ee591b426b6cac903696a0754c1458f645fd3a3497d0fb746494ec
1 file changed +4 -2
+4 -2
--- src/file.c
+++ src/file.c
@@ -2400,11 +2400,13 @@
24002400
}
24012401
}
24022402
24032403
/*
24042404
** If zFileName is not NULL and contains a '.', this returns a pointer
2405
-** to the position after the final '.', else it returns NULL.
2405
+** to the position after the final '.', else it returns NULL. As a
2406
+** special case, if it ends with a period then a pointer to the
2407
+** terminating NUL byte is returned.
24062408
*/
24072409
const char * file_extension(const char *zFileName){
2408
- const char * zExt = strrchr(zFileName, '.');
2410
+ const char * zExt = zFileName ? strrchr(zFileName, '.') : 0;
24092411
return zExt ? &zExt[1] : 0;
24102412
}
24112413
--- src/file.c
+++ src/file.c
@@ -2400,11 +2400,13 @@
2400 }
2401 }
2402
2403 /*
2404 ** If zFileName is not NULL and contains a '.', this returns a pointer
2405 ** to the position after the final '.', else it returns NULL.
 
 
2406 */
2407 const char * file_extension(const char *zFileName){
2408 const char * zExt = strrchr(zFileName, '.');
2409 return zExt ? &zExt[1] : 0;
2410 }
2411
--- src/file.c
+++ src/file.c
@@ -2400,11 +2400,13 @@
2400 }
2401 }
2402
2403 /*
2404 ** If zFileName is not NULL and contains a '.', this returns a pointer
2405 ** to the position after the final '.', else it returns NULL. As a
2406 ** special case, if it ends with a period then a pointer to the
2407 ** terminating NUL byte is returned.
2408 */
2409 const char * file_extension(const char *zFileName){
2410 const char * zExt = zFileName ? strrchr(zFileName, '.') : 0;
2411 return zExt ? &zExt[1] : 0;
2412 }
2413

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button