[Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.63,2.64

Guido van Rossum python-dev@python.org
Fri, 5 May 2000 16:44:27 -0400 (EDT)


Update of /projects/cvsroot/python/dist/src/Objects
In directory eric:/projects/python/develop/guido/src/Objects

Modified Files:
	stringobject.c 
Log Message:
The methods islower(), isupper(), isspace(), isdigit() and istitle()
gave bogus results for chars in the range 128-255, because their
implementation was using signed characters.  Fixed this by using
unsigned character pointers (as opposed to using Py_CHARMASK()).


Index: stringobject.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.63
retrieving revision 2.64
diff -C2 -r2.63 -r2.64
*** stringobject.c	2000/05/03 23:44:35	2.63
--- stringobject.c	2000/05/05 20:44:24	2.64
***************
*** 1911,1916 ****
  string_isspace(PyStringObject *self, PyObject *args)
  {
!     register const char *p = PyString_AS_STRING(self);
!     register const char *e;
  
      if (!PyArg_NoArgs(args))
--- 1911,1916 ----
  string_isspace(PyStringObject *self, PyObject *args)
  {
!     register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
!     register const unsigned char *e;
  
      if (!PyArg_NoArgs(args))
***************
*** 1940,1945 ****
  string_isdigit(PyStringObject *self, PyObject *args)
  {
!     register const char *p = PyString_AS_STRING(self);
!     register const char *e;
  
      if (!PyArg_NoArgs(args))
--- 1940,1945 ----
  string_isdigit(PyStringObject *self, PyObject *args)
  {
!     register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
!     register const unsigned char *e;
  
      if (!PyArg_NoArgs(args))
***************
*** 1969,1974 ****
  string_islower(PyStringObject *self, PyObject *args)
  {
!     register const char *p = PyString_AS_STRING(self);
!     register const char *e;
      int cased;
  
--- 1969,1974 ----
  string_islower(PyStringObject *self, PyObject *args)
  {
!     register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
!     register const unsigned char *e;
      int cased;
  
***************
*** 2001,2006 ****
  string_isupper(PyStringObject *self, PyObject *args)
  {
!     register const char *p = PyString_AS_STRING(self);
!     register const char *e;
      int cased;
  
--- 2001,2006 ----
  string_isupper(PyStringObject *self, PyObject *args)
  {
!     register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
!     register const unsigned char *e;
      int cased;
  
***************
*** 2034,2039 ****
  string_istitle(PyStringObject *self, PyObject *args)
  {
!     register const char *p = PyString_AS_STRING(self);
!     register const char *e;
      int cased, previous_is_cased;
  
--- 2034,2039 ----
  string_istitle(PyStringObject *self, PyObject *args)
  {
!     register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
!     register const unsigned char *e;
      int cased, previous_is_cased;
  
***************
*** 2049,2053 ****
      previous_is_cased = 0;
      for (; p < e; p++) {
! 	register const char ch = *p;
  
  	if (isupper(ch)) {
--- 2049,2053 ----
      previous_is_cased = 0;
      for (; p < e; p++) {
! 	register const unsigned char ch = *p;
  
  	if (isupper(ch)) {