From 177e06808c5bbb48c7c32ceee2696857844f3e38 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 6 Jan 2017 18:19:42 +0100 Subject: [PATCH] Replace all printf invocations with wprintf Remember, GNU doesn't allow mixing narrow and wide IO. --- src/autoload.cpp | 2 +- src/common.cpp | 4 ++-- src/event.cpp | 2 +- src/expand.cpp | 2 +- src/fish_key_reader.cpp | 2 +- src/fish_tests.cpp | 2 +- src/iothread.cpp | 2 +- src/output.cpp | 2 +- src/proc.cpp | 2 +- src/tokenizer.cpp | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/autoload.cpp b/src/autoload.cpp index dbfa54e9f..46e36ac57 100644 --- a/src/autoload.cpp +++ b/src/autoload.cpp @@ -25,7 +25,7 @@ static const int kAutoloadStalenessInterval = 15; file_access_attempt_t access_file(const wcstring &path, int mode) { - // printf("Touch %ls\n", path.c_str()); + // wprintf(L"Touch %ls\n", path.c_str()); file_access_attempt_t result = {}; struct stat statbuf; if (wstat(path, &statbuf)) { diff --git a/src/common.cpp b/src/common.cpp index 6e9604227..0cfd6959e 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -608,7 +608,7 @@ void debug_safe(int level, const char *msg, const char *param1, const char *para param7, param8, param9, param10, param11, param12}; if (!msg) return; - // Can't call printf, that may allocate memory Just call write() over and over. + // Can't call wprintf, that may allocate memory Just call write() over and over. if (level > debug_level) return; int errno_old = errno; @@ -1691,7 +1691,7 @@ bool is_forked_child(void) { bool is_child_of_fork = (getpid() != initial_pid); if (is_child_of_fork) { - printf("Uh-oh: %d\n", getpid()); + wprintf(L"Uh-oh: %d\n", getpid()); while (1) sleep(10000); } return is_child_of_fork; diff --git a/src/event.cpp b/src/event.cpp index 31651054c..81d4ef373 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -166,7 +166,7 @@ static void show_all_handlers(void) { for (event_list_t::const_iterator iter = events.begin(); iter != events.end(); ++iter) { const event_t *foo = *iter; wcstring tmp = event_get_desc(foo); - printf(" handler now %ls\n", tmp.c_str()); + wprintf(L" handler now %ls\n", tmp.c_str()); } } #endif diff --git a/src/expand.cpp b/src/expand.cpp index 7027416b5..2004f8970 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -763,7 +763,7 @@ static int expand_variables(const wcstring &instr, std::vector *ou stop_pos++; } - // printf( "Stop for '%c'\n", in[stop_pos]); + // wprintf(L"Stop for '%c'\n", in[stop_pos]); var_len = stop_pos - start_pos; if (var_len == 0) { diff --git a/src/fish_key_reader.cpp b/src/fish_key_reader.cpp index b767bfa18..c3a6380b8 100644 --- a/src/fish_key_reader.cpp +++ b/src/fish_key_reader.cpp @@ -183,7 +183,7 @@ static void output_info_about_char(wchar_t wc) { static bool output_matching_key_name(wchar_t wc) { char *name = sequence_name(wc); if (name) { - printf("bind -k %s 'do something'\n", name); + wprintf(L"bind -k %s 'do something'\n", name); free(name); return true; } diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 714de42c1..ac038e0bd 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -1726,7 +1726,7 @@ static void test_1_word_motion(word_motion_t motion, move_word_style_t style, size_t char_idx = (motion == word_motion_left ? idx - 1 : idx); wchar_t wc = command.at(char_idx); bool will_stop = !sm.consume_char(wc); - // printf("idx %lu, looking at %lu (%c): %d\n", idx, char_idx, (char)wc, will_stop); + // wprintf(L"idx %lu, looking at %lu (%c): %d\n", idx, char_idx, (char)wc, will_stop); bool expected_stop = (stops.count(idx) > 0); if (will_stop != expected_stop) { wcstring tmp = command; diff --git a/src/iothread.cpp b/src/iothread.cpp index d80496bfc..eb55f8da5 100644 --- a/src/iothread.cpp +++ b/src/iothread.cpp @@ -275,7 +275,7 @@ void iothread_drain_all(void) { } #if TIME_DRAIN double after = timef(); - printf("(Waited %.02f msec for %d thread(s) to drain)\n", 1000 * (after - now), thread_count); + wprintf(L"(Waited %.02f msec for %d thread(s) to drain)\n", 1000 * (after - now), thread_count); #endif } diff --git a/src/output.cpp b/src/output.cpp index d948d3bbd..1716597ea 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -537,7 +537,7 @@ rgb_color_t parse_color(const wcstring &val, bool is_background) { #if 0 wcstring desc = result.description(); - printf("Parsed %ls from %ls (%s)\n", desc.c_str(), val.c_str(), + wprintf(L"Parsed %ls from %ls (%s)\n", desc.c_str(), val.c_str(), is_background ? "background" : "foreground"); #endif diff --git a/src/proc.cpp b/src/proc.cpp index 3a392d56c..116d1d116 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -80,7 +80,7 @@ void print_jobs(void) job_iterator_t jobs; job_t *j; while (j = jobs.next()) { - printf("%p -> %ls -> (foreground %d, complete %d, stopped %d, constructed %d)\n", + wprintf("%p -> %ls -> (foreground %d, complete %d, stopped %d, constructed %d)\n", j, j->command_wcstr(), job_get_flag(j, JOB_FOREGROUND), job_is_completed(j), job_is_stopped(j), job_get_flag(j, JOB_CONSTRUCTED)); } diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 672c26693..0bbfd84ef 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -666,7 +666,7 @@ bool move_word_state_machine_t::consume_char_path_components(wchar_t c) { s_end }; - // printf("state %d, consume '%lc'\n", state, c); + // wprintf(L"state %d, consume '%lc'\n", state, c); bool consumed = false; while (state != s_end && !consumed) { switch (state) {