int exp=0, sign=1;
const MSVCRT_wchar_t *p;
double ret;
+ BOOL found_digit = FALSE;
- if(!str) {
- MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
+ if (!MSVCRT_CHECK_PMT(str != NULL)) {
*MSVCRT__errno() = MSVCRT_EINVAL;
return 0;
}
p++;
while(isdigitW(*p)) {
+ found_digit = TRUE;
hlp = d*10+*(p++)-'0';
if(d>MSVCRT_UI64_MAX/10 || hlp<d) {
exp++;
p++;
while(isdigitW(*p)) {
+ found_digit = TRUE;
hlp = d*10+*(p++)-'0';
if(d>MSVCRT_UI64_MAX/10 || hlp<d)
break;
while(isdigitW(*p))
p++;
- if(p == str) {
+ if(!found_digit) {
if(end)
*end = (MSVCRT_wchar_t*)str;
return 0.0;
return 0;
}
- if(!wcstr || !mbstr) {
- MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
+ if (!MSVCRT_CHECK_PMT(wcstr != NULL) || !MSVCRT_CHECK_PMT(mbstr != NULL)) {
if(mbstr && size)
mbstr[0] = '\0';
*MSVCRT__errno() = MSVCRT_EINVAL;
else if(conv==size && (count==MSVCRT__TRUNCATE || mbstr[conv-1]=='\0'))
mbstr[conv-1] = '\0';
else {
- MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
+ MSVCRT_INVALID_PMT("mbstr[size] is too small");
if(size)
mbstr[0] = '\0';
*MSVCRT__errno() = MSVCRT_ERANGE;
/* deal with integer width modifier */
while( *p )
{
- if( *p == 'h' || *p == 'l' || *p == 'L' )
+ if( *p == 'l' && *(p+1) == 'l' )
+ {
+ flags.IntegerDouble++;
+ p += 2;
+ }
+ else if( *p == 'h' || *p == 'l' || *p == 'L' )
{
flags.IntegerLength = *p;
p++;
if(ret<0 || ret==len) {
if(count!=MSVCRT__TRUNCATE && count>sizeOfBuffer) {
- MSVCRT__invalid_parameter( NULL, NULL, NULL, 0, 0 );
+ MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small");
*MSVCRT__errno() = MSVCRT_ERANGE;
memset(str, 0, sizeOfBuffer);
} else
return retval;
}
+/*********************************************************************
+ * _scprintf (MSVCRT.@)
+ */
+int CDECL MSVCRT__scprintf(const char *format, ...)
+{
+ int retval;
+ __ms_va_list valist;
+ __ms_va_start(valist, format);
+ retval = _vscprintf(format, valist);
+ __ms_va_end(valist);
+ return retval;
+}
+
/*********************************************************************
* vsnwprintf_internal (INTERNAL)
*/
if(ret<0 || ret==len) {
if(count!=MSVCRT__TRUNCATE && count>sizeOfBuffer) {
- MSVCRT__invalid_parameter( NULL, NULL, NULL, 0, 0 );
+ MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small");
*MSVCRT__errno() = MSVCRT_ERANGE;
memset(str, 0, sizeOfBuffer*sizeof(MSVCRT_wchar_t));
} else
}
/*********************************************************************
- * wcstok (MSVCRT.@)
+ * wcstok_s (MSVCRT.@)
*/
-MSVCRT_wchar_t * CDECL MSVCRT_wcstok( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *delim )
+MSVCRT_wchar_t * CDECL wcstok_s( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *delim,
+ MSVCRT_wchar_t **next_token )
{
- thread_data_t *data = msvcrt_get_thread_data();
MSVCRT_wchar_t *ret;
- if (!str)
- if (!(str = data->wcstok_next)) return NULL;
+ if (!MSVCRT_CHECK_PMT(delim != NULL) || !MSVCRT_CHECK_PMT(next_token != NULL) ||
+ !MSVCRT_CHECK_PMT(str != NULL || *next_token != NULL))
+ {
+ *MSVCRT__errno() = MSVCRT_EINVAL;
+ return NULL;
+ }
+ if (!str) str = *next_token;
while (*str && strchrW( delim, *str )) str++;
if (!*str) return NULL;
ret = str++;
while (*str && !strchrW( delim, *str )) str++;
if (*str) *str++ = 0;
- data->wcstok_next = str;
+ *next_token = str;
return ret;
}
+/*********************************************************************
+ * wcstok (MSVCRT.@)
+ */
+MSVCRT_wchar_t * CDECL MSVCRT_wcstok( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *delim )
+{
+ return wcstok_s(str, delim, &msvcrt_get_thread_data()->wcstok_next);
+}
/*********************************************************************
* wctomb (MSVCRT.@)
return MSVCRT_ERANGE;
}
+/*********************************************************************
+ * wcsncat_s (MSVCRT.@)
+ *
+ */
+INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
+ const MSVCRT_wchar_t *src, MSVCRT_size_t count)
+{
+ MSVCRT_size_t srclen;
+ MSVCRT_wchar_t dststart;
+ INT ret = 0;
+
+ if (src == NULL && count > 0)
+ return MSVCRT_EINVAL;
+ if (dst == NULL)
+ return MSVCRT_EINVAL;
+ if (elem == 0)
+ return MSVCRT_EINVAL;
+ if (count == 0)
+ return 0;
+
+ for (dststart = 0; dststart < elem; dststart++)
+ {
+ if (dst[dststart] == '\0')
+ break;
+ }
+ if (dststart == elem)
+ return MSVCRT_EINVAL;
+
+ if (count == MSVCRT__TRUNCATE)
+ {
+ srclen = strlenW(src);
+ if (srclen >= (elem - dststart))
+ {
+ srclen = elem - dststart - 1;
+ ret = MSVCRT_STRUNCATE;
+ }
+ }
+ else
+ srclen = min(strlenW(src), count);
+ if (srclen < (elem - dststart))
+ {
+ memcpy(&dst[dststart], src, srclen*sizeof(MSVCRT_wchar_t));
+ dst[srclen] = '\0';
+ return ret;
+ }
+ dst[0] = '\0';
+ return MSVCRT_ERANGE;
+}
+
/*********************************************************************
* _wcstoi64_l (MSVCRT.@)
*
TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale);
- if(!nptr || base<0 || base>36 || base==1) {
- MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
+ if (!MSVCRT_CHECK_PMT(nptr != NULL) || !MSVCRT_CHECK_PMT(base == 0 || base >= 2) ||
+ !MSVCRT_CHECK_PMT(base <= 36)) {
+ *MSVCRT__errno() = MSVCRT_EINVAL;
return 0;
}
TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale);
- if(!nptr || base<0 || base>36 || base==1) {
- MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
+ if (!MSVCRT_CHECK_PMT(nptr != NULL) || !MSVCRT_CHECK_PMT(base == 0 || base >= 2) ||
+ !MSVCRT_CHECK_PMT(base <= 36)) {
+ *MSVCRT__errno() = MSVCRT_EINVAL;
return 0;
}
{
return MSVCRT__wcstoui64_l(nptr, endptr, base, NULL);
}
+
+/******************************************************************
+ * wcsnlen (MSVCRT.@)
+ */
+MSVCRT_size_t CDECL MSVCRT_wcsnlen(const MSVCRT_wchar_t *s, MSVCRT_size_t maxlen)
+{
+ MSVCRT_size_t i;
+
+ for (i = 0; i < maxlen; i++)
+ if (!s[i]) break;
+ return i;
+}