From 59594e70d20f72c6f6f75060834af5bed0b22b88 Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Thu, 19 Nov 2009 00:04:49 +0100 Subject: [PATCH] Added support for \Sx to $format_time --- doc/variables.xml | 2 ++ src/timeinfo.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/doc/variables.xml b/doc/variables.xml index e660befa..10b4abfb 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -1123,6 +1123,8 @@ then you can see the numbers behind the point by using \S followed by a number that specifies the amount of digits behind the point that you want to see (maximum 9). + You can also place a 'x' behind \S so you have all digits behind + the point and no trailing zero's. (also maximum 9) diff --git a/src/timeinfo.c b/src/timeinfo.c index 7c112dfd..df0a2a27 100644 --- a/src/timeinfo.c +++ b/src/timeinfo.c @@ -217,6 +217,12 @@ void print_format_time(struct text_object *obj, char *p, unsigned int p_max_size currentchar++; if(*currentchar >= '0' && *currentchar <= '9') { asprintf(&temp, "%.*f", (*currentchar) - '0', seconds); + } else if(*currentchar == 'x') { + asprintf(&temp, "%.9f", seconds); + while(*(temp + strlen(temp) - 1) == '0' || *(temp + strlen(temp) - 1) == '.') { + *(temp + strlen(temp) - 1) = 0; + } + if(*temp == 0) *temp = '0'; }else{ currentchar--; NORM_ERR("$format_time needs a digit behind 'S' to specify precision")