aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/fish_indent.cpp
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-06-03 19:05:13 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-06-05 15:49:34 -0700
commit0b385f145ce6144b5812bd89fa8f73369bcbe57f (patch)
tree3d3b059af2e9a7efb6fe38e33ee1782b23e6167e /src/fish_indent.cpp
parent32a585a52b20687a1a16c45142da2261d28b7a27 (diff)
simplify, and fix, setting the current locale
Fix test setup bogosities. Specifically, they weren't hermetic with respect to locale env vars. Rewrite the handling of locale vars to simplify the code and make it more like the pattern most programs employ. Fixes #3110
Diffstat (limited to 'src/fish_indent.cpp')
-rw-r--r--src/fish_indent.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp
index a1479f47..cab9df03 100644
--- a/src/fish_indent.cpp
+++ b/src/fish_indent.cpp
@@ -328,12 +328,16 @@ static std::string html_colorize(const wcstring &text,
static std::string no_colorize(const wcstring &text) { return wcs2string(text); }
int main(int argc, char *argv[]) {
+ program_name = L"fish_indent";
set_main_thread();
setup_fork_guards();
-
- wsetlocale(LC_ALL, L"");
- program_name = L"fish_indent";
-
+ // Using the user's default locale could be a problem if it doesn't use UTF-8 encoding. That's
+ // because the fish project assumes Unicode UTF-8 encoding in all of its scripts.
+ //
+ // TODO: Auto-detect the encoding of the script. We should look for a vim style comment
+ // (e.g., "# vim: set fileencoding=<encoding-name>:") or an emacs style comment
+ // (e.g., "# -*- coding: <encoding-name> -*-").
+ setlocale(LC_ALL, "");
env_init();
input_init();