From ef5eab2263099cabb678b86bd1f8f261d7d5139d Mon Sep 17 00:00:00 2001 From: fgsfds Date: Mon, 8 Jun 2020 07:44:03 +0300 Subject: [PATCH] fix sys_file_extension for folders that start with dot --- src/pc/platform.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pc/platform.c b/src/pc/platform.c index fb4b08ec..0aea20fa 100644 --- a/src/pc/platform.c +++ b/src/pc/platform.c @@ -51,7 +51,10 @@ int sys_strcasecmp(const char *s1, const char *s2) { const char *sys_file_extension(const char *fname) { const char *dot = strrchr(fname, '.'); - if (!dot || !dot[1]) return NULL; + const char *sep = strrchr(fname, '/'); + if (!sep) sep = strrchr(fname, '\\'); + if (!dot || !dot[1]) return NULL; // no dot + if (dot <= sep + 1) return NULL; // dot is before the last separator or right after it (e.g. /.local) return dot + 1; }