Mercurial > hg > octave-nkf
diff src/input.cc @ 3180:c17387059fd3
[project @ 1998-09-24 18:59:11 by jwe]
author | jwe |
---|---|
date | Thu, 24 Sep 1998 19:00:19 +0000 |
parents | fccab8e7d35f |
children | bef7b73c0724 |
line wrap: on
line diff
--- a/src/input.cc +++ b/src/input.cc @@ -473,13 +473,18 @@ static bool match_sans_spaces (const string& standard, const string& test) { - string tmp = test; + size_t beg = test.find_first_not_of (" \t"); + + if (beg != NPOS) + { + size_t end = test.find_last_not_of (" \t"); - size_t beg = test.find_first_not_of (" \t"); - size_t end = test.find_last_not_of (" \t"); - size_t len = beg - end + 1; + size_t len = end == NPOS ? NPOS : end - beg + 1; - return test.compare (standard, beg, len) == 0; + return test.compare (standard, beg, len) == 0; + } + + return false; } // If the user simply hits return, this will produce an empty matrix. @@ -535,9 +540,10 @@ } } - if (match_sans_spaces ("exit", input_buf) - || match_sans_spaces ("quit", input_buf) - || match_sans_spaces ("return", input_buf)) + if (debug + && (match_sans_spaces ("exit", input_buf) + || match_sans_spaces ("quit", input_buf) + || match_sans_spaces ("return", input_buf))) { return retval; }