summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2009-04-25 21:40:15 (GMT)
committerEric Smith <eric@trueblade.com>2009-04-25 21:40:15 (GMT)
commit068f06568be288b8628a4e24118503e4d9b7af1b (patch)
treee1d01c08ed08489c994e7cbf167fd703c7f2c64e /Objects/unicodeobject.c
parentdfcffd40447de8e04376f8946fb71a9c16151563 (diff)
downloadcpython-068f06568be288b8628a4e24118503e4d9b7af1b.zip
cpython-068f06568be288b8628a4e24118503e4d9b7af1b.tar.gz
cpython-068f06568be288b8628a4e24118503e4d9b7af1b.tar.bz2
Issue #5835, deprecate PyOS_ascii_formatd.
If anyone wants to clean up the documentation, feel free. It's my first documentation foray, and it's not that great. Will port to py3k with a different strategy.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 6edc2f8..62191ad 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8245,11 +8245,13 @@ strtounicode(Py_UNICODE *buffer, const char *charbuffer)
}
static int
-doubletounicode(Py_UNICODE *buffer, size_t len, const char *format, double x)
+doubletounicode(Py_UNICODE *buffer, size_t len, int format_code,
+ int precision, int flags, double x)
{
Py_ssize_t result;
- PyOS_ascii_formatd((char *)buffer, len, format, x);
+ _PyOS_double_to_string((char *)buffer, len, x, format_code, precision,
+ flags, NULL);
result = strtounicode(buffer, (char *)buffer);
return Py_SAFE_DOWNCAST(result, Py_ssize_t, int);
}
@@ -8276,9 +8278,6 @@ formatfloat(Py_UNICODE *buf,
int type,
PyObject *v)
{
- /* fmt = '%#.' + `prec` + `type`
- worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/
- char fmt[20];
double x;
x = PyFloat_AsDouble(v);
@@ -8320,10 +8319,8 @@ formatfloat(Py_UNICODE *buf,
"formatted float is too long (precision too large?)");
return -1;
}
- PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%d%c",
- (flags&F_ALT) ? "#" : "",
- prec, type);
- return doubletounicode(buf, buflen, fmt, x);
+ return doubletounicode(buf, buflen, type, prec,
+ (flags&F_ALT)?Py_DTSF_ALT:0, x);
}
static PyObject*