Skip to content

Commit

Permalink
Exclude '\\' and ':' as file path separators except for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
arithy committed Apr 17, 2024
1 parent b5f1f44 commit eeefb0c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/packcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit eeefb0c

Please sign in to comment.