mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 13:05:59 +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*
|
||||
file_get_extension(const char* path)
|
||||
{
|
||||
if (!path) {
|
||||
if (path == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int i = strlen(path);
|
||||
for (; i > 0; i--) {
|
||||
if (*(path + i) != '.') {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!i) {
|
||||
const char* res = strrchr(path, '.');
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return path + i + 1;
|
||||
return res + 1;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Reference in a new issue