diff options
author | Eric Smith <eric@trueblade.com> | 2009-04-22 13:29:05 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2009-04-22 13:29:05 (GMT) |
commit | aca19e6a740c424aec243a4721b18d12e9129aa7 (patch) | |
tree | 89b7a3d0e2b7246f483baba919002a24e95bb1d2 /Objects/stringlib/stringdefs.h | |
parent | cbb530872354fb4eb3b8b5bbaa36db38a0d9a64a (diff) | |
download | cpython-aca19e6a740c424aec243a4721b18d12e9129aa7.zip cpython-aca19e6a740c424aec243a4721b18d12e9129aa7.tar.gz cpython-aca19e6a740c424aec243a4721b18d12e9129aa7.tar.bz2 |
Backport of some of the work in r71665 to trunk. This reworks much of
int, long, and float __format__(), and it keeps their implementation
in sync with py3k.
Also added PyOS_double_to_string. This is the "fallback" version
that's also available in trunk, and should be kept in sync with that
code. I'll add an issue to document PyOS_double_to_string in the C
API.
There are many internal cleanups. Externally visible changes include:
- Implement PEP 378, Format Specifier for Thousands Separator, for
floats, ints, and longs.
- Issue #5515: 'n' formatting for ints, longs, and floats handles
leading zero formatting poorly.
- Issue #5772: For float.__format__, don't add a trailing ".0" if
we're using no type code and we have an exponent.
Diffstat (limited to 'Objects/stringlib/stringdefs.h')
-rw-r--r-- | Objects/stringlib/stringdefs.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Objects/stringlib/stringdefs.h b/Objects/stringlib/stringdefs.h index daaa2e2..d08971a 100644 --- a/Objects/stringlib/stringdefs.h +++ b/Objects/stringlib/stringdefs.h @@ -6,6 +6,15 @@ compiled as unicode. */ #define STRINGLIB_IS_UNICODE 0 +/* _tolower and _toupper are defined by SUSv2, but they're not ISO C */ +/* This needs to be cleaned up. See issue 5793. */ +#ifndef _tolower +#define _tolower tolower +#endif +#ifndef _toupper +#define _toupper toupper +#endif + #define STRINGLIB_OBJECT PyStringObject #define STRINGLIB_CHAR char #define STRINGLIB_TYPE_NAME "string" @@ -13,8 +22,8 @@ #define STRINGLIB_EMPTY nullstring #define STRINGLIB_ISDECIMAL(x) ((x >= '0') && (x <= '9')) #define STRINGLIB_TODECIMAL(x) (STRINGLIB_ISDECIMAL(x) ? (x - '0') : -1) -#define STRINGLIB_TOUPPER toupper -#define STRINGLIB_TOLOWER tolower +#define STRINGLIB_TOUPPER(x) _toupper(Py_CHARMASK(x)) +#define STRINGLIB_TOLOWER(x) _tolower(Py_CHARMASK(x)) #define STRINGLIB_FILL memset #define STRINGLIB_STR PyString_AS_STRING #define STRINGLIB_LEN PyString_GET_SIZE @@ -24,5 +33,6 @@ #define STRINGLIB_CMP memcmp #define STRINGLIB_TOSTR PyObject_Str #define STRINGLIB_GROUPING _PyString_InsertThousandsGrouping +#define STRINGLIB_GROUPING_LOCALE _PyString_InsertThousandsGroupingLocale #endif /* !STRINGLIB_STRINGDEFS_H */ |