summaryrefslogtreecommitdiff
path: root/Libraries/LibLine
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-12 21:07:52 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-12 21:28:55 +0200
commitfdfda6dec20101013bb33633e657f06ef2a1ea96 (patch)
tree2157f8281cd9bc33a6984455c4831c397d2bd30c /Libraries/LibLine
parent15f4043a7a80f52c0fa05c4e69771e758464cd20 (diff)
downloadserenity-fdfda6dec20101013bb33633e657f06ef2a1ea96.zip
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<int> StringType::to_int() const
Diffstat (limited to 'Libraries/LibLine')
-rw-r--r--Libraries/LibLine/Editor.cpp13
1 files changed, 8 insertions, 5 deletions
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<size_t, 2> 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 };