[Python-checkins] CVS: python/dist/src/Modules stropmodule.c,2.78,2.79
Tim Peters
tim_one@users.sourceforge.net
2001年5月09日 17:32:59 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv29092/python/dist/src/Modules
Modified Files:
stropmodule.c
Log Message:
Heh. I need a break. After this: stropmodule & stringobject were more
out of synch than I realized, and I managed to break replace's "count"
argument when it was 0. All is well again. Maybe.
Bugfix candidate.
Index: stropmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/stropmodule.c,v
retrieving revision 2.78
retrieving revision 2.79
diff -C2 -r2.78 -r2.79
*** stropmodule.c 2001年05月10日 00:05:33 2.78
--- stropmodule.c 2001年05月10日 00:32:57 2.79
***************
*** 1059,1064 ****
/* find length of output string */
nfound = mymemcnt(str, len, pat, pat_len);
! if (count > 0)
! nfound = nfound > count ? count : nfound;
if (nfound == 0)
goto return_same;
--- 1059,1066 ----
/* find length of output string */
nfound = mymemcnt(str, len, pat, pat_len);
! if (count < 0)
! count = INT_MAX;
! else if (nfound > count)
! nfound = count;
if (nfound == 0)
goto return_same;
***************
*** 1068,1072 ****
/* Have to allocate something for the caller to free(). */
out_s = (char *)PyMem_MALLOC(1);
! if (out_s = NULL)
return NULL;
out_s[0] = '0円';
--- 1070,1074 ----
/* Have to allocate something for the caller to free(). */
out_s = (char *)PyMem_MALLOC(1);
! if (out_s == NULL)
return NULL;
out_s[0] = '0円';
***************
*** 1079,1083 ****
out_s = new_s;
! while (len > 0) {
/* find index of next instance of pattern */
offset = mymemfind(str, len, pat, pat_len);
--- 1081,1085 ----
out_s = new_s;
! for (; count > 0 && len > 0; --count) {
/* find index of next instance of pattern */
offset = mymemfind(str, len, pat, pat_len);
***************
*** 1094,1101 ****
memcpy(new_s, sub, sub_len);
new_s += sub_len;
-
- /* note count==0 is effectively infinity */
- if (--count == 0)
- break;
}
/* copy any remaining values into output string */
--- 1096,1099 ----