Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines
Untabify C files. Will watch buildbots.
........
diff --git a/Objects/stringlib/formatter.h b/Objects/stringlib/formatter.h
index d8e66a6..e9495c9 100644
--- a/Objects/stringlib/formatter.h
+++ b/Objects/stringlib/formatter.h
@@ -132,7 +132,7 @@
*/
static int
parse_internal_render_format_spec(STRINGLIB_CHAR *format_spec,
- Py_ssize_t format_spec_len,
+ Py_ssize_t format_spec_len,
InternalFormatSpec *format,
char default_type)
{
@@ -178,8 +178,8 @@
/* If the next character is #, we're in alternate mode. This only
applies to integers. */
if (end-ptr >= 1 && ptr[0] == '#') {
- format->alternate = 1;
- ++ptr;
+ format->alternate = 1;
+ ++ptr;
}
/* The special case for 0-padding (backwards compat) */
@@ -259,8 +259,8 @@
and more efficient enough to justify a little obfuscation? */
static void
calc_number_widths(NumberFieldWidths *spec, STRINGLIB_CHAR actual_sign,
- Py_ssize_t n_prefix, Py_ssize_t n_digits,
- const InternalFormatSpec *format)
+ Py_ssize_t n_prefix, Py_ssize_t n_digits,
+ const InternalFormatSpec *format)
{
spec->n_lpadding = 0;
spec->n_prefix = 0;
@@ -327,7 +327,7 @@
else {
/* see if any padding is needed */
if (spec->n_lsign + n_digits + spec->n_rsign +
- spec->n_prefix >= format->width) {
+ spec->n_prefix >= format->width) {
/* no padding needed, we're already bigger than the
requested width */
}
@@ -335,8 +335,8 @@
/* determine which of left, space, or right padding is
needed */
Py_ssize_t padding = format->width -
- (spec->n_lsign + spec->n_prefix +
- n_digits + spec->n_rsign);
+ (spec->n_lsign + spec->n_prefix +
+ n_digits + spec->n_rsign);
if (format->align == '<')
spec->n_rpadding = padding;
else if (format->align == '>')
@@ -352,7 +352,7 @@
}
}
spec->n_total = spec->n_lpadding + spec->n_lsign + spec->n_prefix +
- spec->n_spadding + n_digits + spec->n_rsign + spec->n_rpadding;
+ spec->n_spadding + n_digits + spec->n_rsign + spec->n_rpadding;
}
/* fill in the non-digit parts of a numbers's string representation,
@@ -360,8 +360,8 @@
where the digits go. */
static STRINGLIB_CHAR *
fill_non_digits(STRINGLIB_CHAR *p_buf, const NumberFieldWidths *spec,
- STRINGLIB_CHAR *prefix, Py_ssize_t n_digits,
- STRINGLIB_CHAR fill_char)
+ STRINGLIB_CHAR *prefix, Py_ssize_t n_digits,
+ STRINGLIB_CHAR fill_char)
{
STRINGLIB_CHAR *p_digits;
@@ -373,10 +373,10 @@
*p_buf++ = spec->lsign;
}
if (spec->n_prefix) {
- memmove(p_buf,
- prefix,
- spec->n_prefix * sizeof(STRINGLIB_CHAR));
- p_buf += spec->n_prefix;
+ memmove(p_buf,
+ prefix,
+ spec->n_prefix * sizeof(STRINGLIB_CHAR));
+ p_buf += spec->n_prefix;
}
if (spec->n_spadding) {
STRINGLIB_FILL(p_buf, fill_char, spec->n_spadding);
@@ -420,7 +420,7 @@
if (format->alternate) {
PyErr_SetString(PyExc_ValueError,
"Alternate form (#) not allowed in string format "
- "specifier");
+ "specifier");
goto done;
}
@@ -504,7 +504,7 @@
static PyObject *
format_int_or_long_internal(PyObject *value, const InternalFormatSpec *format,
- IntOrLongToString tostring)
+ IntOrLongToString tostring)
{
PyObject *result = NULL;
PyObject *tmp = NULL;
@@ -516,8 +516,8 @@
string */
Py_ssize_t n_leading_chars;
Py_ssize_t n_grouping_chars = 0; /* Count of additional chars to
- allocate, used for 'n'
- formatting. */
+ allocate, used for 'n'
+ formatting. */
Py_ssize_t n_prefix = 0; /* Count of prefix chars, (e.g., '0x') */
STRINGLIB_CHAR *prefix = NULL;
NumberFieldWidths spec;
@@ -562,31 +562,31 @@
goto done;
}
#endif
- numeric_char = (STRINGLIB_CHAR)x;
- pnumeric_chars = &numeric_char;
+ numeric_char = (STRINGLIB_CHAR)x;
+ pnumeric_chars = &numeric_char;
n_digits = 1;
}
else {
int base;
- int leading_chars_to_skip = 0; /* Number of characters added by
- PyNumber_ToBase that we want to
- skip over. */
+ int leading_chars_to_skip = 0; /* Number of characters added by
+ PyNumber_ToBase that we want to
+ skip over. */
/* Compute the base and how many characters will be added by
PyNumber_ToBase */
switch (format->type) {
case 'b':
base = 2;
- leading_chars_to_skip = 2; /* 0b */
+ leading_chars_to_skip = 2; /* 0b */
break;
case 'o':
base = 8;
- leading_chars_to_skip = 2; /* 0o */
+ leading_chars_to_skip = 2; /* 0o */
break;
case 'x':
case 'X':
base = 16;
- leading_chars_to_skip = 2; /* 0x */
+ leading_chars_to_skip = 2; /* 0x */
break;
default: /* shouldn't be needed, but stops a compiler warning */
case 'd':
@@ -595,52 +595,52 @@
break;
}
- /* The number of prefix chars is the same as the leading
- chars to skip */
- if (format->alternate)
- n_prefix = leading_chars_to_skip;
+ /* The number of prefix chars is the same as the leading
+ chars to skip */
+ if (format->alternate)
+ n_prefix = leading_chars_to_skip;
/* Do the hard part, converting to a string in a given base */
- tmp = tostring(value, base);
+ tmp = tostring(value, base);
if (tmp == NULL)
goto done;
- pnumeric_chars = STRINGLIB_STR(tmp);
+ pnumeric_chars = STRINGLIB_STR(tmp);
n_digits = STRINGLIB_LEN(tmp);
- prefix = pnumeric_chars;
+ prefix = pnumeric_chars;
- /* Remember not to modify what pnumeric_chars points to. it
- might be interned. Only modify it after we copy it into a
- newly allocated output buffer. */
+ /* Remember not to modify what pnumeric_chars points to. it
+ might be interned. Only modify it after we copy it into a
+ newly allocated output buffer. */
/* Is a sign character present in the output? If so, remember it
and skip it */
sign = pnumeric_chars[0];
if (sign == '-') {
- ++prefix;
- ++leading_chars_to_skip;
+ ++prefix;
+ ++leading_chars_to_skip;
}
- /* Skip over the leading chars (0x, 0b, etc.) */
- n_digits -= leading_chars_to_skip;
- pnumeric_chars += leading_chars_to_skip;
+ /* Skip over the leading chars (0x, 0b, etc.) */
+ n_digits -= leading_chars_to_skip;
+ pnumeric_chars += leading_chars_to_skip;
}
if (format->type == 'n')
- /* Compute how many additional chars we need to allocate
- to hold the thousands grouping. */
- STRINGLIB_GROUPING(NULL, n_digits, n_digits,
- 0, &n_grouping_chars, 0);
+ /* Compute how many additional chars we need to allocate
+ to hold the thousands grouping. */
+ STRINGLIB_GROUPING(NULL, n_digits, n_digits,
+ 0, &n_grouping_chars, 0);
/* Calculate the widths of the various leading and trailing parts */
calc_number_widths(&spec, sign, n_prefix, n_digits + n_grouping_chars,
- format);
+ format);
/* Allocate a new string to hold the result */
result = STRINGLIB_NEW(NULL, spec.n_total);
if (!result)
- goto done;
+ goto done;
p = STRINGLIB_STR(result);
/* XXX There is too much magic here regarding the internals of
@@ -651,44 +651,44 @@
/* Fill in the digit parts */
n_leading_chars = spec.n_lpadding + spec.n_lsign +
- spec.n_prefix + spec.n_spadding;
+ spec.n_prefix + spec.n_spadding;
memmove(p + n_leading_chars,
- pnumeric_chars,
- n_digits * sizeof(STRINGLIB_CHAR));
+ pnumeric_chars,
+ n_digits * sizeof(STRINGLIB_CHAR));
/* If type is 'X', convert the filled in digits to uppercase */
if (format->type == 'X') {
- Py_ssize_t t;
- for (t = 0; t < n_digits; ++t)
- p[t + n_leading_chars] = STRINGLIB_TOUPPER(p[t + n_leading_chars]);
+ Py_ssize_t t;
+ for (t = 0; t < n_digits; ++t)
+ p[t + n_leading_chars] = STRINGLIB_TOUPPER(p[t + n_leading_chars]);
}
/* Insert the grouping, if any, after the uppercasing of the digits, so
we can ensure that grouping chars won't be affected. */
if (n_grouping_chars) {
- /* We know this can't fail, since we've already
- reserved enough space. */
- STRINGLIB_CHAR *pstart = p + n_leading_chars;
+ /* We know this can't fail, since we've already
+ reserved enough space. */
+ STRINGLIB_CHAR *pstart = p + n_leading_chars;
#ifndef NDEBUG
- int r =
+ int r =
#endif
- STRINGLIB_GROUPING(pstart, n_digits, n_digits,
- spec.n_total+n_grouping_chars-n_leading_chars,
- NULL, 0);
- assert(r);
+ STRINGLIB_GROUPING(pstart, n_digits, n_digits,
+ spec.n_total+n_grouping_chars-n_leading_chars,
+ NULL, 0);
+ assert(r);
}
/* Fill in the non-digit parts (padding, sign, etc.) */
fill_non_digits(p, &spec, prefix, n_digits + n_grouping_chars,
- format->fill_char == '\0' ? ' ' : format->fill_char);
+ format->fill_char == '\0' ? ' ' : format->fill_char);
/* If type is 'X', uppercase the prefix. This has to be done after the
prefix is filled in by fill_non_digits */
if (format->type == 'X') {
- Py_ssize_t t;
- for (t = 0; t < n_prefix; ++t)
- p[t + spec.n_lpadding + spec.n_lsign] =
- STRINGLIB_TOUPPER(p[t + spec.n_lpadding + spec.n_lsign]);
+ Py_ssize_t t;
+ for (t = 0; t < n_prefix; ++t)
+ p[t + spec.n_lpadding + spec.n_lsign] =
+ STRINGLIB_TOUPPER(p[t + spec.n_lpadding + spec.n_lsign]);
}
@@ -723,7 +723,7 @@
/* much of this is taken from unicodeobject.c */
static PyObject *
format_float_internal(PyObject *value,
- const InternalFormatSpec *format)
+ const InternalFormatSpec *format)
{
/* fmt = '%.' + `prec` + `type` + '%%'
worst case length = 2 + 10 (len of INT_MAX) + 1 + 2 = 15 (use 20)*/
@@ -765,7 +765,7 @@
if (format->alternate) {
PyErr_SetString(PyExc_ValueError,
"Alternate form (#) not allowed in float format "
- "specifier");
+ "specifier");
goto done;
}
@@ -796,7 +796,7 @@
8-bit char. this is safe, because we've restricted what "type"
can be */
PyOS_snprintf(fmt, sizeof(fmt), "%%.%" PY_FORMAT_SIZE_T "d%c", precision,
- (char)type);
+ (char)type);
/* do the actual formatting */
PyOS_ascii_formatd(charbuf, sizeof(charbuf), fmt, x);
@@ -838,11 +838,11 @@
/* Fill in the non-digit parts (padding, sign, etc.) */
fill_non_digits(STRINGLIB_STR(result), &spec, NULL, n_digits,
- format->fill_char == '\0' ? ' ' : format->fill_char);
+ format->fill_char == '\0' ? ' ' : format->fill_char);
/* fill in the digit parts */
memmove(STRINGLIB_STR(result) +
- (spec.n_lpadding + spec.n_lsign + spec.n_spadding),
+ (spec.n_lpadding + spec.n_lsign + spec.n_spadding),
p,
n_digits * sizeof(STRINGLIB_CHAR));
@@ -856,8 +856,8 @@
/************************************************************************/
PyObject *
FORMAT_STRING(PyObject *obj,
- STRINGLIB_CHAR *format_spec,
- Py_ssize_t format_spec_len)
+ STRINGLIB_CHAR *format_spec,
+ Py_ssize_t format_spec_len)
{
InternalFormatSpec format;
PyObject *result = NULL;
@@ -871,7 +871,7 @@
/* parse the format_spec */
if (!parse_internal_render_format_spec(format_spec, format_spec_len,
- &format, 's'))
+ &format, 's'))
goto done;
/* type conversion? */
@@ -893,9 +893,9 @@
#if defined FORMAT_LONG || defined FORMAT_INT
static PyObject*
format_int_or_long(PyObject* obj,
- STRINGLIB_CHAR *format_spec,
- Py_ssize_t format_spec_len,
- IntOrLongToString tostring)
+ STRINGLIB_CHAR *format_spec,
+ Py_ssize_t format_spec_len,
+ IntOrLongToString tostring)
{
PyObject *result = NULL;
PyObject *tmp = NULL;
@@ -910,8 +910,8 @@
/* parse the format_spec */
if (!parse_internal_render_format_spec(format_spec,
- format_spec_len,
- &format, 'd'))
+ format_spec_len,
+ &format, 'd'))
goto done;
/* type conversion? */
@@ -924,8 +924,8 @@
case 'X':
case 'n':
/* no type conversion needed, already an int (or long). do
- the formatting */
- result = format_int_or_long_internal(obj, &format, tostring);
+ the formatting */
+ result = format_int_or_long_internal(obj, &format, tostring);
break;
case 'e':
@@ -974,11 +974,11 @@
PyObject *
FORMAT_LONG(PyObject *obj,
- STRINGLIB_CHAR *format_spec,
- Py_ssize_t format_spec_len)
+ STRINGLIB_CHAR *format_spec,
+ Py_ssize_t format_spec_len)
{
return format_int_or_long(obj, format_spec, format_spec_len,
- long_format);
+ long_format);
}
#endif /* FORMAT_LONG */
@@ -995,19 +995,19 @@
PyObject *
FORMAT_INT(PyObject *obj,
- STRINGLIB_CHAR *format_spec,
- Py_ssize_t format_spec_len)
+ STRINGLIB_CHAR *format_spec,
+ Py_ssize_t format_spec_len)
{
return format_int_or_long(obj, format_spec, format_spec_len,
- int_format);
+ int_format);
}
#endif /* FORMAT_INT */
#ifdef FORMAT_FLOAT
PyObject *
FORMAT_FLOAT(PyObject *obj,
- STRINGLIB_CHAR *format_spec,
- Py_ssize_t format_spec_len)
+ STRINGLIB_CHAR *format_spec,
+ Py_ssize_t format_spec_len)
{
PyObject *result = NULL;
InternalFormatSpec format;
@@ -1021,17 +1021,17 @@
/* parse the format_spec */
if (!parse_internal_render_format_spec(format_spec,
- format_spec_len,
- &format, '\0'))
+ format_spec_len,
+ &format, '\0'))
goto done;
/* type conversion? */
switch (format.type) {
case '\0':
- /* 'Z' means like 'g', but with at least one decimal. See
- PyOS_ascii_formatd */
- format.type = 'Z';
- /* Deliberate fall through to the next case statement */
+ /* 'Z' means like 'g', but with at least one decimal. See
+ PyOS_ascii_formatd */
+ format.type = 'Z';
+ /* Deliberate fall through to the next case statement */
case 'e':
case 'E':
case 'f':
diff --git a/Objects/stringlib/localeutil.h b/Objects/stringlib/localeutil.h
index 1105609..9730c67 100644
--- a/Objects/stringlib/localeutil.h
+++ b/Objects/stringlib/localeutil.h
@@ -34,97 +34,97 @@
**/
int
_Py_InsertThousandsGrouping(STRINGLIB_CHAR *buffer,
- Py_ssize_t n_buffer,
- Py_ssize_t n_digits,
- Py_ssize_t buf_size,
- Py_ssize_t *count,
- int append_zero_char)
+ Py_ssize_t n_buffer,
+ Py_ssize_t n_digits,
+ Py_ssize_t buf_size,
+ Py_ssize_t *count,
+ int append_zero_char)
{
- struct lconv *locale_data = localeconv();
- const char *grouping = locale_data->grouping;
- const char *thousands_sep = locale_data->thousands_sep;
- Py_ssize_t thousands_sep_len = strlen(thousands_sep);
- STRINGLIB_CHAR *pend = NULL; /* current end of buffer */
- STRINGLIB_CHAR *pmax = NULL; /* max of buffer */
- char current_grouping;
- Py_ssize_t remaining = n_digits; /* Number of chars remaining to
- be looked at */
+ struct lconv *locale_data = localeconv();
+ const char *grouping = locale_data->grouping;
+ const char *thousands_sep = locale_data->thousands_sep;
+ Py_ssize_t thousands_sep_len = strlen(thousands_sep);
+ STRINGLIB_CHAR *pend = NULL; /* current end of buffer */
+ STRINGLIB_CHAR *pmax = NULL; /* max of buffer */
+ char current_grouping;
+ Py_ssize_t remaining = n_digits; /* Number of chars remaining to
+ be looked at */
- /* Initialize the character count, if we're just counting. */
- if (count)
- *count = 0;
- else {
- /* We're not just counting, we're modifying buffer */
- pend = buffer + n_buffer;
- pmax = buffer + buf_size;
- }
+ /* Initialize the character count, if we're just counting. */
+ if (count)
+ *count = 0;
+ else {
+ /* We're not just counting, we're modifying buffer */
+ pend = buffer + n_buffer;
+ pmax = buffer + buf_size;
+ }
- /* Starting at the end and working right-to-left, keep track of
- what grouping needs to be added and insert that. */
- current_grouping = *grouping++;
+ /* Starting at the end and working right-to-left, keep track of
+ what grouping needs to be added and insert that. */
+ current_grouping = *grouping++;
- /* If the first character is 0, perform no grouping at all. */
- if (current_grouping == 0)
- return 1;
+ /* If the first character is 0, perform no grouping at all. */
+ if (current_grouping == 0)
+ return 1;
- while (remaining > current_grouping) {
- /* Always leave buffer and pend valid at the end of this
- loop, since we might leave with a return statement. */
+ while (remaining > current_grouping) {
+ /* Always leave buffer and pend valid at the end of this
+ loop, since we might leave with a return statement. */
- remaining -= current_grouping;
- if (count) {
- /* We're only counting, not touching the memory. */
- *count += thousands_sep_len;
- }
- else {
- /* Do the formatting. */
+ remaining -= current_grouping;
+ if (count) {
+ /* We're only counting, not touching the memory. */
+ *count += thousands_sep_len;
+ }
+ else {
+ /* Do the formatting. */
- STRINGLIB_CHAR *plast = buffer + remaining;
+ STRINGLIB_CHAR *plast = buffer + remaining;
- /* Is there room to insert thousands_sep_len chars? */
- if (pmax - pend < thousands_sep_len)
- /* No room. */
- return 0;
+ /* Is there room to insert thousands_sep_len chars? */
+ if (pmax - pend < thousands_sep_len)
+ /* No room. */
+ return 0;
- /* Move the rest of the string down. */
- memmove(plast + thousands_sep_len,
- plast,
- (pend - plast) * sizeof(STRINGLIB_CHAR));
- /* Copy the thousands_sep chars into the buffer. */
+ /* Move the rest of the string down. */
+ memmove(plast + thousands_sep_len,
+ plast,
+ (pend - plast) * sizeof(STRINGLIB_CHAR));
+ /* Copy the thousands_sep chars into the buffer. */
#if STRINGLIB_IS_UNICODE
- /* Convert from the char's of the thousands_sep from
- the locale into unicode. */
- {
- Py_ssize_t i;
- for (i = 0; i < thousands_sep_len; ++i)
- plast[i] = thousands_sep[i];
- }
+ /* Convert from the char's of the thousands_sep from
+ the locale into unicode. */
+ {
+ Py_ssize_t i;
+ for (i = 0; i < thousands_sep_len; ++i)
+ plast[i] = thousands_sep[i];
+ }
#else
- /* No conversion, just memcpy the thousands_sep. */
- memcpy(plast, thousands_sep, thousands_sep_len);
+ /* No conversion, just memcpy the thousands_sep. */
+ memcpy(plast, thousands_sep, thousands_sep_len);
#endif
- }
+ }
- /* Adjust end pointer. */
- pend += thousands_sep_len;
+ /* Adjust end pointer. */
+ pend += thousands_sep_len;
- /* Move to the next grouping character, unless we're
- repeating (which is designated by a grouping of 0). */
- if (*grouping != 0) {
- current_grouping = *grouping++;
- if (current_grouping == CHAR_MAX)
- /* We're done. */
- break;
- }
- }
- if (append_zero_char) {
- /* Append a zero character to mark the end of the string,
- if there's room. */
- if (pend - (buffer + remaining) < 1)
- /* No room, error. */
- return 0;
- *pend = 0;
- }
- return 1;
+ /* Move to the next grouping character, unless we're
+ repeating (which is designated by a grouping of 0). */
+ if (*grouping != 0) {
+ current_grouping = *grouping++;
+ if (current_grouping == CHAR_MAX)
+ /* We're done. */
+ break;
+ }
+ }
+ if (append_zero_char) {
+ /* Append a zero character to mark the end of the string,
+ if there's room. */
+ if (pend - (buffer + remaining) < 1)
+ /* No room, error. */
+ return 0;
+ *pend = 0;
+ }
+ return 1;
}
#endif /* STRINGLIB_LOCALEUTIL_H */
diff --git a/Objects/stringlib/partition.h b/Objects/stringlib/partition.h
index 105ba31..20c7507 100644
--- a/Objects/stringlib/partition.h
+++ b/Objects/stringlib/partition.h
@@ -18,23 +18,23 @@
if (sep_len == 0) {
PyErr_SetString(PyExc_ValueError, "empty separator");
- return NULL;
+ return NULL;
}
out = PyTuple_New(3);
if (!out)
- return NULL;
+ return NULL;
pos = fastsearch(str, str_len, sep, sep_len, FAST_SEARCH);
if (pos < 0) {
- Py_INCREF(str_obj);
- PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj);
- Py_INCREF(STRINGLIB_EMPTY);
- PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
- Py_INCREF(STRINGLIB_EMPTY);
- PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY);
- return out;
+ Py_INCREF(str_obj);
+ PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj);
+ Py_INCREF(STRINGLIB_EMPTY);
+ PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
+ Py_INCREF(STRINGLIB_EMPTY);
+ PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY);
+ return out;
}
PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos));
@@ -44,8 +44,8 @@
PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos));
if (PyErr_Occurred()) {
- Py_DECREF(out);
- return NULL;
+ Py_DECREF(out);
+ return NULL;
}
return out;
@@ -62,29 +62,29 @@
if (sep_len == 0) {
PyErr_SetString(PyExc_ValueError, "empty separator");
- return NULL;
+ return NULL;
}
out = PyTuple_New(3);
if (!out)
- return NULL;
+ return NULL;
/* XXX - create reversefastsearch helper! */
pos = -1;
- for (j = str_len - sep_len; j >= 0; --j)
+ for (j = str_len - sep_len; j >= 0; --j)
if (STRINGLIB_CMP(str+j, sep, sep_len) == 0) {
pos = j;
break;
}
if (pos < 0) {
- Py_INCREF(STRINGLIB_EMPTY);
- PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY);
- Py_INCREF(STRINGLIB_EMPTY);
- PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
- Py_INCREF(str_obj);
- PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj);
- return out;
+ Py_INCREF(STRINGLIB_EMPTY);
+ PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY);
+ Py_INCREF(STRINGLIB_EMPTY);
+ PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
+ Py_INCREF(str_obj);
+ PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj);
+ return out;
}
PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos));
@@ -94,8 +94,8 @@
PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos));
if (PyErr_Occurred()) {
- Py_DECREF(out);
- return NULL;
+ Py_DECREF(out);
+ return NULL;
}
return out;
diff --git a/Objects/stringlib/string_format.h b/Objects/stringlib/string_format.h
index 6c531e8..42ead89 100644
--- a/Objects/stringlib/string_format.h
+++ b/Objects/stringlib/string_format.h
@@ -487,15 +487,15 @@
PyObject *format_spec_object = NULL;
PyObject *(*formatter)(PyObject *, STRINGLIB_CHAR *, Py_ssize_t) = NULL;
STRINGLIB_CHAR* format_spec_start = format_spec->ptr ?
- format_spec->ptr : NULL;
+ format_spec->ptr : NULL;
Py_ssize_t format_spec_len = format_spec->ptr ?
- format_spec->end - format_spec->ptr : 0;
+ format_spec->end - format_spec->ptr : 0;
/* If we know the type exactly, skip the lookup of __format__ and just
call the formatter directly. */
#if STRINGLIB_IS_UNICODE
if (PyUnicode_CheckExact(fieldobj))
- formatter = _PyUnicode_FormatAdvanced;
+ formatter = _PyUnicode_FormatAdvanced;
/* Unfortunately, there's a problem with checking for int, long,
and float here. If we're being included as unicode, their
formatters expect string format_spec args. For now, just skip
@@ -503,29 +503,29 @@
hassle. */
#else
if (PyString_CheckExact(fieldobj))
- formatter = _PyBytes_FormatAdvanced;
+ formatter = _PyBytes_FormatAdvanced;
else if (PyInt_CheckExact(fieldobj))
- formatter =_PyInt_FormatAdvanced;
+ formatter =_PyInt_FormatAdvanced;
else if (PyLong_CheckExact(fieldobj))
- formatter =_PyLong_FormatAdvanced;
+ formatter =_PyLong_FormatAdvanced;
else if (PyFloat_CheckExact(fieldobj))
- formatter = _PyFloat_FormatAdvanced;
+ formatter = _PyFloat_FormatAdvanced;
#endif
if (formatter) {
- /* we know exactly which formatter will be called when __format__ is
- looked up, so call it directly, instead. */
- result = formatter(fieldobj, format_spec_start, format_spec_len);
+ /* we know exactly which formatter will be called when __format__ is
+ looked up, so call it directly, instead. */
+ result = formatter(fieldobj, format_spec_start, format_spec_len);
}
else {
- /* We need to create an object out of the pointers we have, because
- __format__ takes a string/unicode object for format_spec. */
- format_spec_object = STRINGLIB_NEW(format_spec_start,
- format_spec_len);
- if (format_spec_object == NULL)
- goto done;
+ /* We need to create an object out of the pointers we have, because
+ __format__ takes a string/unicode object for format_spec. */
+ format_spec_object = STRINGLIB_NEW(format_spec_start,
+ format_spec_len);
+ if (format_spec_object == NULL)
+ goto done;
- result = PyObject_Format(fieldobj, format_spec_object);
+ result = PyObject_Format(fieldobj, format_spec_object);
}
if (result == NULL)
goto done;
@@ -538,11 +538,11 @@
/* Convert result to our type. We could be str, and result could
be unicode */
{
- PyObject *tmp = STRINGLIB_TOSTR(result);
- if (tmp == NULL)
- goto done;
- Py_DECREF(result);
- result = tmp;
+ PyObject *tmp = STRINGLIB_TOSTR(result);
+ if (tmp == NULL)
+ goto done;
+ Py_DECREF(result);
+ result = tmp;
}
#endif
@@ -777,17 +777,17 @@
case 's':
return STRINGLIB_TOSTR(obj);
default:
- if (conversion > 32 && conversion < 127) {
- /* It's the ASCII subrange; casting to char is safe
- (assuming the execution character set is an ASCII
- superset). */
- PyErr_Format(PyExc_ValueError,
+ if (conversion > 32 && conversion < 127) {
+ /* It's the ASCII subrange; casting to char is safe
+ (assuming the execution character set is an ASCII
+ superset). */
+ PyErr_Format(PyExc_ValueError,
"Unknown conversion specifier %c",
(char)conversion);
- } else
- PyErr_Format(PyExc_ValueError,
- "Unknown conversion specifier \\x%x",
- (unsigned int)conversion);
+ } else
+ PyErr_Format(PyExc_ValueError,
+ "Unknown conversion specifier \\x%x",
+ (unsigned int)conversion);
return NULL;
}
}
@@ -1041,7 +1041,7 @@
Py_INCREF(conversion_str);
}
else
- conversion_str = STRINGLIB_NEW(&conversion, 1);
+ conversion_str = STRINGLIB_NEW(&conversion, 1);
if (conversion_str == NULL)
goto done;
@@ -1057,39 +1057,39 @@
}
static PyMethodDef formatteriter_methods[] = {
- {NULL, NULL} /* sentinel */
+ {NULL, NULL} /* sentinel */
};
static PyTypeObject PyFormatterIter_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "formatteriterator", /* tp_name */
- sizeof(formatteriterobject), /* tp_basicsize */
- 0, /* tp_itemsize */
+ "formatteriterator", /* tp_name */
+ sizeof(formatteriterobject), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)formatteriter_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- 0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- PyObject_SelfIter, /* tp_iter */
- (iternextfunc)formatteriter_next, /* tp_iternext */
- formatteriter_methods, /* tp_methods */
+ (destructor)formatteriter_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ PyObject_SelfIter, /* tp_iter */
+ (iternextfunc)formatteriter_next, /* tp_iternext */
+ formatteriter_methods, /* tp_methods */
0,
};
@@ -1190,39 +1190,39 @@
}
static PyMethodDef fieldnameiter_methods[] = {
- {NULL, NULL} /* sentinel */
+ {NULL, NULL} /* sentinel */
};
static PyTypeObject PyFieldNameIter_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "fieldnameiterator", /* tp_name */
- sizeof(fieldnameiterobject), /* tp_basicsize */
- 0, /* tp_itemsize */
+ "fieldnameiterator", /* tp_name */
+ sizeof(fieldnameiterobject), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)fieldnameiter_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- 0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- PyObject_SelfIter, /* tp_iter */
- (iternextfunc)fieldnameiter_next, /* tp_iternext */
- fieldnameiter_methods, /* tp_methods */
+ (destructor)fieldnameiter_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ PyObject_SelfIter, /* tp_iter */
+ (iternextfunc)fieldnameiter_next, /* tp_iternext */
+ fieldnameiter_methods, /* tp_methods */
0};
/* unicode_formatter_field_name_split is used to implement
diff --git a/Objects/stringlib/transmogrify.h b/Objects/stringlib/transmogrify.h
index 7dc8177..4390e22 100644
--- a/Objects/stringlib/transmogrify.h
+++ b/Objects/stringlib/transmogrify.h
@@ -25,10 +25,10 @@
size_t i, j;
PyObject *u;
int tabsize = 8;
-
+
if (!PyArg_ParseTuple(args, "|i:expandtabs", &tabsize))
return NULL;
-
+
/* First pass: determine size of output string */
i = j = 0;
e = STRINGLIB_STR(self) + STRINGLIB_LEN(self);
@@ -55,20 +55,20 @@
}
}
}
-
+
if ((i + j) > PY_SSIZE_T_MAX) {
PyErr_SetString(PyExc_OverflowError, "result is too long");
return NULL;
}
-
+
/* Second pass: create output string and fill it */
u = STRINGLIB_NEW(NULL, i + j);
if (!u)
return NULL;
-
+
j = 0;
q = STRINGLIB_STR(u);
-
+
for (p = STRINGLIB_STR(self); p < e; p++)
if (*p == '\t') {
if (tabsize > 0) {
@@ -84,7 +84,7 @@
if (*p == '\n' || *p == '\r')
j = 0;
}
-
+
return u;
}
@@ -110,16 +110,16 @@
}
u = STRINGLIB_NEW(NULL,
- left + STRINGLIB_LEN(self) + right);
+ left + STRINGLIB_LEN(self) + right);
if (u) {
if (left)
memset(STRINGLIB_STR(u), fill, left);
Py_MEMCPY(STRINGLIB_STR(u) + left,
- STRINGLIB_STR(self),
- STRINGLIB_LEN(self));
+ STRINGLIB_STR(self),
+ STRINGLIB_LEN(self));
if (right)
memset(STRINGLIB_STR(u) + left + STRINGLIB_LEN(self),
- fill, right);
+ fill, right);
}
return u;
@@ -271,17 +271,17 @@
}
-#define _STRINGLIB_SPLIT_APPEND(data, left, right) \
- str = STRINGLIB_NEW((data) + (left), \
- (right) - (left)); \
- if (str == NULL) \
- goto onError; \
- if (PyList_Append(list, str)) { \
- Py_DECREF(str); \
- goto onError; \
- } \
- else \
- Py_DECREF(str);
+#define _STRINGLIB_SPLIT_APPEND(data, left, right) \
+ str = STRINGLIB_NEW((data) + (left), \
+ (right) - (left)); \
+ if (str == NULL) \
+ goto onError; \
+ if (PyList_Append(list, str)) { \
+ Py_DECREF(str); \
+ goto onError; \
+ } \
+ else \
+ Py_DECREF(str);
PyDoc_STRVAR(splitlines__doc__,
"B.splitlines([keepends]) -> list of lines\n\
@@ -320,28 +320,28 @@
goto onError;
for (i = j = 0; i < len; ) {
- Py_ssize_t eol;
+ Py_ssize_t eol;
- /* Find a line and append it */
- while (i < len && data[i] != '\n' && data[i] != '\r')
- i++;
+ /* Find a line and append it */
+ while (i < len && data[i] != '\n' && data[i] != '\r')
+ i++;
- /* Skip the line break reading CRLF as one line break */
- eol = i;
- if (i < len) {
- if (data[i] == '\r' && i + 1 < len &&
- data[i+1] == '\n')
- i += 2;
- else
- i++;
- if (keepends)
- eol = i;
- }
- _STRINGLIB_SPLIT_APPEND(data, j, eol);
- j = i;
+ /* Skip the line break reading CRLF as one line break */
+ eol = i;
+ if (i < len) {
+ if (data[i] == '\r' && i + 1 < len &&
+ data[i+1] == '\n')
+ i += 2;
+ else
+ i++;
+ if (keepends)
+ eol = i;
+ }
+ _STRINGLIB_SPLIT_APPEND(data, j, eol);
+ j = i;
}
if (j < len) {
- _STRINGLIB_SPLIT_APPEND(data, j, len);
+ _STRINGLIB_SPLIT_APPEND(data, j, len);
}
return list;