]> granicus.if.org Git - python/commitdiff
Issue #9642: Uniformize the tests on the availability of the mbcs codec
authorVictor Stinner <victor.stinner@haypocalc.com>
Mon, 4 Jul 2011 12:23:54 +0000 (14:23 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Mon, 4 Jul 2011 12:23:54 +0000 (14:23 +0200)
Add a new HAVE_MBCS define.

Include/unicodeobject.h
Misc/NEWS
Modules/_codecsmodule.c
Modules/timemodule.c
Objects/unicodeobject.c
Python/bltinmodule.c

index 6c492d1abe24558f5c65fd434846633a46207c8f..44c1775441c27160ab0b47c6a91027ce12eceb9d 100644 (file)
@@ -109,6 +109,10 @@ Copyright (c) Corporation for National Research Initiatives.
 # endif
 #endif
 
+#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+#  define HAVE_MBCS
+#endif
+
 #ifdef HAVE_WCHAR_H
 /* Work around a cosmetic bug in BSDI 4.x wchar.h; thanks to Thomas Wouters */
 # ifdef _HAVE_BSDI
@@ -1162,7 +1166,7 @@ PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap(
     );
 #endif
 
-#ifdef MS_WIN32
+#ifdef HAVE_MBCS
 
 /* --- MBCS codecs for Windows -------------------------------------------- */
 
@@ -1191,7 +1195,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
     );
 #endif
 
-#endif /* MS_WIN32 */
+#endif /* HAVE_MBCS */
 
 /* --- Decimal Encoder ---------------------------------------------------- */
 
index 350427e06bf96a071fcae6e0a3c262afe65a6dbd..6678aceefe5f6c17c95bbcc60618b4f96dcff99c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
 Core and Builtins
 -----------------
 
+- Issue #9642: Uniformize the tests on the availability of the mbcs codec, add
+  a new HAVE_MBCS define.
+
 - Issue #9642: Fix filesystem encoding initialization: use the ANSI code page
   on Windows if the mbcs codec is not available, and fail with a fatal error if
   we cannot get the locale encoding (if nl_langinfo(CODESET) is not available)
index eb740f95fdcd037505055b9e923ac5a70517c819..4bc0482c4dc8b40b97019d0434ad308eb2fea998 100644 (file)
@@ -588,7 +588,7 @@ charmap_decode(PyObject *self,
     return codec_tuple(unicode, pbuf.len);
 }
 
-#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+#ifdef HAVE_MBCS
 
 static PyObject *
 mbcs_decode(PyObject *self,
@@ -613,7 +613,7 @@ mbcs_decode(PyObject *self,
     return codec_tuple(decoded, consumed);
 }
 
-#endif /* MS_WINDOWS */
+#endif /* HAVE_MBCS */
 
 /* --- Encoder ------------------------------------------------------------ */
 
@@ -989,7 +989,7 @@ charmap_build(PyObject *self, PyObject *args)
     return PyUnicode_BuildEncodingMap(map);
 }
 
-#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+#ifdef HAVE_MBCS
 
 static PyObject *
 mbcs_encode(PyObject *self,
@@ -1014,7 +1014,7 @@ mbcs_encode(PyObject *self,
     return v;
 }
 
-#endif /* MS_WINDOWS */
+#endif /* HAVE_MBCS */
 
 /* --- Error handler registry --------------------------------------------- */
 
@@ -1101,7 +1101,7 @@ static PyMethodDef _codecs_functions[] = {
     {"charmap_decode",          charmap_decode,                 METH_VARARGS},
     {"charmap_build",           charmap_build,                  METH_VARARGS},
     {"readbuffer_encode",       readbuffer_encode,              METH_VARARGS},
-#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+#ifdef HAVE_MBCS
     {"mbcs_encode",             mbcs_encode,                    METH_VARARGS},
     {"mbcs_decode",             mbcs_decode,                    METH_VARARGS},
 #endif
index 8e29e0c7b580a0303677406ef320e249b0526f46..636d4adcf0b02de16a70f1e7241e846b370dd5c9 100644 (file)
@@ -43,7 +43,7 @@ static long main_thread;
 #endif /* MS_WINDOWS */
 #endif /* !__WATCOMC__ || __QNX__ */
 
-#if defined(MS_WINDOWS)
+#if defined(HAVE_MBCS)
 #  define TZNAME_ENCODING "mbcs"
 #else
 #  define TZNAME_ENCODING "utf-8"
index 7043599e599584dc3b9f6b15ec79594b92b53d3f..9ecf89bdc3acf92c0d2d7d30210c7d9edd66a973 100644 (file)
@@ -1506,7 +1506,7 @@ PyUnicode_Decode(const char *s,
                  (strcmp(lower, "latin1") == 0) ||
                  (strcmp(lower, "iso-8859-1") == 0))
             return PyUnicode_DecodeLatin1(s, size, errors);
-#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+#ifdef HAVE_MBCS
         else if (strcmp(lower, "mbcs") == 0)
             return PyUnicode_DecodeMBCS(s, size, errors);
 #endif
@@ -1644,7 +1644,7 @@ PyUnicode_AsEncodedObject(PyObject *unicode,
 PyObject *
 PyUnicode_EncodeFSDefault(PyObject *unicode)
 {
-#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+#ifdef HAVE_MBCS
     return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(unicode),
                                 PyUnicode_GET_SIZE(unicode),
                                 NULL);
@@ -1746,7 +1746,7 @@ PyUnicode_AsEncodedString(PyObject *unicode,
             return PyUnicode_EncodeLatin1(PyUnicode_AS_UNICODE(unicode),
                                           PyUnicode_GET_SIZE(unicode),
                                           errors);
-#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+#ifdef HAVE_MBCS
         else if (strcmp(lower, "mbcs") == 0)
             return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(unicode),
                                         PyUnicode_GET_SIZE(unicode),
@@ -1848,7 +1848,7 @@ PyUnicode_DecodeFSDefault(const char *s) {
 PyObject*
 PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size)
 {
-#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+#ifdef HAVE_MBCS
     return PyUnicode_DecodeMBCS(s, size, NULL);
 #elif defined(__APPLE__)
     return PyUnicode_DecodeUTF8(s, size, "surrogateescape");
@@ -4942,7 +4942,7 @@ PyUnicode_AsASCIIString(PyObject *unicode)
                                  NULL);
 }
 
-#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+#ifdef HAVE_MBCS
 
 /* --- MBCS codecs for Windows -------------------------------------------- */
 
@@ -5229,7 +5229,7 @@ PyUnicode_AsMBCSString(PyObject *unicode)
 
 #undef NEED_RETRY
 
-#endif /* MS_WINDOWS */
+#endif /* HAVE_MBCS */
 
 /* --- Character Mapping Codec -------------------------------------------- */
 
index 9adf530d27362489ebed02d85defbb4cbac38dfb..291ef45e67c7d629bfcf2d99ac4a1e9bf414a187 100644 (file)
@@ -18,7 +18,7 @@
    Don't forget to modify PyUnicode_DecodeFSDefault() if you touch any of the
    values for Py_FileSystemDefaultEncoding!
 */
-#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+#ifdef HAVE_MBCS
 const char *Py_FileSystemDefaultEncoding = "mbcs";
 int Py_HasFileSystemDefaultEncoding = 1;
 #elif defined(__APPLE__)