mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	Issue #26765: Ensure that bytes- and unicode-specific stringlib files are used
with correct type.
This commit is contained in:
		
							parent
							
								
									cbcc2fd641
								
							
						
					
					
						commit
						bcde10aa7e
					
				
					 6 changed files with 15 additions and 12 deletions
				
			
		|  | @ -1,6 +1,8 @@ | ||||||
| /* stringlib: codec implementations */ | /* 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
 | /* Mask to quickly check whether a C 'long' contains a
 | ||||||
|    non-ASCII, UTF8-encoded char. */ |    non-ASCII, UTF8-encoded char. */ | ||||||
|  | @ -823,5 +825,3 @@ STRINGLIB(utf32_encode)(const STRINGLIB_CHAR *in, | ||||||
| #undef SWAB4 | #undef SWAB4 | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
| 
 |  | ||||||
| #endif /* STRINGLIB_IS_UNICODE */ |  | ||||||
|  |  | ||||||
|  | @ -1,5 +1,6 @@ | ||||||
| /* NOTE: this API is -ONLY- for use with single byte character strings. */ | #if STRINGLIB_IS_UNICODE | ||||||
| /* Do not use it with Unicode. */ | # error "ctype.h only compatible with byte-wise strings" | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| #include "bytes_methods.h" | #include "bytes_methods.h" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,8 @@ | ||||||
| /* Finding the optimal width of unicode characters in a buffer */ | /* 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
 | /* Mask to quickly check whether a C 'long' contains a
 | ||||||
|    non-ASCII, UTF8-encoded char. */ |    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 | #undef MAX_CHAR_UCS4 | ||||||
| 
 | 
 | ||||||
| #endif /* STRINGLIB_SIZEOF_CHAR == 1 */ | #endif /* STRINGLIB_SIZEOF_CHAR == 1 */ | ||||||
| #endif /* STRINGLIB_IS_UNICODE */ |  | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| /* stringlib: bytes joining implementation */ | /* stringlib: bytes joining implementation */ | ||||||
| 
 | 
 | ||||||
| #if STRINGLIB_SIZEOF_CHAR != 1 | #if STRINGLIB_IS_UNICODE | ||||||
| #error join.h only compatible with byte-wise strings | #error join.h only compatible with byte-wise strings | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -2,8 +2,8 @@ | ||||||
| 
 | 
 | ||||||
| #include <locale.h> | #include <locale.h> | ||||||
| 
 | 
 | ||||||
| #ifndef STRINGLIB_IS_UNICODE | #if !STRINGLIB_IS_UNICODE | ||||||
| #   error "localeutil is specific to Unicode" | #   error "localeutil.h is specific to Unicode" | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|  |  | ||||||
|  | @ -1,5 +1,6 @@ | ||||||
| /* NOTE: this API is -ONLY- for use with single byte character strings. */ | #if STRINGLIB_IS_UNICODE | ||||||
| /* Do not use it with Unicode. */ | # error "transmogrify.h only compatible with byte-wise strings" | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| /* the more complicated methods.  parts of these should be pulled out into the
 | /* 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.  */ |    shared code in bytes_methods.c to cut down on duplicate code bloat.  */ | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka