diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2015-09-21 11:24:49 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2015-09-22 18:08:00 -0700 |
commit | c1bd3b5824027f23b41bbac77c5e28f856c5dc18 (patch) | |
tree | f406ad2f859df99f65c059f8c4019d5a2db1e459 /src/common.cpp | |
parent | fb615843b329b4d3c303b9cebe2af134a52b5bfd (diff) |
Eliminate global variables associated with builtin IO
This change eliminates global variables like stdout_buffer. Instead we wrap up
the IO information into a new struct io_streams_t, and thread that through
every builtin. This makes the intent clearer, gives us a place to hang new IO
data, and eliminates the ugly global state management like builtin_push_io.
Diffstat (limited to 'src/common.cpp')
-rw-r--r-- | src/common.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/common.cpp b/src/common.cpp index 50cb1102..2d844129 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -641,9 +641,7 @@ static bool should_debug(int level) static void debug_shared(const wcstring &msg) { const wcstring sb = wcstring(program_name) + L": " + msg; - wcstring sb2; - write_screen(sb, sb2); - fwprintf(stderr, L"%ls", sb2.c_str()); + fwprintf(stderr, L"%ls", reformat_for_screen(sb).c_str()); } void debug(int level, const wchar_t *msg, ...) @@ -806,8 +804,9 @@ void format_long_safe(wchar_t buff[64], long val) } } -void write_screen(const wcstring &msg, wcstring &buff) +wcstring reformat_for_screen(const wcstring &msg) { + wcstring buff; int line_width = 0; int screen_width = common_get_width(); @@ -892,6 +891,7 @@ void write_screen(const wcstring &msg, wcstring &buff) buff.append(msg); } buff.push_back(L'\n'); + return buff; } /* Escape a string, storing the result in out_str */ |