+static int
+get_integer_from_environment (const char *var, int def)
+{
+ char *end = 0;
+ char *val = getenv (var);
+ long res = def;
+ if (!val)
+ return def;
+ res = strtol (val, &end, 10);
+ if (end == val)
+ {
+ fprintf (stderr, "guile: warning: invalid %s: %s\n", var, val);
+ return def;
+ }
+ return res;
+}
+
+static int
+should_install_locale (void)
+{
+ /* If the GUILE_INSTALL_LOCALE environment variable is set to a
+ nonzero value, we should install the locale via setlocale(). This
+ behavior is off by default for compatibility with previous 2.0.x
+ releases. It will be on by default in 2.2. */
+ return get_integer_from_environment ("GUILE_INSTALL_LOCALE", 0);
+}
+