[Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.78,2.79
M.-A. Lemburg
lemburg@users.sourceforge.net
Mon, 29 Jan 2001 03:14:18 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv11671/Objects
Modified Files:
unicodeobject.c
Log Message:
Fixed .capitalize() method of Unicode objects to work like the
corresponding string method. Added tests for this too.
Patch written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.78
retrieving revision 2.79
diff -C2 -r2.78 -r2.79
*** unicodeobject.c 2001/01/24 17:19:08 2.78
--- unicodeobject.c 2001/01/29 11:14:16 2.79
***************
*** 2632,2640 ****
int fixcapitalize(PyUnicodeObject *self)
{
! if (self->length > 0 && Py_UNICODE_ISLOWER(self->str[0])) {
! self->str[0] = Py_UNICODE_TOUPPER(self->str[0]);
! return 1;
}
! return 0;
}
--- 2632,2654 ----
int fixcapitalize(PyUnicodeObject *self)
{
! int len = self->length;
! Py_UNICODE *s = self->str;
! int status = 0;
!
! if (len == 0)
! return 0;
! if (Py_UNICODE_ISLOWER(*s)) {
! *s = Py_UNICODE_TOUPPER(*s);
! status = 1;
}
! s++;
! while (--len > 0) {
! if (Py_UNICODE_ISUPPER(*s)) {
! *s = Py_UNICODE_TOLOWER(*s);
! status = 1;
! }
! s++;
! }
! return status;
}