]> granicus.if.org Git - python/commitdiff
Issue #26765: Ensure that bytes- and unicode-specific stringlib files are used
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 16 May 2016 06:42:29 +0000 (09:42 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 16 May 2016 06:42:29 +0000 (09:42 +0300)
with correct type.

Objects/stringlib/codecs.h
Objects/stringlib/ctype.h
Objects/stringlib/find_max_char.h
Objects/stringlib/join.h
Objects/stringlib/localeutil.h
Objects/stringlib/transmogrify.h

index 2beb604f1168d390559d9715017a3b3f26cbcd5c..2846d7e8462e96ec82e7d3a0a47da8afc705cb94 100644 (file)
@@ -1,6 +1,8 @@
 /* stringlib: codec implementations */
 
-#if STRINGLIB_IS_UNICODE
+#if !STRINGLIB_IS_UNICODE
+# error "codecs.h is specific to Unicode"
+#endif
 
 /* Mask to quickly check whether a C 'long' contains a
    non-ASCII, UTF8-encoded char. */
@@ -823,5 +825,3 @@ STRINGLIB(utf32_encode)(const STRINGLIB_CHAR *in,
 #undef SWAB4
 
 #endif
-
-#endif /* STRINGLIB_IS_UNICODE */
index 739cf3d9ebe2b640fd173e3d59a06c0abb279456..f0546256ed911cdaecbb40568ba18f5d6ee1b25f 100644 (file)
@@ -1,5 +1,6 @@
-/* NOTE: this API is -ONLY- for use with single byte character strings. */
-/* Do not use it with Unicode. */
+#if STRINGLIB_IS_UNICODE
+# error "ctype.h only compatible with byte-wise strings"
+#endif
 
 #include "bytes_methods.h"
 
index eb3fe886e2974e36b8208dd23188499012d81b64..8ccbc3094463df3123873d44f32f7dc2fbf58ee6 100644 (file)
@@ -1,6 +1,8 @@
 /* Finding the optimal width of unicode characters in a buffer */
 
-#if STRINGLIB_IS_UNICODE
+#if !STRINGLIB_IS_UNICODE
+# error "find_max_char.h is specific to Unicode"
+#endif
 
 /* Mask to quickly check whether a C 'long' contains a
    non-ASCII, UTF8-encoded char. */
@@ -129,5 +131,4 @@ STRINGLIB(find_max_char)(const STRINGLIB_CHAR *begin, const STRINGLIB_CHAR *end)
 #undef MAX_CHAR_UCS4
 
 #endif /* STRINGLIB_SIZEOF_CHAR == 1 */
-#endif /* STRINGLIB_IS_UNICODE */
 
index cbf81be170684797ae3b139004779b1fad90b38f..90f966dd5ce71398d3e7e3cb256ad75151af214c 100644 (file)
@@ -1,6 +1,6 @@
 /* stringlib: bytes joining implementation */
 
-#if STRINGLIB_SIZEOF_CHAR != 1
+#if STRINGLIB_IS_UNICODE
 #error join.h only compatible with byte-wise strings
 #endif
 
index 6e2f07342c9fbb9f7e618c426b7bfbfbad9a5918..df501ed05c7e97f03ed2d8fad3fa28ca1bd10d7f 100644 (file)
@@ -2,8 +2,8 @@
 
 #include <locale.h>
 
-#ifndef STRINGLIB_IS_UNICODE
-#   error "localeutil is specific to Unicode"
+#if !STRINGLIB_IS_UNICODE
+#   error "localeutil.h is specific to Unicode"
 #endif
 
 typedef struct {
index 8b147dec8221baeaef11420b875678eb88178de2..625507ddb1d768688a87312655410857a9f69eb9 100644 (file)
@@ -1,5 +1,6 @@
-/* NOTE: this API is -ONLY- for use with single byte character strings. */
-/* Do not use it with Unicode. */
+#if STRINGLIB_IS_UNICODE
+# error "transmogrify.h only compatible with byte-wise strings"
+#endif
 
 /* the more complicated methods.  parts of these should be pulled out into the
    shared code in bytes_methods.c to cut down on duplicate code bloat.  */