From be20a78ab01b924fc1261ff3c71361feb440e592 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 3 Oct 2021 09:01:14 +0200 Subject: xv: fix missing search results, incorrect title to thumbnail matches --- src/StringUtils.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/StringUtils.cpp') diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 6a8d3f2..5706499 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -171,6 +171,31 @@ namespace QuickMedia { return true; } + bool to_num_hex(const char *str, size_t size, int &num) { + size_t i = 0; + const bool is_negative = size > 0 && str[0] == '-'; + if(is_negative) + i = 1; + + num = 0; + for(; i < size; ++i) { + const signed char c = str[i]; + if(c - '0' <= 9) + num = (num << 4) | (c - '0'); + else if(c - 'a' <= 'f' - 'a') + num = (num << 4) | (10 + (c - 'a')); + else if(c - 'A' <= 'F' - 'A') + num = (num << 4) | (10 + (c - 'A')); + else + return false; + } + + if(is_negative) + num = -num; + + return true; + } + // Returns relative time as a string (approximation) std::string seconds_to_relative_time_str(time_t seconds) { seconds = std::max(0L, seconds); -- cgit v1.2.3