git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] msvc: Directly use MS version (_stricmp) of strcasecmp
@ 2018-11-18 21:02 Sven Strickroth
  2018-11-18 21:58 ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Sven Strickroth @ 2018-11-18 21:02 UTC (permalink / raw)
  To: git; +Cc: gitster, peff, Johannes.Schindelin

This also removes an implicit conversion from size_t (unsigned) to int (signed).

_stricmp as well as _strnicmp are both available since VS2012.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
---
 compat/msvc.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/compat/msvc.h b/compat/msvc.h
index 580bb55bf4..ea6527f8b6 100644
--- a/compat/msvc.h
+++ b/compat/msvc.h
@@ -14,13 +14,7 @@
 #define ftruncate    _chsize
 #define strtoull     _strtoui64
 #define strtoll      _strtoi64
-
-static __inline int strcasecmp (const char *s1, const char *s2)
-{
-       int size1 = strlen(s1);
-       int sisz2 = strlen(s2);
-       return _strnicmp(s1, s2, sisz2 > size1 ? sisz2 : size1);
-}
+#define strcasecmp   _stricmp

 #undef ERROR

--
2.19.1.windows.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] msvc: Directly use MS version (_stricmp) of strcasecmp
  2018-11-18 21:02 [PATCH] msvc: Directly use MS version (_stricmp) of strcasecmp Sven Strickroth
@ 2018-11-18 21:58 ` Jeff King
  2018-11-19  2:02   ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2018-11-18 21:58 UTC (permalink / raw)
  To: Sven Strickroth; +Cc: git, gitster, Johannes.Schindelin

On Sun, Nov 18, 2018 at 10:02:02PM +0100, Sven Strickroth wrote:

> This also removes an implicit conversion from size_t (unsigned) to int (signed).
> 
> _stricmp as well as _strnicmp are both available since VS2012.

Once upon a time we had problems with taking a function pointer of
strcasecmp (to use as a comparator with string_list), so I wondered if
that might be part of why it's defined the way it is.

But the current definition is already inline:

> -
> -static __inline int strcasecmp (const char *s1, const char *s2)
> -{
> -       int size1 = strlen(s1);
> -       int sisz2 = strlen(s2);
> -       return _strnicmp(s1, s2, sisz2 > size1 ? sisz2 : size1);
> -}
> +#define strcasecmp   _stricmp

And it seems we worked around this in de2f95ebed (mailmap: work around
implementations with pure inline strcasecmp, 2013-09-12). So I don't
think there is any blocker there.

(Though of course I have no idea on other portability questions around
_stricmp(); I'll leave that for Windows folks).

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] msvc: Directly use MS version (_stricmp) of strcasecmp
  2018-11-18 21:58 ` Jeff King
@ 2018-11-19  2:02   ` Junio C Hamano
  2018-11-19 15:14     ` Sven Strickroth
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2018-11-19  2:02 UTC (permalink / raw)
  To: Jeff King; +Cc: Sven Strickroth, git, Johannes.Schindelin

Jeff King <peff@peff.net> writes:

> And it seems we worked around this in de2f95ebed (mailmap: work around
> implementations with pure inline strcasecmp, 2013-09-12). So I don't
> think there is any blocker there.
>
> (Though of course I have no idea on other portability questions around
> _stricmp(); I'll leave that for Windows folks).

Likewise.  As to the placement for the replacement #define, the
patch puts it where the inline version was, but I would think it
would work better if it were in the block of #defines, immediately
next to #define strncasecmp above.
.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] msvc: Directly use MS version (_stricmp) of strcasecmp
  2018-11-19  2:02   ` Junio C Hamano
@ 2018-11-19 15:14     ` Sven Strickroth
  2018-11-20  1:58       ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Sven Strickroth @ 2018-11-19 15:14 UTC (permalink / raw)
  To: git; +Cc: gitster, peff, Johannes.Schindelin

This also removes an implicit conversion from size_t (unsigned) to int (signed).

_stricmp as well as _strnicmp are both available since VS2012.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
---
 compat/msvc.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/compat/msvc.h b/compat/msvc.h
index e6e1a6bbf7..2d558bae14 100644
--- a/compat/msvc.h
+++ b/compat/msvc.h
@@ -14,18 +14,12 @@
 #define inline __inline
 #define __inline__ __inline
 #define __attribute__(x)
+#define strcasecmp   _stricmp
 #define strncasecmp  _strnicmp
 #define ftruncate    _chsize
 #define strtoull     _strtoui64
 #define strtoll      _strtoi64
 
-static __inline int strcasecmp (const char *s1, const char *s2)
-{
-	int size1 = strlen(s1);
-	int sisz2 = strlen(s2);
-	return _strnicmp(s1, s2, sisz2 > size1 ? sisz2 : size1);
-}
-
 #undef ERROR
 
 #define ftello _ftelli64
-- 
2.19.1.windows.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] msvc: Directly use MS version (_stricmp) of strcasecmp
  2018-11-19 15:14     ` Sven Strickroth
@ 2018-11-20  1:58       ` Junio C Hamano
  2018-11-20 20:52         ` Johannes Schindelin
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2018-11-20  1:58 UTC (permalink / raw)
  To: Sven Strickroth; +Cc: git, peff, Johannes.Schindelin

Sven Strickroth <email@cs-ware.de> writes:

> This also removes an implicit conversion from size_t (unsigned) to int (signed).
>
> _stricmp as well as _strnicmp are both available since VS2012.
>
> Signed-off-by: Sven Strickroth <email@cs-ware.de>
> ---
>  compat/msvc.h | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)

Will apply, thanks.

The substition from ftello with _ftelli64 does not appear in our
codebase yet, but it was easy enough to adjust the patch myself, so
no need to resend this patch.

> diff --git a/compat/msvc.h b/compat/msvc.h
> index e6e1a6bbf7..2d558bae14 100644
> --- a/compat/msvc.h
> +++ b/compat/msvc.h
> @@ -14,18 +14,12 @@
>  #define inline __inline
>  #define __inline__ __inline
>  #define __attribute__(x)
> +#define strcasecmp   _stricmp
>  #define strncasecmp  _strnicmp
>  #define ftruncate    _chsize
>  #define strtoull     _strtoui64
>  #define strtoll      _strtoi64
>  
> -static __inline int strcasecmp (const char *s1, const char *s2)
> -{
> -	int size1 = strlen(s1);
> -	int sisz2 = strlen(s2);
> -	return _strnicmp(s1, s2, sisz2 > size1 ? sisz2 : size1);
> -}
> -
>  #undef ERROR
>  
>  #define ftello _ftelli64

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] msvc: Directly use MS version (_stricmp) of strcasecmp
  2018-11-20  1:58       ` Junio C Hamano
@ 2018-11-20 20:52         ` Johannes Schindelin
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2018-11-20 20:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sven Strickroth, git, peff

Hi Junio,

On Tue, 20 Nov 2018, Junio C Hamano wrote:

> Sven Strickroth <email@cs-ware.de> writes:
> 
> > This also removes an implicit conversion from size_t (unsigned) to int (signed).
> >
> > _stricmp as well as _strnicmp are both available since VS2012.

Looks good to me.

> > Signed-off-by: Sven Strickroth <email@cs-ware.de>
> > ---
> >  compat/msvc.h | 8 +-------
> >  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> Will apply, thanks.
> 
> The substition from ftello with _ftelli64 does not appear in our
> codebase yet, but it was easy enough to adjust the patch myself, so
> no need to resend this patch.

Indeed, that is only in Git for Windows' code base yet, AFAICT.

For the record: I am currently holding off from contributing those patches
(I am talking about the patch series to make Git compile with MS Visual
C++ on the command line, followed by the patch series to generate project
definitions ready for use with MS Visual Studio) because of the feature
freeze. I had hoped to be able to contribute them sooner, but it took Jeff
Hostetler and myself a combined gargantuan effort to reorder and
disentangle Git for Windows' branch thicket so that those patches apply
cleanly on top of git.git's `master`.

Happily, almost all of the prerequisites made it upstream (e.g. the
nanosecond support for Windows, the patches to require Windows Vista or
later, the patch to use CreateHardLink() directly, etc). By my counting,
only two, relatively small patch series are left, and both are already
under discussion (but on hold, due to the code freeze).

For interested parties: the current shape of the `visual-studio` patch
series can be seen here:
https://github.com/git-for-windows/git/compare/581eb5441089%5E...581eb5441089%5E2
and the current shape of the `msvc` patch series can be seen here:
https://github.com/git-for-windows/git/compare/e9e7bd2a2485%5E...e9e7bd2a2485%5E2

Ciao,
Dscho

> 
> > diff --git a/compat/msvc.h b/compat/msvc.h
> > index e6e1a6bbf7..2d558bae14 100644
> > --- a/compat/msvc.h
> > +++ b/compat/msvc.h
> > @@ -14,18 +14,12 @@
> >  #define inline __inline
> >  #define __inline__ __inline
> >  #define __attribute__(x)
> > +#define strcasecmp   _stricmp
> >  #define strncasecmp  _strnicmp
> >  #define ftruncate    _chsize
> >  #define strtoull     _strtoui64
> >  #define strtoll      _strtoi64
> >  
> > -static __inline int strcasecmp (const char *s1, const char *s2)
> > -{
> > -	int size1 = strlen(s1);
> > -	int sisz2 = strlen(s2);
> > -	return _strnicmp(s1, s2, sisz2 > size1 ? sisz2 : size1);
> > -}
> > -
> >  #undef ERROR
> >  
> >  #define ftello _ftelli64
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-11-20 20:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-18 21:02 [PATCH] msvc: Directly use MS version (_stricmp) of strcasecmp Sven Strickroth
2018-11-18 21:58 ` Jeff King
2018-11-19  2:02   ` Junio C Hamano
2018-11-19 15:14     ` Sven Strickroth
2018-11-20  1:58       ` Junio C Hamano
2018-11-20 20:52         ` Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).