diff options
Diffstat (limited to 'libntp/timetoa.c')
-rw-r--r-- | libntp/timetoa.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/libntp/timetoa.c b/libntp/timetoa.c index c04d34e..f294e16 100644 --- a/libntp/timetoa.c +++ b/libntp/timetoa.c @@ -57,14 +57,12 @@ format_time_fraction( u_int u; long fraclimit; int notneg; /* flag for non-negative value */ - const char * fmt; ldiv_t qr; DEBUG_REQUIRE(prec != 0); LIB_GETBUF(cp); secs_u = (u_time)secs; - fmt = "-%" UTIME_FORMAT ".%0*ld"; /* check if we need signed or unsigned mode */ notneg = (prec < 0); @@ -92,9 +90,7 @@ format_time_fraction( /* Get the absolute value of the split representation time. */ notneg = notneg || ((time_t)secs_u >= 0); - if (notneg) { - fmt++; /* skip '-' */ - } else { + if (!notneg) { secs_u = ~secs_u; if (0 == frac) secs_u++; @@ -103,7 +99,8 @@ format_time_fraction( } /* finally format the data and return the result */ - snprintf(cp, LIB_BUFLENGTH, fmt, secs_u, prec_u, frac); + snprintf(cp, LIB_BUFLENGTH, "%s%" UTIME_FORMAT ".%0*ld", + notneg? "" : "-", secs_u, prec_u, frac); return cp; } |