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

Guido van Rossum guido@cnri.reston.va.us
Tue, 7 Mar 2000 10:53:46 -0500 (EST)


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

Modified Files:
	stringobject.c 
Log Message:
Patch by Moshe Zadka: move the string special case from abstract.c
here.

[Patch modified by GvR to keep the original exception.]



Index: stringobject.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.56
retrieving revision 2.57
diff -C2 -r2.56 -r2.57
*** stringobject.c	2000/03/06 14:52:18	2.56
--- stringobject.c	2000/03/07 15:53:43	2.57
***************
*** 382,385 ****
--- 382,406 ----
  }
  
+ static int
+ string_contains(a, el)
+ PyObject *a, *el;
+ {
+ 	register char *s, *end;
+ 	register char c;
+ 	if (!PyString_Check(el) || PyString_Size(el) != 1) {
+ 		PyErr_SetString(PyExc_TypeError,
+ 				"string member test needs char left operand");
+ 		return -1;
+ 	}
+ 	c = PyString_AsString(el)[0];
+ 	s = PyString_AsString(a);
+ 	end = s + PyString_Size(a);
+ 	while (s < end) {
+ 		if (c == *s++)
+ 			return 1;
+ 	}
+ 	return 0;
+ }
+ 
  static PyObject *
  string_item(a, i)
***************
*** 517,520 ****
--- 538,542 ----
  	0,		/*sq_ass_item*/
  	0,		/*sq_ass_slice*/
+ 	(objobjproc)string_contains /*sq_contains*/
  };