"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "util/String.cpp" between
muscle8.20.zip and muscle8.30.zip

About: MUSCLE (Multi User Server Client Linking Environment) is a messaging server and networking API. The included server program ("muscled") lets its clients message each other, and/or store information in its serverside hierarchical database.

String.cpp  (muscle8.20):String.cpp  (muscle8.30)
skipping to change at line 1000 skipping to change at line 1000
{ {
char buf[256]; char buf[256];
if (maxDigitsAfterDecimal == MUSCLE_NO_LIMIT) muscleSprintf(buf, "%f", f); if (maxDigitsAfterDecimal == MUSCLE_NO_LIMIT) muscleSprintf(buf, "%f", f);
else else
{ {
char formatBuf[128]; char formatBuf[128];
muscleSprintf(formatBuf, "%%.0" UINT32_FORMAT_SPEC "f", maxDigitsAfterDeci mal); muscleSprintf(formatBuf, "%%.0" UINT32_FORMAT_SPEC "f", maxDigitsAfterDeci mal);
muscleSprintf(buf, formatBuf, f); muscleSprintf(buf, formatBuf, f);
} }
String ret = buf; String s = buf;
// Start by removing all trailing zeroes from the String // Start by removing all trailing zeroes from the String
if (ret.Contains('.')) while(ret.EndsWith('0')) ret--; if (s.Contains('.')) while(s.EndsWith('0')) s--;
if (minDigitsAfterDecimal == 0) if (minDigitsAfterDecimal == 0)
{ {
if (ret.EndsWith('.')) ret--; // Remove trailing . for integer-style disp lay if (s.EndsWith('.')) s--; // Remove trailing . for integer-style display
} }
else else
{ {
// Pad with 0's if necessary to meet the minDigitsAfterDecimal requirement // Pad with 0's if necessary to meet the minDigitsAfterDecimal requirement
int32 dotIdx = ret.LastIndexOf('.'); int32 dotIdx = s.LastIndexOf('.');
if (dotIdx < 0) {ret += '.'; dotIdx = ret.Length()-1;} // semi-paranoia if (dotIdx < 0) {s += '.'; dotIdx = s.Length()-1;} // semi-paranoia
uint32 numDigitsPresent = (ret.Length()-dotIdx)-1;
for(uint32 i=numDigitsPresent; i<minDigitsAfterDecimal; i++) ret += '0'; const uint32 numDigitsPresent = (s.Length()-dotIdx)-1;
for(uint32 i=numDigitsPresent; i<minDigitsAfterDecimal; i++) s += '0';
} }
return ArgAux(buf); return ArgAux(s());
} }
String String :: Arg(const Point & value, const char * fmt) const String String :: Arg(const Point & value, const char * fmt) const
{ {
char buf[512]; char buf[512];
muscleSprintf(buf, fmt, value.x(), value.y()); muscleSprintf(buf, fmt, value.x(), value.y());
return ArgAux(buf); return ArgAux(buf);
} }
String String :: Arg(const Rect & value, const char * fmt) const String String :: Arg(const Rect & value, const char * fmt) const
 End of changes. 5 change blocks. 
8 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)