1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 18:45:10 +00:00

Bugfix: Sx in $format_time prints out wrong values when number of seconds ends with a zero and has no numbers behind the point

This commit is contained in:
Nikolas Garofil 2009-11-20 15:23:54 +01:00
parent 7291184783
commit b85b0d5aab

View File

@ -235,11 +235,14 @@ void print_format_time(struct text_object *obj, char *p, unsigned int p_max_size
if(*currentchar >= '0' && *currentchar <= '9') { if(*currentchar >= '0' && *currentchar <= '9') {
asprintf(&temp, "%.*f", (*currentchar) - '0', seconds); asprintf(&temp, "%.*f", (*currentchar) - '0', seconds);
} else if(*currentchar == 'x') { } else if(*currentchar == 'x') {
if(seconds == (int) seconds ) {
asprintf(&temp, "%d", (int) seconds);
} else {
asprintf(&temp, "%.9f", seconds); asprintf(&temp, "%.9f", seconds);
while(*(temp + strlen(temp) - 1) == '0' || *(temp + strlen(temp) - 1) == '.') { while(*(temp + strlen(temp) - 1) == '0' || *(temp + strlen(temp) - 1) == '.') {
*(temp + strlen(temp) - 1) = 0; *(temp + strlen(temp) - 1) = 0;
} }
if(*temp == 0) *temp = '0'; }
}else{ }else{
currentchar--; currentchar--;
NORM_ERR("$format_time needs a digit behind 'S' to specify precision") NORM_ERR("$format_time needs a digit behind 'S' to specify precision")