From eeefb0c3a25a384a0eef8e00d6c929d08e22cc45 Mon Sep 17 00:00:00 2001 From: Arihiro Yoshida Date: Wed, 17 Apr 2024 13:00:04 +0900 Subject: [PATCH] Exclude '\\' and ':' as file path separators except for Windows --- src/packcc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/packcc.c b/src/packcc.c index 89bffb4..9938ac8 100644 --- a/src/packcc.c +++ b/src/packcc.c @@ -1029,7 +1029,11 @@ static const char *extract_filename(const char *path) { size_t i = strlen(path); while (i > 0) { i--; - if (path[i] == '/' || path[i] == '\\' || path[i] == ':') return path + i + 1; +#ifdef _WIN32 + if (strchr("/\\:", path[i])) return path + i + 1; +#else + if (path[i] == '/') return path + i + 1; +#endif } return path; } @@ -1039,7 +1043,11 @@ static const char *extract_fileext(const char *path) { size_t i = n; while (i > 0) { i--; - if (path[i] == '/' || path[i] == '\\' || path[i] == ':') break; +#ifdef _WIN32 + if (strchr("/\\:", path[i])) break; +#else + if (path[i] == '/') break; +#endif if (path[i] == '.') return path + i; } return path + n;