]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/utf-8-conv.c
ITS#6510
[openldap] / libraries / libldap / utf-8-conv.c
index b21f011999e9709c7a30f855665794a115573fb2..7101c77ef75d75fab2aab650f13576c4b79cfdd3 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2009 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 */