iconv() doesn't write to the data, just make compilers happy
--HG-- branch : SDL-1.2 extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402389
This commit is contained in:
parent
2fd06952d1
commit
9a001803a5
1 changed files with 12 additions and 12 deletions
|
@ -28,6 +28,15 @@
|
||||||
|
|
||||||
#ifdef HAVE_ICONV
|
#ifdef HAVE_ICONV
|
||||||
|
|
||||||
|
/* 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(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
|
||||||
|
#define ICONV_INBUF_NONCONST
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
size_t SDL_iconv(SDL_iconv_t cd,
|
size_t SDL_iconv(SDL_iconv_t cd,
|
||||||
|
@ -35,19 +44,10 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||||
char **outbuf, size_t *outbytesleft)
|
char **outbuf, size_t *outbytesleft)
|
||||||
{
|
{
|
||||||
size_t retCode;
|
size_t retCode;
|
||||||
#ifdef ICONV_REALLY_MODIFIES_INBUF
|
#ifdef ICONV_INBUF_NONCONST
|
||||||
if ( inbuf && *inbuf && inbytesleft ) {
|
|
||||||
char *tmp = SDL_stack_alloc(char, *inbytesleft);
|
|
||||||
char *ptr = tmp;
|
|
||||||
SDL_memcpy(tmp, inbuf, *inbytesleft);
|
|
||||||
retCode = iconv(cd, &ptr, inbytesleft, outbuf, outbytesleft);
|
|
||||||
inbuf += (ptr - tmp);
|
|
||||||
SDL_stack_free(tmp);
|
|
||||||
} else {
|
|
||||||
retCode = iconv(cd, NULL, inbytesleft, outbuf, outbytesleft);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
retCode = iconv(cd, (char **)inbuf, inbytesleft, outbuf, outbytesleft);
|
retCode = iconv(cd, (char **)inbuf, inbytesleft, outbuf, outbytesleft);
|
||||||
|
#else
|
||||||
|
retCode = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft);
|
||||||
#endif
|
#endif
|
||||||
if ( retCode == (size_t)-1 ) {
|
if ( retCode == (size_t)-1 ) {
|
||||||
switch(errno) {
|
switch(errno) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue