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 <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
May 22, 2017 at 20:58 UTC
e20b5b59099a960d59f20276ae37353870e714de
1 file changed
+5
-1
compat/mingw.h
+5
-1
@@ -395,7 +395,11 @@ HANDLE winansi_get_osfhandle(int fd);
395
(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
396
int mingw_skip_dos_drive_prefix(char **path);
397
#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
403
static inline char *mingw_find_last_dir_sep(const char *path)
404
{
405
char *ret = NULL;