[gs-code-review] Re: [gs-cvs] rev 7674 - trunk/gs/src
Leonardo
leonardo at artifex.com
Sun Feb 4 02:28:57 PST 2007
_vsnprintf appears working with MSVC8, so I'll commit it soon.
Why do you need buffer[n - 1] = 0 ?
_vsnprintf looks doing that.
So here is a simpler code :
int snprintf(char *buffer, size_t count, const char *format, ...)
{
va_list args;
va_start(args, format);
return _vsnprintf(buffer, count, format, args);
}
Leo.
----- Original Message -----
From: "SaGS" <sags5495 at hotmail.com>
To: "gs-code-review" <gs-code-review at ghostscript.com>
Sent: Sunday, February 04, 2007 11:36 AM
Subject: [gs-code-review] Re: [gs-cvs] rev 7674 - trunk/gs/src
> Hello all,
>
> Current TRUNK (rev 7674) doesn't compile anymore with .NET2003 or VS6.
> These
> define neither "snprintf" nor "vsnprintf_s".
>
> I suggest to emulate the missing "snprintf" using "_[v]snprintf" (with a
> leading
> underscore), which exist in Microsoft CRTLs since ages; see attached
> patch.
> This emulation is not perfect (see comment in code), but I consider that a
> perfect emulation, expected to return the exact number of bytes needed for
> the output string no matter how large this would be, is overkill.
>
> Non-MS compilers may still need some different solution, with #ifdef /etc.
> I don't have any of these to check and suggest something for them.
>
> ----- Original Message -----
> From: "Leonardo" <leonardo at artifex.com>
> To: <gs-cvs at ghostscript.com>
> Sent: Saturday, 03 February 2007 15:34
> Subject: [gs-cvs] rev 7674 - wrong log message
>
>
>> The log message should start as this :
>>
>> > Fix : MSVC doesn't implement snprintf.
>>
>> Leo.
>>
>>
>>
>> ----- Original Message -----
>> From: <leonardo at ghostscript.com>
>> To: <gs-cvs at ghostscript.com>
>> Sent: Saturday, February 03, 2007 4:30 PM
>> Subject: [gs-cvs] rev 7674 - trunk/gs/src
>>
>>
>> > Author: leonardo
>> > Date: 2007-02-03 05:30:24 -0800 (Sat, 03 Feb 2007)
>> > New Revision: 7674
>> >
>> > Modified:
>> > trunk/gs/src/gp_mswin.c
>> > trunk/gs/src/iscan.c
>> > trunk/gs/src/stdio_.h
>> > Log:
>> > Fix : MSVC doesn't implement snscanf.
>> >
>> > DETAILS :
>> >
>> > The revision 7672 doesn't compile with Microsoft Visual C++ 2005,
>> > because this compiler doesn't properly define snprintf.
>> >
>> > The function snsprintf is a part of the C standard ISO/IEC 9899:1999
>> > (E),
>> > so we decided to define it in the Windows platform-dependent module.
>> > Possibly we'll need a further improvement for other Windows compilers.
>> >
>> > Minor change : fixed an MSVC cast warning in iscan.c,
>> > which has been introduced in revision 7672.
>> >
>> > EXPECTED DIFFERENCES :
>> >
>> > None.
>> >
>> >
>> > Modified: trunk/gs/src/gp_mswin.c
>> > ===================================================================
>> > --- trunk/gs/src/gp_mswin.c 2007-02-03 06:27:14 UTC (rev 7673)
>> > +++ trunk/gs/src/gp_mswin.c 2007-02-03 13:30:24 UTC (rev 7674)
>> > @@ -46,6 +46,7 @@
>> > #include "gsexit.h"
>> >
>> > #include "windows_.h"
>> > +#include <stdarg.h>
>> > #include <shellapi.h>
>> > #include <winspool.h>
>> > #include "gp_mswin.h"
>> > @@ -716,3 +717,16 @@
>> > return _fseeki64(strm, offset, origin);
>> > #endif
>> > }
>> > +
>> > +/* -------------------------
>> > _snprintf -----------------------------*/
>> > +
>> > +/* Microsoft Visual C++ 2005 doesn't properly define snprintf,
>> > + which is defined in the C standard ISO/IEC 9899:1999 (E) */
>> > +
>> > +int snprintf(char *buffer, size_t count, const char *format, ...)
>> > +{
>> > + va_list args;
>> > + va_start(args, format);
>> > +
>> > + return vsnprintf_s(buffer, count, count - 1, format, args);
>> > +}
>> > \ No newline at end of file
>> >
>> > Modified: trunk/gs/src/iscan.c
>> > ===================================================================
>> > --- trunk/gs/src/iscan.c 2007-02-03 06:27:14 UTC (rev 7673)
>> > +++ trunk/gs/src/iscan.c 2007-02-03 13:30:24 UTC (rev 7674)
>> > @@ -258,7 +258,7 @@
>> > int len = strlen(pstate->s_error.string);
>> >
>> > if (pstate->s_error.is_name) {
>> > - int code = name_ref(imemory, pstate->s_error.string, len, pseo,
>> > 1);
>> > + int code = name_ref(imemory, (const byte
>> > *)pstate->s_error.string,
>> > len, pseo, 1);
>> >
>> > if (code < 0)
>> > return code;
>> >
>> > Modified: trunk/gs/src/stdio_.h
>> > ===================================================================
>> > --- trunk/gs/src/stdio_.h 2007-02-03 06:27:14 UTC (rev 7673)
>> > +++ trunk/gs/src/stdio_.h 2007-02-03 13:30:24 UTC (rev 7674)
>> > @@ -68,6 +68,8 @@
>> > #if defined(_MSC_VER)
>> > # define fdopen(handle,mode) _fdopen(handle,mode)
>> > # define fileno(file) _fileno(file)
>> > +/* Microsoft Visual C++ 2005 doesn't properly define snprintf */
>> > +int snprintf(char *buffer, size_t count, const char *format , ...);
>> > #endif
>> >
>> > #endif /* stdio__INCLUDED */
>> >
>> > _______________________________________________
>> > gs-cvs mailing list
>> > gs-cvs at ghostscript.com
>> > http://www.ghostscript.com/mailman/listinfo/gs-cvs
>>
>> _______________________________________________
>> gs-cvs mailing list
>> gs-cvs at ghostscript.com
>> http://www.ghostscript.com/mailman/listinfo/gs-cvs
>>
>
--------------------------------------------------------------------------------
> _______________________________________________
> gs-code-review mailing list
> gs-code-review at ghostscript.com
> http://www.ghostscript.com/mailman/listinfo/gs-code-review
>
More information about the gs-code-review
mailing list