[Python-checkins] CVS: python/dist/src/Python modsupport.c,2.41,2.42

Fred Drake python-dev@python.org
2000年4月28日 10:42:41 -0400


Update of /projects/cvsroot/python/dist/src/Python
In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Python
Modified Files:
	modsupport.c 
Log Message:
Brian Hooper <brian_takashi@hotmail.com>:
Here's a patch which changes modsupport to add 'u' and 'u#',
to support building Unicode objects from a null-terminated
Py_UNICODE *, and a Py_UNICODE * with length, respectively.
[Conversion from 'U' to 'u' by Fred, based on python-dev comments.]
Note that the use of None for NULL values of the Py_UNICODE* value is
still in; I'm not sure of the conclusion on that issue.
Index: modsupport.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/modsupport.c,v
retrieving revision 2.41
retrieving revision 2.42
diff -C2 -r2.41 -r2.42
*** modsupport.c	1999年01月25日 21:48:56	2.41
--- modsupport.c	2000年04月28日 14:42:37	2.42
***************
*** 233,236 ****
--- 233,245 ----
 }
 
+ static int
+ _ustrlen(Py_UNICODE *u)
+ {
+ 	int i = 0;
+ 	Py_UNICODE *v = u;
+ 	while (*v != 0) { i++; v++; } 
+ 	return i;
+ }
+ 
 static PyObject *
 do_mktuple(p_format, p_va, endchar, n)
***************
*** 296,300 ****
 			return PyLong_FromLongLong((LONG_LONG)va_arg(*p_va, LONG_LONG));
 #endif
! 
 		case 'f':
 		case 'd':
--- 305,330 ----
 			return PyLong_FromLongLong((LONG_LONG)va_arg(*p_va, LONG_LONG));
 #endif
! 		case 'u':
! 		{
! 			PyObject *v;
! 			Py_UNICODE *u = va_arg(*p_va, Py_UNICODE *);
! 			int n;
! 			if (**p_format == '#') {
! 				++*p_format;
! 				n = va_arg(*p_va, int);
! 			}
! 			else
! 				n = -1;
! 			if (u == NULL) {
! 				v = Py_None;
! 				Py_INCREF(v);
! 			}
! 			else {
! 				if (n < 0)
! 					n = _ustrlen(u);
! 				v = PyUnicode_FromUnicode(u, n);
! 			}
! 			return v;
! 		}
 		case 'f':
 		case 'd':

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