Skip to content

Commit e20b5b5

Browse files
j6tgitster
authored andcommitted
mingw.h: permit arguments with side effects for is_dir_sep
Taking git-compat-util.h's cue (which uses an inline function to back is_dir_sep()), let's use an inline function to back also the Windows version of is_dir_sep(). This avoids problems when calling the function with arguments that do more than just provide a single character, e.g. incrementing a pointer. Example: is_dir_sep(*p++) Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 840ed14 commit e20b5b5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compat/mingw.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,11 @@ HANDLE winansi_get_osfhandle(int fd);
395395
(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
396396
int mingw_skip_dos_drive_prefix(char **path);
397397
#define skip_dos_drive_prefix mingw_skip_dos_drive_prefix
398-
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
398+
static inline int mingw_is_dir_sep(int c)
399+
{
400+
return c == '/' || c == '\\';
401+
}
402+
#define is_dir_sep mingw_is_dir_sep
399403
static inline char *mingw_find_last_dir_sep(const char *path)
400404
{
401405
char *ret = NULL;

0 commit comments

Comments
 (0)