Use a '*' printf() field width rather than an intermediate format string

This commit is contained in:
Daniel Richard G 2013-09-19 00:50:11 -04:00
parent 16179f34cd
commit 30ca4ec8ac

View File

@ -210,18 +210,15 @@ const char *SolveSpace::UnitName(void) {
char *SolveSpace::MmToString(double v) {
static int WhichBuf;
static char Bufs[8][128];
char fmt[128];
WhichBuf++;
if(WhichBuf >= 8 || WhichBuf < 0) WhichBuf = 0;
char *s = Bufs[WhichBuf];
if(viewUnits == UNIT_INCHES) {
sprintf(fmt, "%%.%df", afterDecimalInch);
sprintf(s, fmt, v/25.4);
sprintf(s, "%.*f", afterDecimalInch, v/25.4);
} else {
sprintf(fmt, "%%.%df", afterDecimalMm);
sprintf(s, fmt, v);
sprintf(s, "%.*f", afterDecimalMm, v);
}
return s;
}