mirror of https://github.com/encounter/SDL.git
stdlib: just cast iconv()'s 2nd arg to void *.
This makes the compiler happy (enough) regardless of whether the C runtime headers think this argument should be const or not. Fixes #4966.
This commit is contained in:
parent
4b8d69a416
commit
8df045cc7d
|
@ -36,18 +36,6 @@
|
||||||
#define LIBICONV_PLUG 1
|
#define LIBICONV_PLUG 1
|
||||||
#endif
|
#endif
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
|
|
||||||
/* Depending on which standard the iconv() was implemented with,
|
|
||||||
iconv() may or may not use const char ** for the inbuf param.
|
|
||||||
If we get this wrong, it's just a warning, so no big deal.
|
|
||||||
*/
|
|
||||||
#if defined(_XGP6) || defined(__APPLE__) || defined(__RISCOS__) || defined(__FREEBSD__) || \
|
|
||||||
defined(__EMSCRIPTEN__) || \
|
|
||||||
(defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) || \
|
|
||||||
(defined(_NEWLIB_VERSION)))
|
|
||||||
#define ICONV_INBUF_NONCONST
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
SDL_COMPILE_TIME_ASSERT(iconv_t, sizeof (iconv_t) <= sizeof (SDL_iconv_t));
|
SDL_COMPILE_TIME_ASSERT(iconv_t, sizeof (iconv_t) <= sizeof (SDL_iconv_t));
|
||||||
|
@ -69,12 +57,9 @@ SDL_iconv(SDL_iconv_t cd,
|
||||||
const char **inbuf, size_t * inbytesleft,
|
const char **inbuf, size_t * inbytesleft,
|
||||||
char **outbuf, size_t * outbytesleft)
|
char **outbuf, size_t * outbytesleft)
|
||||||
{
|
{
|
||||||
size_t retCode;
|
/* iconv's second parameter may or may not be `const char const *` depending on the
|
||||||
#ifdef ICONV_INBUF_NONCONST
|
C runtime's whims. Casting to void * seems to make everyone happy, though. */
|
||||||
retCode = iconv((iconv_t) ((uintptr_t) cd), (char **) inbuf, inbytesleft, outbuf, outbytesleft);
|
const size_t retCode = iconv((iconv_t) ((uintptr_t) cd), (void *) inbuf, inbytesleft, outbuf, outbytesleft);
|
||||||
#else
|
|
||||||
retCode = iconv((iconv_t) ((uintptr_t) cd), inbuf, inbytesleft, outbuf, outbytesleft);
|
|
||||||
#endif
|
|
||||||
if (retCode == (size_t) - 1) {
|
if (retCode == (size_t) - 1) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case E2BIG:
|
case E2BIG:
|
||||||
|
|
Loading…
Reference in New Issue