[ctypes-commit] ctypes/source cfield.c,1.46,1.47 callproc.c,1.106,1.107
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2004-10-12 08:30:27
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv978 Modified Files: cfield.c callproc.c Log Message: More changes for unicode support. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** callproc.c 11 Oct 2004 08:58:28 -0000 1.106 --- callproc.c 12 Oct 2004 08:29:11 -0000 1.107 *************** *** 504,510 **** --- 504,514 ---- if (PyUnicode_Check(obj)) { pa->ffi_type = &ffi_type_pointer; + #ifdef HAVE_USABLE_WCHAR_T pa->value.p = PyUnicode_AS_UNICODE(obj); Py_INCREF(obj); pa->keep = obj; + #else + #error FIXME - create a 'wchar_t *' + #endif return 0; } Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** cfield.c 11 Oct 2004 08:58:28 -0000 1.46 --- cfield.c 12 Oct 2004 08:29:11 -0000 1.47 *************** *** 637,641 **** #ifdef Py_USING_UNICODE ! /* u - a single unicode character */ static PyObject * u_set(void *ptr, PyObject *value, unsigned size) --- 637,641 ---- #ifdef Py_USING_UNICODE ! /* u - a single wchar_t character */ static PyObject * u_set(void *ptr, PyObject *value, unsigned size) *************** *** 698,705 **** /* We need 'result' to be able to count the characters with wcslen, since ptr may not be NUL terminated. If the length is smaller (if ! it was actually NUL terminated, we construct a new one and thorw away the result. */ /* chop off at the first NUL character, if any. */ len = wcslen(PyUnicode_AS_UNICODE(result)); if (len < size) { --- 698,709 ---- /* We need 'result' to be able to count the characters with wcslen, since ptr may not be NUL terminated. If the length is smaller (if ! it was actually NUL terminated, we construct a new one and throw away the result. */ /* chop off at the first NUL character, if any. */ + /* XXX FIXME: But it seems wcslen would access forbidden memory locations + if the original pointer was not zero terminated */ + + /* Anyway, this is very strange code */ len = wcslen(PyUnicode_AS_UNICODE(result)); if (len < size) { *************** *** 739,743 **** --- 743,751 ---- /* copy terminating NUL character */ size += sizeof(wchar_t); + #ifdef HAVE_USABLE_WCHAR_T memcpy((wchar_t *)ptr, PyUnicode_AS_UNICODE(value), size); + #else + #error FIXME: use PyUnicode_FromWideChar() + #endif return value; } *************** *** 862,866 **** --- 870,878 ---- } else Py_INCREF(value); + #ifdef HAVE_USABLE_WCHAR_T *(wchar_t **)ptr = PyUnicode_AS_UNICODE(value); + #else + #error FIXME + #endif return value; } |