Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 37596:1b078493d538 legacy-trunk
More low-hanging fruit. Still need to re-arrange some code (or find a better
solution) in the same way as listobject.c got changed. Hoping for a better
solution.
| author | Anthony Baxter <anthonybaxter@gmail.com> |
|---|---|
| date | Tue, 11 Apr 2006 07:42:36 +0000 |
| parents | 7cd3bf2399e6 |
| children | b1724e926e07 |
line wrap: on
line diff
--- a/Objects/stringobject.c Tue Apr 11 07:23:05 2006 +0000 +++ b/Objects/stringobject.c Tue Apr 11 07:42:36 2006 +0000 @@ -1051,7 +1051,7 @@ lastchar = sub[shortsub]; last = s + PyString_GET_SIZE(a) - len_sub + 1; while (s < last) { - s = memchr(s, firstchar, last-s); + s = (char *)memchr(s, firstchar, last-s); if (s == NULL) return 0; assert(s < last); @@ -1210,7 +1210,7 @@ } else { source_buf = PyString_AsString((PyObject*)self); - result_buf = PyMem_Malloc(slicelength); + result_buf = (char *)PyMem_Malloc(slicelength); if (result_buf == NULL) return PyErr_NoMemory(); @@ -2028,12 +2028,12 @@ { char *s = PyString_AS_STRING(self), *s_new; Py_ssize_t i, n = PyString_GET_SIZE(self); - PyObject *new; - - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) + PyObject *newobj; + + newobj = PyString_FromStringAndSize(NULL, n); + if (newobj == NULL) return NULL; - s_new = PyString_AsString(new); + s_new = PyString_AsString(newobj); for (i = 0; i < n; i++) { int c = Py_CHARMASK(*s++); if (isupper(c)) { @@ -2042,7 +2042,7 @@ *s_new = c; s_new++; } - return new; + return newobj; } @@ -2056,12 +2056,12 @@ { char *s = PyString_AS_STRING(self), *s_new; Py_ssize_t i, n = PyString_GET_SIZE(self); - PyObject *new; - - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) + PyObject *newobj; + + newobj = PyString_FromStringAndSize(NULL, n); + if (newobj == NULL) return NULL; - s_new = PyString_AsString(new); + s_new = PyString_AsString(newobj); for (i = 0; i < n; i++) { int c = Py_CHARMASK(*s++); if (islower(c)) { @@ -2070,7 +2070,7 @@ *s_new = c; s_new++; } - return new; + return newobj; } @@ -2086,12 +2086,12 @@ char *s = PyString_AS_STRING(self), *s_new; Py_ssize_t i, n = PyString_GET_SIZE(self); int previous_is_cased = 0; - PyObject *new; - - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) + PyObject *newobj; + + newobj = PyString_FromStringAndSize(NULL, n); + if (newobj == NULL) return NULL; - s_new = PyString_AsString(new); + s_new = PyString_AsString(newobj); for (i = 0; i < n; i++) { int c = Py_CHARMASK(*s++); if (islower(c)) { @@ -2106,7 +2106,7 @@ previous_is_cased = 0; *s_new++ = c; } - return new; + return newobj; } PyDoc_STRVAR(capitalize__doc__, @@ -2120,12 +2120,12 @@ { char *s = PyString_AS_STRING(self), *s_new; Py_ssize_t i, n = PyString_GET_SIZE(self); - PyObject *new; - - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) + PyObject *newobj; + + newobj = PyString_FromStringAndSize(NULL, n); + if (newobj == NULL) return NULL; - s_new = PyString_AsString(new); + s_new = PyString_AsString(newobj); if (0 < n) { int c = Py_CHARMASK(*s++); if (islower(c)) @@ -2142,7 +2142,7 @@ *s_new = c; s_new++; } - return new; + return newobj; } @@ -2199,7 +2199,7 @@ } if (i >= m) break; - t = memchr(s+i, sub[0], m-i); + t = (const char *)memchr(s+i, sub[0], m-i); if (t == NULL) break; i = t - s; @@ -2218,12 +2218,12 @@ { char *s = PyString_AS_STRING(self), *s_new; Py_ssize_t i, n = PyString_GET_SIZE(self); - PyObject *new; - - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) + PyObject *newobj; + + newobj = PyString_FromStringAndSize(NULL, n); + if (newobj == NULL) return NULL; - s_new = PyString_AsString(new); + s_new = PyString_AsString(newobj); for (i = 0; i < n; i++) { int c = Py_CHARMASK(*s++); if (islower(c)) { @@ -2236,7 +2236,7 @@ *s_new = c; s_new++; } - return new; + return newobj; } @@ -2524,7 +2524,7 @@ const Py_ssize_t len = PyString_GET_SIZE(self); Py_ssize_t sub_len, repl_len, out_len; int count = -1; - PyObject *new; + PyObject *newobj; PyObject *subobj, *replobj; if (!PyArg_ParseTuple(args, "OO|i:replace", @@ -2563,20 +2563,20 @@ if (out_len == -1) { if (PyString_CheckExact(self)) { /* we're returning another reference to self */ - new = (PyObject*)self; - Py_INCREF(new); + newobj = (PyObject*)self; + Py_INCREF(newobj); } else { - new = PyString_FromStringAndSize(str, len); - if (new == NULL) + newobj = PyString_FromStringAndSize(str, len); + if (newobj == NULL) return NULL; } } else { - new = PyString_FromStringAndSize(new_s, out_len); + newobj = PyString_FromStringAndSize(new_s, out_len); PyMem_FREE(new_s); } - return new; + return newobj; }
