summaryrefslogtreecommitdiffstats
path: root/Include/pyport.h
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2004-08-04 06:33:51 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2004-08-04 06:33:51 (GMT)
commitb5047fd01948ab108edcc1b3c2c901d915814cfd (patch)
tree57da79f0a53a1886bd1cdc431d86c0c18aa5a413 /Include/pyport.h
parent6db15d7307b831766617f6a9700ecc4c75a16081 (diff)
downloadcpython-b5047fd01948ab108edcc1b3c2c901d915814cfd.zip
cpython-b5047fd01948ab108edcc1b3c2c901d915814cfd.tar.gz
cpython-b5047fd01948ab108edcc1b3c2c901d915814cfd.tar.bz2
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.
Diffstat (limited to 'Include/pyport.h')
-rw-r--r--Include/pyport.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/Include/pyport.h b/Include/pyport.h
index 0ee42f0..b20bc15 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -411,6 +411,39 @@ extern int fdatasync(int);
extern double hypot(double, double);
#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.
PyAPI_FUNC(type): Declares a public Python API function and return type