summaryrefslogtreecommitdiff
path: root/lib/igt_core.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2015-06-24 11:26:33 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2015-06-24 17:03:04 +0100
commit453792c501b4553ed3c4135057249e300d3c0362 (patch)
treec4ba89f7078344bc97f9ff83bd6d39582d2ca815 /lib/igt_core.c
parent7eb5f079491e5c078cf44d5ddb52824bb2c6bfb0 (diff)
lib: Enable locale dependent output to a terminal
If we are in an interactive session, enable the locale. This allows for features like setting thousand separators for printing large values. By only enabling it for interactive terminals, we avoid changing outputs for the test scripts (leaving them as the "C" locale). Note this mainly affects the testcases, or binaries built using libigt. Other binaries need to be localised separately. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Michel Thierry <michel.thierry@intel.com>
Diffstat (limited to 'lib/igt_core.c')
-rw-r--r--lib/igt_core.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 2cf23934..051bc6a4 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -55,6 +55,7 @@
#include <time.h>
#include <ctype.h>
#include <limits.h>
+#include <locale.h>
#include "drmtest.h"
#include "intel_chipset.h"
@@ -522,6 +523,9 @@ static int common_init(int *argc, char **argv,
int ret = 0;
char *env = getenv("IGT_LOG_LEVEL");
+ if (isatty(STDOUT_FILENO))
+ setlocale(LC_ALL, "");
+
if (env) {
if (strcmp(env, "debug") == 0)
igt_log_level = IGT_LOG_DEBUG;