string.c revision 114410893548b9522c46fdcbd8f63385eb8bfb68
/*
* Unicode string manipulation functions
*
* Copyright 2000 Alexandre Julliard
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Sun elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#include "config.h"
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#define WINE_UNICODE_INLINE /* nothing */
{
for (;;)
{
str1++;
str2++;
}
}
{
int ret = 0;
return ret;
}
{
int ret = 0;
return ret;
}
{
while (*str)
{
str++;
}
return NULL;
}
/* strtolW and strtoulW implementation based on the GNU C library code */
/* Copyright (C) 1991,92,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc. */
{
int negative;
register unsigned long int cutoff;
register unsigned int cutlim;
register unsigned long int i;
register const WCHAR *s;
register WCHAR c;
int overflow;
/* Skip white space. */
while (isspaceW (*s))
++s;
if (!*s) goto noconv;
/* Check for a sign. */
negative = 0;
if (*s == '-')
{
negative = 1;
++s;
}
else if (*s == '+')
++s;
/* Recognize number prefix and if BASE is zero, figure it out ourselves. */
if (*s == '0')
{
{
s += 2;
base = 16;
}
else if (base == 0)
base = 8;
}
else if (base == 0)
base = 10;
/* Save the pointer so we can check later if anything happened. */
save = s;
overflow = 0;
i = 0;
c = *s;
for (;c != '\0'; c = *++s)
{
if (s == end)
break;
if (c >= '0' && c <= '9')
c -= '0';
else if (isalphaW (c))
else
break;
if ((int) c >= base)
break;
/* Check for overflow. */
overflow = 1;
else
{
i *= (unsigned long int) base;
i += c;
}
}
/* Check if anything actually happened. */
if (s == save)
goto noconv;
/* Store in ENDPTR the address of one character
past the last character we converted. */
/* Check for a value that is within the range of
`unsigned LONG int', but outside the range of `LONG int'. */
if (overflow == 0
&& i > (negative
: (unsigned long int) LONG_MAX))
overflow = 1;
if (overflow)
{
}
/* Return the result of the appropriate sign. */
return negative ? -i : i;
/* We must handle a special case here: the base is 0 or 16 and the
first two characters are '0' and 'x', but the rest are not
hexadecimal digits. This is no error case. We return 0 and
ENDPTR points to the `x`. */
{
else
/* There was no number to convert. */
}
return 0L;
}
{
int negative;
register unsigned long int cutoff;
register unsigned int cutlim;
register unsigned long int i;
register const WCHAR *s;
register WCHAR c;
int overflow;
/* Skip white space. */
while (isspaceW (*s))
++s;
if (!*s) goto noconv;
/* Check for a sign. */
negative = 0;
if (*s == '-')
{
negative = 1;
++s;
}
else if (*s == '+')
++s;
/* Recognize number prefix and if BASE is zero, figure it out ourselves. */
if (*s == '0')
{
{
s += 2;
base = 16;
}
else if (base == 0)
base = 8;
}
else if (base == 0)
base = 10;
/* Save the pointer so we can check later if anything happened. */
save = s;
overflow = 0;
i = 0;
c = *s;
for (;c != '\0'; c = *++s)
{
if (s == end)
break;
if (c >= '0' && c <= '9')
c -= '0';
else if (isalphaW (c))
else
break;
if ((int) c >= base)
break;
/* Check for overflow. */
overflow = 1;
else
{
i *= (unsigned long int) base;
i += c;
}
}
/* Check if anything actually happened. */
if (s == save)
goto noconv;
/* Store in ENDPTR the address of one character
past the last character we converted. */
if (overflow)
{
return ULONG_MAX;
}
/* Return the result of the appropriate sign. */
return negative ? -i : i;
/* We must handle a special case here: the base is 0 or 16 and the
first two characters are '0' and 'x', but the rest are not
hexadecimal digits. This is no error case. We return 0 and
ENDPTR points to the `x`. */
{
else
/* There was no number to convert. */
}
return 0L;
}
/* format a WCHAR string according to a printf format; helper for vsnprintfW */
{
format++; /* skip '%' */
{
format++;
}
if (*format == '.')
{
format++;
}
{
}
{
}
return count;
}
{
unsigned int written = 0;
while (*iter)
{
{
return -1;
}
if (*iter == '%')
{
{
return -1;
iter += 2;
continue;
}
while (*iter == '0' ||
*iter == '+' ||
*iter == '-' ||
*iter == ' ' ||
*iter == '*' ||
*iter == '#')
{
if (*iter == '*')
{
while (*buffiter)
}
else
iter++;
}
if (*iter == '.')
{
if (*iter == '*')
{
while (*buffiter)
}
else
}
switch (*iter)
{
case 's':
{
int count;
*fmta++ = 's';
*fmta = 0;
iter++;
break;
}
case 'c':
{
int count;
wstr[1] = 0;
*fmta++ = 's';
*fmta = 0;
iter++;
break;
}
default:
{
/* For non wc types, use system sprintf and append to wide char output */
/* FIXME: for unrecognised types, should ignore % when printing */
if (*iter == 'p')
else
{
*fmta = '\0';
else
{
/* FIXME: On 32 bit systems this doesn't handle int 64's. */
}
}
while (*bufaiter)
{
return -1;
}
iter++;
break;
}
}
}
}
return -1;
*str++ = 0;
return (int)written;
}
{
}
{
int retval;
return retval;
}
{
int retval;
return retval;
}