[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Include unicodeobject.h,2.9,2.10

M.-A. Lemburg mal@lemburg.com
Mon, 19 Jun 2000 01:20:27 +0200


Fredrik Lundh wrote:
> 
> mal wrote:
> >
> >   #define Py_UNICODE_MATCH(string, offset, substring)\
> > !     ((*((string)->str + (offset)) == *((substring)->str)) &&\
> > !      !memcmp((string)->str + (offset), (substring)->str,\
> >                (substring)->length*sizeof(Py_UNICODE)))
> >
> 
> I completely forgot that this has different semantics if the
> substring happens to be empty.
> 
> (substrings are null terminated, but "\0" isn't the same
> thing as ""...)
> 
> don't have time to screen unicodeobject.c right now, but
> maybe someone else can do it?  if not, maybe amk's patch
> was a better idea after all...

I've checked the places where this macro is used: all
except the in .count() method showed the same behaviour
as for 8-bit strings.

The Unicode .count() method now also returns the same
value for empty substrings as the 8-bit strings.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/