Added support for \Sx to $format_time
authorNikolas Garofil <garo@dunaldi.garofil.be>
Wed, 18 Nov 2009 23:04:49 +0000 (00:04 +0100)
committerNikolas Garofil <garo@dunaldi.garofil.be>
Wed, 18 Nov 2009 23:04:49 +0000 (00:04 +0100)
doc/variables.xml
src/timeinfo.c

index e660bef..10b4abf 100644 (file)
        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)
         <para /></listitem>
     </varlistentry>
     <varlistentry>
index 7c112df..df0a2a2 100644 (file)
@@ -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")