diff options
author | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2016-05-16 21:30:31 +0000 |
---|---|---|
committer | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2016-05-18 22:39:20 +0000 |
commit | 7c2c516353bbf6fae20fb5ec8fba373cf70d3aba (patch) | |
tree | 0eb7f6f231bca8b4eec432ceabf4da7d624df0ab | |
parent | db18449f4cdc190c74a2ba3228fbd1e0ca467154 (diff) |
move convert_digit from fallback to common
It's not required as part of fallback functions any more.
-rw-r--r-- | src/common.cpp | 16 | ||||
-rw-r--r-- | src/common.h | 4 | ||||
-rw-r--r-- | src/fallback.cpp | 16 | ||||
-rw-r--r-- | src/fallback.h | 5 |
4 files changed, 20 insertions, 21 deletions
diff --git a/src/common.cpp b/src/common.cpp index aa27c537..7bd90915 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1919,3 +1919,19 @@ wchar_t **make_null_terminated_array(const wcstring_list_t &lst) { char **make_null_terminated_array(const std::vector<std::string> &lst) { return make_null_terminated_array_helper(lst); } + +long convert_digit(wchar_t d, int base) { + long res = -1; + if ((d <= L'9') && (d >= L'0')) { + res = d - L'0'; + } else if ((d <= L'z') && (d >= L'a')) { + res = d + 10 - L'a'; + } else if ((d <= L'Z') && (d >= L'A')) { + res = d + 10 - L'A'; + } + if (res >= base) { + res = -1; + } + + return res; +} diff --git a/src/common.h b/src/common.h index ea0805f0..e59dfc0e 100644 --- a/src/common.h +++ b/src/common.h @@ -765,4 +765,8 @@ extern "C" { __attribute__((noinline)) void debug_thread_error(void); } +/// Converts from wide char to digit in the specified base. If d is not a valid digit in the +/// specified base, return -1. +long convert_digit(wchar_t d, int base); + #endif diff --git a/src/fallback.cpp b/src/fallback.cpp index 74635acc..7a829124 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -161,22 +161,6 @@ wchar_t *wcsndup(const wchar_t *in, size_t c) { } #endif -long convert_digit(wchar_t d, int base) { - long res = -1; - if ((d <= L'9') && (d >= L'0')) { - res = d - L'0'; - } else if ((d <= L'z') && (d >= L'a')) { - res = d + 10 - L'a'; - } else if ((d <= L'Z') && (d >= L'A')) { - res = d + 10 - L'A'; - } - if (res >= base) { - res = -1; - } - - return res; -} - #ifndef HAVE_WCSLCAT /*$OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $*/ diff --git a/src/fallback.h b/src/fallback.h index 97f49523..b28e7b17 100644 --- a/src/fallback.h +++ b/src/fallback.h @@ -76,11 +76,6 @@ int wcsncasecmp_use_weak(const wchar_t *s1, const wchar_t *s2, size_t n); wchar_t *wcsndup(const wchar_t *in, size_t c); #endif -/// Converts from wide char to digit in the specified base. If d is not a valid digit in the -/// specified base, return -1. This is a helper function for wcstol, but it is useful itself, so it -/// is exported. -long convert_digit(wchar_t d, int base); - #ifndef HAVE_WCSLCAT /// Appends src to string dst of size siz (unlike wcsncat, siz is the full size of dst, not space /// left). At most siz-1 characters will be copied. Always NUL terminates (unless siz <= |