Make reader_push accept wcstring instead of wchar_t*

This commit is contained in:
ridiculousfish 2018-08-11 12:43:11 -07:00
parent 82bff2d692
commit f7d846ad8b
3 changed files with 4 additions and 7 deletions

View File

@ -211,7 +211,7 @@ static int read_interactive(wcstring &buff, int nchars, bool shell, bool silent,
wcstring read_history_ID = history_session_id(); wcstring read_history_ID = history_session_id();
if (!read_history_ID.empty()) read_history_ID += L"_read"; 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_left_prompt(prompt);
reader_set_right_prompt(right_prompt); reader_set_right_prompt(right_prompt);

View File

@ -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, /// 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. /// 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) { static parser_test_error_bits_t default_test(const wcstring &b) {
UNUSED(b); UNUSED(b);
return 0; 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(); reader_data_t *n = new reader_data_t();
n->history = &history_t::history_with_name(name); 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. /// Read interactively. Read input from stdin while providing editing facilities.
static int read_i() { static int read_i() {
reader_push(history_session_id().c_str()); reader_push(history_session_id());
reader_set_complete_function(&complete); reader_set_complete_function(&complete);
reader_set_highlight_function(&highlight_shell); reader_set_highlight_function(&highlight_shell);
reader_set_test_function(&reader_shell_test); reader_set_test_function(&reader_shell_test);

View File

@ -144,7 +144,7 @@ bool reader_thread_job_is_stale();
const wchar_t *reader_readline(int nchars); const wchar_t *reader_readline(int nchars);
/// Push a new reader environment. /// Push a new reader environment.
void reader_push(const wchar_t *name); void reader_push(const wcstring &name);
/// Return to previous reader environment. /// Return to previous reader environment.
void reader_pop(); void reader_pop();