|
amiconn: apps misc.c,1.24,1.25: msg#00251systems.archos.rockbox.cvs
Update of /cvsroot/rockbox/apps In directory labb:/tmp/cvs-serv16007/apps Modified Files: misc.c Log Message: Slightly more compact code; cleanup. Index: misc.c =================================================================== RCS file: /cvsroot/rockbox/apps/misc.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- misc.c 31 Jan 2005 01:27:48 -0000 1.24 +++ misc.c 31 Jan 2005 02:25:36 -0000 1.25 @@ -40,9 +40,6 @@ #include "ata_mmc.h" #endif -#define ONE_KILOBYTE 1024 -#define ONE_MEGABYTE (1024*1024) - /* Format a large-range value for output, using the appropriate unit so that * the displayed value is in the range 1 <= display < 1000 (1024 for "binary" * units) if possible, and 3 significant digits are shown. If a buffer is @@ -66,28 +63,23 @@ if (bin_scale) fraction = fraction * 1000 / 1024; + if (value >= 100 || !unit_no) + tbuf[0] = '\0'; + else if (value >= 10) + snprintf(tbuf, sizeof(tbuf), "%01d", fraction / 100); + else + snprintf(tbuf, sizeof(tbuf), "%02d", fraction / 10); + if (buf) { - if (value >= 100 || !unit_no) - snprintf(tbuf, sizeof(tbuf), "%d", value); - else if (value >= 10) - snprintf(tbuf, sizeof(tbuf), "%d%s%01d", value, str(LANG_POINT), - fraction / 100); + if (strlen(tbuf)) + snprintf(buf, buf_size, "%d%s%s%s", value, str(LANG_POINT), + tbuf, P2STR(units[unit_no])); else - snprintf(tbuf, sizeof(tbuf), "%d%s%02d", value, str(LANG_POINT), - fraction / 10); - - snprintf(buf, buf_size, "%s%s", tbuf, P2STR(units[unit_no])); + snprintf(buf, buf_size, "%d%s", value, P2STR(units[unit_no])); } else { - if (value >= 100 || !unit_no) - tbuf[0] = '\0'; - else if (value >= 10) - snprintf(tbuf, sizeof(tbuf), "%01d", fraction / 100); - else - snprintf(tbuf, sizeof(tbuf), "%02d", fraction / 10); - /* strip trailing zeros from the fraction */ for (i = strlen(tbuf) - 1; (i >= 0) && (tbuf[i] == '0'); i--) tbuf[i] = '\0'; @@ -139,20 +131,6 @@ return errno ? -1 : num_read; } -#ifdef TEST_MAX5 -int main(int argc, char **argv) -{ - char buffer[32]; - if(argc>1) { - printf("%d => %s\n", - atoi(argv[1]), - num2max5(atoi(argv[1]), buffer)); - } - return 0; -} - -#endif - #ifdef HAVE_LCD_BITMAP extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; static const unsigned char bmpheader[] = _______________________________________________ http://cool.haxx.se/mailman/listinfo/rockbox-cvs |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | amiconn: firmware/drivers ata_mmc.c,1.32,1.33: 00251, cvs |
|---|---|
| Next by Date: | matsl: apps/lang svenska.lang,1.56,1.57: 00251, cvs |
| Previous by Thread: | amiconn: firmware/drivers ata_mmc.c,1.32,1.33i: 00251, cvs |
| Next by Thread: | matsl: apps/lang svenska.lang,1.56,1.57: 00251, cvs |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |