V3 PATCH: Fix const-correctness in use of iconv
Mark Mitchell
mark@codesourcery.com
Wed Nov 8 18:59:00 GMT 2000
As far as I can tell `iconv' always takes a `const char **' as its
second argument. If there are platforms where this is not true, we
need to either use autoconf or fixincludes. This fixes the sources to
work on Solaris and Linux, which both have the type described above.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2000-11-08 Mark Mitchell <mark@codesourcery.com>
* include/bits/codecvt.h (codecvt::do_out): Make it const-correct.
(codecvt::do_in): Likewise.
Index: include/bits/codecvt.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/codecvt.h,v
retrieving revision 1.4
diff -c -p -r1.4 codecvt.h
*** codecvt.h 2000/10/31 01:26:05 1.4
--- codecvt.h 2000/11/09 02:53:48
*************** namespace std
*** 393,399 ****
// Argument list for iconv specifies a byte sequence. Thus,
// all to/from arrays must be brutally casted to char*.
char* __cto = reinterpret_cast<char*>(__to);
! char* __cfrom;
size_t __conv;
// Some encodings need a byte order marker as the first item
--- 393,399 ----
// Argument list for iconv specifies a byte sequence. Thus,
// all to/from arrays must be brutally casted to char*.
char* __cto = reinterpret_cast<char*>(__to);
! const char* __cfrom;
size_t __conv;
// Some encodings need a byte order marker as the first item
*************** namespace std
*** 408,420 ****
intern_type __cfixed[__size + 1];
__cfixed[0] = static_cast<intern_type>(__int_bom);
char_traits<intern_type>::copy(__cfixed + 1, __from, __size);
! __cfrom = reinterpret_cast<char*>(__cfixed);
__conv = iconv(*__desc, &__cfrom, &__flen, &__cto, &__tlen);
}
else
{
intern_type* __cfixed = const_cast<intern_type*>(__from);
! __cfrom = reinterpret_cast<char*>(__cfixed);
__conv = iconv(*__desc, &__cfrom, &__flen, &__cto, &__tlen);
}
--- 408,420 ----
intern_type __cfixed[__size + 1];
__cfixed[0] = static_cast<intern_type>(__int_bom);
char_traits<intern_type>::copy(__cfixed + 1, __from, __size);
! __cfrom = reinterpret_cast<const char*>(__cfixed);
__conv = iconv(*__desc, &__cfrom, &__flen, &__cto, &__tlen);
}
else
{
intern_type* __cfixed = const_cast<intern_type*>(__from);
! __cfrom = reinterpret_cast<const char*>(__cfixed);
__conv = iconv(*__desc, &__cfrom, &__flen, &__cto, &__tlen);
}
*************** namespace std
*** 495,501 ****
// Argument list for iconv specifies a byte sequence. Thus,
// all to/from arrays must be brutally casted to char*.
char* __cto = reinterpret_cast<char*>(__to);
! char* __cfrom;
size_t __conv;
// Some encodings need a byte order marker as the first item
--- 495,501 ----
// Argument list for iconv specifies a byte sequence. Thus,
// all to/from arrays must be brutally casted to char*.
char* __cto = reinterpret_cast<char*>(__to);
! const char* __cfrom;
size_t __conv;
// Some encodings need a byte order marker as the first item
*************** namespace std
*** 510,522 ****
extern_type __cfixed[__size + 1];
__cfixed[0] = static_cast<extern_type>(__ext_bom);
char_traits<extern_type>::copy(__cfixed + 1, __from, __size);
! __cfrom = reinterpret_cast<char*>(__cfixed);
__conv = iconv(*__desc, &__cfrom, &__flen, &__cto, &__tlen);
}
else
{
extern_type* __cfixed = const_cast<extern_type*>(__from);
! __cfrom = reinterpret_cast<char*>(__cfixed);
__conv = iconv(*__desc, &__cfrom, &__flen, &__cto, &__tlen);
}
--- 510,522 ----
extern_type __cfixed[__size + 1];
__cfixed[0] = static_cast<extern_type>(__ext_bom);
char_traits<extern_type>::copy(__cfixed + 1, __from, __size);
! __cfrom = reinterpret_cast<const char*>(__cfixed);
__conv = iconv(*__desc, &__cfrom, &__flen, &__cto, &__tlen);
}
else
{
extern_type* __cfixed = const_cast<extern_type*>(__from);
! __cfrom = reinterpret_cast<const char*>(__cfixed);
__conv = iconv(*__desc, &__cfrom, &__flen, &__cto, &__tlen);
}
More information about the Libstdc++
mailing list