future these routines may try to do even more sharing of objects.
*/
PyObject *
-PyString_FromStringAndSize(str, size)
- const char *str;
- int size;
+PyString_FromStringAndSize(const char *str, int size)
{
register PyStringObject *op;
#ifndef DONT_SHARE_SHORT_STRINGS
}
PyObject *
-PyString_FromString(str)
- const char *str;
+PyString_FromString(const char *str)
{
register size_t size = strlen(str);
register PyStringObject *op;
}
static void
-string_dealloc(op)
- PyObject *op;
+string_dealloc(PyObject *op)
{
PyObject_DEL(op);
}
int
-PyString_Size(op)
- register PyObject *op;
+PyString_Size(register PyObject *op)
{
if (!PyString_Check(op)) {
PyErr_BadInternalCall();
}
/*const*/ char *
-PyString_AsString(op)
- register PyObject *op;
+PyString_AsString(register PyObject *op)
{
if (!PyString_Check(op)) {
PyErr_BadInternalCall();
/* Methods */
static int
-string_print(op, fp, flags)
- PyStringObject *op;
- FILE *fp;
- int flags;
+string_print(PyStringObject *op, FILE *fp, int flags)
{
int i;
char c;
}
static PyObject *
-string_repr(op)
- register PyStringObject *op;
+string_repr(register PyStringObject *op)
{
size_t newsize = 2 + 4 * op->ob_size * sizeof(char);
PyObject *v;
}
static int
-string_length(a)
- PyStringObject *a;
+string_length(PyStringObject *a)
{
return a->ob_size;
}
static PyObject *
-string_concat(a, bb)
- register PyStringObject *a;
- register PyObject *bb;
+string_concat(register PyStringObject *a, register PyObject *bb)
{
register unsigned int size;
register PyStringObject *op;
}
static PyObject *
-string_repeat(a, n)
- register PyStringObject *a;
- register int n;
+string_repeat(register PyStringObject *a, register int n)
{
register int i;
register int size;
/* String slice a[i:j] consists of characters a[i] ... a[j-1] */
static PyObject *
-string_slice(a, i, j)
- register PyStringObject *a;
- register int i, j; /* May be negative! */
+string_slice(register PyStringObject *a, register int i, register int j)
+ /* j -- may be negative! */
{
if (i < 0)
i = 0;
}
static int
-string_contains(a, el)
-PyObject *a, *el;
+string_contains(PyObject *a, PyObject *el)
{
register char *s, *end;
register char c;
}
static PyObject *
-string_item(a, i)
- PyStringObject *a;
- register int i;
+string_item(PyStringObject *a, register int i)
{
int c;
PyObject *v;
}
static int
-string_compare(a, b)
- PyStringObject *a, *b;
+string_compare(PyStringObject *a, PyStringObject *b)
{
int len_a = a->ob_size, len_b = b->ob_size;
int min_len = (len_a < len_b) ? len_a : len_b;
}
static long
-string_hash(a)
- PyStringObject *a;
+string_hash(PyStringObject *a)
{
register int len;
register unsigned char *p;
}
static int
-string_buffer_getreadbuf(self, index, ptr)
- PyStringObject *self;
- int index;
- const void **ptr;
+string_buffer_getreadbuf(PyStringObject *self, int index, const void **ptr)
{
if ( index != 0 ) {
PyErr_SetString(PyExc_SystemError,
}
static int
-string_buffer_getwritebuf(self, index, ptr)
- PyStringObject *self;
- int index;
- const void **ptr;
+string_buffer_getwritebuf(PyStringObject *self, int index, const void **ptr)
{
PyErr_SetString(PyExc_TypeError,
"Cannot use string as modifiable buffer");
}
static int
-string_buffer_getsegcount(self, lenp)
- PyStringObject *self;
- int *lenp;
+string_buffer_getsegcount(PyStringObject *self, int *lenp)
{
if ( lenp )
*lenp = self->ob_size;
}
static int
-string_buffer_getcharbuf(self, index, ptr)
- PyStringObject *self;
- int index;
- const char **ptr;
+string_buffer_getcharbuf(PyStringObject *self, int index, const char **ptr)
{
if ( index != 0 ) {
PyErr_SetString(PyExc_SystemError,
static PyObject *
-split_whitespace(s, len, maxsplit)
- char *s;
- int len;
- int maxsplit;
+split_whitespace(char *s, int len, int maxsplit)
{
int i, j, err;
PyObject* item;
is a separator.";
static PyObject *
-string_split(self, args)
- PyStringObject *self;
- PyObject *args;
+string_split(PyStringObject *self, PyObject *args)
{
int len = PyString_GET_SIZE(self), n, i, j, err;
int maxsplit = -1;
sequence. The separator between elements is S.";
static PyObject *
-string_join(self, args)
- PyStringObject *self;
- PyObject *args;
+string_join(PyStringObject *self, PyObject *args)
{
char *sep = PyString_AS_STRING(self);
int seplen = PyString_GET_SIZE(self);
static long
-string_find_internal(self, args, dir)
- PyStringObject *self;
- PyObject *args;
- int dir;
+string_find_internal(PyStringObject *self, PyObject *args, int dir)
{
const char *s = PyString_AS_STRING(self), *sub;
int len = PyString_GET_SIZE(self);
Return -1 on failure.";
static PyObject *
-string_find(self, args)
- PyStringObject *self;
- PyObject *args;
+string_find(PyStringObject *self, PyObject *args)
{
long result = string_find_internal(self, args, +1);
if (result == -2)
Like S.find() but raise ValueError when the substring is not found.";
static PyObject *
-string_index(self, args)
- PyStringObject *self;
- PyObject *args;
+string_index(PyStringObject *self, PyObject *args)
{
long result = string_find_internal(self, args, +1);
if (result == -2)
Return -1 on failure.";
static PyObject *
-string_rfind(self, args)
- PyStringObject *self;
- PyObject *args;
+string_rfind(PyStringObject *self, PyObject *args)
{
long result = string_find_internal(self, args, -1);
if (result == -2)
Like S.rfind() but raise ValueError when the substring is not found.";
static PyObject *
-string_rindex(self, args)
- PyStringObject *self;
- PyObject *args;
+string_rindex(PyStringObject *self, PyObject *args)
{
long result = string_find_internal(self, args, -1);
if (result == -2)
static PyObject *
-do_strip(self, args, striptype)
- PyStringObject *self;
- PyObject *args;
- int striptype;
+do_strip(PyStringObject *self, PyObject *args, int striptype)
{
char *s = PyString_AS_STRING(self);
int len = PyString_GET_SIZE(self), i, j;
whitespace removed.";
static PyObject *
-string_strip(self, args)
- PyStringObject *self;
- PyObject *args;
+string_strip(PyStringObject *self, PyObject *args)
{
return do_strip(self, args, BOTHSTRIP);
}
Return a copy of the string S with leading whitespace removed.";
static PyObject *
-string_lstrip(self, args)
- PyStringObject *self;
- PyObject *args;
+string_lstrip(PyStringObject *self, PyObject *args)
{
return do_strip(self, args, LEFTSTRIP);
}
Return a copy of the string S with trailing whitespace removed.";
static PyObject *
-string_rstrip(self, args)
- PyStringObject *self;
- PyObject *args;
+string_rstrip(PyStringObject *self, PyObject *args)
{
return do_strip(self, args, RIGHTSTRIP);
}
Return a copy of the string S converted to lowercase.";
static PyObject *
-string_lower(self, args)
- PyStringObject *self;
- PyObject *args;
+string_lower(PyStringObject *self, PyObject *args)
{
char *s = PyString_AS_STRING(self), *s_new;
int i, n = PyString_GET_SIZE(self);
Return a copy of the string S converted to uppercase.";
static PyObject *
-string_upper(self, args)
- PyStringObject *self;
- PyObject *args;
+string_upper(PyStringObject *self, PyObject *args)
{
char *s = PyString_AS_STRING(self), *s_new;
int i, n = PyString_GET_SIZE(self);
capitalized.";
static PyObject *
-string_capitalize(self, args)
- PyStringObject *self;
- PyObject *args;
+string_capitalize(PyStringObject *self, PyObject *args)
{
char *s = PyString_AS_STRING(self), *s_new;
int i, n = PyString_GET_SIZE(self);
interpreted as in slice notation.";
static PyObject *
-string_count(self, args)
- PyStringObject *self;
- PyObject *args;
+string_count(PyStringObject *self, PyObject *args)
{
const char *s = PyString_AS_STRING(self), *sub;
int len = PyString_GET_SIZE(self), n;
converted to lowercase and vice versa.";
static PyObject *
-string_swapcase(self, args)
- PyStringObject *self;
- PyObject *args;
+string_swapcase(PyStringObject *self, PyObject *args)
{
char *s = PyString_AS_STRING(self), *s_new;
int i, n = PyString_GET_SIZE(self);
translation table, which must be a string of length 256.";
static PyObject *
-string_translate(self, args)
- PyStringObject *self;
- PyObject *args;
+string_translate(PyStringObject *self, PyObject *args)
{
register char *input, *output;
register const char *table;
MEM, the function returns -1.
*/
static int
-mymemfind(mem, len, pat, pat_len)
- char *mem;
- int len;
- char *pat;
- int pat_len;
+mymemfind(char *mem, int len, char *pat, int pat_len)
{
register int ii;
mem=11111 and pat==11 also return 2.
*/
static int
-mymemcnt(mem, len, pat, pat_len)
- char *mem;
- int len;
- char *pat;
- int pat_len;
+mymemcnt(char *mem, int len, char *pat, int pat_len)
{
register int offset = 0;
int nfound = 0;
NULL if an error occurred.
*/
static char *
-mymemreplace(str, len, pat, pat_len, sub, sub_len, count, out_len)
- char *str;
- int len; /* input string */
- char *pat;
- int pat_len; /* pattern string to find */
- char *sub;
- int sub_len; /* substitution string */
- int count; /* number of replacements */
- int *out_len;
-
+mymemreplace(char *str, int len, /* input string */
+ char *pat, int pat_len, /* pattern string to find */
+ char *sub, int sub_len, /* substitution string */
+ int count, /* number of replacements */
+ int *out_len)
{
char *out_s;
char *new_s;
given, only the first maxsplit occurrences are replaced.";
static PyObject *
-string_replace(self, args)
- PyStringObject *self;
- PyObject *args;
+string_replace(PyStringObject *self, PyObject *args)
{
const char *str = PyString_AS_STRING(self), *sub, *repl;
char *new_s;
comparing S at that position.";
static PyObject *
-string_startswith(self, args)
- PyStringObject *self;
- PyObject *args;
+string_startswith(PyStringObject *self, PyObject *args)
{
const char* str = PyString_AS_STRING(self);
int len = PyString_GET_SIZE(self);
comparing S at that position.";
static PyObject *
-string_endswith(self, args)
- PyStringObject *self;
- PyObject *args;
+string_endswith(PyStringObject *self, PyObject *args)
{
const char* str = PyString_AS_STRING(self);
int len = PyString_GET_SIZE(self);
static PyObject*
string_isspace(PyStringObject *self, PyObject *args)
{
- register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
+ register const unsigned char *p
+ = (unsigned char *) PyString_AS_STRING(self);
register const unsigned char *e;
if (!PyArg_NoArgs(args))
static PyObject*
string_isalpha(PyUnicodeObject *self, PyObject *args)
{
- register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
+ register const unsigned char *p
+ = (unsigned char *) PyString_AS_STRING(self);
register const unsigned char *e;
if (!PyArg_NoArgs(args))
static PyObject*
string_isalnum(PyUnicodeObject *self, PyObject *args)
{
- register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
+ register const unsigned char *p
+ = (unsigned char *) PyString_AS_STRING(self);
register const unsigned char *e;
if (!PyArg_NoArgs(args))
static PyObject*
string_isdigit(PyStringObject *self, PyObject *args)
{
- register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
+ register const unsigned char *p
+ = (unsigned char *) PyString_AS_STRING(self);
register const unsigned char *e;
if (!PyArg_NoArgs(args))
static PyObject*
string_islower(PyStringObject *self, PyObject *args)
{
- register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
+ register const unsigned char *p
+ = (unsigned char *) PyString_AS_STRING(self);
register const unsigned char *e;
int cased;
static PyObject*
string_isupper(PyStringObject *self, PyObject *args)
{
- register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
+ register const unsigned char *p
+ = (unsigned char *) PyString_AS_STRING(self);
register const unsigned char *e;
int cased;
static PyObject*
string_istitle(PyStringObject *self, PyObject *args)
{
- register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self);
+ register const unsigned char *p
+ = (unsigned char *) PyString_AS_STRING(self);
register const unsigned char *e;
int cased, previous_is_cased;
};
static PyObject *
-string_getattr(s, name)
- PyStringObject *s;
- char *name;
+string_getattr(PyStringObject *s, char *name)
{
return Py_FindMethod(string_methods, (PyObject*)s, name);
}
};
void
-PyString_Concat(pv, w)
- register PyObject **pv;
- register PyObject *w;
+PyString_Concat(register PyObject **pv, register PyObject *w)
{
register PyObject *v;
if (*pv == NULL)
}
void
-PyString_ConcatAndDel(pv, w)
- register PyObject **pv;
- register PyObject *w;
+PyString_ConcatAndDel(register PyObject **pv, register PyObject *w)
{
PyString_Concat(pv, w);
Py_XDECREF(w);
already be known to some other part of the code... */
int
-_PyString_Resize(pv, newsize)
- PyObject **pv;
- int newsize;
+_PyString_Resize(PyObject **pv, int newsize)
{
register PyObject *v;
register PyStringObject *sv;
/* Helpers for formatstring */
static PyObject *
-getnextarg(args, arglen, p_argidx)
- PyObject *args;
- int arglen;
- int *p_argidx;
+getnextarg(PyObject *args, int arglen, int *p_argidx)
{
int argidx = *p_argidx;
if (argidx < arglen) {
#define F_ZERO (1<<4)
static int
-formatfloat(buf, buflen, flags, prec, type, v)
- char *buf;
- size_t buflen;
- int flags;
- int prec;
- int type;
- PyObject *v;
+formatfloat(char *buf, size_t buflen, int flags,
+ int prec, int type, PyObject *v)
{
/* fmt = '%#.' + `prec` + `type`
worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/
}
static int
-formatint(buf, buflen, flags, prec, type, v)
- char *buf;
- size_t buflen;
- int flags;
- int prec;
- int type;
- PyObject *v;
+formatint(char *buf, size_t buflen, int flags,
+ int prec, int type, PyObject *v)
{
/* fmt = '%#.' + `prec` + 'l' + `type`
worst case length = 3 + 10 (len of INT_MAX) + 1 + 1 = 15 (use 20)*/
}
static int
-formatchar(buf, buflen, v)
- char *buf;
- size_t buflen;
- PyObject *v;
+formatchar(char *buf, size_t buflen, PyObject *v)
{
/* presume that the buffer is at least 2 characters long */
if (PyString_Check(v)) {
#define FORMATBUFLEN (size_t)120
PyObject *
-PyString_Format(format, args)
- PyObject *format;
- PyObject *args;
+PyString_Format(PyObject *format, PyObject *args)
{
char *fmt, *res;
int fmtcnt, rescnt, reslen, arglen, argidx;
static PyObject *interned;
void
-PyString_InternInPlace(p)
- PyObject **p;
+PyString_InternInPlace(PyObject **p)
{
register PyStringObject *s = (PyStringObject *)(*p);
PyObject *t;
PyObject *
-PyString_InternFromString(cp)
- const char *cp;
+PyString_InternFromString(const char *cp)
{
PyObject *s = PyString_FromString(cp);
if (s == NULL)
#endif
void
-PyString_Fini()
+PyString_Fini(void)
{
int i;
for (i = 0; i < UCHAR_MAX + 1; i++) {