Skip to content

Commit e7d5ce8

Browse files
j6tgitster
authored andcommitted
mingw: avoid linking to the C library's isalpha()
The implementation of mingw_skip_dos_drive_prefix() calls isalpha() via has_dos_drive_prefix(). Since the definition occurs long before isalpha() is defined in git-compat-util.h, my build environment reports: CC alloc.o In file included from git-compat-util.h:186, from cache.h:4, from alloc.c:12: compat/mingw.h: In function 'mingw_skip_dos_drive_prefix': compat/mingw.h:365: warning: implicit declaration of function 'isalpha' Dscho does not see a similar warning in his build and suspects that ctype.h is included somehow behind the scenes. This implies that his build links to the C library's isalpha() and does not use git's isalpha(). To fix both the warning in my build and the inconsistency in Dscho's build, move the function definition to mingw.c. Then it picks up git's isalpha() because git-compat-util.h is included at the top of the file. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 371471c commit e7d5ce8

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

compat/mingw.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,13 @@ pid_t waitpid(pid_t pid, int *status, int options)
19151915
return -1;
19161916
}
19171917

1918+
int mingw_skip_dos_drive_prefix(char **path)
1919+
{
1920+
int ret = has_dos_drive_prefix(*path);
1921+
*path += ret;
1922+
return ret;
1923+
}
1924+
19181925
int mingw_offset_1st_component(const char *path)
19191926
{
19201927
char *pos = (char *)path;

compat/mingw.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,7 @@ HANDLE winansi_get_osfhandle(int fd);
360360

361361
#define has_dos_drive_prefix(path) \
362362
(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
363-
static inline int mingw_skip_dos_drive_prefix(char **path)
364-
{
365-
int ret = has_dos_drive_prefix(*path);
366-
*path += ret;
367-
return ret;
368-
}
363+
int mingw_skip_dos_drive_prefix(char **path);
369364
#define skip_dos_drive_prefix mingw_skip_dos_drive_prefix
370365
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
371366
static inline char *mingw_find_last_dir_sep(const char *path)

0 commit comments

Comments
 (0)