From fdfda6dec20101013bb33633e657f06ef2a1ea96 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 12 Jun 2020 21:07:52 +0200 Subject: AK: Make string-to-number conversion helpers return Optional Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional StringType::to_int() const --- Libraries/LibLine/Editor.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Libraries/LibLine') diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp index f8600758db..f3728f67b8 100644 --- a/Libraries/LibLine/Editor.cpp +++ b/Libraries/LibLine/Editor.cpp @@ -1431,14 +1431,17 @@ Vector Editor::vt_dsr() if (buf[0] == '\033' && buf[1] == '[') { auto parts = StringView(buf + 2, length - 3).split_view(';'); - bool ok; - row = parts[0].to_int(ok); - if (!ok) { + auto row_opt = parts[0].to_int(); + if (!row_opt.has_value()) { dbg() << "Terminal DSR issue; received garbage row"; + } else { + row = row_opt.value(); } - col = parts[1].to_int(ok); - if (!ok) { + auto col_opt = parts[1].to_int(); + if (!col_opt.has_value()) { dbg() << "Terminal DSR issue; received garbage col"; + } else { + col = col_opt.value(); } } return { row, col }; -- cgit v1.2.3