[Python-checkins] CVS: python/dist/src/Modules _codecsmodule.c,2.8,2.9 _sre.c,2.62,2.63 _tkinter.c,1.118,1.119 cPickle.c,2.61,2.62 pyexpat.c,2.47,2.48

Martin v. L?wis loewis@users.sourceforge.net
2001年8月17日 11:39:27 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv28889/Modules
Modified Files:
	_codecsmodule.c _sre.c _tkinter.c cPickle.c pyexpat.c 
Log Message:
Patch #445762: Support --disable-unicode
- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled
- check for Py_USING_UNICODE in all places that use Unicode functions
- disables unicode literals, and the builtin functions
- add the types.StringTypes list
- remove Unicode literals from most tests.
Index: _codecsmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_codecsmodule.c,v
retrieving revision 2.8
retrieving revision 2.9
diff -C2 -d -r2.8 -r2.9
*** _codecsmodule.c	2001年06月26日 15:11:00	2.8
--- _codecsmodule.c	2001年08月17日 18:39:25	2.9
***************
*** 72,75 ****
--- 72,76 ----
 }
 
+ #ifdef Py_USING_UNICODE
 /* --- Helpers ------------------------------------------------------------ */
 
***************
*** 622,625 ****
--- 623,627 ----
 
 #endif /* MS_WIN32 */
+ #endif /* Py_USING_UNICODE */
 
 /* --- Module API --------------------------------------------------------- */
***************
*** 628,631 ****
--- 630,634 ----
 {"register",		codecregister,			1},
 {"lookup",			codeclookup, 			1},
+ #ifdef Py_USING_UNICODE
 {"utf_8_encode",		utf_8_encode,			1},
 {"utf_8_decode",		utf_8_decode,			1},
***************
*** 655,658 ****
--- 658,662 ----
 {"mbcs_decode", 		mbcs_decode,			1},
 #endif
+ #endif /* Py_USING_UNICODE */
 {NULL, NULL}		/* sentinel */
 };
Index: _sre.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v
retrieving revision 2.62
retrieving revision 2.63
diff -C2 -d -r2.62 -r2.63
*** _sre.c	2001年08月16日 20:33:48	2.62
--- _sre.c	2001年08月17日 18:39:25	2.63
***************
*** 64,68 ****
 #undef VERBOSE
 
! #if PY_VERSION_HEX >= 0x01060000
 /* defining this enables unicode support (default under 1.6a1 and later) */
 #define HAVE_UNICODE
--- 64,68 ----
 #undef VERBOSE
 
! #if PY_VERSION_HEX >= 0x01060000 && defined(Py_USING_UNICODE)
 /* defining this enables unicode support (default under 1.6a1 and later) */
 #define HAVE_UNICODE
Index: _tkinter.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v
retrieving revision 1.118
retrieving revision 1.119
diff -C2 -d -r1.118 -r1.119
*** _tkinter.c	2001年08月07日 15:32:37	1.118
--- _tkinter.c	2001年08月17日 18:39:25	1.119
***************
*** 256,259 ****
--- 256,260 ----
 	if (PyString_Check(value))
 		return PyString_AsString(value);
+ #ifdef Py_USING_UNICODE
 	else if (PyUnicode_Check(value)) {
 		PyObject *v = PyUnicode_AsUTF8String(value);
***************
*** 267,270 ****
--- 268,272 ----
 		return PyString_AsString(v);
 	}
+ #endif
 	else {
 		PyObject *v = PyObject_Str(value);
***************
*** 521,524 ****
--- 523,527 ----
 		return result;
 	}
+ #ifdef Py_USING_UNICODE
 	else if (PyUnicode_Check(value)) {
 #if TKMAJORMINOR <= 8001
***************
*** 543,546 ****
--- 546,550 ----
 #endif /* TKMAJORMINOR > 8001 */
 	}
+ #endif
 	else {
 		PyObject *v = PyObject_Str(value);
***************
*** 617,622 ****
--- 621,628 ----
 		char *s = Tcl_GetStringResult(interp);
 		char *p = s;
+ 
 		/* If the result contains any bytes with the top bit set,
 		 it's UTF-8 and we should decode it to Unicode */
+ #ifdef Py_USING_UNICODE
 		while (*p != '0円') {
 			if (*p & 0x80)
***************
*** 624,627 ****
--- 630,634 ----
 			p++;
 		}
+ 
 		if (*p == '0円')
 			res = PyString_FromStringAndSize(s, (int)(p-s));
***************
*** 635,638 ****
--- 642,649 ----
 			}
 		}
+ #else
+ 		p = strchr(p, '0円');
+ 		res = PyString_FromStringAndSize(s, (int)(p-s));
+ #endif
 	}
 
Index: cPickle.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v
retrieving revision 2.61
retrieving revision 2.62
diff -C2 -d -r2.61 -r2.62
*** cPickle.c	2001年08月02日 04:15:00	2.61
--- cPickle.c	2001年08月17日 18:39:25	2.62
***************
*** 1173,1176 ****
--- 1173,1177 ----
 
 
+ #ifdef Py_USING_UNICODE
 /* A copy of PyUnicode_EncodeRawUnicodeEscape() that also translates
 backslash and newline characters to \uXXXX escapes. */
***************
*** 1290,1293 ****
--- 1291,1295 ----
 return -1;
 }
+ #endif
 
 
***************
*** 1825,1828 ****
--- 1827,1831 ----
 }
 
+ #ifdef Py_USING_UNICODE
 case 'u':
 if ((type == &PyUnicode_Type) && (PyString_GET_SIZE(args) < 2)) {
***************
*** 1830,1833 ****
--- 1833,1837 ----
 goto finally;
 }
+ #endif
 }
 
***************
*** 1858,1861 ****
--- 1862,1866 ----
 break;
 
+ #ifdef Py_USING_UNICODE
 case 'u':
 if (type == &PyUnicode_Type) {
***************
*** 1864,1867 ****
--- 1869,1873 ----
 }
 break;
+ #endif
 
 case 't':
***************
*** 2819,2822 ****
--- 2825,2829 ----
 
 
+ #ifdef Py_USING_UNICODE
 static int
 load_unicode(Unpicklerobject *self) {
***************
*** 2837,2842 ****
--- 2844,2851 ----
 return res;
 }
+ #endif
 
 
+ #ifdef Py_USING_UNICODE
 static int
 load_binunicode(Unpicklerobject *self) {
***************
*** 2858,2861 ****
--- 2867,2871 ----
 return 0;
 }
+ #endif
 
 
***************
*** 3616,3619 ****
--- 3626,3630 ----
 continue;
 
+ #ifdef Py_USING_UNICODE
 case UNICODE:
 if (load_unicode(self) < 0)
***************
*** 3625,3628 ****
--- 3636,3640 ----
 break;
 continue;
+ #endif
 
 case EMPTY_TUPLE:
***************
*** 3906,3909 ****
--- 3918,3922 ----
 continue;
 
+ #ifdef Py_USING_UNICODE
 case UNICODE:
 if (load_unicode(self) < 0)
***************
*** 3915,3918 ****
--- 3928,3932 ----
 break;
 continue;
+ #endif
 
 case EMPTY_TUPLE:
Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.47
retrieving revision 2.48
diff -C2 -d -r2.47 -r2.48
*** pyexpat.c	2001年07月28日 09:36:36	2.47
--- pyexpat.c	2001年08月17日 18:39:25	2.48
***************
*** 29,32 ****
--- 29,37 ----
 #endif
 
+ #if (PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION > 5) || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2)
+ /* In Python 1.6, 2.0 and 2.1, disabling Unicode was not possible. */
+ #define Py_USING_UNICODE
+ #endif
+ 
 enum HandlerTypes {
 StartElement,
***************
*** 174,178 ****
 #endif
 
! #if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6)
 #if EXPAT_VERSION == 0x010200
 static PyObject *
--- 179,183 ----
 #endif
 
! #ifdef Py_USING_UNICODE
 #if EXPAT_VERSION == 0x010200
 static PyObject *
***************
*** 371,375 ****
 }
 
! #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
 #define STRING_CONV_FUNC conv_string_to_utf8
 #else
--- 376,380 ----
 }
 
! #ifndef Py_USING_UNICODE
 #define STRING_CONV_FUNC conv_string_to_utf8
 #else
***************
*** 507,511 ****
 ("(O&O&)",STRING_CONV_FUNC,target, STRING_CONV_FUNC,data))
 
! #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
 VOID_HANDLER(CharacterData, 
 (void *userData, const XML_Char *data, int len), 
--- 512,516 ----
 ("(O&O&)",STRING_CONV_FUNC,target, STRING_CONV_FUNC,data))
 
! #ifndef Py_USING_UNICODE
 VOID_HANDLER(CharacterData, 
 (void *userData, const XML_Char *data, int len), 
***************
*** 532,536 ****
 
 #if EXPAT_VERSION >= 0x015f00
! #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
 VOID_HANDLER(EntityDecl,
 (void *userData,
--- 537,541 ----
 
 #if EXPAT_VERSION >= 0x015f00
! #ifndef Py_USING_UNICODE
 VOID_HANDLER(EntityDecl,
 (void *userData,
***************
*** 609,613 ****
 }
 
! #if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6)
 static PyObject *
 conv_content_model_unicode(XML_Content * const model)
--- 614,618 ----
 }
 
! #ifdef Py_USING_UNICODE
 static PyObject *
 conv_content_model_unicode(XML_Content * const model)
***************
*** 679,683 ****
 		("()"))
 
! #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
 VOID_HANDLER(Default,
 	 (void *userData, const XML_Char *s, int len),
--- 684,688 ----
 		("()"))
 
! #ifndef Py_USING_UNICODE
 VOID_HANDLER(Default,
 	 (void *userData, const XML_Char *s, int len),
***************
*** 1065,1069 ****
 
 
! #if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6)
 
 /* 
--- 1070,1074 ----
 
 
! #ifdef Py_USING_UNICODE
 
 /* 
***************
*** 1159,1164 ****
 }
 XML_SetUserData(self->itself, (void *)self);
! #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
! #else
 XML_SetUnknownEncodingHandler(self->itself, (XML_UnknownEncodingHandler) PyUnknownEncodingHandler, NULL);
 #endif
--- 1164,1168 ----
 }
 XML_SetUserData(self->itself, (void *)self);
! #ifdef Py_USING_UNICODE
 XML_SetUnknownEncodingHandler(self->itself, (XML_UnknownEncodingHandler) PyUnknownEncodingHandler, NULL);
 #endif
***************
*** 1293,1297 ****
 if (strcmp(name, "returns_unicode") == 0) {
 if (PyObject_IsTrue(v)) {
! #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
 PyErr_SetString(PyExc_ValueError, 
 "Cannot return Unicode strings in Python 1.5");
--- 1297,1301 ----
 if (strcmp(name, "returns_unicode") == 0) {
 if (PyObject_IsTrue(v)) {
! #ifndef Py_USING_UNICODE
 PyErr_SetString(PyExc_ValueError, 
 "Cannot return Unicode strings in Python 1.5");
***************
*** 1546,1551 ****
 }
 #endif
! #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
! #else
 init_template_buffer();
 #endif
--- 1550,1554 ----
 }
 #endif
! #ifdef Py_USING_UNICODE
 init_template_buffer();
 #endif

AltStyle によって変換されたページ (->オリジナル) /