+ unsigned total_diff;
+
+#if ENABLE_FEATURE_TOP_DECIMALS
+ /* formats 7 char string (8 with terminating NUL) */
+ /* using GCCism (nested function) - we need to access total_diff */
+ /* This produces more than 100 bytes smaller code */
+ char *fmt_100percent_8(char pbuf[8], unsigned value)
+ {
+ unsigned t;
+ if (value >= total_diff) { /* 100% ? */
+ strcpy(pbuf, " 100% ");
+ return pbuf;
+ }
+ /* else generate " [N/space]N.N% " string */
+ value = 1000 * value / total_diff;
+ t = value / 100;
+ value = value % 100;
+ pbuf[0] = ' ';
+ pbuf[1] = t ? t + '0' : ' ';
+ pbuf[2] = '0' + (value / 10);
+ pbuf[3] = '.';
+ pbuf[4] = '0' + (value % 10);
+ pbuf[5] = '%';
+ pbuf[6] = ' ';
+ pbuf[7] = '\0';
+ return pbuf;
+ }
+#endif