diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Python/formatter_unicode.c | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Python/formatter_unicode.c')
-rw-r--r-- | contrib/tools/python3/src/Python/formatter_unicode.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/contrib/tools/python3/src/Python/formatter_unicode.c b/contrib/tools/python3/src/Python/formatter_unicode.c index 4dbd78aa5c..e7ec4dd5cb 100644 --- a/contrib/tools/python3/src/Python/formatter_unicode.c +++ b/contrib/tools/python3/src/Python/formatter_unicode.c @@ -3,7 +3,7 @@ of int.__float__, etc., that take and return unicode objects */ #include "Python.h" -#include "pycore_fileutils.h" +#include "pycore_fileutils.h" #include <locale.h> /* Raises an exception about an unknown presentation type for this @@ -62,7 +62,7 @@ get_integer(PyObject *str, Py_ssize_t *ppos, Py_ssize_t end, Py_ssize_t accumulator, digitval, pos = *ppos; int numdigits; int kind = PyUnicode_KIND(str); - const void *data = PyUnicode_DATA(str); + const void *data = PyUnicode_DATA(str); accumulator = numdigits = 0; for (; pos < end; pos++, numdigits++) { @@ -170,7 +170,7 @@ parse_internal_render_format_spec(PyObject *format_spec, { Py_ssize_t pos = start; int kind = PyUnicode_KIND(format_spec); - const void *data = PyUnicode_DATA(format_spec); + const void *data = PyUnicode_DATA(format_spec); /* end-pos is used throughout this code to specify the length of the input string */ #define READ_spec(index) PyUnicode_READ(kind, data, index) @@ -252,10 +252,10 @@ parse_internal_render_format_spec(PyObject *format_spec, ++pos; } if (end-pos && READ_spec(pos) == ',') { - if (format->thousands_separators == LT_UNDERSCORE_LOCALE) { - invalid_comma_and_underscore(); - return 0; - } + if (format->thousands_separators == LT_UNDERSCORE_LOCALE) { + invalid_comma_and_underscore(); + return 0; + } } /* Parse field precision */ @@ -402,7 +402,7 @@ typedef struct { char *grouping_buffer; } LocaleInfo; -#define LocaleInfo_STATIC_INIT {0, 0, 0, 0} +#define LocaleInfo_STATIC_INIT {0, 0, 0, 0} /* describes the layout for an integer, see the comment in calc_number_widths() for details */ @@ -445,7 +445,7 @@ parse_number(PyObject *s, Py_ssize_t pos, Py_ssize_t end, { Py_ssize_t remainder; int kind = PyUnicode_KIND(s); - const void *data = PyUnicode_DATA(s); + const void *data = PyUnicode_DATA(s); while (pos<end && Py_ISDIGIT(PyUnicode_READ(kind, data, pos))) ++pos; @@ -468,7 +468,7 @@ parse_number(PyObject *s, Py_ssize_t pos, Py_ssize_t end, Return -1 on error. */ static Py_ssize_t calc_number_widths(NumberFieldWidths *spec, Py_ssize_t n_prefix, - Py_UCS4 sign_char, Py_ssize_t n_start, + Py_UCS4 sign_char, Py_ssize_t n_start, Py_ssize_t n_end, Py_ssize_t n_remainder, int has_decimal, const LocaleInfo *locale, const InternalFormatSpec *format, Py_UCS4 *maxchar) @@ -576,7 +576,7 @@ calc_number_widths(NumberFieldWidths *spec, Py_ssize_t n_prefix, spec->n_lpadding = n_padding; break; default: - /* Shouldn't get here */ + /* Shouldn't get here */ Py_UNREACHABLE(); } } @@ -592,12 +592,12 @@ calc_number_widths(NumberFieldWidths *spec, Py_ssize_t n_prefix, spec->n_remainder + spec->n_rpadding; } -/* Fill in the digit parts of a number's string representation, +/* Fill in the digit parts of a number's string representation, as determined in calc_number_widths(). Return -1 on error, or 0 on success. */ static int fill_number(_PyUnicodeWriter *writer, const NumberFieldWidths *spec, - PyObject *digits, Py_ssize_t d_start, + PyObject *digits, Py_ssize_t d_start, PyObject *prefix, Py_ssize_t p_start, Py_UCS4 fill_char, LocaleInfo *locale, int toupper) @@ -701,17 +701,17 @@ get_locale_info(enum LocaleType type, LocaleInfo *locale_info) { switch (type) { case LT_CURRENT_LOCALE: { - struct lconv *lc = localeconv(); - if (_Py_GetLocaleconvNumeric(lc, - &locale_info->decimal_point, - &locale_info->thousands_sep) < 0) { + struct lconv *lc = localeconv(); + if (_Py_GetLocaleconvNumeric(lc, + &locale_info->decimal_point, + &locale_info->thousands_sep) < 0) { return -1; } /* localeconv() grouping can become a dangling pointer or point to a different string if another thread calls localeconv() during the string formatting. Copy the string to avoid this risk. */ - locale_info->grouping_buffer = _PyMem_Strdup(lc->grouping); + locale_info->grouping_buffer = _PyMem_Strdup(lc->grouping); if (locale_info->grouping_buffer == NULL) { PyErr_NoMemory(); return -1; @@ -773,14 +773,14 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format, /* sign is not allowed on strings */ if (format->sign != '\0') { - if (format->sign == ' ') { - PyErr_SetString(PyExc_ValueError, - "Space not allowed in string format specifier"); - } - else { - PyErr_SetString(PyExc_ValueError, - "Sign not allowed in string format specifier"); - } + if (format->sign == ' ') { + PyErr_SetString(PyExc_ValueError, + "Space not allowed in string format specifier"); + } + else { + PyErr_SetString(PyExc_ValueError, + "Sign not allowed in string format specifier"); + } goto done; } @@ -869,7 +869,7 @@ format_long_internal(PyObject *value, const InternalFormatSpec *format, /* Locale settings, either from the actual locale or from a hard-code pseudo-locale */ - LocaleInfo locale = LocaleInfo_STATIC_INIT; + LocaleInfo locale = LocaleInfo_STATIC_INIT; /* no precision allowed on integers */ if (format->precision != -1) { @@ -991,7 +991,7 @@ format_long_internal(PyObject *value, const InternalFormatSpec *format, goto done; /* Calculate how much memory we'll need. */ - n_total = calc_number_widths(&spec, n_prefix, sign_char, inumeric_chars, + n_total = calc_number_widths(&spec, n_prefix, sign_char, inumeric_chars, inumeric_chars + n_digits, n_remainder, 0, &locale, format, &maxchar); if (n_total == -1) { @@ -1004,7 +1004,7 @@ format_long_internal(PyObject *value, const InternalFormatSpec *format, /* Populate the memory. */ result = fill_number(writer, &spec, - tmp, inumeric_chars, + tmp, inumeric_chars, tmp, prefix, format->fill_char, &locale, format->type == 'X'); @@ -1044,7 +1044,7 @@ format_float_internal(PyObject *value, /* Locale settings, either from the actual locale or from a hard-code pseudo-locale */ - LocaleInfo locale = LocaleInfo_STATIC_INIT; + LocaleInfo locale = LocaleInfo_STATIC_INIT; if (format->precision > INT_MAX) { PyErr_SetString(PyExc_ValueError, "precision too big"); @@ -1139,7 +1139,7 @@ format_float_internal(PyObject *value, goto done; /* Calculate how much memory we'll need. */ - n_total = calc_number_widths(&spec, 0, sign_char, index, + n_total = calc_number_widths(&spec, 0, sign_char, index, index + n_digits, n_remainder, has_decimal, &locale, format, &maxchar); if (n_total == -1) { @@ -1152,7 +1152,7 @@ format_float_internal(PyObject *value, /* Populate the memory. */ result = fill_number(writer, &spec, - unicode_tmp, index, + unicode_tmp, index, NULL, 0, format->fill_char, &locale, 0); @@ -1210,7 +1210,7 @@ format_complex_internal(PyObject *value, /* Locale settings, either from the actual locale or from a hard-code pseudo-locale */ - LocaleInfo locale = LocaleInfo_STATIC_INIT; + LocaleInfo locale = LocaleInfo_STATIC_INIT; if (format->precision > INT_MAX) { PyErr_SetString(PyExc_ValueError, "precision too big"); @@ -1324,7 +1324,7 @@ format_complex_internal(PyObject *value, tmp_format.width = -1; /* Calculate how much memory we'll need. */ - n_re_total = calc_number_widths(&re_spec, 0, re_sign_char, + n_re_total = calc_number_widths(&re_spec, 0, re_sign_char, i_re, i_re + n_re_digits, n_re_remainder, re_has_decimal, &locale, &tmp_format, &maxchar); @@ -1337,7 +1337,7 @@ format_complex_internal(PyObject *value, * requested by the original format. */ if (!skip_re) tmp_format.sign = '+'; - n_im_total = calc_number_widths(&im_spec, 0, im_sign_char, + n_im_total = calc_number_widths(&im_spec, 0, im_sign_char, i_im, i_im + n_im_digits, n_im_remainder, im_has_decimal, &locale, &tmp_format, &maxchar); @@ -1374,7 +1374,7 @@ format_complex_internal(PyObject *value, if (!skip_re) { result = fill_number(writer, &re_spec, - re_unicode_tmp, i_re, + re_unicode_tmp, i_re, NULL, 0, 0, &locale, 0); @@ -1382,7 +1382,7 @@ format_complex_internal(PyObject *value, goto done; } result = fill_number(writer, &im_spec, - im_unicode_tmp, i_im, + im_unicode_tmp, i_im, NULL, 0, 0, &locale, 0); @@ -1455,7 +1455,7 @@ _PyUnicode_FormatAdvancedWriter(_PyUnicodeWriter *writer, return format_string_internal(obj, &format, writer); default: /* unknown */ - unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name); + unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name); return -1; } } @@ -1466,7 +1466,7 @@ _PyLong_FormatAdvancedWriter(_PyUnicodeWriter *writer, PyObject *format_spec, Py_ssize_t start, Py_ssize_t end) { - PyObject *tmp = NULL; + PyObject *tmp = NULL; InternalFormatSpec format; int result = -1; @@ -1513,7 +1513,7 @@ _PyLong_FormatAdvancedWriter(_PyUnicodeWriter *writer, default: /* unknown */ - unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name); + unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name); goto done; } @@ -1556,7 +1556,7 @@ _PyFloat_FormatAdvancedWriter(_PyUnicodeWriter *writer, default: /* unknown */ - unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name); + unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name); return -1; } } @@ -1594,7 +1594,7 @@ _PyComplex_FormatAdvancedWriter(_PyUnicodeWriter *writer, default: /* unknown */ - unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name); + unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name); return -1; } } |