| 201 | */ |
| 202 | |
| 203 | char * /* O - Pointer to end of string */ |
| 204 | _cupsStrFormatd(char *buf, /* I - String */ |
| 205 | char *bufend, /* I - End of string buffer */ |
| 206 | double number, /* I - Number to format */ |
| 207 | struct lconv *loc) /* I - Locale data */ |
| 208 | { |
| 209 | char *bufptr, /* Pointer into buffer */ |
| 210 | temp[1024], /* Temporary string */ |
| 211 | *tempdec, /* Pointer to decimal point */ |
| 212 | *tempptr; /* Pointer into temporary string */ |
| 213 | const char *dec; /* Decimal point */ |
| 214 | int declen; /* Length of decimal point */ |
| 215 | |
| 216 | |
| 217 | /* |
| 218 | * Format the number using the "%.12f" format and then eliminate |
| 219 | * unnecessary trailing 0's. |
| 220 | */ |
| 221 | |
| 222 | snprintf(temp, sizeof(temp), "%.12f", number); |
| 223 | for (tempptr = temp + strlen(temp) - 1; |
| 224 | tempptr > temp && *tempptr == '0'; |
| 225 | *tempptr-- = '\0'); |
| 226 | |
| 227 | /* |
| 228 | * Next, find the decimal point... |
| 229 | */ |
| 230 | |
| 231 | if (loc && loc->decimal_point) |
| 232 | { |
| 233 | dec = loc->decimal_point; |
| 234 | declen = (int)strlen(dec); |
| 235 | } |
| 236 | else |
| 237 | { |
| 238 | dec = "."; |
| 239 | declen = 1; |
| 240 | } |
| 241 | |
| 242 | if (declen == 1) |
| 243 | tempdec = strchr(temp, *dec); |
| 244 | else |
| 245 | tempdec = strstr(temp, dec); |
| 246 | |
| 247 | /* |
| 248 | * Copy everything up to the decimal point... |
| 249 | */ |
| 250 | |
| 251 | if (tempdec) |
| 252 | { |
| 253 | for (tempptr = temp, bufptr = buf; |
| 254 | tempptr < tempdec && bufptr < bufend; |
| 255 | *bufptr++ = *tempptr++); |
| 256 | |
| 257 | tempptr += declen; |
| 258 | |
| 259 | if (*tempptr && bufptr < bufend) |
| 260 | { |
no outgoing calls