move convert_digit from fallback to common

It's not required as part of fallback functions any more.
This commit is contained in:
David Adam
2016-05-16 21:30:31 +00:00
parent db18449f4c
commit 7c2c516353
4 changed files with 20 additions and 21 deletions

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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 $*/

View File

@@ -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 <=