mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 02:25:40 +00:00

From releases/0.4.9 to releases/0.4.10 we introduced tons of compiler warnings within the whole host-tools component although the 'offending' code did not change in between both. I am not aware which commit unhid them exactly during 0.4.10-dev', but I will follow the footsteps of master with the fixes. releases/0.4.9 still had 0 warnings within host-tools, and releases/0.4.13 managed to achieve the same again! fix is a pick from: 0.4.13-dev-132-gf47f45dbdd
(picked the remaining parts of that) 0.4.13-dev-133-gc02257ef57
0.4.13-dev-134-g2c11c41115
the warnings could be observed with MSVC 2010SP1 (16.0.40219.1) x86 target in dbg configuration: where the 0.4.13-dev-132-gf47f45dbdd
part fixed the: [6/12736] Performing build step for 'host-tools' [13/250] Building CXX object sdk\tools\hhpcomp\CMakeFiles\hhpcomp.dir\hhpcomp.cpp.obj C:\0410rls\reactos\sdk\tools\hhpcomp\hhpcomp.cpp(59) : warning C4996: 'chdir': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _chdir. See online help for details. C:\VS2010_SP1\VC\INCLUDE\direct.h(123) : see declaration of 'chdir' C:\0410rls\reactos\sdk\tools\hhpcomp\chmc\chmc.c(160) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\hhpcomp\chmc\chmc.c(447) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\hhpcomp\chmc\chmc.c(476) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\hhpcomp\chmc\chmc.c(511) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\hpp\hpp.c(44) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\isohybrid\isohybrid.c(1201) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\isohybrid\isohybrid.c(1204) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\kbdtool\parser.c(448) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\kbdtool\parser.c(523) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\kbdtool\parser.c(598) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\ffileread.c(30) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\fcons.c(62) : warning C4996: 'fdopen': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fdopen. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(721) : see declaration of 'fdopen' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\flag.c(44) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\flag.c(73) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\flag.c(98) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\stdio\filewrite.c(82) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\fconv.c(231) : warning C4996: 'ecvt': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _ecvt. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdlib.h(864) : see declaration of 'ecvt' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\fconv.c(320) : warning C4996: 'fcvt': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fcvt. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdlib.h(865) : see declaration of 'fcvt' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\format.c(745) : warning C4996: 'gcvt': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _gcvt. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdlib.h(866) : see declaration of 'gcvt' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libschily\searchinpath.c(221) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\libsiconv\sic_nls.c(450) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(169) : warning C4996: 'access': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _access. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(299) : see declaration of 'access' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(225) : warning C4996: 'access': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _access. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(299) : see declaration of 'access' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(414) : warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(312) : see declaration of 'open' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(420) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(425) : warning C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _close. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(302) : see declaration of 'close' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(464) : warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(312) : see declaration of 'open' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(467) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(469) : warning C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _close. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(302) : see declaration of 'close' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(536) : warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(312) : see declaration of 'open' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(541) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\boot.c(549) : warning C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _close. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(302) : see declaration of 'close' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(447) : warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(312) : see declaration of 'open' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(453) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(457) : warning C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _close. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(302) : see declaration of 'close' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(585) : warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(312) : see declaration of 'open' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(594) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(615) : warning C4996: 'lseek': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _lseek. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(310) : see declaration of 'lseek' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(623) : warning C4996: 'write': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _write. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(318) : see declaration of 'write' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\eltorito.c(624) : warning C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _close. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(302) : see declaration of 'close' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\match.c(74) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\match.c(201) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(124) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(126) : warning C4996: 'lseek': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _lseek. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(310) : see declaration of 'lseek' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(130) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(124) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(723) : see declaration of 'fileno' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(126) : warning C4996: 'lseek': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _lseek. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(310) : see declaration of 'lseek' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\multi.c(130) : warning C4996: 'read': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _read. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(313) : see declaration of 'read' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\tree.c(1628) : warning C4996: 'access': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _access. See online help for details. C:\VS2010_SP1\VC\INCLUDE\io.h(299) : see declaration of 'access' C:\0410rls\reactos\sdk\tools\mkisofs\schilytools\mkisofs\write.c(204) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\wpp\preproc.c(162) : warning C4013: 'open' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\wpp\preproc.c(165) : warning C4013: 'close' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\widl.c(863) : warning C4996: 'fdopen': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fdopen. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(721) : see declaration of 'fdopen' C:\0410rls\reactos\sdk\tools\widl\widl.c(910) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(912) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(914) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(916) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(918) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(920) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(922) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(924) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\widl.c(926) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' C:\0410rls\reactos\sdk\tools\widl\typelib.c(264) : warning C4013: 'read' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\typelib.c(270) : warning C4013: 'lseek' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\typelib.c(343) : warning C4013: 'open' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\typelib.c(383) : warning C4013: 'close' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\utils.c(281) : warning C4013: 'open' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\utils.c(283) : warning C4013: 'write' undefined; assuming extern returning int C:\0410rls\reactos\sdk\tools\widl\utils.c(285) : warning C4013: 'close' undefined; assuming extern returning int [194/250] Building C object sdk\tools\widl\CMakeFiles\widl.dir\parser.yy.c.obj parser.l(488) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' parser.l(542) : warning C4996: 'fdopen': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fdopen. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(721) : see declaration of 'fdopen' parser.l(562) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details. C:\VS2010_SP1\VC\INCLUDE\stdio.h(299) : see declaration of 'unlink' [197/250] Building C object sdk\tools\widl\CMakeFiles\widl.dir\parser.tab.c.obj parser.y(454) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. C:\VS2010_SP1\VC\INCLUDE\string.h(238) : see declaration of 'strdup' ... and so on ... too many to name them all ---------- 0.4.13-dev-134-g2c11c41115
part fixed the: C:\0410rls\reactos\sdk\tools\widl\getopt.c(233) : warning C4013: '_getopt_internal' undefined; assuming extern returning int ---------- 0.4.13-dev-133-gc02257ef57
part fixed the: C:\0410rls\reactos\sdk\tools\isohybrid\isohybrid.c(978) : warning C4101: 'orig_gpt_size' : unreferenced local variable C:\0410rls\reactos\sdk\tools\isohybrid\isohybrid.c(978) : warning C4101: 'gpt_size' : unreferenced local variable
534 lines
13 KiB
C
534 lines
13 KiB
C
/*
|
|
* Unicode string manipulation functions
|
|
*
|
|
* Copyright 2000 Alexandre Julliard
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* 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
|
|
*/
|
|
|
|
#include <assert.h>
|
|
#include <errno.h>
|
|
#include <limits.h>
|
|
#include <stdio.h>
|
|
|
|
#define WINE_UNICODE_INLINE /* nothing */
|
|
#include "wine/unicode.h"
|
|
|
|
#ifdef __REACTOS__
|
|
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
|
#endif
|
|
|
|
int strcmpiW( const WCHAR *str1, const WCHAR *str2 )
|
|
{
|
|
for (;;)
|
|
{
|
|
int ret = tolowerW(*str1) - tolowerW(*str2);
|
|
if (ret || !*str1) return ret;
|
|
str1++;
|
|
str2++;
|
|
}
|
|
}
|
|
|
|
int strncmpiW( const WCHAR *str1, const WCHAR *str2, int n )
|
|
{
|
|
int ret = 0;
|
|
for ( ; n > 0; n--, str1++, str2++)
|
|
if ((ret = tolowerW(*str1) - tolowerW(*str2)) || !*str1) break;
|
|
return ret;
|
|
}
|
|
|
|
int memicmpW( const WCHAR *str1, const WCHAR *str2, int n )
|
|
{
|
|
int ret = 0;
|
|
for ( ; n > 0; n--, str1++, str2++)
|
|
if ((ret = tolowerW(*str1) - tolowerW(*str2))) break;
|
|
return ret;
|
|
}
|
|
|
|
WCHAR *strstrW( const WCHAR *str, const WCHAR *sub )
|
|
{
|
|
while (*str)
|
|
{
|
|
const WCHAR *p1 = str, *p2 = sub;
|
|
while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
|
|
if (!*p2) return (WCHAR *)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. */
|
|
|
|
long int strtolW( const WCHAR *nptr, WCHAR **endptr, int base )
|
|
{
|
|
int negative;
|
|
register unsigned long int cutoff;
|
|
register unsigned int cutlim;
|
|
register unsigned long int i;
|
|
register const WCHAR *s;
|
|
register WCHAR c;
|
|
const WCHAR *save, *end;
|
|
int overflow;
|
|
|
|
if (base < 0 || base == 1 || base > 36) return 0;
|
|
|
|
save = s = nptr;
|
|
|
|
/* 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')
|
|
{
|
|
if ((base == 0 || base == 16) && toupperW(s[1]) == 'X')
|
|
{
|
|
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;
|
|
end = NULL;
|
|
|
|
cutoff = ULONG_MAX / (unsigned long int) base;
|
|
cutlim = ULONG_MAX % (unsigned long int) base;
|
|
|
|
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))
|
|
c = toupperW (c) - 'A' + 10;
|
|
else
|
|
break;
|
|
if ((int) c >= base)
|
|
break;
|
|
/* Check for overflow. */
|
|
if (i > cutoff || (i == cutoff && c > cutlim))
|
|
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 (endptr != NULL)
|
|
*endptr = (WCHAR *)s;
|
|
|
|
/* 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_MIN + 1)) + 1
|
|
: (unsigned long int) LONG_MAX))
|
|
overflow = 1;
|
|
|
|
if (overflow)
|
|
{
|
|
errno = ERANGE;
|
|
return negative ? LONG_MIN : LONG_MAX;
|
|
}
|
|
|
|
/* Return the result of the appropriate sign. */
|
|
return negative ? -i : i;
|
|
|
|
noconv:
|
|
/* 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`. */
|
|
if (endptr != NULL)
|
|
{
|
|
if (save - nptr >= 2 && toupperW (save[-1]) == 'X'
|
|
&& save[-2] == '0')
|
|
*endptr = (WCHAR *)&save[-1];
|
|
else
|
|
/* There was no number to convert. */
|
|
*endptr = (WCHAR *)nptr;
|
|
}
|
|
|
|
return 0L;
|
|
}
|
|
|
|
|
|
unsigned long int strtoulW( const WCHAR *nptr, WCHAR **endptr, int base )
|
|
{
|
|
int negative;
|
|
register unsigned long int cutoff;
|
|
register unsigned int cutlim;
|
|
register unsigned long int i;
|
|
register const WCHAR *s;
|
|
register WCHAR c;
|
|
const WCHAR *save, *end;
|
|
int overflow;
|
|
|
|
if (base < 0 || base == 1 || base > 36) return 0;
|
|
|
|
save = s = nptr;
|
|
|
|
/* 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')
|
|
{
|
|
if ((base == 0 || base == 16) && toupperW(s[1]) == 'X')
|
|
{
|
|
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;
|
|
end = NULL;
|
|
|
|
cutoff = ULONG_MAX / (unsigned long int) base;
|
|
cutlim = ULONG_MAX % (unsigned long int) base;
|
|
|
|
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))
|
|
c = toupperW (c) - 'A' + 10;
|
|
else
|
|
break;
|
|
if ((int) c >= base)
|
|
break;
|
|
/* Check for overflow. */
|
|
if (i > cutoff || (i == cutoff && c > cutlim))
|
|
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 (endptr != NULL)
|
|
*endptr = (WCHAR *)s;
|
|
|
|
if (overflow)
|
|
{
|
|
errno = ERANGE;
|
|
return ULONG_MAX;
|
|
}
|
|
|
|
/* Return the result of the appropriate sign. */
|
|
return negative ? -i : i;
|
|
|
|
noconv:
|
|
/* 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`. */
|
|
if (endptr != NULL)
|
|
{
|
|
if (save - nptr >= 2 && toupperW (save[-1]) == 'X'
|
|
&& save[-2] == '0')
|
|
*endptr = (WCHAR *)&save[-1];
|
|
else
|
|
/* There was no number to convert. */
|
|
*endptr = (WCHAR *)nptr;
|
|
}
|
|
|
|
return 0L;
|
|
}
|
|
|
|
|
|
/* format a WCHAR string according to a printf format; helper for vsnprintfW */
|
|
static size_t format_string( WCHAR *buffer, size_t len, const char *format, const WCHAR *str, int str_len )
|
|
{
|
|
size_t count = 0;
|
|
int i, left_align = 0, width = 0, max = 0;
|
|
|
|
assert( *format == '%' );
|
|
format++; /* skip '%' */
|
|
|
|
while (*format == '0' || *format == '+' || *format == '-' || *format == ' ' || *format == '#')
|
|
{
|
|
if (*format == '-') left_align = 1;
|
|
format++;
|
|
}
|
|
|
|
while (isdigit(*format)) width = width * 10 + *format++ - '0';
|
|
|
|
if (str_len == -1) str_len = strlenW( str );
|
|
if (*format == '.')
|
|
{
|
|
format++;
|
|
while (isdigit(*format)) max = max * 10 + *format++ - '0';
|
|
if (max > str_len) max = str_len;
|
|
}
|
|
else max = str_len;
|
|
|
|
if (*format == 'h' || *format == 'l') format++;
|
|
|
|
assert( *format == 's' );
|
|
|
|
if (!left_align && width > max)
|
|
{
|
|
for (i = 0; i < width - max; i++)
|
|
{
|
|
if (count++ < len)
|
|
*buffer++ = ' ';
|
|
}
|
|
}
|
|
|
|
if (count < len)
|
|
memcpy( buffer, str, min( max, len - count ) * sizeof(WCHAR) );
|
|
count += max;
|
|
buffer += max;
|
|
|
|
if (left_align && width > max)
|
|
{
|
|
for (i = 0; i < width - max; i++)
|
|
{
|
|
if (count++ < len)
|
|
*buffer++ = ' ';
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
|
|
int vsnprintfW(WCHAR *str, size_t len, const WCHAR *format, va_list valist)
|
|
{
|
|
unsigned int written = 0;
|
|
const WCHAR *iter = format;
|
|
char bufa[512], fmtbufa[64], *fmta;
|
|
|
|
while (*iter)
|
|
{
|
|
while (*iter && *iter != '%')
|
|
{
|
|
if (written++ < len)
|
|
*str++ = *iter;
|
|
iter++;
|
|
}
|
|
if (*iter == '%')
|
|
{
|
|
if (iter[1] == '%')
|
|
{
|
|
if (written++ < len)
|
|
*str++ = '%'; /* "%%"->'%' */
|
|
iter += 2;
|
|
continue;
|
|
}
|
|
|
|
fmta = fmtbufa;
|
|
*fmta++ = *iter++;
|
|
while (*iter == '0' ||
|
|
*iter == '+' ||
|
|
*iter == '-' ||
|
|
*iter == ' ' ||
|
|
*iter == '*' ||
|
|
*iter == '#')
|
|
{
|
|
if (*iter == '*')
|
|
{
|
|
char *buffiter = bufa;
|
|
int fieldlen = va_arg(valist, int);
|
|
sprintf(buffiter, "%d", fieldlen);
|
|
while (*buffiter)
|
|
*fmta++ = *buffiter++;
|
|
}
|
|
else
|
|
*fmta++ = *iter;
|
|
iter++;
|
|
}
|
|
|
|
while (isdigit(*iter))
|
|
*fmta++ = *iter++;
|
|
|
|
if (*iter == '.')
|
|
{
|
|
*fmta++ = *iter++;
|
|
if (*iter == '*')
|
|
{
|
|
char *buffiter = bufa;
|
|
int fieldlen = va_arg(valist, int);
|
|
sprintf(buffiter, "%d", fieldlen);
|
|
while (*buffiter)
|
|
*fmta++ = *buffiter++;
|
|
iter++;
|
|
}
|
|
else
|
|
while (isdigit(*iter))
|
|
*fmta++ = *iter++;
|
|
}
|
|
if (*iter == 'h' || *iter == 'l')
|
|
*fmta++ = *iter++;
|
|
|
|
switch (*iter)
|
|
{
|
|
case 's':
|
|
{
|
|
static const WCHAR none[] = { '(','n','u','l','l',')',0 };
|
|
const WCHAR *wstr = va_arg(valist, const WCHAR *);
|
|
size_t remaining = written < len ? len - written : 0;
|
|
size_t count;
|
|
|
|
*fmta++ = 's';
|
|
*fmta = 0;
|
|
count = format_string( str, remaining, fmtbufa, wstr ? wstr : none, -1 );
|
|
str += min( count, remaining );
|
|
written += count;
|
|
iter++;
|
|
break;
|
|
}
|
|
|
|
case 'c':
|
|
{
|
|
WCHAR wstr;
|
|
size_t remaining = written < len ? len - written : 0;
|
|
size_t count;
|
|
|
|
wstr = va_arg(valist, int);
|
|
*fmta++ = 's';
|
|
*fmta = 0;
|
|
count = format_string( str, remaining, fmtbufa, &wstr, 1 );
|
|
str += min( count, remaining );
|
|
written += count;
|
|
iter++;
|
|
break;
|
|
}
|
|
|
|
default:
|
|
{
|
|
/* For non wc types, use system sprintf and append to wide char output */
|
|
/* FIXME: for unrecognised types, should ignore % when printing */
|
|
char *bufaiter = bufa;
|
|
if (*iter == 'p')
|
|
sprintf(bufaiter, "%p", va_arg(valist, void*));
|
|
else
|
|
{
|
|
*fmta++ = *iter;
|
|
*fmta = '\0';
|
|
if (*iter == 'a' || *iter == 'A' ||
|
|
*iter == 'e' || *iter == 'E' ||
|
|
*iter == 'f' || *iter == 'F' ||
|
|
*iter == 'g' || *iter == 'G')
|
|
sprintf(bufaiter, fmtbufa, va_arg(valist, double));
|
|
else
|
|
{
|
|
/* FIXME: On 32 bit systems this doesn't handle int 64's. */
|
|
sprintf(bufaiter, fmtbufa, va_arg(valist, void *));
|
|
}
|
|
}
|
|
while (*bufaiter)
|
|
{
|
|
if (written++ < len)
|
|
*str++ = *bufaiter;
|
|
bufaiter++;
|
|
}
|
|
iter++;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (len)
|
|
{
|
|
if (written >= len)
|
|
str--;
|
|
*str++ = 0;
|
|
}
|
|
|
|
/* FIXME: POSIX [v]snprintf() returns the equivalent of written, not -1, on short buffer. */
|
|
return written < len ? (int)written : -1;
|
|
}
|
|
|
|
int vsprintfW( WCHAR *str, const WCHAR *format, va_list valist )
|
|
{
|
|
return vsnprintfW( str, INT_MAX, format, valist );
|
|
}
|
|
|
|
int snprintfW( WCHAR *str, size_t len, const WCHAR *format, ...)
|
|
{
|
|
int retval;
|
|
va_list valist;
|
|
va_start(valist, format);
|
|
retval = vsnprintfW(str, len, format, valist);
|
|
va_end(valist);
|
|
return retval;
|
|
}
|
|
|
|
int sprintfW( WCHAR *str, const WCHAR *format, ...)
|
|
{
|
|
int retval;
|
|
va_list valist;
|
|
va_start(valist, format);
|
|
retval = vsnprintfW(str, INT_MAX, format, valist);
|
|
va_end(valist);
|
|
return retval;
|
|
}
|