Remove 'const' from local variable declaration in string_zfill() -- it

isn't constant, so why bother.

Folded long lines.

Whitespace normalization.
This commit is contained in:
Guido van Rossum 2002-04-15 13:48:52 +00:00
parent 068325ef92
commit 3aa3fc46c8
1 changed files with 79 additions and 70 deletions

View File

@ -1,4 +1,3 @@
/* String object implementation */
#include "Python.h"
@ -25,21 +24,22 @@ static PyStringObject *nullstring;
string containing exactly `size' bytes.
For PyString_FromStringAndSize(), the parameter the parameter `str' is
either NULL or else points to a string containing at least `size' bytes. For
PyString_FromStringAndSize(), the string in the `str' parameter does not
have to be null-terminated. (Therefore it is safe to construct a substring
by calling `PyString_FromStringAndSize(origstring, substrlen)'.) If `str'
is NULL then PyString_FromStringAndSize() will allocate `size+1' bytes
(setting the last byte to the null terminating character) and you can fill in
the data yourself. If `str' is non-NULL then the resulting PyString object
must be treated as immutable and you must not fill in nor alter the data
yourself, since the strings may be shared.
either NULL or else points to a string containing at least `size' bytes.
For PyString_FromStringAndSize(), the string in the `str' parameter does
not have to be null-terminated. (Therefore it is safe to construct a
substring by calling `PyString_FromStringAndSize(origstring, substrlen)'.)
If `str' is NULL then PyString_FromStringAndSize() will allocate `size+1'
bytes (setting the last byte to the null terminating character) and you can
fill in the data yourself. If `str' is non-NULL then the resulting
PyString object must be treated as immutable and you must not fill in nor
alter the data yourself, since the strings may be shared.
The PyObject member `op->ob_size', which denotes the number of "extra items"
in a variable-size object, will contain the number of bytes allocated for
string data, not counting the null terminating character. It is therefore
equal to the equal to the `size' parameter (for PyString_FromStringAndSize())
or the length of the string in the `str' parameter (for PyString_FromString()).
The PyObject member `op->ob_size', which denotes the number of "extra
items" in a variable-size object, will contain the number of bytes
allocated for string data, not counting the null terminating character. It
is therefore equal to the equal to the `size' parameter (for
PyString_FromStringAndSize()) or the length of the string in the `str'
parameter (for PyString_FromString()).
*/
PyObject *
PyString_FromStringAndSize(const char *str, int size)
@ -586,7 +586,8 @@ string_print(PyStringObject *op, FILE *fp, int flags)
/* figure out which quote to use; single is preferred */
quote = '\'';
if (memchr(op->ob_sval, '\'', op->ob_size) && !memchr(op->ob_sval, '"', op->ob_size))
if (memchr(op->ob_sval, '\'', op->ob_size) &&
!memchr(op->ob_sval, '"', op->ob_size))
quote = '"';
fputc(quote, fp);
@ -630,7 +631,8 @@ string_repr(register PyStringObject *op)
/* figure out which quote to use; single is preferred */
quote = '\'';
if (memchr(op->ob_sval, '\'', op->ob_size) && !memchr(op->ob_sval, '"', op->ob_size))
if (memchr(op->ob_sval, '\'', op->ob_size) &&
!memchr(op->ob_sval, '"', op->ob_size))
quote = '"';
p = PyString_AS_STRING(v);
@ -2392,7 +2394,7 @@ string_zfill(PyStringObject *self, PyObject *args)
{
int fill;
PyObject *s;
const char *p;
char *p;
int width;
if (!PyArg_ParseTuple(args, "i:zfill", &width))
@ -2749,9 +2751,11 @@ string_methods[] = {
{"istitle", (PyCFunction)string_istitle, METH_NOARGS, istitle__doc__},
{"isalpha", (PyCFunction)string_isalpha, METH_NOARGS, isalpha__doc__},
{"isalnum", (PyCFunction)string_isalnum, METH_NOARGS, isalnum__doc__},
{"capitalize", (PyCFunction)string_capitalize, METH_NOARGS, capitalize__doc__},
{"capitalize", (PyCFunction)string_capitalize, METH_NOARGS,
capitalize__doc__},
{"count", (PyCFunction)string_count, METH_VARARGS, count__doc__},
{"endswith", (PyCFunction)string_endswith, METH_VARARGS, endswith__doc__},
{"endswith", (PyCFunction)string_endswith, METH_VARARGS,
endswith__doc__},
{"find", (PyCFunction)string_find, METH_VARARGS, find__doc__},
{"index", (PyCFunction)string_index, METH_VARARGS, index__doc__},
{"lstrip", (PyCFunction)string_lstrip, METH_VARARGS, lstrip__doc__},
@ -2759,10 +2763,13 @@ string_methods[] = {
{"rfind", (PyCFunction)string_rfind, METH_VARARGS, rfind__doc__},
{"rindex", (PyCFunction)string_rindex, METH_VARARGS, rindex__doc__},
{"rstrip", (PyCFunction)string_rstrip, METH_VARARGS, rstrip__doc__},
{"startswith", (PyCFunction)string_startswith, METH_VARARGS, startswith__doc__},
{"startswith", (PyCFunction)string_startswith, METH_VARARGS,
startswith__doc__},
{"strip", (PyCFunction)string_strip, METH_VARARGS, strip__doc__},
{"swapcase", (PyCFunction)string_swapcase, METH_NOARGS, swapcase__doc__},
{"translate", (PyCFunction)string_translate, METH_VARARGS, translate__doc__},
{"swapcase", (PyCFunction)string_swapcase, METH_NOARGS,
swapcase__doc__},
{"translate", (PyCFunction)string_translate, METH_VARARGS,
translate__doc__},
{"title", (PyCFunction)string_title, METH_NOARGS, title__doc__},
{"ljust", (PyCFunction)string_ljust, METH_VARARGS, ljust__doc__},
{"rjust", (PyCFunction)string_rjust, METH_VARARGS, rjust__doc__},
@ -2770,11 +2777,10 @@ string_methods[] = {
{"zfill", (PyCFunction)string_zfill, METH_VARARGS, zfill__doc__},
{"encode", (PyCFunction)string_encode, METH_VARARGS, encode__doc__},
{"decode", (PyCFunction)string_decode, METH_VARARGS, decode__doc__},
{"expandtabs", (PyCFunction)string_expandtabs, METH_VARARGS, expandtabs__doc__},
{"splitlines", (PyCFunction)string_splitlines, METH_VARARGS, splitlines__doc__},
#if 0
{"zfill", (PyCFunction)string_zfill, METH_VARARGS, zfill__doc__},
#endif
{"expandtabs", (PyCFunction)string_expandtabs, METH_VARARGS,
expandtabs__doc__},
{"splitlines", (PyCFunction)string_splitlines, METH_VARARGS,
splitlines__doc__},
{NULL, NULL} /* sentinel */
};
@ -3280,7 +3286,8 @@ PyString_Format(PyObject *format, PyObject *args)
char *pbuf;
int sign;
int len;
char formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */
char formatbuf[FORMATBUFLEN];
/* For format{float,int,char}() */
#ifdef Py_USING_UNICODE
char *fmt_start = fmt;
int argidx_start = argidx;
@ -3478,7 +3485,8 @@ PyString_Format(PyObject *format, PyObject *args)
}
else {
pbuf = formatbuf;
len = formatint(pbuf, sizeof(formatbuf),
len = formatint(pbuf,
sizeof(formatbuf),
flags, prec, c, v);
if (len < 0)
goto error;
@ -3494,7 +3502,8 @@ PyString_Format(PyObject *format, PyObject *args)
case 'g':
case 'G':
pbuf = formatbuf;
len = formatfloat(pbuf, sizeof(formatbuf), flags, prec, c, v);
len = formatfloat(pbuf, sizeof(formatbuf),
flags, prec, c, v);
if (len < 0)
goto error;
sign = 1;