{"thread":{"id":"41863","subject":"[PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more","startedAt":"2016-03-29T16:25:28Z","lastAt":"2016-03-30T07:57:27Z","messageCount":7,"participants":["Sven Strickroth","Junio C Hamano","Sebastian Schuberth","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"282066","messageId":"56FAAC78.2040304@cs-ware.de","threadId":"41863","inReplyTo":null,"subject":"[PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more","fromName":"Sven Strickroth","fromEmail":"sven@cs-ware.de","sentAt":"2016-03-29T16:25:28Z","receivedAt":"2016-03-29T16:25:28Z","isPatch":true,"sender":{"key":"sven@cs-ware.de","avatar":null},"body":"In MSVC2015 the behavior of vsnprintf was changed.\nW/o this fix there is one character missing at the end.\n\nSigned-off-by: Sven Strickroth <sven@cs-ware.de>\n---\n compat/snprintf.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/snprintf.c b/compat/snprintf.c\nindex 42ea1ac..0b11688 100644\n--- a/compat/snprintf.c\n+++ b/compat/snprintf.c\n@@ -9,7 +9,7 @@\n  * always have room for a trailing NUL byte.\n  */\n #ifndef SNPRINTF_SIZE_CORR\n-#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)\n+#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)\n #define SNPRINTF_SIZE_CORR 1\n #else\n #define SNPRINTF_SIZE_CORR 0\n-- \n2.7.4.windows.1\n"},{"id":"282068","messageId":"xmqqio05z12u.fsf@gitster.mtv.corp.google.com","threadId":"41863","inReplyTo":"56FAAC78.2040304@cs-ware.de","subject":"Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-03-29T16:43:53Z","receivedAt":"2016-03-29T16:43:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sven Strickroth <sven@cs-ware.de> writes:\n\n> In MSVC2015 the behavior of vsnprintf was changed.\n> W/o this fix there is one character missing at the end.\n>\n> Signed-off-by: Sven Strickroth <sven@cs-ware.de>\n> ---\n\nThanks.\n\nI am not qualified to judge the correctness of the assertion that\nMSVC at or more recent than version 1900 does not need the\ncorrection and will wait for Windows folks to Ack.\n\nThanks.\n\n>  compat/snprintf.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/compat/snprintf.c b/compat/snprintf.c\n> index 42ea1ac..0b11688 100644\n> --- a/compat/snprintf.c\n> +++ b/compat/snprintf.c\n> @@ -9,7 +9,7 @@\n>   * always have room for a trailing NUL byte.\n>   */\n>  #ifndef SNPRINTF_SIZE_CORR\n> -#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)\n> +#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)\n>  #define SNPRINTF_SIZE_CORR 1\n>  #else\n>  #define SNPRINTF_SIZE_CORR 0\n"},{"id":"282086","messageId":"CAHGBnuP1Y1F-CrQJx9zNKSv1KP7gH86WSKo7tbmcYT3Vf2cQ_g@mail.gmail.com","threadId":"41863","inReplyTo":"56FAAC78.2040304@cs-ware.de","subject":"Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2016-03-29T19:09:19Z","receivedAt":"2016-03-29T19:09:19Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Tue, Mar 29, 2016 at 6:25 PM, Sven Strickroth <sven@cs-ware.de> wrote:\n\n> In MSVC2015 the behavior of vsnprintf was changed.\n> W/o this fix there is one character missing at the end.\n\nHow about adding a link to [1] in the commit message and quoting the\ncentral \"Beginning with the UCRT in Visual Studio 2015 and Windows 10,\nvsnprintf is no longer identical to _vsnprintf. The vsnprintf function\ncomplies with the C99 standard; _vnsprintf is retained for backward\ncompatibility\" statement?\n\n[1] https://msdn.microsoft.com/en-us/library/1kt27hek.aspx\n\n-- \nSebastian Schuberth\n"},{"id":"282087","messageId":"56FAD3DD.4060009@cs-ware.de","threadId":"41863","inReplyTo":"CAHGBnuP1Y1F-CrQJx9zNKSv1KP7gH86WSKo7tbmcYT3Vf2cQ_g@mail.gmail.com","subject":"Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more","fromName":"Sven Strickroth","fromEmail":"sven@cs-ware.de","sentAt":"2016-03-29T19:13:33Z","receivedAt":"2016-03-29T19:13:33Z","isPatch":true,"sender":{"key":"sven@cs-ware.de","avatar":null},"body":"\"Beginning with the UCRT in Visual Studio 2015 and Windows 10,\nvsnprintf is no longer identical to _vsnprintf. The vsnprintf function\ncomplies with the C99 standard; _vnsprintf is retained for backward\ncompatibility\" [1]\n\nW/o this fix there is one character missing at the end.\n\n[1] https://msdn.microsoft.com/en-us/library/1kt27hek.aspx\n\nSigned-off-by: Sven Strickroth <sven@cs-ware.de>\n---\n compat/snprintf.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/snprintf.c b/compat/snprintf.c\nindex 42ea1ac..0b11688 100644\n--- a/compat/snprintf.c\n+++ b/compat/snprintf.c\n@@ -9,7 +9,7 @@\n  * always have room for a trailing NUL byte.\n  */\n #ifndef SNPRINTF_SIZE_CORR\n-#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)\n+#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)\n #define SNPRINTF_SIZE_CORR 1\n #else\n #define SNPRINTF_SIZE_CORR 0\n-- \n2.7.4.windows.1\n"},{"id":"282089","messageId":"CAHGBnuNkuiyk1uvJqT1_1UWOhpVTg+TxJ2QvepuMBpvOD8AyFw@mail.gmail.com","threadId":"41863","inReplyTo":"56FAD3DD.4060009@cs-ware.de","subject":"Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2016-03-29T19:20:18Z","receivedAt":"2016-03-29T19:20:18Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Tue, Mar 29, 2016 at 9:13 PM, Sven Strickroth <sven@cs-ware.de> wrote:\n\n> diff --git a/compat/snprintf.c b/compat/snprintf.c\n> index 42ea1ac..0b11688 100644\n> --- a/compat/snprintf.c\n> +++ b/compat/snprintf.c\n> @@ -9,7 +9,7 @@\n>   * always have room for a trailing NUL byte.\n>   */\n>  #ifndef SNPRINTF_SIZE_CORR\n> -#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)\n> +#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)\n>  #define SNPRINTF_SIZE_CORR 1\n>  #else\n>  #define SNPRINTF_SIZE_CORR 0\n\nI wonder if the logic is (and was) sensible here. We assume that every\nnon-__GNUC__ and non-_MSC_VER compiler on Windows requires the\ncorrection. Wouldn't it make sense to not assume requiring the\ncorrection unless we know the compiler has this bug? That is,\nshouldn't this better say\n\n#if defined(WIN32) && (defined(__GNUC__) && __GNUC__ < 4) ||\n(defined(_MSC_VER) && _MSC_VER < 1900))\n#define SNPRINTF_SIZE_CORR 1\n#else\n#define SNPRINTF_SIZE_CORR 0\n\n-- \nSebastian Schuberth\n"},{"id":"282198","messageId":"alpine.DEB.2.20.1603300946410.4690@virtualbox","threadId":"41863","inReplyTo":"CAHGBnuNkuiyk1uvJqT1_1UWOhpVTg+TxJ2QvepuMBpvOD8AyFw@mail.gmail.com","subject":"Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-03-30T07:49:42Z","receivedAt":"2016-03-30T07:49:42Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Sven & Sebastian,\n\nOn Tue, 29 Mar 2016, Sebastian Schuberth wrote:\n\n> On Tue, Mar 29, 2016 at 9:13 PM, Sven Strickroth <sven@cs-ware.de> wrote:\n\nACK on the patch.\n\n> > diff --git a/compat/snprintf.c b/compat/snprintf.c\n> > index 42ea1ac..0b11688 100644\n> > --- a/compat/snprintf.c\n> > +++ b/compat/snprintf.c\n> > @@ -9,7 +9,7 @@\n> >   * always have room for a trailing NUL byte.\n> >   */\n> >  #ifndef SNPRINTF_SIZE_CORR\n> > -#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)\n> > +#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)\n> >  #define SNPRINTF_SIZE_CORR 1\n> >  #else\n> >  #define SNPRINTF_SIZE_CORR 0\n> \n> I wonder if the logic is (and was) sensible here. We assume that every\n> non-__GNUC__ and non-_MSC_VER compiler on Windows requires the\n> correction. Wouldn't it make sense to not assume requiring the\n> correction unless we know the compiler has this bug? That is,\n> shouldn't this better say\n> \n> #if defined(WIN32) && (defined(__GNUC__) && __GNUC__ < 4) ||\n> (defined(_MSC_VER) && _MSC_VER < 1900))\n> #define SNPRINTF_SIZE_CORR 1\n> #else\n> #define SNPRINTF_SIZE_CORR 0\n\nSince the standard on Windows always was MS Visual C, it should be assumed\nthat compilers *other* than GCC followed Visual C's lead.\n\nOf course, evidence speaks louder than assumptions.\n\nTherefore I would prefer to keep the current version, at least until we\nencounter a case where it is incorrect.\n\nThanks,\nJohannes\n"},{"id":"282199","messageId":"CAHGBnuOu9BMfDjmozMHSGKCaA5sYYHYmPupL2-51has4rv-MqA@mail.gmail.com","threadId":"41863","inReplyTo":"alpine.DEB.2.20.1603300946410.4690@virtualbox","subject":"Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2016-03-30T07:57:27Z","receivedAt":"2016-03-30T07:57:27Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Wed, Mar 30, 2016 at 9:49 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n\n>> >  #ifndef SNPRINTF_SIZE_CORR\n>> > -#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)\n>> > +#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)\n>> >  #define SNPRINTF_SIZE_CORR 1\n>> >  #else\n>> >  #define SNPRINTF_SIZE_CORR 0\n>>\n>> I wonder if the logic is (and was) sensible here. We assume that every\n>> non-__GNUC__ and non-_MSC_VER compiler on Windows requires the\n>> correction. Wouldn't it make sense to not assume requiring the\n>> correction unless we know the compiler has this bug? That is,\n>> shouldn't this better say\n>>\n>> #if defined(WIN32) && (defined(__GNUC__) && __GNUC__ < 4) ||\n>> (defined(_MSC_VER) && _MSC_VER < 1900))\n>> #define SNPRINTF_SIZE_CORR 1\n>> #else\n>> #define SNPRINTF_SIZE_CORR 0\n>\n> Since the standard on Windows always was MS Visual C, it should be assumed\n> that compilers *other* than GCC followed Visual C's lead.\n>\n> Of course, evidence speaks louder than assumptions.\n>\n> Therefore I would prefer to keep the current version, at least until we\n> encounter a case where it is incorrect.\n\nFine with me. It's probably better not to change the logic as we\nwouldn't know whether this would break things for some exotic compiler\ncurrently in use to compile Git.\n\nAlso ACK from my side on the path then.\n\n-- \nSebastian Schuberth\n"}]}