diff --git a/repos/base/include/util/string.h b/repos/base/include/util/string.h index 683070132e..f82fbabacb 100644 --- a/repos/base/include/util/string.h +++ b/repos/base/include/util/string.h @@ -459,20 +459,21 @@ namespace Genode { /** - * Read signed long value from string + * Read signed value from string * * \return number of consumed characters */ - inline size_t ascii_to(const char *s, long &result) + template + inline size_t ascii_to_signed(const char *s, T &result) { - int i = 0; + size_t i = 0; /* read sign */ int sign = (*s == '-') ? -1 : 1; if (*s == '-' || *s == '+') { s++; i++; } - unsigned long value = 0; + T value = 0; size_t const j = ascii_to_unsigned(s, value, 0); @@ -484,6 +485,28 @@ namespace Genode { } + /** + * Read signed long value from string + * + * \return number of consumed characters + */ + inline size_t ascii_to(const char *s, long &result) + { + return ascii_to_signed(s, result); + } + + + /** + * Read signed integer value from string + * + * \return number of consumed characters + */ + inline size_t ascii_to(const char *s, int &result) + { + return ascii_to_signed(s, result); + } + + /** * Read 'Number_of_bytes' value from string and handle the size suffixes *