mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 09:26:01 +01:00
Use strrchr in file_get_extension
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
5bc7c7212d
commit
7ebf15543b
1 changed files with 4 additions and 12 deletions
16
utils.c
16
utils.c
|
@ -29,24 +29,16 @@
|
||||||
const char*
|
const char*
|
||||||
file_get_extension(const char* path)
|
file_get_extension(const char* path)
|
||||||
{
|
{
|
||||||
if (!path) {
|
if (path == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int i = strlen(path);
|
const char* res = strrchr(path, '.');
|
||||||
for (; i > 0; i--) {
|
if (res == NULL) {
|
||||||
if (*(path + i) != '.') {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!i) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path + i + 1;
|
return res + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
Loading…
Reference in a new issue