Lines Matching refs:format
20 "Unknown format code '%c' "
26 "Unknown format code '\\x%x' "
81 "Too many decimal digits in format string");
93 /*********** standard format specifier parsing **************************/
144 fills in format with the parsed information.
152 InternalFormatSpec *format,
167 format->fill_char = ' ';
168 format->align = default_align;
169 format->alternate = 0;
170 format->no_neg_0 = 0;
171 format->sign = '\0';
172 format->width = -1;
173 format->thousands_separators = LT_NO_LOCALE;
174 format->precision = -1;
175 format->type = default_type;
180 format->align = READ_spec(pos+1);
181 format->fill_char = READ_spec(pos);
187 format->align = READ_spec(pos);
194 format->sign = READ_spec(pos);
201 format->no_neg_0 = 1;
208 format->alternate = 1;
214 format->fill_char = '0';
216 format->align = '=';
221 consumed = get_integer(format_spec, &pos, end, &format->width);
231 format->width = -1;
235 format->thousands_separators = LT_DEFAULT_LOCALE;
240 if (format->thousands_separators != LT_NO_LOCALE) {
244 format->thousands_separators = LT_UNDERSCORE_LOCALE;
248 if (format->thousands_separators == LT_UNDERSCORE_LOCALE) {
258 consumed = get_integer(format_spec, &pos, end, &format->precision);
275 /* More than one char remains, so this is an invalid format
277 /* Create a temporary object that contains the format spec we're
284 "Invalid format specifier '%U' for object of type '%.200s'",
292 format->type = READ_spec(pos);
296 /* Do as much validating as we can, just by looking at the format
300 if (format->thousands_separators) {
301 switch (format->type) {
318 if (format->thousands_separators == LT_UNDERSCORE_LOCALE) {
320 format->thousands_separators = LT_UNDER_FOUR_LOCALE;
325 invalid_thousands_separator_type(format->thousands_separators, format->type);
330 assert (format->align <= 127);
331 assert (format->sign <= 127);
468 /* not all fields of format are used. for example, precision is
470 about what it does? or is passing a single format parameter easier
478 const InternalFormatSpec *format, Py_UCS4 *maxchar)
498 sign is computed from format->sign and the actual
513 switch (format->sign) {
535 /* min_width can go negative, that's okay. format->width == -1 means
537 if (format->fill_char == '0' && format->align == '=')
538 spec->n_min_width = format->width - n_non_digit_non_padding;
561 space we consume, see if we need any padding. format->width can
564 n_padding = format->width -
568 switch (format->align) {
589 *maxchar = Py_MAX(*maxchar, format->fill_char);
765 format_string_internal(PyObject *value, const InternalFormatSpec *format,
779 if (format->sign != '\0') {
780 if (format->sign == ' ') {
782 "Space not allowed in string format specifier");
786 "Sign not allowed in string format specifier");
792 if (format->no_neg_0) {
794 "Negative zero coercion (z) not allowed in string format "
800 if (format->alternate) {
802 "Alternate form (#) not allowed in string format "
808 if (format->align == '=') {
811 "in string format specifier");
815 if ((format->width == -1 || format->width <= len)
816 && (format->precision == -1 || format->precision >= len)) {
821 /* if precision is specified, output no more that format.precision
823 if (format->precision >= 0 && len >= format->precision) {
824 len = format->precision;
827 calc_padding(len, format->width, format->align, &lpad, &rpad, &total);
831 maxchar = Py_MAX(maxchar, format->fill_char);
842 result = fill_padding(writer, len, format->fill_char, lpad, rpad);
864 format_long_internal(PyObject *value, const InternalFormatSpec *format,
887 if (format->precision != -1) {
889 "Precision not allowed in integer format specifier");
893 if (format->no_neg_0) {
896 " format specifier");
901 if (format->type == 'c') {
903 if (format->sign != '\0') {
906 " format specifier 'c'");
909 /* error to request alternate format */
910 if (format->alternate) {
913 " format specifier 'c'");
947 switch (format->type) {
968 if (format->sign != '+' && format->sign != ' '
969 && format->width == -1
970 && format->type != 'X' && format->type != 'n'
971 && !format->thousands_separators
975 return _PyLong_FormatWriter(writer, value, base, format->alternate);
980 if (format->alternate)
1007 if (get_locale_info(format->type == 'n' ? LT_CURRENT_LOCALE :
1008 format->thousands_separators,
1015 &locale, format, &maxchar);
1027 tmp, prefix, format->fill_char,
1028 &locale, format->type == 'X');
1043 const InternalFormatSpec *format,
1053 Py_UCS4 type = format->type;
1068 if (format->precision > INT_MAX) {
1072 precision = (int)format->precision;
1074 if (format->alternate)
1076 if (format->no_neg_0)
1090 format the result. We take care of that later. */
1125 if (format->sign != '+' && format->sign != ' '
1126 && format->width == -1
1127 && format->type != 'n'
1128 && !format->thousands_separators)
1157 if (get_locale_info(format->type == 'n' ? LT_CURRENT_LOCALE :
1158 format->thousands_separators,
1165 &locale, format, &maxchar);
1177 NULL, 0, format->fill_char,
1192 const InternalFormatSpec *format,
1200 InternalFormatSpec tmp_format = *format;
1210 Py_UCS4 type = format->type;
1236 if (format->precision > INT_MAX) {
1240 precision = (int)format->precision;
1243 if (format->fill_char == '0') {
1245 "Zero padding is not allowed in complex format "
1251 if (format->align == '=') {
1253 "'=' alignment flag is not allowed in complex format "
1265 if (format->alternate)
1267 if (format->no_neg_0)
1282 format the result. We take care of that later. */
1338 if (get_locale_info(format->type == 'n' ? LT_CURRENT_LOCALE :
1339 format->thousands_separators,
1360 * requested by the original format. */
1376 format->width, format->align, &lpad, &rpad, &total);
1379 maxchar = Py_MAX(maxchar, format->fill_char);
1389 format->fill_char, lpad, rpad);
1456 InternalFormatSpec format;
1460 /* check for the special case of zero length format spec, make
1471 &format, 's', '<'))
1475 switch (format.type) {
1478 return format_string_internal(obj, &format, writer);
1481 unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name);
1493 InternalFormatSpec format;
1496 /* check for the special case of zero length format spec, make
1507 &format, 'd', '>'))
1511 switch (format.type) {
1520 result = format_long_internal(obj, &format, writer);
1534 result = format_float_internal(tmp, &format, writer);
1539 unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name);
1554 InternalFormatSpec format;
1556 /* check for the special case of zero length format spec, make
1563 &format, '\0', '>'))
1567 switch (format.type) {
1568 case '\0': /* No format code: like 'g', but with at least one decimal. */
1578 return format_float_internal(obj, &format, writer);
1582 unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name);
1593 InternalFormatSpec format;
1595 /* check for the special case of zero length format spec, make
1602 &format, '\0', '>'))
1606 switch (format.type) {
1607 case '\0': /* No format code: like 'g', but with at least one decimal. */
1616 return format_complex_internal(obj, &format, writer);
1620 unknown_presentation_type(format.type, Py_TYPE(obj)->tp_name);