From ea4e997dc96e918fd8b8f0e2091450583bbd56ae Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 18 Feb 2018 13:17:45 -0800 Subject: [PATCH] Remove ends_with_pipe from reader Now that parse_util_detect_errors() can report incomplete pipelines, we no longer have to detect this in the reader. --- src/reader.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index bcb5a99e5..5c05d388e 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -302,7 +302,6 @@ static volatile sig_atomic_t interrupted = 0; // Prototypes for a bunch of functions defined later on. static bool is_backslashed(const wcstring &str, size_t pos); static wchar_t unescaped_quote(const wcstring &str, size_t pos); -static bool ends_with_pipe(const wcstring &str, size_t pos); /// Mode on startup, which we restore on exit. static struct termios terminal_mode_on_startup; @@ -2303,19 +2302,6 @@ static bool is_backslashed(const wcstring &str, size_t pos) { return (count % 2) == 1; } -/// Test if the specified string ends with pipe. Whitespaces at the end are ignored. It returns -/// false if backslashed before the pipe because it should be treated as an escaped character. -static bool ends_with_pipe(const wcstring &str, size_t pos) { - if (pos > str.size()) return false; - - while (pos--) { - wchar_t c = str.at(pos); - if (c == L'|') return !is_backslashed(str, pos); - if (!iswspace(c)) break; - } - return false; -} - static wchar_t unescaped_quote(const wcstring &str, size_t pos) { wchar_t result = L'\0'; if (pos < str.size()) { @@ -2765,12 +2751,6 @@ const wchar_t *reader_readline(int nchars) { insert_char(el, '\n'); break; } - // A newline is inserted if the line ends with a pipe (issue #1285). - if (ends_with_pipe(el->text, el->size())) { - el->position = el->size(); - insert_char(el, '\n'); - break; - } // See if this command is valid. int command_test_result = data->test_func(el->text.c_str());