From e81d9d49145e432d917eea3a70d2ae74dcad1d89 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 30 Dec 2015 11:55:28 +0000 Subject: Vendor import of stripped lldb trunk r256633: https://llvm.org/svn/llvm-project/lldb/trunk@256633 --- source/Utility/StringExtractor.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source/Utility/StringExtractor.cpp') diff --git a/source/Utility/StringExtractor.cpp b/source/Utility/StringExtractor.cpp index 6302c033c0c1..ae92704668fc 100644 --- a/source/Utility/StringExtractor.cpp +++ b/source/Utility/StringExtractor.cpp @@ -120,19 +120,30 @@ StringExtractor::DecodeHexU8() //---------------------------------------------------------------------- // Extract an unsigned character from two hex ASCII chars in the packet -// string +// string, or return fail_value on failure //---------------------------------------------------------------------- uint8_t StringExtractor::GetHexU8 (uint8_t fail_value, bool set_eof_on_fail) +{ + // On success, fail_value will be overwritten with the next + // character in the stream + GetHexU8Ex(fail_value, set_eof_on_fail); + return fail_value; +} + +bool +StringExtractor::GetHexU8Ex (uint8_t& ch, bool set_eof_on_fail) { int byte = DecodeHexU8(); if (byte == -1) { if (set_eof_on_fail || m_index >= m_packet.size()) m_index = UINT64_MAX; - return fail_value; + // ch should not be changed in case of failure + return false; } - return (uint8_t)byte; + ch = (uint8_t)byte; + return true; } uint32_t -- cgit v1.2.3