aboutsummaryrefslogtreecommitdiff
path: root/libXfont/src/util/fontxlfd.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-05 09:59:38 +0100
committermarha <marha@users.sourceforge.net>2012-03-05 09:59:38 +0100
commitffe218bbb0ffa6d2a7f7cbf6b1f81797e667183a (patch)
tree233b818e67de2073647e46e91ac688c6b43d5917 /libXfont/src/util/fontxlfd.c
parent15a500d3edb03668b43cc6898fafcda024d0f006 (diff)
downloadvcxsrv-ffe218bbb0ffa6d2a7f7cbf6b1f81797e667183a.tar.gz
vcxsrv-ffe218bbb0ffa6d2a7f7cbf6b1f81797e667183a.tar.bz2
vcxsrv-ffe218bbb0ffa6d2a7f7cbf6b1f81797e667183a.zip
libfontenc xserver pixman mesa git update 5 Mar 2012
font-util-1.3.0 xclock-1.0.6 libXfont-1.4.5 inputproto-2.2
Diffstat (limited to 'libXfont/src/util/fontxlfd.c')
-rw-r--r--libXfont/src/util/fontxlfd.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/libXfont/src/util/fontxlfd.c b/libXfont/src/util/fontxlfd.c
index 81240376f..974128ee3 100644
--- a/libXfont/src/util/fontxlfd.c
+++ b/libXfont/src/util/fontxlfd.c
@@ -70,7 +70,7 @@ GetInt(char *ptr, int *val)
#ifndef NO_LOCALE
static struct lconv *locale = 0;
#endif
-static char *radix = ".", *plus = "+", *minus = "-";
+static const char *radix = ".", *plus = "+", *minus = "-";
static char *
readreal(char *ptr, double *result)
@@ -116,7 +116,6 @@ readreal(char *ptr, double *result)
static char *
xlfd_double_to_text(double value, char *buffer, int space_required)
{
- char formatbuf[40];
register char *p1;
int ndigits, exponent;
@@ -132,14 +131,12 @@ xlfd_double_to_text(double value, char *buffer, int space_required)
minus = locale->negative_sign;
}
#endif
- /* Compute a format to use to render the number */
- sprintf(formatbuf, "%%.%dle", XLFD_NDIGITS);
if (space_required)
*buffer++ = ' ';
/* Render the number using printf's idea of formatting */
- sprintf(buffer, formatbuf, value);
+ sprintf(buffer, "%.*le", XLFD_NDIGITS, value);
/* Find and read the exponent value */
for (p1 = buffer + strlen(buffer);
@@ -156,16 +153,14 @@ xlfd_double_to_text(double value, char *buffer, int space_required)
if (exponent >= XLFD_NDIGITS || ndigits - exponent > XLFD_NDIGITS + 1)
{
/* Scientific */
- sprintf(formatbuf, "%%.%dle", ndigits - 1);
- sprintf(buffer, formatbuf, value);
+ sprintf(buffer, "%.*le", ndigits - 1, value);
}
else
{
/* Fixed */
ndigits -= exponent + 1;
if (ndigits < 0) ndigits = 0;
- sprintf(formatbuf, "%%.%dlf", ndigits);
- sprintf(buffer, formatbuf, value);
+ sprintf(buffer, "%.*lf", ndigits, value);
if (exponent < 0)
{
p1 = buffer;
@@ -265,10 +260,9 @@ xlfd_round_double(double x)
* If not IEEE 754: Let printf() do it for you.
*/
- char formatbuf[40], buffer[40];
+ char buffer[40];
- sprintf(formatbuf, "%%.%dlg", XLFD_NDIGITS);
- sprintf(buffer, formatbuf, x);
+ sprintf(buffer, "%.*lg", XLFD_NDIGITS, x);
return atof(buffer);
}
}