added the endptr parameter to various string to number conversion functions

This commit is contained in:
hyung-hwan 2017-12-18 07:20:02 +00:00
parent 42ecad1e38
commit 0c8608f81b
12 changed files with 415 additions and 225 deletions

View File

@ -637,7 +637,7 @@ static int comparg (int argc, qse_char_t* argv[], struct arg_t* arg)
case QSE_T('m'): case QSE_T('m'):
{ {
arg->memlimit = qse_strtoulong (opt.arg, 10); arg->memlimit = qse_strtoulong (opt.arg, 10, QSE_NULL);
break; break;
} }
@ -650,7 +650,7 @@ static int comparg (int argc, qse_char_t* argv[], struct arg_t* arg)
#if defined(QSE_BUILD_DEBUG) #if defined(QSE_BUILD_DEBUG)
case QSE_T('X'): case QSE_T('X'):
{ {
arg->failmalloc = qse_strtoulong (opt.arg, 10); arg->failmalloc = qse_strtoulong (opt.arg, 10, QSE_NULL);
break; break;
} }
#endif #endif

View File

@ -1188,7 +1188,7 @@ static int get_intercept (const qse_xli_str_t* v)
static int get_integer (const qse_xli_str_t* v) static int get_integer (const qse_xli_str_t* v)
{ {
/* TODO: be more strict */ /* TODO: be more strict */
return qse_strxtoi (v->ptr, v->len, 10); return qse_strxtoi (v->ptr, v->len, 10, QSE_NULL);
} }
static int parse_dns_query_types (qse_httpd_t* httpd, const qse_xli_str_t* str) static int parse_dns_query_types (qse_httpd_t* httpd, const qse_xli_str_t* str)
@ -2046,7 +2046,7 @@ static qse_httpd_server_t* attach_server (qse_httpd_t* httpd, int num, qse_xli_l
else else
{ {
unsigned int v; unsigned int v;
v = qse_strtoui (((qse_xli_str_t*)pair->val)->ptr, 10); v = qse_strtoui (((qse_xli_str_t*)pair->val)->ptr, 10, QSE_NULL);
if (v <= 0) v = 256; if (v <= 0) v = 256;
dope.backlog_size = v; dope.backlog_size = v;
} }
@ -2409,7 +2409,7 @@ static void set_limit (qse_httpd_t* httpd, const qse_char_t* name, int what)
if (qse_strxcmp (str, len, QSE_T("unlimited")) == 0) if (qse_strxcmp (str, len, QSE_T("unlimited")) == 0)
lim.rlim_cur = RLIM_INFINITY; lim.rlim_cur = RLIM_INFINITY;
else else
lim.rlim_cur = qse_strtoui (((qse_xli_str_t*)pair->val)->ptr, 10); lim.rlim_cur = qse_strtoui (((qse_xli_str_t*)pair->val)->ptr, 10, QSE_NULL);
if (setrlimit (what, &lim) <= -1) if (setrlimit (what, &lim) <= -1)
{ {
/* TODO: warning */ /* TODO: warning */

View File

@ -963,7 +963,7 @@ static int httpd_main (int argc, qse_char_t* argv[])
signal (SIGPIPE, SIG_IGN); signal (SIGPIPE, SIG_IGN);
#endif #endif
if (init_ursd (&ursd, qse_strtoi(argv[2], 10), argv[1], argv[3]) <= -1) goto oops; if (init_ursd (&ursd, qse_strtoi(argv[2], 10, QSE_NULL), argv[1], argv[3]) <= -1) goto oops;
ursd_inited = 1; ursd_inited = 1;
while (!g_stop_requested) while (!g_stop_requested)

View File

@ -362,7 +362,7 @@ static int handle_args (int argc, qse_char_t* argv[])
#endif #endif
case QSE_T('m'): case QSE_T('m'):
g_memlimit = qse_strtoulong (opt.arg, 10); g_memlimit = qse_strtoulong (opt.arg, 10, QSE_NULL);
break; break;
case QSE_T('w'): case QSE_T('w'):
@ -371,7 +371,7 @@ static int handle_args (int argc, qse_char_t* argv[])
#if defined(QSE_BUILD_DEBUG) #if defined(QSE_BUILD_DEBUG)
case QSE_T('X'): case QSE_T('X'):
g_failmalloc = qse_strtoulong (opt.arg, 10); g_failmalloc = qse_strtoulong (opt.arg, 10, QSE_NULL);
break; break;
#endif #endif

View File

@ -296,12 +296,12 @@ static int handle_args (int argc, qse_char_t* argv[])
break; break;
case QSE_T('m'): case QSE_T('m'):
g_memlimit = qse_strtoulong (opt.arg, 10); g_memlimit = qse_strtoulong (opt.arg, 10, QSE_NULL);
break; break;
#if defined(QSE_BUILD_DEBUG) #if defined(QSE_BUILD_DEBUG)
case QSE_T('X'): case QSE_T('X'):
g_failmalloc = qse_strtoulong (opt.arg, 10); g_failmalloc = qse_strtoulong (opt.arg, 10, QSE_NULL);
break; break;
#endif #endif

View File

@ -167,7 +167,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
(c>=QSE_T('a') && c<=QSE_T('z'))? ((c-QSE_T('a')+10<base)? (c-QSE_T('a')+10): base): base) (c>=QSE_T('a') && c<=QSE_T('z'))? ((c-QSE_T('a')+10<base)? (c-QSE_T('a')+10): base): base)
/* qse_strtonum (const qse_char_t* nptr, qse_char_t** endptr, int base) */ /* qse_strtonum (const qse_char_t* nptr, qse_char_t** endptr, int base) */
#define QSE_STRTONUM(value,nptr,endptr,base) do {\ #define QSE_STRTONUM(value,nptr,endptr,base,allowneg) do {\
int __ston_f = 0, __ston_v; \ int __ston_f = 0, __ston_v; \
const qse_char_t* __ston_ptr = nptr; \ const qse_char_t* __ston_ptr = nptr; \
int __ston_base = base; \ int __ston_base = base; \
@ -175,7 +175,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
qse_char_t __ston_c = *__ston_ptr; \ qse_char_t __ston_c = *__ston_ptr; \
if (__ston_c == QSE_T(' ') || \ if (__ston_c == QSE_T(' ') || \
__ston_c == QSE_T('\t')) { __ston_ptr++; continue; } \ __ston_c == QSE_T('\t')) { __ston_ptr++; continue; } \
else if (__ston_c == QSE_T('-')) { __ston_f++; __ston_ptr++; } \ else if ((allowneg) && __ston_c == QSE_T('-')) { __ston_f++; __ston_ptr++; } \
else if (__ston_c == QSE_T('+')) { __ston_ptr++; } \ else if (__ston_c == QSE_T('+')) { __ston_ptr++; } \
break; \ break; \
} \ } \
@ -194,7 +194,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
} while(0) } while(0)
/* qse_strxtonum (const qse_char_t* nptr, qse_size_t len, qse_char_char** endptr, int base) */ /* qse_strxtonum (const qse_char_t* nptr, qse_size_t len, qse_char_char** endptr, int base) */
#define QSE_STRXTONUM(value,nptr,len,endptr,base) do {\ #define QSE_STRXTONUM(value,nptr,len,endptr,base,allowneg) do {\
int __ston_f = 0, __ston_v; \ int __ston_f = 0, __ston_v; \
const qse_char_t* __ston_ptr = nptr; \ const qse_char_t* __ston_ptr = nptr; \
const qse_char_t* __ston_end = __ston_ptr + len; \ const qse_char_t* __ston_end = __ston_ptr + len; \
@ -204,7 +204,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
if (__ston_c == QSE_T(' ') || __ston_c == QSE_T('\t')) { \ if (__ston_c == QSE_T(' ') || __ston_c == QSE_T('\t')) { \
__ston_ptr++; continue; \ __ston_ptr++; continue; \
} \ } \
else if (__ston_c == QSE_T('-')) { __ston_f++; __ston_ptr++; } \ else if (allowneg && __ston_c == QSE_T('-')) { __ston_f++; __ston_ptr++; } \
else if (__ston_c == QSE_T('+')) { __ston_ptr++; } \ else if (__ston_c == QSE_T('+')) { __ston_ptr++; } \
break; \ break; \
} \ } \
@ -229,7 +229,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
(c>=QSE_MT('a') && c<=QSE_MT('z'))? ((c-QSE_MT('a')+10<base)? (c-QSE_MT('a')+10): base): base) (c>=QSE_MT('a') && c<=QSE_MT('z'))? ((c-QSE_MT('a')+10<base)? (c-QSE_MT('a')+10): base): base)
/* qse_strtonum (const qse_mchar_t* nptr, qse_mchar_t** endptr, int base) */ /* qse_strtonum (const qse_mchar_t* nptr, qse_mchar_t** endptr, int base) */
#define QSE_MBSTONUM(value,nptr,endptr,base) do {\ #define QSE_MBSTONUM(value,nptr,endptr,base,allowneg) do {\
int __ston_f = 0, __ston_v; \ int __ston_f = 0, __ston_v; \
const qse_mchar_t* __ston_ptr = nptr; \ const qse_mchar_t* __ston_ptr = nptr; \
int __ston_base = base; \ int __ston_base = base; \
@ -237,7 +237,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
qse_mchar_t __ston_c = *__ston_ptr; \ qse_mchar_t __ston_c = *__ston_ptr; \
if (__ston_c == QSE_MT(' ') || \ if (__ston_c == QSE_MT(' ') || \
__ston_c == QSE_MT('\t')) { __ston_ptr++; continue; } \ __ston_c == QSE_MT('\t')) { __ston_ptr++; continue; } \
else if (__ston_c == QSE_MT('-')) { __ston_f++; __ston_ptr++; } \ else if ((allowneg) && __ston_c == QSE_MT('-')) { __ston_f++; __ston_ptr++; } \
else if (__ston_c == QSE_MT('+')) { __ston_ptr++; } \ else if (__ston_c == QSE_MT('+')) { __ston_ptr++; } \
break; \ break; \
} \ } \
@ -256,7 +256,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
} while(0) } while(0)
/* qse_strxtonum (const qse_mchar_t* nptr, qse_size_t len, qse_mchar_t** endptr, int base) */ /* qse_strxtonum (const qse_mchar_t* nptr, qse_size_t len, qse_mchar_t** endptr, int base) */
#define QSE_MBSXTONUM(value,nptr,len,endptr,base) do {\ #define QSE_MBSXTONUM(value,nptr,len,endptr,base,allowneg) do {\
int __ston_f = 0, __ston_v; \ int __ston_f = 0, __ston_v; \
const qse_mchar_t* __ston_ptr = nptr; \ const qse_mchar_t* __ston_ptr = nptr; \
const qse_mchar_t* __ston_end = __ston_ptr + len; \ const qse_mchar_t* __ston_end = __ston_ptr + len; \
@ -266,7 +266,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
if (__ston_c == QSE_MT(' ') || __ston_c == QSE_MT('\t')) { \ if (__ston_c == QSE_MT(' ') || __ston_c == QSE_MT('\t')) { \
__ston_ptr++; continue; \ __ston_ptr++; continue; \
} \ } \
else if (__ston_c == QSE_MT('-')) { __ston_f++; __ston_ptr++; } \ else if ((allowneg) && __ston_c == QSE_MT('-')) { __ston_f++; __ston_ptr++; } \
else if (__ston_c == QSE_MT('+')) { __ston_ptr++; } \ else if (__ston_c == QSE_MT('+')) { __ston_ptr++; } \
break; \ break; \
} \ } \
@ -291,7 +291,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
(c>=QSE_WT('a') && c<=QSE_WT('z'))? ((c-QSE_WT('a')+10<base)? (c-QSE_WT('a')+10): base): base) (c>=QSE_WT('a') && c<=QSE_WT('z'))? ((c-QSE_WT('a')+10<base)? (c-QSE_WT('a')+10): base): base)
/* qse_strtonum (const qse_wchar_t* nptr, qse_wchar_t** endptr, int base) */ /* qse_strtonum (const qse_wchar_t* nptr, qse_wchar_t** endptr, int base) */
#define QSE_WCSTONUM(value,nptr,endptr,base) do {\ #define QSE_WCSTONUM(value,nptr,endptr,base,allowneg) do {\
int __ston_f = 0, __ston_v; \ int __ston_f = 0, __ston_v; \
const qse_wchar_t* __ston_ptr = nptr; \ const qse_wchar_t* __ston_ptr = nptr; \
int __ston_base = base; \ int __ston_base = base; \
@ -299,7 +299,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
qse_wchar_t __ston_c = *__ston_ptr; \ qse_wchar_t __ston_c = *__ston_ptr; \
if (__ston_c == QSE_WT(' ') || \ if (__ston_c == QSE_WT(' ') || \
__ston_c == QSE_WT('\t')) { __ston_ptr++; continue; } \ __ston_c == QSE_WT('\t')) { __ston_ptr++; continue; } \
else if (__ston_c == QSE_WT('-')) { __ston_f++; __ston_ptr++; } \ else if ((allowneg) && __ston_c == QSE_WT('-')) { __ston_f++; __ston_ptr++; } \
else if (__ston_c == QSE_WT('+')) { __ston_ptr++; } \ else if (__ston_c == QSE_WT('+')) { __ston_ptr++; } \
break; \ break; \
} \ } \
@ -318,7 +318,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
} while(0) } while(0)
/* qse_strxtonum (const qse_wchar_t* nptr, qse_size_t len, qse_wchar_t** endptr, int base) */ /* qse_strxtonum (const qse_wchar_t* nptr, qse_size_t len, qse_wchar_t** endptr, int base) */
#define QSE_WCSXTONUM(value,nptr,len,endptr,base) do {\ #define QSE_WCSXTONUM(value,nptr,len,endptr,base,allowneg) do {\
int __ston_f = 0, __ston_v; \ int __ston_f = 0, __ston_v; \
const qse_wchar_t* __ston_ptr = nptr; \ const qse_wchar_t* __ston_ptr = nptr; \
const qse_wchar_t* __ston_end = __ston_ptr + len; \ const qse_wchar_t* __ston_end = __ston_ptr + len; \
@ -328,7 +328,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
if (__ston_c == QSE_WT(' ') || __ston_c == QSE_WT('\t')) { \ if (__ston_c == QSE_WT(' ') || __ston_c == QSE_WT('\t')) { \
__ston_ptr++; continue; \ __ston_ptr++; continue; \
} \ } \
else if (__ston_c == QSE_WT('-')) { __ston_f++; __ston_ptr++; } \ else if ((allowneg) && __ston_c == QSE_WT('-')) { __ston_f++; __ston_ptr++; } \
else if (__ston_c == QSE_WT('+')) { __ston_ptr++; } \ else if (__ston_c == QSE_WT('+')) { __ston_ptr++; } \
break; \ break; \
} \ } \
@ -2052,226 +2052,332 @@ QSE_EXPORT qse_wchar_t* qse_wcsxrpbrk (
* string conversion * string conversion
*/ */
QSE_EXPORT int qse_mbstoi ( QSE_EXPORT int qse_mbstoi (
const qse_mchar_t* str, const qse_mchar_t* str,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT long qse_mbstol ( QSE_EXPORT long qse_mbstol (
const qse_mchar_t* str, const qse_mchar_t* str,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT unsigned int qse_mbstoui ( QSE_EXPORT unsigned int qse_mbstoui (
const qse_mchar_t* str, const qse_mchar_t* str,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT unsigned long qse_mbstoul ( QSE_EXPORT unsigned long qse_mbstoul (
const qse_mchar_t* str, const qse_mchar_t* str,
int base int base,
const qse_mchar_t** end
); );
/* ----- */
QSE_EXPORT int qse_mbsxtoi ( QSE_EXPORT int qse_mbsxtoi (
const qse_mchar_t* str, const qse_mchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT long qse_mbsxtol ( QSE_EXPORT long qse_mbsxtol (
const qse_mchar_t* str, const qse_mchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT unsigned int qse_mbsxtoui ( QSE_EXPORT unsigned int qse_mbsxtoui (
const qse_mchar_t* str, const qse_mchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT unsigned long qse_mbsxtoul ( QSE_EXPORT unsigned long qse_mbsxtoul (
const qse_mchar_t* str, const qse_mchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_mchar_t** end
); );
/* ----- */
QSE_EXPORT qse_int_t qse_mbstoint ( QSE_EXPORT qse_int_t qse_mbstoint (
const qse_mchar_t* str, const qse_mchar_t* str,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT qse_long_t qse_mbstolong ( QSE_EXPORT qse_long_t qse_mbstolong (
const qse_mchar_t* str, const qse_mchar_t* str,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT qse_intmax_t qse_mbstointmax (
const qse_mchar_t* str,
int base,
const qse_mchar_t** end
);
/* ----- */
QSE_EXPORT qse_uint_t qse_mbstouint ( QSE_EXPORT qse_uint_t qse_mbstouint (
const qse_mchar_t* str, const qse_mchar_t* str,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT qse_ulong_t qse_mbstoulong ( QSE_EXPORT qse_ulong_t qse_mbstoulong (
const qse_mchar_t* str, const qse_mchar_t* str,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT qse_uintmax_t qse_mbstouintmax (
const qse_mchar_t* str,
int base,
const qse_mchar_t** end
);
/* ----- */
QSE_EXPORT qse_int_t qse_mbsxtoint ( QSE_EXPORT qse_int_t qse_mbsxtoint (
const qse_mchar_t* str, const qse_mchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT qse_long_t qse_mbsxtolong ( QSE_EXPORT qse_long_t qse_mbsxtolong (
const qse_mchar_t* str, const qse_mchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT qse_intmax_t qse_mbsxtointmax (
const qse_mchar_t* str,
qse_size_t len,
int base,
const qse_mchar_t** end
);
/* ----- */
QSE_EXPORT qse_uint_t qse_mbsxtouint ( QSE_EXPORT qse_uint_t qse_mbsxtouint (
const qse_mchar_t* str, const qse_mchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT qse_ulong_t qse_mbsxtoulong ( QSE_EXPORT qse_ulong_t qse_mbsxtoulong (
const qse_mchar_t* str, const qse_mchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_mchar_t** end
); );
QSE_EXPORT qse_uintmax_t qse_mbsxtouintmax (
const qse_mchar_t* str,
qse_size_t len,
int base,
const qse_mchar_t** end
);
/* ------------------------------------------------------ */
QSE_EXPORT int qse_wcstoi ( QSE_EXPORT int qse_wcstoi (
const qse_wchar_t* str, const qse_wchar_t* str,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT long qse_wcstol ( QSE_EXPORT long qse_wcstol (
const qse_wchar_t* str, const qse_wchar_t* str,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT unsigned int qse_wcstoui ( QSE_EXPORT unsigned int qse_wcstoui (
const qse_wchar_t* str, const qse_wchar_t* str,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT unsigned long qse_wcstoul ( QSE_EXPORT unsigned long qse_wcstoul (
const qse_wchar_t* str, const qse_wchar_t* str,
int base int base,
const qse_wchar_t** end
); );
/* ----- */
QSE_EXPORT int qse_wcsxtoi ( QSE_EXPORT int qse_wcsxtoi (
const qse_wchar_t* str, const qse_wchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT long qse_wcsxtol ( QSE_EXPORT long qse_wcsxtol (
const qse_wchar_t* str, const qse_wchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT unsigned int qse_wcsxtoui ( QSE_EXPORT unsigned int qse_wcsxtoui (
const qse_wchar_t* str, const qse_wchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT unsigned long qse_wcsxtoul ( QSE_EXPORT unsigned long qse_wcsxtoul (
const qse_wchar_t* str, const qse_wchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_wchar_t** end
); );
/* ----- */
QSE_EXPORT qse_int_t qse_wcstoint ( QSE_EXPORT qse_int_t qse_wcstoint (
const qse_wchar_t* str, const qse_wchar_t* str,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT qse_long_t qse_wcstolong ( QSE_EXPORT qse_long_t qse_wcstolong (
const qse_wchar_t* str, const qse_wchar_t* str,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT qse_intmax_t qse_wcstointmax (
const qse_wchar_t* str,
int base,
const qse_wchar_t** end
);
/* ----- */
QSE_EXPORT qse_uint_t qse_wcstouint ( QSE_EXPORT qse_uint_t qse_wcstouint (
const qse_wchar_t* str, const qse_wchar_t* str,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT qse_ulong_t qse_wcstoulong ( QSE_EXPORT qse_ulong_t qse_wcstoulong (
const qse_wchar_t* str, const qse_wchar_t* str,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT qse_uintmax_t qse_wcstouintmax (
const qse_wchar_t* str,
int base,
const qse_wchar_t** end
);
/* ----- */
QSE_EXPORT qse_int_t qse_wcsxtoint ( QSE_EXPORT qse_int_t qse_wcsxtoint (
const qse_wchar_t* str, const qse_wchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT qse_long_t qse_wcsxtolong ( QSE_EXPORT qse_long_t qse_wcsxtolong (
const qse_wchar_t* str, const qse_wchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT qse_intmax_t qse_wcsxtointmax (
const qse_wchar_t* str,
qse_size_t len,
int base,
const qse_wchar_t** end
);
/* ----- */
QSE_EXPORT qse_uint_t qse_wcsxtouint ( QSE_EXPORT qse_uint_t qse_wcsxtouint (
const qse_wchar_t* str, const qse_wchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_wchar_t** end
); );
QSE_EXPORT qse_ulong_t qse_wcsxtoulong ( QSE_EXPORT qse_ulong_t qse_wcsxtoulong (
const qse_wchar_t* str, const qse_wchar_t* str,
qse_size_t len, qse_size_t len,
int base int base,
const qse_wchar_t** end
);
QSE_EXPORT qse_uintmax_t qse_wcsxtouintmax (
const qse_wchar_t* str,
qse_size_t len,
int base,
const qse_wchar_t** end
); );
#if defined(QSE_CHAR_IS_MCHAR) #if defined(QSE_CHAR_IS_MCHAR)
# define qse_strtoi(str,base) qse_mbstoi(str,base) # define qse_strtoi(str,base,end) qse_mbstoi(str,base,end)
# define qse_strtol(str,base) qse_mbstol(str,base) # define qse_strtol(str,base,end) qse_mbstol(str,base,end)
# define qse_strtoui(str,base) qse_mbstoui(str,base) # define qse_strtoui(str,base,end) qse_mbstoui(str,base,end)
# define qse_strtoul(str,base) qse_mbstoul(str,base) # define qse_strtoul(str,base,end) qse_mbstoul(str,base,end)
/* ----- */
# define qse_strxtoi(str,len,base) qse_mbsxtoi(str,len,base) # define qse_strxtoi(str,len,base,end) qse_mbsxtoi(str,len,base,end)
# define qse_strxtol(str,len,base) qse_mbsxtol(str,len,base) # define qse_strxtol(str,len,base,end) qse_mbsxtol(str,len,base,end)
# define qse_strxtoui(str,len,base) qse_mbsxtoui(str,len,base) # define qse_strxtoui(str,len,base,end) qse_mbsxtoui(str,len,base,end)
# define qse_strxtoul(str,len,base) qse_mbsxtoul(str,len,base) # define qse_strxtoul(str,len,base,end) qse_mbsxtoul(str,len,base,end)
/* ----- */
# define qse_strtoint(str,base) qse_mbstoint(str,base) # define qse_strtoint(str,base,end) qse_mbstoint(str,base,end)
# define qse_strtolong(str,base) qse_mbstolong(str,base) # define qse_strtolong(str,base,end) qse_mbstolong(str,base,end)
# define qse_strtouint(str,base) qse_mbstouint(str,base) # define qse_strtointmax(str,base,end) qse_mbstointmax(str,base,end)
# define qse_strtoulong(str,base) qse_mbstoulong(str,base) /* ----- */
# define qse_strtouint(str,base,end) qse_mbstouint(str,base,end)
# define qse_strxtoint(str,len,base) qse_mbsxtoint(str,len,base) # define qse_strtoulong(str,base,end) qse_mbstoulong(str,base,end)
# define qse_strxtolong(str,len,base) qse_mbsxtolong(str,len,base) # define qse_strtouintmax(str,base,end) qse_mbstouintmax(str,base,end)
# define qse_strxtouint(str,len,base) qse_mbsxtouint(str,len,base) /* ----- */
# define qse_strxtoulong(str,len,base) qse_mbsxtoulong(str,len,base) # define qse_strxtoint(str,len,base,end) qse_mbsxtoint(str,len,base,end)
# define qse_strxtolong(str,len,base,end) qse_mbsxtolong(str,len,base,end)
# define qse_strxtointmax(str,len,base,end) qse_mbsxtointmax(str,len,base,end)
/* ----- */
# define qse_strxtouint(str,len,base,end) qse_mbsxtouint(str,len,base,end)
# define qse_strxtoulong(str,len,base,end) qse_mbsxtoulong(str,len,base,end)
# define qse_strxtouintmax(str,len,base,end) qse_mbsxtouintmax(str,len,base,end)
#else #else
# define qse_strtoi(str,base) qse_wcstoi(str,base) # define qse_strtoi(str,base,end) qse_wcstoi(str,base,end)
# define qse_strtol(str,base) qse_wcstol(str,base) # define qse_strtol(str,base,end) qse_wcstol(str,base,end)
# define qse_strtoui(str,base) qse_wcstoui(str,base) # define qse_strtoui(str,base,end) qse_wcstoui(str,base,end)
# define qse_strtoul(str,base) qse_wcstoul(str,base) # define qse_strtoul(str,base,end) qse_wcstoul(str,base,end)
/* ----- */
# define qse_strxtoi(str,len,base) qse_wcsxtoi(str,len,base) # define qse_strxtoi(str,len,base,end) qse_wcsxtoi(str,len,base,end)
# define qse_strxtol(str,len,base) qse_wcsxtol(str,len,base) # define qse_strxtol(str,len,base,end) qse_wcsxtol(str,len,base,end)
# define qse_strxtoui(str,len,base) qse_wcsxtoui(str,len,base) # define qse_strxtoui(str,len,base,end) qse_wcsxtoui(str,len,base,end)
# define qse_strxtoul(str,len,base) qse_wcsxtoul(str,len,base) # define qse_strxtoul(str,len,base,end) qse_wcsxtoul(str,len,base,end)
/* ----- */
# define qse_strtoint(str,base) qse_wcstoint(str,base) # define qse_strtoint(str,base,end) qse_wcstoint(str,base,end)
# define qse_strtolong(str,base) qse_wcstolong(str,base) # define qse_strtolong(str,base,end) qse_wcstolong(str,base,end)
# define qse_strtouint(str,base) qse_wcstouint(str,base) # define qse_strtointmax(str,base,end) qse_wcstointmax(str,base,end)
# define qse_strtoulong(str,base) qse_wcstoulong(str,base) /* ----- */
# define qse_strtouint(str,base,end) qse_wcstouint(str,base,end)
# define qse_strxtoint(str,len,base) qse_wcsxtoint(str,len,base) # define qse_strtoulong(str,base,end) qse_wcstoulong(str,base,end)
# define qse_strxtolong(str,len,base) qse_wcsxtolong(str,len,base) # define qse_strtouintmax(str,base,end) qse_wcstouintmax(str,base,end)
# define qse_strxtouint(str,len,base) qse_wcsxtouint(str,len,base) /* ----- */
# define qse_strxtoulong(str,len,base) qse_wcsxtoulong(str,len,base) # define qse_strxtoint(str,len,base,end) qse_wcsxtoint(str,len,base,end)
# define qse_strxtolong(str,len,base,end) qse_wcsxtolong(str,len,base,end)
# define qse_strxtointmax(str,len,base,end) qse_wcsxtointmax(str,len,base,end)
/* ----- */
# define qse_strxtouint(str,len,base,end) qse_wcsxtouint(str,len,base,end)
# define qse_strxtoulong(str,len,base,end) qse_wcsxtoulong(str,len,base,end)
# define qse_strxtouintmax(str,len,base,end) qse_wcsxtouintmax(str,len,base,end)
#endif #endif
@ -2461,12 +2567,12 @@ QSE_EXPORT qse_size_t qse_wcsrev (
qse_wchar_t* str qse_wchar_t* str
); );
QSE_EXPORT qse_size_t qse_mbsxrev ( QSE_EXPORT qse_size_t qse_mbsxrev (
qse_mchar_t* str, qse_mchar_t* str,
qse_size_t len qse_size_t len
); );
QSE_EXPORT qse_size_t qse_wcsxrev ( QSE_EXPORT qse_size_t qse_wcsxrev (
qse_wchar_t* str, qse_wchar_t* str,
qse_size_t len qse_size_t len
); );

View File

@ -32,231 +32,303 @@
/*--------------------------------------------------------------- /*---------------------------------------------------------------
* multi-byte string to number conversion * multi-byte string to number conversion
*---------------------------------------------------------------*/ *---------------------------------------------------------------*/
int qse_mbstoi (const qse_mchar_t* mbs, int base) int qse_mbstoi (const qse_mchar_t* mbs, int base, const qse_mchar_t** end)
{ {
int v; int v;
QSE_MBSTONUM (v, mbs, QSE_NULL, base);
QSE_MBSTONUM (v, mbs, end, base, 1);
return v; return v;
} }
long qse_mbstol (const qse_mchar_t* mbs, int base) long qse_mbstol (const qse_mchar_t* mbs, int base, const qse_mchar_t** end)
{ {
long v; long v;
QSE_MBSTONUM (v, mbs, QSE_NULL, base); QSE_MBSTONUM (v, mbs, end, base, 1);
return v; return v;
} }
unsigned int qse_mbstoui (const qse_mchar_t* mbs, int base) unsigned int qse_mbstoui (const qse_mchar_t* mbs, int base, const qse_mchar_t** end)
{ {
unsigned int v; unsigned int v;
QSE_MBSTONUM (v, mbs, QSE_NULL, base); QSE_MBSTONUM (v, mbs, end, base, 0);
return v; return v;
} }
unsigned long qse_mbstoul (const qse_mchar_t* mbs, int base) unsigned long qse_mbstoul (const qse_mchar_t* mbs, int base, const qse_mchar_t** end)
{ {
unsigned long v; unsigned long v;
QSE_MBSTONUM (v, mbs, QSE_NULL, base); QSE_MBSTONUM (v, mbs, end, base, 0);
return v; return v;
} }
int qse_mbsxtoi (const qse_mchar_t* mbs, qse_size_t len, int base) /* ----- */
int qse_mbsxtoi (const qse_mchar_t* mbs, qse_size_t len, int base, const qse_mchar_t** end)
{ {
int v; int v;
QSE_MBSXTONUM (v, mbs, len, QSE_NULL, base); QSE_MBSXTONUM (v, mbs, len, end, base, 1);
return v; return v;
} }
long qse_mbsxtol (const qse_mchar_t* mbs, qse_size_t len, int base) long qse_mbsxtol (const qse_mchar_t* mbs, qse_size_t len, int base, const qse_mchar_t** end)
{ {
long v; long v;
QSE_MBSXTONUM (v, mbs, len, QSE_NULL, base); QSE_MBSXTONUM (v, mbs, len, end, base, 1);
return v; return v;
} }
unsigned int qse_mbsxtoui (const qse_mchar_t* mbs, qse_size_t len, int base) unsigned int qse_mbsxtoui (const qse_mchar_t* mbs, qse_size_t len, int base, const qse_mchar_t** end)
{ {
unsigned int v; unsigned int v;
QSE_MBSXTONUM (v, mbs, len, QSE_NULL, base); QSE_MBSXTONUM (v, mbs, len, end, base, 0);
return v; return v;
} }
unsigned long qse_mbsxtoul (const qse_mchar_t* mbs, qse_size_t len, int base) unsigned long qse_mbsxtoul (const qse_mchar_t* mbs, qse_size_t len, int base, const qse_mchar_t** end)
{ {
unsigned long v; unsigned long v;
QSE_MBSXTONUM (v, mbs, len, QSE_NULL, base); QSE_MBSXTONUM (v, mbs, len, end, base, 0);
return v; return v;
} }
qse_int_t qse_mbstoint (const qse_mchar_t* mbs, int base) /* ----- */
qse_int_t qse_mbstoint (const qse_mchar_t* mbs, int base, const qse_mchar_t** end)
{ {
qse_int_t v; qse_int_t v;
QSE_MBSTONUM (v, mbs, QSE_NULL, base); QSE_MBSTONUM (v, mbs, end, base, 1);
return v; return v;
} }
qse_long_t qse_mbstolong (const qse_mchar_t* mbs, int base) qse_long_t qse_mbstolong (const qse_mchar_t* mbs, int base, const qse_mchar_t** end)
{ {
qse_long_t v; qse_long_t v;
QSE_MBSTONUM (v, mbs, QSE_NULL, base); QSE_MBSTONUM (v, mbs, end, base, 1);
return v; return v;
} }
qse_uint_t qse_mbstouint (const qse_mchar_t* mbs, int base) qse_intmax_t qse_mbstointmax (const qse_mchar_t* mbs, int base, const qse_mchar_t** end)
{
qse_intmax_t v;
QSE_MBSTONUM (v, mbs, end, base, 1);
return v;
}
/* ----- */
qse_uint_t qse_mbstouint (const qse_mchar_t* mbs, int base, const qse_mchar_t** end)
{ {
qse_uint_t v; qse_uint_t v;
QSE_MBSTONUM (v, mbs, QSE_NULL, base); QSE_MBSTONUM (v, mbs, end, base, 0);
return v; return v;
} }
qse_ulong_t qse_mbstoulong (const qse_mchar_t* mbs, int base) qse_ulong_t qse_mbstoulong (const qse_mchar_t* mbs, int base, const qse_mchar_t** end)
{ {
qse_ulong_t v; qse_ulong_t v;
QSE_MBSTONUM (v, mbs, QSE_NULL, base); QSE_MBSTONUM (v, mbs, end, base, 0);
return v; return v;
} }
qse_int_t qse_mbsxtoint (const qse_mchar_t* mbs, qse_size_t len, int base) qse_uintmax_t qse_mbstouintmax (const qse_mchar_t* mbs, int base, const qse_mchar_t** end)
{
qse_uintmax_t v;
QSE_MBSTONUM (v, mbs, end, base, 0);
return v;
}
/* ----- */
qse_int_t qse_mbsxtoint (const qse_mchar_t* mbs, qse_size_t len, int base, const qse_mchar_t** end)
{ {
qse_int_t v; qse_int_t v;
QSE_MBSXTONUM (v, mbs, len, QSE_NULL, base); QSE_MBSXTONUM (v, mbs, len, end, base, 1);
return v; return v;
} }
qse_long_t qse_mbsxtolong (const qse_mchar_t* mbs, qse_size_t len, int base) qse_long_t qse_mbsxtolong (const qse_mchar_t* mbs, qse_size_t len, int base, const qse_mchar_t** end)
{ {
qse_long_t v; qse_long_t v;
QSE_MBSXTONUM (v, mbs, len, QSE_NULL, base); QSE_MBSXTONUM (v, mbs, len, end, base, 1);
return v; return v;
} }
qse_uint_t qse_mbsxtouint (const qse_mchar_t* mbs, qse_size_t len, int base) qse_intmax_t qse_mbsxtointmax (const qse_mchar_t* mbs, qse_size_t len, int base, const qse_mchar_t** end)
{
qse_intmax_t v;
QSE_MBSXTONUM (v, mbs, len, end, base, 1);
return v;
}
/* ----- */
qse_uint_t qse_mbsxtouint (const qse_mchar_t* mbs, qse_size_t len, int base, const qse_mchar_t** end)
{ {
qse_uint_t v; qse_uint_t v;
QSE_MBSXTONUM (v, mbs, len, QSE_NULL, base); QSE_MBSXTONUM (v, mbs, len, end, base, 0);
return v; return v;
} }
qse_ulong_t qse_mbsxtoulong (const qse_mchar_t* mbs, qse_size_t len, int base) qse_ulong_t qse_mbsxtoulong (const qse_mchar_t* mbs, qse_size_t len, int base, const qse_mchar_t** end)
{ {
qse_ulong_t v; qse_ulong_t v;
QSE_MBSXTONUM (v, mbs, len, QSE_NULL, base); QSE_MBSXTONUM (v, mbs, len, end, base, 0);
return v; return v;
} }
qse_uintmax_t qse_mbsxtouintmax (const qse_mchar_t* mbs, qse_size_t len, int base, const qse_mchar_t** end)
{
qse_uintmax_t v;
QSE_MBSXTONUM (v, mbs, len, end, base, 0);
return v;
}
/*--------------------------------------------------------------- /*---------------------------------------------------------------
* wide string to number conversion * wide string to number conversion
*---------------------------------------------------------------*/ *---------------------------------------------------------------*/
int qse_wcstoi (const qse_wchar_t* wcs, int base) int qse_wcstoi (const qse_wchar_t* wcs, int base, const qse_wchar_t** end)
{ {
int v; int v;
QSE_WCSTONUM (v, wcs, QSE_NULL, base); QSE_WCSTONUM (v, wcs, end, base, 1);
return v; return v;
} }
long qse_wcstol (const qse_wchar_t* wcs, int base) long qse_wcstol (const qse_wchar_t* wcs, int base, const qse_wchar_t** end)
{ {
long v; long v;
QSE_WCSTONUM (v, wcs, QSE_NULL, base); QSE_WCSTONUM (v, wcs, end, base, 1);
return v; return v;
} }
unsigned int qse_wcstoui (const qse_wchar_t* wcs, int base) unsigned int qse_wcstoui (const qse_wchar_t* wcs, int base, const qse_wchar_t** end)
{ {
unsigned int v; unsigned int v;
QSE_WCSTONUM (v, wcs, QSE_NULL, base); QSE_WCSTONUM (v, wcs, end, base, 0);
return v; return v;
} }
unsigned long qse_wcstoul (const qse_wchar_t* wcs, int base) unsigned long qse_wcstoul (const qse_wchar_t* wcs, int base, const qse_wchar_t** end)
{ {
unsigned long v; unsigned long v;
QSE_WCSTONUM (v, wcs, QSE_NULL, base); QSE_WCSTONUM (v, wcs, end, base, 0);
return v; return v;
} }
int qse_wcsxtoi (const qse_wchar_t* wcs, qse_size_t len, int base) /* ----- */
int qse_wcsxtoi (const qse_wchar_t* wcs, qse_size_t len, int base, const qse_wchar_t** end)
{ {
int v; int v;
QSE_WCSXTONUM (v, wcs, len, QSE_NULL, base); QSE_WCSXTONUM (v, wcs, len, end, base, 1);
return v; return v;
} }
long qse_wcsxtol (const qse_wchar_t* wcs, qse_size_t len, int base) long qse_wcsxtol (const qse_wchar_t* wcs, qse_size_t len, int base, const qse_wchar_t** end)
{ {
long v; long v;
QSE_WCSXTONUM (v, wcs, len, QSE_NULL, base); QSE_WCSXTONUM (v, wcs, len, end, base, 1);
return v; return v;
} }
unsigned int qse_wcsxtoui (const qse_wchar_t* wcs, qse_size_t len, int base) unsigned int qse_wcsxtoui (const qse_wchar_t* wcs, qse_size_t len, int base, const qse_wchar_t** end)
{ {
unsigned int v; unsigned int v;
QSE_WCSXTONUM (v, wcs, len, QSE_NULL, base); QSE_WCSXTONUM (v, wcs, len, end, base, 0);
return v; return v;
} }
unsigned long qse_wcsxtoul (const qse_wchar_t* wcs, qse_size_t len, int base) unsigned long qse_wcsxtoul (const qse_wchar_t* wcs, qse_size_t len, int base, const qse_wchar_t** end)
{ {
unsigned long v; unsigned long v;
QSE_WCSXTONUM (v, wcs, len, QSE_NULL, base); QSE_WCSXTONUM (v, wcs, len, end, base, 0);
return v; return v;
} }
qse_int_t qse_wcstoint (const qse_wchar_t* wcs, int base) /* ----- */
qse_int_t qse_wcstoint (const qse_wchar_t* wcs, int base, const qse_wchar_t** end)
{ {
qse_int_t v; qse_int_t v;
QSE_WCSTONUM (v, wcs, QSE_NULL, base); QSE_WCSTONUM (v, wcs, end, base, 1);
return v; return v;
} }
qse_long_t qse_wcstolong (const qse_wchar_t* wcs, int base) qse_long_t qse_wcstolong (const qse_wchar_t* wcs, int base, const qse_wchar_t** end)
{ {
qse_long_t v; qse_long_t v;
QSE_WCSTONUM (v, wcs, QSE_NULL, base); QSE_WCSTONUM (v, wcs, end, base, 1);
return v; return v;
} }
qse_uint_t qse_wcstouint (const qse_wchar_t* wcs, int base) qse_intmax_t qse_wcstointmax (const qse_wchar_t* wcs, int base, const qse_wchar_t** end)
{
qse_intmax_t v;
QSE_WCSTONUM (v, wcs, end, base, 1);
return v;
}
/* ----- */
qse_uint_t qse_wcstouint (const qse_wchar_t* wcs, int base, const qse_wchar_t** end)
{ {
qse_uint_t v; qse_uint_t v;
QSE_WCSTONUM (v, wcs, QSE_NULL, base); QSE_WCSTONUM (v, wcs, end, base, 0);
return v; return v;
} }
qse_ulong_t qse_wcstoulong (const qse_wchar_t* wcs, int base) qse_ulong_t qse_wcstoulong (const qse_wchar_t* wcs, int base, const qse_wchar_t** end)
{ {
qse_ulong_t v; qse_ulong_t v;
QSE_WCSTONUM (v, wcs, QSE_NULL, base); QSE_WCSTONUM (v, wcs, end, base, 0);
return v; return v;
} }
qse_int_t qse_wcsxtoint (const qse_wchar_t* wcs, qse_size_t len, int base) qse_uintmax_t qse_wcstouintmax (const qse_wchar_t* wcs, int base, const qse_wchar_t** end)
{
qse_uintmax_t v;
QSE_WCSTONUM (v, wcs, end, base, 0);
return v;
}
/* ----- */
qse_int_t qse_wcsxtoint (const qse_wchar_t* wcs, qse_size_t len, int base, const qse_wchar_t** end)
{ {
qse_int_t v; qse_int_t v;
QSE_WCSXTONUM (v, wcs, len, QSE_NULL, base); QSE_WCSXTONUM (v, wcs, len, end, base, 1);
return v; return v;
} }
qse_long_t qse_wcsxtolong (const qse_wchar_t* wcs, qse_size_t len, int base) qse_long_t qse_wcsxtolong (const qse_wchar_t* wcs, qse_size_t len, int base, const qse_wchar_t** end)
{ {
qse_long_t v; qse_long_t v;
QSE_WCSXTONUM (v, wcs, len, QSE_NULL, base); QSE_WCSXTONUM (v, wcs, len, end, base, 1);
return v; return v;
} }
qse_uint_t qse_wcsxtouint (const qse_wchar_t* wcs, qse_size_t len, int base) qse_intmax_t qse_wcsxtointmax (const qse_wchar_t* wcs, qse_size_t len, int base, const qse_wchar_t** end)
{
qse_intmax_t v;
QSE_WCSXTONUM (v, wcs, len, end, base, 1);
return v;
}
/* ----- */
qse_uint_t qse_wcsxtouint (const qse_wchar_t* wcs, qse_size_t len, int base, const qse_wchar_t** end)
{ {
qse_uint_t v; qse_uint_t v;
QSE_WCSXTONUM (v, wcs, len, QSE_NULL, base); QSE_WCSXTONUM (v, wcs, len, end, base, 0);
return v; return v;
} }
qse_ulong_t qse_wcsxtoulong (const qse_wchar_t* wcs, qse_size_t len, int base) qse_ulong_t qse_wcsxtoulong (const qse_wchar_t* wcs, qse_size_t len, int base, const qse_wchar_t** end)
{ {
qse_ulong_t v; qse_ulong_t v;
QSE_WCSXTONUM (v, wcs, len, QSE_NULL, base); QSE_WCSXTONUM (v, wcs, len, end, base, 0);
return v;
}
qse_uintmax_t qse_wcsxtouintmax (const qse_wchar_t* wcs, qse_size_t len, int base, const qse_wchar_t** end)
{
qse_uintmax_t v;
QSE_WCSXTONUM (v, wcs, len, end, base, 0);
return v; return v;
} }

View File

@ -251,7 +251,8 @@ static int cgi_htrd_peek_script_output (qse_htrd_t* htrd, qse_htre_t* req)
qse_mchar_t* endptr; qse_mchar_t* endptr;
/* TODO: check the syntax of status value??? if not numeric??? */ /* TODO: check the syntax of status value??? if not numeric??? */
QSE_MBSTONUM (nstatus, req->attr.status, &endptr, 10); /*QSE_MBSTONUM (nstatus, req->attr.status, &endptr, 10);*/
nstatus = qse_mbstoi (req->attr.status, 10, &endptr);
/* /*
Would it need this kind of extra work? Would it need this kind of extra work?

View File

@ -927,7 +927,7 @@ static void adjust_peer_name_and_port (task_proxy_t* proxy)
{ {
/* handle a port number after the colon sign */ /* handle a port number after the colon sign */
*colon = QSE_MT('\0'); *colon = QSE_MT('\0');
proxy->peer_port = qse_mbstoui (colon + 1, 10); proxy->peer_port = qse_mbstoui (colon + 1, 10, QSE_NULL);
/* TODO: check if there is a garbage after the port number. /* TODO: check if there is a garbage after the port number.
* check if the port number has overflown */ * check if the port number has overflown */
} }

View File

@ -1227,7 +1227,7 @@ static int sscanf_i (qse_raddic_t* dic, const qse_char_t* str, int* pvalue)
qse_long_t v; qse_long_t v;
const qse_char_t* end; const qse_char_t* end;
QSE_STRTONUM (v, str, &end, 0); v = qse_strtolong (str, 0, &end);
if (*end != '\0') if (*end != '\0')
{ {
qse_raddic_seterrfmt (dic, QSE_RADDIC_ESYNERR, QSE_T("invalid number - %s"), str); qse_raddic_seterrfmt (dic, QSE_RADDIC_ESYNERR, QSE_T("invalid number - %s"), str);
@ -1248,9 +1248,9 @@ static int sscanf_ui (qse_raddic_t* dic, const qse_char_t* str, qse_uintmax_t* p
return -1; return -1;
} }
QSE_STRTONUM (v, str, &end, 0); /*QSE_STRTONUM (v, str, &end, 0);*/
v = qse_strtouintmax (str, 0, &end);
if (*end != '\0') if (*end != QSE_T('\0'))
{ {
qse_raddic_seterrfmt (dic, QSE_RADDIC_ESYNERR, QSE_T("invalid unsigned number - %s"), str); qse_raddic_seterrfmt (dic, QSE_RADDIC_ESYNERR, QSE_T("invalid unsigned number - %s"), str);
return -1; return -1;
@ -1260,6 +1260,7 @@ static int sscanf_ui (qse_raddic_t* dic, const qse_char_t* str, qse_uintmax_t* p
return 0; return 0;
} }
#if 0
static int sscanf_ui32 (qse_raddic_t* dic, const qse_char_t* str, qse_uint32_t* pvalue, qse_uint32_t* pvalue2) static int sscanf_ui32 (qse_raddic_t* dic, const qse_char_t* str, qse_uint32_t* pvalue, qse_uint32_t* pvalue2)
{ {
qse_long_t v, v2; qse_long_t v, v2;
@ -1272,11 +1273,13 @@ static int sscanf_ui32 (qse_raddic_t* dic, const qse_char_t* str, qse_uint32_t*
return -1; return -1;
} }
QSE_STRTONUM (v, str, &end, 0); /*QSE_STRTONUM (v, str, &end, 0);*/
v = qse_strtolong (str, 0, &end);
if (pvalue2 && *end == '.') if (pvalue2 && *end == '.')
{ {
start2 = end + 1; start2 = end + 1;
QSE_STRTONUM (v2, start2, &end, 0); /*QSE_STRTONUM (v2, start2, &end, 0);*/
v2 = qse_strtolong (start2, 0, &end);
} }
if (*end != '\0') if (*end != '\0')
@ -1294,6 +1297,7 @@ static int sscanf_ui32 (qse_raddic_t* dic, const qse_char_t* str, qse_uint32_t*
return 0; return 0;
} }
#endif
/* /*
* Process the ATTRIBUTE command * Process the ATTRIBUTE command
@ -1322,7 +1326,7 @@ static int process_attribute (
*/ */
if (sscanf_ui(dic, argv[1], &value) <= -1 || value > QSE_TYPE_MAX(qse_uint16_t)) if (sscanf_ui(dic, argv[1], &value) <= -1 || value > QSE_TYPE_MAX(qse_uint16_t))
{ {
qse_raddic_seterrfmt (dic, QSE_RADDIC_ESYNERR, QSE_T("%s[%zd]: invalid attribute value %s"), fn, line, argv[1]); qse_raddic_seterrfmt (dic, QSE_RADDIC_ESYNERR, QSE_T("%s[%zd]: invalid attribute value %s"), fn, line, argv[1]);
return -1; return -1;
} }
@ -1530,9 +1534,10 @@ static int process_constant(qse_raddic_t* dic, const qse_char_t* fn, const qse_s
*/ */
static int process_vendor (qse_raddic_t* dic, const qse_char_t* fn, const qse_size_t line, qse_char_t** argv, int argc) static int process_vendor (qse_raddic_t* dic, const qse_char_t* fn, const qse_size_t line, qse_char_t** argv, int argc)
{ {
int value; unsigned int value;
int continuation = 0; int continuation = 0;
const qse_char_t* format = QSE_NULL; const qse_char_t* format = QSE_NULL;
const qse_char_t* end;
if ((argc < 2) || (argc > 3)) if ((argc < 2) || (argc > 3))
{ {
@ -1541,14 +1546,18 @@ static int process_vendor (qse_raddic_t* dic, const qse_char_t* fn, const qse_si
} }
/* /*
* Validate all entries * Validate all entries
*/ */
if (!QSE_ISDIGIT(argv[1][0])) //if (!QSE_ISDIGIT(argv[1][0]))
//{
//
//}
value = qse_strtoui(argv[1], 0, &end);
if (*end != QSE_T('\0') || value <= 0u || value > 65535u)
{ {
qse_raddic_seterrfmt (dic, QSE_RADDIC_ESYNERR, QSE_T("%s[%zd]: invalid value"), fn, line); qse_raddic_seterrfmt (dic, QSE_RADDIC_ESYNERR, QSE_T("%s[%zd]: invalid value"), fn, line);
return -1; return -1;
} }
value = qse_strtoi(argv[1], 0);
/* Create a new VENDOR entry for the list */ /* Create a new VENDOR entry for the list */
if (qse_raddic_addvendor(dic, argv[0], value) == QSE_NULL) if (qse_raddic_addvendor(dic, argv[0], value) == QSE_NULL)

View File

@ -342,7 +342,7 @@ static void read_proc_net_if_inet6 (qse_nwifcfg_t* cfg, struct ifreq* ifr)
if (count >= 6) if (count >= 6)
{ {
index = qse_mbsxtoi (tok[1].ptr, tok[1].len, 16); index = qse_mbsxtoi (tok[1].ptr, tok[1].len, 16, QSE_NULL);
if (index == cfg->index) if (index == cfg->index)
{ {
int ti; int ti;
@ -356,7 +356,7 @@ static void read_proc_net_if_inet6 (qse_nwifcfg_t* cfg, struct ifreq* ifr)
cfg->addr.type = QSE_NWAD_IN6; cfg->addr.type = QSE_NWAD_IN6;
ti = qse_mbsxtoi (tok[2].ptr, tok[0].len, 16); ti = qse_mbsxtoi (tok[2].ptr, tok[0].len, 16, QSE_NULL);
qse_prefixtoip6ad (ti, &cfg->mask.u.in6.addr); qse_prefixtoip6ad (ti, &cfg->mask.u.in6.addr);
cfg->mask.type = QSE_NWAD_IN6; cfg->mask.type = QSE_NWAD_IN6;

View File

@ -65,7 +65,8 @@ int qse_get_highest_fd (void)
if (de->d_name[0] == QSE_MT('.')) continue; if (de->d_name[0] == QSE_MT('.')) continue;
QSE_MBSTONUM (l, de->d_name, &endptr, 10); /*QSE_MBSTONUM (l, de->d_name, &endptr, 10);*/
l = qse_mbstolong (de->d_name, 10, &endptr);
if (*endptr == QSE_MT('\0')) if (*endptr == QSE_MT('\0'))
{ {
fd = (int)l; fd = (int)l;
@ -137,7 +138,8 @@ int qse_close_open_fds_using_proc (int* excepts, qse_size_t count)
if (de->d_name[0] == QSE_MT('.')) continue; if (de->d_name[0] == QSE_MT('.')) continue;
QSE_MBSTONUM (l, de->d_name, &endptr, 10); /*QSE_MBSTONUM (l, de->d_name, &endptr, 10);*/
l = qse_mbstolong (de->d_name, 10, &endptr);
if (*endptr == QSE_MT('\0')) if (*endptr == QSE_MT('\0'))
{ {
int fd = (int)l; int fd = (int)l;