From ae641886fd11a593ab854f87a8ec6fb8f35b9f3e Mon Sep 17 00:00:00 2001 From: zv0n Date: Mon, 11 Apr 2022 09:02:00 +0200 Subject: [PATCH] Fix Tao --- CMakeLists.txt | 2 ++ restaurants/tao.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5a4aa5..439ebe4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ find_library(Restbed restbed find_library(Curl curl PATHS /usr/lib) +set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") + project(LunchRest) list(APPEND Restaurants diff --git a/restaurants/tao.cpp b/restaurants/tao.cpp index 642d854..aebb75c 100644 --- a/restaurants/tao.cpp +++ b/restaurants/tao.cpp @@ -10,6 +10,9 @@ std::pair getPricePosFromText(const std::string &text) { price_pos = possible_price; possible_price = text.find('k', possible_price + 1); } + if(price_pos == 0 || price_pos == std::string::npos) { + return {-1, -1}; + } auto end_pos = price_pos; price_pos -= 1; while (text[price_pos] >= '0' && text[price_pos] <= '9') { @@ -57,6 +60,10 @@ void LunchRest::TaoRestaurant::parse() { if (!texts.empty()) { auto text = nodeToText(texts[0]); auto price_positions = getPricePosFromText(text); + if(price_positions.first == (size_t)-1) { + week_meals.emplace_back(false, text, "", 0); + continue; + } auto end_pos = getEndOfTextPos(text, price_positions.first); week_meals.emplace_back( false, text.substr(0, end_pos), "", @@ -71,6 +78,9 @@ void LunchRest::TaoRestaurant::parse() { auto text = nodeToText(texts[0]); auto day = nodeToText(days[0]); auto price_positions = getPricePosFromText(text); + if(price_positions.first == (size_t)-1) { + continue; + } auto end_pos = getEndOfTextPos(text, price_positions.first); int cur_day = 0;