[Python-checkins] python/dist/src/Include pyport.h,2.68,2.69

perky at users.sourceforge.net perky at users.sourceforge.net
Wed Aug 4 08:33:53 CEST 2004


Update of /cvsroot/python/python/dist/src/Include
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25741/Include

Modified Files:
	pyport.h 
Log Message:
Add a workaround for a problem that UTF-8 strings can be corrupted
or broken by basic ctype functions in 4.4BSD descendants.  This
will be fixed in their future development branches but they'll keep
the POSIX-incompatibility for their backward-compatiblities in near
future.


Index: pyport.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v
retrieving revision 2.68
retrieving revision 2.69
diff -C2 -d -r2.68 -r2.69
*** pyport.h	15 Jul 2004 15:54:03 -0000	2.68
--- pyport.h	4 Aug 2004 06:33:50 -0000	2.69
***************
*** 412,415 ****
--- 412,448 ----
  #endif
  
+ 
+ /*******************************************************************
+ On 4.4BSD-descendants, ctype functions serves the whole range of
+ wchar_t character set rather than single byte code points only.
+ This characteristic can break some operations of string object
+ including str.upper() and str.split() on UTF-8 locales.  This
+ workaround was provided by Tim Robbins of FreeBSD project.  He said
+ the incompatibility will be fixed in FreeBSD 6.
+ ********************************************************************/
+ 
+ #ifdef __FreeBSD__
+ #include <osreldate.h>
+ #if __FreeBSD_version > 500039
+ #include <ctype.h>
+ #include <wctype.h>
+ #undef isalnum
+ #define isalnum(c) iswalnum(btowc(c))
+ #undef isalpha
+ #define isalpha(c) iswalpha(btowc(c))
+ #undef islower
+ #define islower(c) iswlower(btowc(c))
+ #undef isspace
+ #define isspace(c) iswspace(btowc(c))
+ #undef isupper
+ #define isupper(c) iswupper(btowc(c))
+ #undef tolower
+ #define tolower(c) towlower(btowc(c))
+ #undef toupper
+ #define toupper(c) towupper(btowc(c))
+ #endif
+ #endif
+ 
+ 
  /* Declarations for symbol visibility.
  



More information about the Python-checkins mailing list