X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fconky.c;h=cc92a0bdeae8e8124efecd318b4c1b348cce7e3d;hb=174c256c81a027a2ea406f5f37dc036fac0a524b;hp=1bef267181db090290504b7a54145f9c383e6bbf;hpb=d75e2db5ed3fc788fb8514121f67316ac3e5f29f;p=monky diff --git a/src/conky.c b/src/conky.c index 1bef267..cc92a0b 100644 --- a/src/conky.c +++ b/src/conky.c @@ -2296,18 +2296,26 @@ void generate_text_internal(char *p, int p_max_size, } } } - OBJ(to_bytes) { + OBJ(to_bytes) {//commented code is original - not working when input value contains a decimal point char buf[max_user_text]; - long long bytes; + //long long bytes; + long double bytes; char unit[16]; // 16 because we can also have long names (like mega-bytes) generate_text_internal(buf, max_user_text, *obj->sub, cur); - if(sscanf(buf, "%lli%s", &bytes, unit) == 2 && strlen(unit) < 16){ - if(strncasecmp("b", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes); - else if(strncasecmp("k", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024); - else if(strncasecmp("m", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024 * 1024); - else if(strncasecmp("g", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024 * 1024 * 1024); - else if(strncasecmp("t", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024 * 1024 * 1024 * 1024); +// if(sscanf(buf, "%lli%s", &bytes, unit) == 2 && strlen(unit) < 16){ +// if(strncasecmp("b", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes); +// else if(strncasecmp("k", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024); +// else if(strncasecmp("m", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024 * 1024); +// else if(strncasecmp("g", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024 * 1024 * 1024); +// else if(strncasecmp("t", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024 * 1024 * 1024 * 1024); +// } + if(sscanf(buf, "%Lf%s", &bytes, unit) == 2 && strlen(unit) < 16){ + if(strncasecmp("b", unit, 1) == 0) snprintf(buf, max_user_text, "%Lf", bytes); + else if(strncasecmp("k", unit, 1) == 0) snprintf(buf, max_user_text, "%Lf", bytes * 1024); + else if(strncasecmp("m", unit, 1) == 0) snprintf(buf, max_user_text, "%Lf", bytes * 1024 * 1024); + else if(strncasecmp("g", unit, 1) == 0) snprintf(buf, max_user_text, "%Lf", bytes * 1024 * 1024 * 1024); + else if(strncasecmp("t", unit, 1) == 0) snprintf(buf, max_user_text, "%Lf", bytes * 1024 * 1024 * 1024 * 1024); } snprintf(p, p_max_size, "%s", buf); }