Re: [PATCH v4 1/4] Refactor skipping DOS drive prefixes
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 24, 2016, 10:56 UTC
- Message-ID
- <alpine.DEB.2.20.1601241152060.2964@virtualbox>
- In-Reply-To
- <56A3CE34.20808@kdbg.org>
Hi Hannes,
On Sat, 23 Jan 2016, Johannes Sixt wrote:
Show 59 quoted lines
> Am 23.01.2016 um 09:25 schrieb Johannes Schindelin:
>
> > On Fri, 22 Jan 2016, Junio C Hamano wrote:
> >
> > > Johannes Sixt <j6t@kdbg.org> writes:
> > >
> > > > I suggest to move the function definition out of line:
> > > >
> > > > diff --git a/compat/mingw.c b/compat/mingw.c
> > > > index 10a51c0..0cebb61 100644
> > > > --- a/compat/mingw.c
> > > > +++ b/compat/mingw.c
> > > > @@ -1915,6 +1915,13 @@ pid_t waitpid(pid_t pid, int *status, int
> > > > options)
> > > > return -1;
> > > > }
> > > >
> > > > +int mingw_skip_dos_drive_prefix(char **path)
> > > > +{
> > > > + int ret = has_dos_drive_prefix(*path);
> > > > + *path += ret;
> > > > + return ret;
> > > > +}
> > > > +
> > > > int mingw_offset_1st_component(const char *path)
> > > > {
> > > > char *pos = (char *)path;
> > > > diff --git a/compat/mingw.h b/compat/mingw.h
> > > > index 9b5db4e..2099b79 100644
> > > > --- a/compat/mingw.h
> > > > +++ b/compat/mingw.h
> > > > @@ -360,12 +360,7 @@ HANDLE winansi_get_osfhandle(int fd);
> > > >
> > > > #define has_dos_drive_prefix(path) \
> > > > (isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
> > > > -static inline int mingw_skip_dos_drive_prefix(char **path)
> > > > -{
> > > > - int ret = has_dos_drive_prefix(*path);
> > > > - *path += ret;
> > > > - return ret;
> > > > -}
> > > > +int mingw_skip_dos_drive_prefix(char **path);
> > > > #define skip_dos_drive_prefix mingw_skip_dos_drive_prefix
> > > > #define is_dir_sep(c) ((c) == '/' || (c) == '\\')
> > > > static inline char *mingw_find_last_dir_sep(const char *path)
> > >
> > > This sounds good to me. Dscho?
> >
> > Yep, sounds good to me, too.
> >
> > Personally, I have no inclination to add compatibility with the
> > now-safely-obsolete MSys to my responsibilities, but if Hannes wants to do
> > it, who am I to stand in his way? Especially when the fix is as trivial as
> > here.
>
> This is not a matter of compatibility. I am VERY curious why you do not see
> an error (or warning) without my proposed fixup. As I mentioned, isalpha() is
> defined much later than the definition of mingw_skip_dos_drive_prefix().
> Where does your build get a declaration of isalpha() from?$ grep -w isalpha /mingw32/i686-w64-mingw32/include/*.h /mingw32/i686-w64-mingw32/include/ctype.h: _CRTIMP int __cdecl isalpha(int _C); /mingw32/i686-w64-mingw32/include/ctype.h:#define __iscsymf(_c) (isalpha(_c) || ((_c)=='_'))
I guess that definition gets pulled in somehow.
Ciao, Dscho