Fossil SCM
Fixed file_extension() to behave like its docs say it does, which would have made [5a9ac6ca3e] unnecessary.
Commit
f95e47b611ee591b426b6cac903696a0754c1458f645fd3a3497d0fb746494ec
Parent
4c4503303318768…
1 file changed
+4
-2
+4
-2
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -2400,11 +2400,13 @@ | ||
| 2400 | 2400 | } |
| 2401 | 2401 | } |
| 2402 | 2402 | |
| 2403 | 2403 | /* |
| 2404 | 2404 | ** 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. | |
| 2406 | 2408 | */ |
| 2407 | 2409 | const char * file_extension(const char *zFileName){ |
| 2408 | - const char * zExt = strrchr(zFileName, '.'); | |
| 2410 | + const char * zExt = zFileName ? strrchr(zFileName, '.') : 0; | |
| 2409 | 2411 | return zExt ? &zExt[1] : 0; |
| 2410 | 2412 | } |
| 2411 | 2413 |
| --- 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 |