X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=libraries%2Flibldap%2Futf-8-conv.c;h=7101c77ef75d75fab2aab650f13576c4b79cfdd3;hb=eb4761c71703bfef45b7b6a1d0d7c4ac7cdacc3c;hp=d764bbad38ba7826034f31e2f5d4e7ff59945ec9;hpb=da6d9eb0463255782f3fa70c61fd958d94c048cf;p=openldap diff --git a/libraries/libldap/utf-8-conv.c b/libraries/libldap/utf-8-conv.c index d764bbad38..7101c77ef7 100644 --- a/libraries/libldap/utf-8-conv.c +++ b/libraries/libldap/utf-8-conv.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2007 The OpenLDAP Foundation. + * Copyright 1998-2010 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -191,7 +191,10 @@ ldap_x_wc_to_utf8 ( char *utf8char, wchar_t wchar, size_t count ) return 4; if( wchar < 0x4000000 ) return 5; - if( wchar < 0x80000000 ) +#if SIZEOF_WCHAR_T > 4 + /* UL is not strictly needed by ANSI C */ + if( wchar < (wchar_t)0x80000000UL ) +#endif /* SIZEOF_WCHAR_T > 4 */ return 6; return -1; } @@ -235,7 +238,12 @@ ldap_x_wc_to_utf8 ( char *utf8char, wchar_t wchar, size_t count ) utf8char[len++] = 0x80 | ( wchar & 0x3f ); } - } else if( wchar < 0x80000000 ) { + } else +#if SIZEOF_WCHAR_T > 4 + /* UL is not strictly needed by ANSI C */ + if( wchar < (wchar_t)0x80000000UL ) +#endif /* SIZEOF_WCHAR_T > 4 */ + { if (count >= 6) { utf8char[len++] = 0xfc | ( wchar >> 30 ); utf8char[len++] = 0x80 | ( (wchar >> 24) & 0x3f ); @@ -245,8 +253,11 @@ ldap_x_wc_to_utf8 ( char *utf8char, wchar_t wchar, size_t count ) utf8char[len++] = 0x80 | ( wchar & 0x3f ); } - } else +#if SIZEOF_WCHAR_T > 4 + } else { len = -1; +#endif /* SIZEOF_WCHAR_T > 4 */ + } return len; @@ -467,4 +478,4 @@ ldap_x_mbs_to_utf8s ( char *utf8str, const char *mbstr, size_t count, return n; } -#endif +#endif /* SIZEOF_WCHAR_T >= 4 */