From f7d846ad8be6beb9c4752e598ac8690a9929320b Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 11 Aug 2018 12:43:11 -0700 Subject: [PATCH] Make reader_push accept wcstring instead of wchar_t* --- src/builtin_read.cpp | 2 +- src/reader.cpp | 7 ++----- src/reader.h | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/builtin_read.cpp b/src/builtin_read.cpp index 4dc957448..88768445e 100644 --- a/src/builtin_read.cpp +++ b/src/builtin_read.cpp @@ -211,7 +211,7 @@ static int read_interactive(wcstring &buff, int nchars, bool shell, bool silent, wcstring read_history_ID = history_session_id(); if (!read_history_ID.empty()) read_history_ID += L"_read"; - reader_push(read_history_ID.c_str()); + reader_push(read_history_ID); reader_set_left_prompt(prompt); reader_set_right_prompt(right_prompt); diff --git a/src/reader.cpp b/src/reader.cpp index be320e034..ad8c589d7 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -1932,9 +1932,6 @@ parser_test_error_bits_t reader_shell_test(const wcstring &b) { /// Test if the given string contains error. Since this is the error detection for general purpose, /// there are no invalid strings, so this function always returns false. -/// -/// TODO: Possibly remove this. It is called from only only one place: reader_push().Since it always -/// returns a static result it's not clear why it's needed. static parser_test_error_bits_t default_test(const wcstring &b) { UNUSED(b); return 0; @@ -1948,7 +1945,7 @@ void reader_change_history(const wchar_t *name) { } } -void reader_push(const wchar_t *name) { +void reader_push(const wcstring &name) { reader_data_t *n = new reader_data_t(); n->history = &history_t::history_with_name(name); @@ -2205,7 +2202,7 @@ static bool selection_is_at_top() { /// Read interactively. Read input from stdin while providing editing facilities. static int read_i() { - reader_push(history_session_id().c_str()); + reader_push(history_session_id()); reader_set_complete_function(&complete); reader_set_highlight_function(&highlight_shell); reader_set_test_function(&reader_shell_test); diff --git a/src/reader.h b/src/reader.h index b68e5b768..50b5ccd84 100644 --- a/src/reader.h +++ b/src/reader.h @@ -144,7 +144,7 @@ bool reader_thread_job_is_stale(); const wchar_t *reader_readline(int nchars); /// Push a new reader environment. -void reader_push(const wchar_t *name); +void reader_push(const wcstring &name); /// Return to previous reader environment. void reader_pop();