summaryrefslogtreecommitdiffstats
path: root/usr.bin/time
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-02-10 22:46:47 +0000
committerache <ache@FreeBSD.org>2001-02-10 22:46:47 +0000
commit2d37319b21349d6f4af771a9f2525e515e7b3581 (patch)
tree3f0ca44e6b68e248ae097ecfbba3b904eeb7555e /usr.bin/time
parent5ee0814345ccf8dd60c034e7d66da7a9bfad97f3 (diff)
downloadFreeBSD-src-2d37319b21349d6f4af771a9f2525e515e7b3581.zip
FreeBSD-src-2d37319b21349d6f4af771a9f2525e515e7b3581.tar.gz
Localize it (LC_NUMERIC)
Diffstat (limited to 'usr.bin/time')
-rw-r--r--usr.bin/time/time.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c
index 48a4007..2bf61d5 100644
--- a/usr.bin/time/time.c
+++ b/usr.bin/time/time.c
@@ -56,6 +56,7 @@ static const char rcsid[] =
#include <err.h>
#include <stdio.h>
#include <errno.h>
+#include <locale.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
@@ -64,6 +65,8 @@ static int getstathz __P((void));
static void humantime __P((FILE *, long, long));
static void usage __P((void));
+static char decimal_point;
+
int
main(argc, argv)
int argc;
@@ -77,6 +80,9 @@ main(argc, argv)
char *ofn = NULL;
int exitonsig = 0; /* Die with same signal as child */
+ (void) setlocale(LC_NUMERIC, "");
+ decimal_point = localeconv()->decimal_point[0];
+
aflag = hflag = lflag = pflag = 0;
while ((ch = getopt(argc, argv, "ahlo:p")) != -1)
switch((char)ch) {
@@ -142,12 +148,15 @@ main(argc, argv)
/* POSIX wants output that must look like
"real %f\nuser %f\nsys %f\n" and requires
at least two digits after the radix. */
- fprintf(out, "real %ld.%02ld\n",
- after.tv_sec, after.tv_usec/10000);
- fprintf(out, "user %ld.%02ld\n",
- ru.ru_utime.tv_sec, ru.ru_utime.tv_usec/10000);
- fprintf(out, "sys %ld.%02ld\n",
- ru.ru_stime.tv_sec, ru.ru_stime.tv_usec/10000);
+ fprintf(out, "real %ld%c%02ld\n",
+ after.tv_sec, decimal_point,
+ after.tv_usec/10000);
+ fprintf(out, "user %ld%c%02ld\n",
+ ru.ru_utime.tv_sec, decimal_point,
+ ru.ru_utime.tv_usec/10000);
+ fprintf(out, "sys %ld%c%02ld\n",
+ ru.ru_stime.tv_sec, decimal_point,
+ ru.ru_stime.tv_usec/10000);
} else if (hflag) {
humantime(out, after.tv_sec, after.tv_usec/10000);
fprintf(out, " real\t");
@@ -156,12 +165,15 @@ main(argc, argv)
humantime(out, ru.ru_stime.tv_sec, ru.ru_stime.tv_usec/10000);
fprintf(out, " sys\n");
} else {
- fprintf(out, "%9ld.%02ld real ",
- after.tv_sec, after.tv_usec/10000);
- fprintf(out, "%9ld.%02ld user ",
- ru.ru_utime.tv_sec, ru.ru_utime.tv_usec/10000);
- fprintf(out, "%9ld.%02ld sys\n",
- ru.ru_stime.tv_sec, ru.ru_stime.tv_usec/10000);
+ fprintf(out, "%9ld%c%02ld real ",
+ after.tv_sec, decimal_point,
+ after.tv_usec/10000);
+ fprintf(out, "%9ld%c%02ld user ",
+ ru.ru_utime.tv_sec, decimal_point,
+ ru.ru_utime.tv_usec/10000);
+ fprintf(out, "%9ld%c%02ld sys\n",
+ ru.ru_stime.tv_sec, decimal_point,
+ ru.ru_stime.tv_usec/10000);
}
if (lflag) {
int hz = getstathz();
@@ -262,5 +274,5 @@ humantime(out, sec, usec)
fprintf(out, "%ldh", hrs);
if (mins)
fprintf(out, "%ldm", mins);
- fprintf(out, "%ld.%02lds", sec, usec);
+ fprintf(out, "%ld%c%02lds", sec, decimal_point, usec);
}
OpenPOWER on IntegriCloud