Create a branch for cmake bringup.

svn path=/branches/cmake-bringup/; revision=48236
This commit is contained in:
Amine Khaldi 2010-07-24 18:52:44 +00:00
parent a28e798006
commit c424146e2c
20602 changed files with 0 additions and 1140137 deletions

View file

@ -0,0 +1,107 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/hanzen.c
* PURPOSE: Multibyte conversion routines formerly called hantozen and zentohan
* PROGRAMER: Ariadne, Taiji Yamada
* UPDATE HISTORY:
Modified from Taiji Yamada japanese code system utilities
* 12/04/99: Created
*/
#include <mbctype.h>
static unsigned short han_to_zen_ascii_table[0x5f] = {
0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166,
0x8169, 0x816a, 0x8196, 0x817b, 0x8143, 0x817c, 0x8144, 0x815e,
0x824f, 0x8250, 0x8251, 0x8252, 0x8253, 0x8254, 0x8255, 0x8256,
0x8257, 0x8258, 0x8146, 0x8147, 0x8183, 0x8181, 0x8184, 0x8148,
0x8197, 0x8260, 0x8261, 0x8262, 0x8263, 0x8264, 0x8265, 0x8266,
0x8267, 0x8268, 0x8269, 0x826a, 0x826b, 0x826c, 0x826d, 0x826e,
0x826f, 0x8270, 0x8271, 0x8272, 0x8273, 0x8274, 0x8275, 0x8276,
0x8277, 0x8278, 0x8279, 0x816d, 0x818f, 0x816e, 0x814f, 0x8151,
0x8165, 0x8281, 0x8282, 0x8283, 0x8284, 0x8285, 0x8286, 0x8287,
0x8288, 0x8289, 0x828a, 0x828b, 0x828c, 0x828d, 0x828e, 0x828f,
0x8290, 0x8291, 0x8292, 0x8293, 0x8294, 0x8295, 0x8296, 0x8297,
0x8298, 0x8299, 0x829a, 0x816f, 0x8162, 0x8170, 0x8150
};
static unsigned short han_to_zen_kana_table[0x40] = {
0x8140, 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x8392, 0x8340,
0x8342, 0x8344, 0x8346, 0x8348, 0x8383, 0x8385, 0x8387, 0x8362,
0x815b, 0x8341, 0x8343, 0x8345, 0x8347, 0x8349, 0x834a, 0x834c,
0x834e, 0x8350, 0x8352, 0x8354, 0x8356, 0x8358, 0x835a, 0x835c,
0x835e, 0x8360, 0x8363, 0x8365, 0x8367, 0x8369, 0x836a, 0x836b,
0x836c, 0x836d, 0x836e, 0x8371, 0x8374, 0x8377, 0x837a, 0x837d,
0x837e, 0x8380, 0x8381, 0x8382, 0x8384, 0x8386, 0x8388, 0x8389,
0x838a, 0x838b, 0x838c, 0x838d, 0x838f, 0x8393, 0x814a, 0x814b
};
static unsigned char zen_to_han_kana_table[0x8396-0x8340+1] = {
0xa7, 0xb1, 0xa8, 0xb2, 0xa9, 0xb3, 0xaa, 0xb4,
0xab, 0xb5, 0xb6, 0xb6, 0xb7, 0xb7, 0xb8, 0xb8,
0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb, 0xbc, 0xbc,
0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0xc0, 0xc0,
0xc1, 0xc1, 0xaf, 0xc2, 0xc2, 0xc3, 0xc3, 0xc4,
0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xca,
0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc, 0xcd,
0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xd0, 0,
0xd1, 0xd2, 0xd3, 0xac, 0xd4, 0xad, 0xd5, 0xae,
0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdc,
0xb2, 0xb4, 0xa6, 0xdd, 0xb3, 0xb6, 0xb9
};
#define ZTOH_SYMBOLS 9
static unsigned short zen_to_han_symbol_table_1[ZTOH_SYMBOLS] = {
0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x815b, 0x814a, 0x814b
};
static unsigned char zen_to_han_symbol_table_2[ZTOH_SYMBOLS] = {
0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xb0, 0xde, 0xdf
};
#define ISKANA(c) ((c) >= 0xa1 && (c) <= 0xdf)
#define JISHIRA(c) ((c) >= 0x829f && (c) <= 0x82f1)
#define JISKANA(c) ((c) >= 0x8340 && (c) <= 0x8396 && (c) != 0x837f)
#define JTOKANA(c) ((c) <= 0x82dd ? (c) + 0xa1 : (c) + 0xa2)
/*
* @implemented
*/
unsigned short _mbbtombc(unsigned short c)
{
if (c >= 0x20 && c <= 0x7e) {
return han_to_zen_ascii_table[c - 0x20];
} else if (ISKANA(c)) {
return han_to_zen_kana_table[c - 0xa0];
}
return c;
}
/*
* @implemented
*/
unsigned short _mbctombb(unsigned short c)
{
int i;
unsigned short *p;
if (JISKANA(c)) {
return zen_to_han_kana_table[c - 0x8340];
} else if (JISHIRA(c)) {
c = JTOKANA(c);
return zen_to_han_kana_table[c - 0x8340];
} else if (c <= 0x8396) {
for (i = 0x20, p = han_to_zen_ascii_table; i <= 0x7e; i++, p++) {
if (*p == c) {
return i;
}
}
for (i = 0; i < ZTOH_SYMBOLS; i++) {
if (zen_to_han_symbol_table_1[i] == c) {
return zen_to_han_symbol_table_2[i];
}
}
}
return c;
}

View file

@ -0,0 +1,58 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/ischira.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 12/04/99: Ariadne Created
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <mbctype.h>
/*
* @implemented
*/
int _ismbchira( unsigned int c )
{
return ((c>=0x829F) && (c<=0x82F1));
}
/*
* @implemented
*/
int _ismbckata( unsigned int c )
{
return ((c>=0x8340) && (c<=0x8396));
}
/*
* @implemented
*/
unsigned int _mbctohira( unsigned int c )
{
if (c >= 0x8340 && c <= 0x837e)
return c - 0xa1;
else if (c >= 0x8380 && c <= 0x8396)
return c - 0xa2;
else
return c;
}
/*
* @implemented
*/
unsigned int _mbctokata( unsigned int c )
{
if (c >= 0x829f && c <= 0x82dd)
return c + 0xa1;
else if (c >= 0x82de && c <= 0x82f1)
return c + 0xa2;
else
return c;
}

View file

@ -0,0 +1,21 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/iskana.c
* PURPOSE: Checks for kana character
* PROGRAMER:
* UPDATE HISTORY:
* 12/04/99: Ariadne, Taiji Yamada Created
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
/*
* @implemented
*/
int _ismbbkana(unsigned int c)
{
return (_mbctype[c & 0xff] & _MBKANA);
}

View file

@ -0,0 +1,17 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/iskmoji.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <mbctype.h>
int _ismbbkalpha(unsigned char c)
{
return (0xA7 <= c && c <= 0xDF);
}

View file

@ -0,0 +1,20 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/iskpun.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 12/04/99: Ariadne Created
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
/*
* @implemented
*/
int _ismbbkpunct( unsigned int c )
{
return (_mbctype[c & 0xff] & _MKPNCT);
}

View file

@ -0,0 +1,11 @@
#include <precomp.h>
#include <mbstring.h>
/*
* @implemented
*/
int isleadbyte(int c)
{
return _isctype( c, _MLEAD );
}

View file

@ -0,0 +1,22 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/ishwr.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 12/04/99: Ariadne Created
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
/*
* @implemented
*/
int _ismbclower( unsigned int c )
{
return ((c) >= 0x8281 && (c) <= 0x829a);
}

View file

@ -0,0 +1,20 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/ismbal.c
* PURPOSE: Checks for alphabetic multibyte character
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <mbctype.h>
#include <ctype.h>
/*
* @implemented
*/
int _ismbbalpha(unsigned int c)
{
return (isalpha(c) || _ismbbkalnum(c));
}

View file

@ -0,0 +1,25 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/ismbaln.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
int _ismbbkalnum( unsigned int c );
/*
* @implemented
*/
int _ismbbalnum(unsigned int c)
{
return (isalnum(c) || _ismbbkalnum(c));
}

View file

@ -0,0 +1,121 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/ismbc.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
#include <mbstring.h>
#include <mbctype.h>
/*
* @implemented
*/
int _ismbcalnum( unsigned int c )
{
if ((c & 0xFF00) != 0) {
// true multibyte character
return 0;
}
else
return _ismbbalnum(c);
return 0;
}
/*
* @implemented
*/
int _ismbcalpha( unsigned int c )
{
return (_ismbcupper (c) || _ismbclower (c));
}
/*
* @implemented
*/
int _ismbcdigit( unsigned int c )
{
return ((c) >= 0x824f && (c) <= 0x8258);
}
/*
* @implemented
*/
int _ismbcprint( unsigned int c )
{
return (_MBHMASK (c) ? _ismbclegal (c) : (isprint (c) || _ismbbkana (c)));
}
/*
* @implemented
*/
int _ismbcsymbol( unsigned int c )
{
return (c >= 0x8141 && c <= 0x817e) || (c >= 0x8180 && c <= 0x81ac);
}
/*
* @implemented
*/
int _ismbcspace( unsigned int c )
{
return ((c) == 0x8140);
}
/*
* @implemented
*/
int _ismbclegal(unsigned int c)
{
return (_ismbblead (_MBGETH (c)) && _ismbbtrail (_MBGETL (c)));
}
/*
* @implemented
*/
int _ismbcl0(unsigned int c)
{
return (c >= 0x8140 && c <= 0x889e);
}
/*
* @implemented
*/
int _ismbcl1(unsigned int c)
{
return (c >= 0x889f && c <= 0x9872);
}
/*
* @implemented
*/
int _ismbcl2(unsigned int c)
{
return (c >= 0x989f && c <= 0xea9e);
}
/*
* @unimplemented
*/
int _ismbcgraph(unsigned int ch)
{
//wchar_t wch = msvcrt_mbc_to_wc( ch );
//return (get_char_typeW( wch ) & (C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_ALPHA));
return 0;
}
/*
* @unimplemented
*/
int _ismbcpunct(unsigned int ch)
{
//wchar_t wch = msvcrt_mbc_to_wc( ch );
//return (get_char_typeW( wch ) & C1_PUNCT);
return 0;
}

View file

@ -0,0 +1,11 @@
#include <mbstring.h>
#include <mbctype.h>
#include <ctype.h>
/*
* @implemented
*/
int _ismbbgraph(unsigned int c)
{
return (isgraph(c) || _ismbbkana(c));
}

View file

@ -0,0 +1,20 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/ismbkaln.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 12/04/99: Ariadne Created
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
/*
* @implemented
*/
int _ismbbkalnum( unsigned int c )
{
return (_mbctype[c & 0xff] & _MKMOJI);
}

View file

@ -0,0 +1,53 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/ismblead.c
* PURPOSE: Checks for a leading byte
* PROGRAMERS:
* Copyright 1999 Ariadne, Taiji Yamada
* Copyright 1999 Alexandre Julliard
* Copyright 2000 Jon Griffths
* Copyright 2008 Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
#include <mbctype.h>
/*
* @implemented
*/
int _ismbblead(unsigned int c)
{
return (_mbctype[(c&0xff) + 1] & _M1) != 0;
}
/*
* @implemented
*/
int _ismbslead( const unsigned char *start, const unsigned char *str)
{
int lead = 0;
/* Lead bytes can also be trail bytes so we need to analyse the string
*/
while (start <= str)
{
if (!*start)
return 0;
lead = !lead && _ismbblead(*start);
start++;
}
return lead ? -1 : 0;
}
/*
* @implemented
*/
unsigned char *__p__mbctype(void)
{
return _mbctype;
}

View file

@ -0,0 +1,11 @@
#include <mbstring.h>
#include <mbctype.h>
#include <ctype.h>
/*
* @implemented
*/
int _ismbbprint(unsigned int c)
{
return (isprint(c) || _ismbbkana(c));
}

View file

@ -0,0 +1,26 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/ismbpun.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
/*
* @implemented
*/
int _ismbbpunct(unsigned int c)
{
// (0xA1 <= c <= 0xA6)
return (_mbctype[c & 0xff] & _MBPUNCT);
}
//iskana() :(0xA1 <= c <= 0xDF)
//iskpun() :(0xA1 <= c <= 0xA6)
//iskmoji() :(0xA7 <= c <= 0xDF)

View file

@ -0,0 +1,39 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/ismbtrl.c
* PURPOSE: Checks for a trailing byte
* PROGRAMERS:
* Copyright 1999 Ariadne
* Copyright 1999 Alexandre Julliard
* Copyright 2000 Jon Griffths
*
*/
#include <precomp.h>
#include <mbctype.h>
size_t _mbclen2(const unsigned int s);
// iskanji2() : (0x40 <= c <= 0x7E 0x80 <= c <= 0xFC)
/*
* @implemented
*/
int _ismbbtrail(unsigned int c)
{
return (_mbctype[(c&0xff) + 1] & _M2) != 0;
}
/*
* @implemented
*/
int _ismbstrail( const unsigned char *start, const unsigned char *str)
{
/* Note: this function doesn't check _ismbbtrail */
if ((str > start) && _ismbslead(start, str-1))
return -1;
else
return 0;
}

View file

@ -0,0 +1,21 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/isuppr.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 12/04/99: Ariadne Created
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
/*
* @implemented
*/
int _ismbcupper( unsigned int c )
{
return ((c) >= 0x8260 && (c) <= 0x8279);
}

View file

@ -0,0 +1,60 @@
/*
* MSVCRT string functions
*
* Copyright 1996,1998 Marcus Meissner
* Copyright 1996 Jukka Iivonen
* Copyright 1997,2000 Uwe Bonnes
* Copyright 2000 Jon Griffiths
*
* 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 <precomp.h>
#include <mbstring.h>
#include <locale.h>
/*
* @implemented
*/
unsigned int _mbcjistojms(unsigned int c)
{
/* Conversion takes place only when codepage is 932.
In all other cases, c is returned unchanged */
if(MSVCRT___lc_codepage == 932)
{
if(HIBYTE(c) >= 0x21 && HIBYTE(c) <= 0x7e &&
LOBYTE(c) >= 0x21 && LOBYTE(c) <= 0x7e)
{
if(HIBYTE(c) % 2)
c += 0x1f;
else
c += 0x7d;
if(LOBYTE(c) > 0x7F)
c += 0x1;
c = (((HIBYTE(c) - 0x21)/2 + 0x81) << 8) | LOBYTE(c);
if(HIBYTE(c) > 0x9f)
c += 0x4000;
}
else
return 0; /* Codepage is 932, but c can't be converted */
}
return c;
}

View file

@ -0,0 +1,28 @@
#include <mbstring.h>
/*
* @implemented
*/
unsigned int _mbcjmstojis(unsigned int c)
{
int c1, c2;
c2 = (unsigned char)c;
c1 = c >> 8;
if (c1 < 0xf0 && _ismbblead(c1) && _ismbbtrail(c2)) {
if (c1 >= 0xe0)
c1 -= 0x40;
c1 -= 0x70;
c1 <<= 1;
if (c2 < 0x9f) {
c1 --;
c2 -= 0x1f;
if (c2 >= (0x80-0x1f))
c2 --;
} else {
c2 -= 0x7e;
}
return ((c1 << 8) | c2);
}
return 0;
}

View file

@ -0,0 +1,77 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/mbbtype.c
* PURPOSE: Determines the type of a multibyte character
* PROGRAMERS:
* Copyright 1999 Ariadne
* Copyright 1999 Alexandre Julliard
* Copyright 2000 Jon Griffths
*
*/
#include <precomp.h>
#include <mbstring.h>
#include <mbctype.h>
/*
* @implemented
*/
int _mbbtype(unsigned char c , int type)
{
if ( type == 1 ) {
if ((c >= 0x40 && c <= 0x7e ) || (c >= 0x80 && c <= 0xfc ) )
{
return _MBC_TRAIL;
}
else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||
( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
return _MBC_ILLEGAL;
else
return 0;
} else {
if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF )) {
return _MBC_SINGLE;
}
else if ( (c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC) )
return _MBC_LEAD;
else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||
( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
return _MBC_ILLEGAL;
else
return 0;
}
return 0;
}
/*
* @implemented
*/
int _mbsbtype( const unsigned char *str, size_t n )
{
int lead = 0;
const unsigned char *end = str + n;
/* Lead bytes can also be trail bytes so we need to analyse the string.
* Also we must return _MBC_ILLEGAL for chars past the end of the string
*/
while (str < end) /* Note: we skip the last byte - will check after the loop */
{
if (!*str)
return _MBC_ILLEGAL;
lead = !lead && _ismbblead(*str);
str++;
}
if (lead)
if (_ismbbtrail(*str))
return _MBC_TRAIL;
else
return _MBC_ILLEGAL;
else
if (_ismbblead(*str))
return _MBC_LEAD;
else
return _MBC_SINGLE;
}

View file

@ -0,0 +1,23 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/mbccpy.c
* PURPOSE: Copies a multi byte character
* PROGRAMERS:
* Copyright 1999 Alexandre Julliard
* Copyright 2000 Jon Griffths
*
*/
#include <mbstring.h>
#include <string.h>
/*
* @implemented
*/
void _mbccpy(unsigned char *dst, const unsigned char *src)
{
*dst = *src;
if(_ismbblead(*src))
*++dst = *++src; /* MB char */
}

View file

@ -0,0 +1,42 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/mbclen.c
* PURPOSE: Determines the length of a multi byte character
* PROGRAMERS:
* Copyright 1999 Alexandre Julliard
* Copyright 2000 Jon Griffths
*
*/
#include <mbstring.h>
#include <stdlib.h>
int isleadbyte(int byte);
/*
* @implemented
*/
size_t _mbclen(const unsigned char *s)
{
return _ismbblead(*s) ? 2 : 1;
}
size_t _mbclen2(const unsigned int s)
{
return (_ismbblead(s>>8) && _ismbbtrail(s&0x00FF)) ? 2 : 1;
}
/*
* assume MB_CUR_MAX == 2
*
* @implemented
*/
int mblen( const char *str, size_t size )
{
if (str && *str && size)
{
return !isleadbyte(*str) ? 1 : (size>1 ? 2 : -1);
}
return 0;
}

View file

@ -0,0 +1,10 @@
#include <precomp.h>
#include <string.h>
/*
* @implemented
*/
unsigned char * _mbscat(unsigned char *dst, const unsigned char *src)
{
return (unsigned char *)strcat((char*)dst,(const char*)src);
}

View file

@ -0,0 +1,9 @@
#include <string.h>
/*
* @implemented
*/
unsigned char * _mbschr(const unsigned char *str, unsigned int c)
{
return (unsigned char *)strchr((const char*)str, c);
}

View file

@ -0,0 +1,10 @@
#include <mbstring.h>
#include <string.h>
/*
* @implemented
*/
int _mbscmp(const unsigned char *str1, const unsigned char *str2)
{
return strcmp((const char*)str1, (char*)str2);
}

View file

@ -0,0 +1,100 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbscoll.c
* PURPOSE:
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <mbstring.h>
int colldif(unsigned short c1, unsigned short c2);
/*
* @implemented
*/
int _mbscoll(const unsigned char *str1, const unsigned char *str2)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
while ( *s1 != 0 ) {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return colldif(*s1, *s2);
else {
s1 += 1;
s2 += 1;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return colldif(*short_s1, *short_s2);
else {
s1 += 2;
s2 += 2;
}
}
else
return colldif(*s1, *s2);
} ;
return 0;
}
#if 0
int _mbsbcoll(const unsigned char *str1, const unsigned char *str2)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
while ( *s1 != 0 ) {
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return colldif(*s1, *s2);
else {
s1 += 1;
s2 += 1;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return colldif(*short_s1, *short_s2);
else {
s1 += 2;
s2 += 2;
}
}
else
return colldif(*s1, *s2);
} ;
return 0;
}
#endif

View file

@ -0,0 +1,11 @@
#include <precomp.h>
#include <mbstring.h>
#include <string.h>
/*
* @implemented
*/
unsigned char * _mbscpy(unsigned char *dst, const unsigned char *str)
{
return (unsigned char*)strcpy((char*)dst,(const char*)str);
}

View file

@ -0,0 +1,33 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/mbscpn.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
#include <mbstring.h>
/*
* @implemented
*/
size_t _mbscspn (const unsigned char *str1, const unsigned char *str2)
{
int c;
const unsigned char *save = str1;
while ((c = _mbsnextc (str1))) {
if (_mbschr (str2, c))
break;
str1 = _mbsinc ((unsigned char *) str1);
}
return str1 - save;
}

View file

@ -0,0 +1,18 @@
#include <precomp.h>
#include <mbstring.h>
/*
* @implemented
*/
unsigned char * _mbsdec(const unsigned char *str, const unsigned char *cur)
{
unsigned char *s = (unsigned char *)cur;
if ( str >= cur )
return NULL;
s--;
if (_ismbblead(*(s-1)) )
s--;
return s;
}

View file

@ -0,0 +1,29 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsdup.c
* PURPOSE: Duplicates a multi byte string
* PROGRAMER: Ariadne
* UPDATE HISTORY:
Modified from DJGPP strdup
* 12/04/99: Created
*/
#include <precomp.h>
#include <mbstring.h>
#include <stdlib.h>
/*
* @implemented
*/
unsigned char * _mbsdup(const unsigned char *_s)
{
unsigned char *rv;
if (_s == 0)
return 0;
rv = (unsigned char *)malloc(_mbslen(_s) + 1);
if (rv == 0)
return 0;
_mbscpy(rv, _s);
return rv;
}

View file

@ -0,0 +1,64 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsicmp.c
* PURPOSE: Duplicates a multi byte string
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <precomp.h>
#include <mbstring.h>
/*
* @implemented
*/
int _mbsicmp(const unsigned char *str1, const unsigned char *str2)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
do {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (toupper(*s1) != toupper(*s2))
return toupper(*s1) - toupper(*s2);
else {
s1 += 1;
s2 += 1;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( _mbctoupper(*short_s1) != _mbctoupper(*short_s2 ))
return _mbctoupper(*short_s1) - _mbctoupper(*short_s2);
else {
s1 += 2;
s2 += 2;
}
}
else
return *s1 - *s2;
} while (*s1 != 0);
return 0;
while (toupper(*s1) == toupper(*s2))
{
if (*s1 == 0)
return 0;
s1++;
s2++;
}
return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2));
}

View file

@ -0,0 +1,58 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsicoll.c
* PURPOSE:
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <mbstring.h>
#include <mbctype.h>
#include <ctype.h>
int colldif(unsigned short c1, unsigned short c2);
/*
* @implemented
*/
int _mbsicoll(const unsigned char *str1, const unsigned char *str2)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
while ( *s1 != 0 ) {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (toupper(*s1) != toupper(*s2))
return colldif(*s1, *s2);
else {
s1 += 1;
s2 += 1;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( _mbctoupper(*short_s1) != _mbctoupper(*short_s2 ))
return colldif(*short_s1, *short_s2);
else {
s1 += 2;
s2 += 2;
}
}
else
return colldif(*s1, *s2);
} ;
return 0;
}

View file

@ -0,0 +1,13 @@
#include <mbstring.h>
/*
* @implemented
*/
unsigned char * _mbsinc(const unsigned char *s)
{
unsigned char *c = (unsigned char *)s;
if (_ismbblead(*s) )
c++;
c++;
return c;
}

View file

@ -0,0 +1,32 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/mbslen.c
* PURPOSE: Determines the length of a multi byte string
* PROGRAMERS:
* Copyright 1999 Alexandre Julliard
* Copyright 2000 Jon Griffths
*
*/
#include <mbstring.h>
/*
* @implemented
*/
size_t _mbslen(const unsigned char *str)
{
size_t len = 0;
while(*str)
{
if (_ismbblead(*str))
{
str++;
if (!*str) /* count only full chars */
break;
}
str++;
len++;
}
return len;
}

View file

@ -0,0 +1,55 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/mbslwr.c
* PURPOSE: Multibyte lowercase functions
* PROGRAMER: Eric Kohl
* Samuel Serapion, adapted from PROJECT C Library
*/
#include <precomp.h>
#include <mbstring.h>
#include <ctype.h>
unsigned int _mbbtolower(unsigned int c)
{
if (!_ismbblead(c) )
return tolower(c);
return c;
}
/*
* @implemented
*/
unsigned int _mbctolower(unsigned int c)
{
return _ismbcupper (c) ? c + 0x21 : c;
}
/*
* @implemented
*/
unsigned char * _mbslwr(unsigned char *x)
{
unsigned char *y=x;
if (x == NULL)
{
return NULL;
}
while (*y)
{
if (!_ismbblead(*y))
{
*y = tolower(*y);
y++;
}
else
{
*y = _mbctolower(*(unsigned short *)y);
y++;
}
}
return x;
}

View file

@ -0,0 +1,67 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsncat.c
* PURPOSE: Concatenate two multi byte string to maximum of n characters or bytes
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <precomp.h>
#include <mbstring.h>
#include <string.h>
size_t _mbclen2(const unsigned int s);
unsigned char *_mbset (unsigned char *string, int c);
/*
* @implemented
*/
unsigned char *_mbsncat (unsigned char *dst, const unsigned char *src, size_t n)
{
int c;
unsigned char *save = dst;
while ((c = _mbsnextc (dst)))
dst = _mbsinc (dst);
while (n-- > 0 && (c = _mbsnextc (src))) {
_mbset (dst, c);
dst = _mbsinc (dst);
src = _mbsinc ((unsigned char *) src);
}
*dst = '\0';
return save;
}
/*
* @implemented
*/
unsigned char * _mbsnbcat(unsigned char *dst, const unsigned char *src, size_t n)
{
unsigned char *d;
const unsigned char *s = src;
if (n != 0) {
d = dst + _mbslen(dst); // get the end of string
d += _mbclen2(*d); // move 1 or 2 up
do {
if ((*d++ = *s++) == 0)
{
while (--n != 0)
*d++ = 0;
break;
}
if ( !(n==1 && _ismbblead(*s)) )
n--;
} while (n > 0);
}
return dst;
}

View file

@ -0,0 +1,35 @@
#include <mbstring.h>
/*
* @implemented
*/
size_t _mbsnccnt(const unsigned char *str, size_t n)
{
unsigned char *s = (unsigned char *)str;
size_t cnt = 0;
while(*s != 0 && n > 0) {
if (_ismbblead(*s) )
s++;
else
n--;
s++;
cnt++;
}
return cnt;
}
/*
* @implemented
*/
size_t _mbsnbcnt(const unsigned char *str, size_t n)
{
unsigned char *s = (unsigned char *)str;
while(*s != 0 && n > 0) {
if (!_ismbblead(*s) )
n--;
s++;
}
return (size_t)(s - str);
}

View file

@ -0,0 +1,109 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsncmp.c
* PURPOSE: Compares two strings to a maximum of n bytes or characters
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <mbstring.h>
/*
* @implemented
*/
int _mbsncmp(const unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
if (n == 0)
return 0;
do {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return *s1 - *s2;
else {
s1 += 1;
s2 += 1;
n--;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return *short_s1 - *short_s2;
else {
s1 += 2;
s2 += 2;
n--;
}
}
else
return *s1 - *s2;
} while (n > 0);
return 0;
}
/*
* @implemented
*/
int _mbsnbcmp(const unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
if (n == 0)
return 0;
do {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return *s1 - *s2;
else {
s1 += 1;
s2 += 1;
n--;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return *short_s1 - *short_s2;
else {
s1 += 2;
s2 += 2;
n-=2;
}
}
else
return *s1 - *s2;
} while (n > 0);
return 0;
}

View file

@ -0,0 +1,115 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsncoll.c
* PURPOSE:
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <mbstring.h>
int colldif(unsigned short c1, unsigned short c2);
/*
* @implemented
*/
int _mbsncoll(const unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
if (n == 0)
return 0;
do {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return colldif(*s1, *s2);
else {
s1 += 1;
s2 += 1;
n--;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return colldif(*short_s1, *short_s2);
else {
s1 += 2;
s2 += 2;
n--;
}
}
else
return colldif(*s1, *s2);
} while (n > 0);
return 0;
}
/*
* @implemented
*/
int _mbsnbcoll(const unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
if (n == 0)
return 0;
do {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return colldif(*s1, *s2);
else {
s1 += 1;
s2 += 1;
n--;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return colldif(*short_s1, *short_s2);
else {
s1 += 2;
s2 += 2;
n-=2;
}
}
else
return colldif(*s1, *s2);
} while (n > 0);
return 0;
}
int colldif(unsigned short c1, unsigned short c2)
{
return c1 - c2;
}

View file

@ -0,0 +1,157 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsncpy.c
* PURPOSE: Copies a string to a maximum of n bytes or characters
* PROGRAMERS:
* Copyright 1999 Ariadne
* Copyright 1999 Alexandre Julliard
* Copyright 2000 Jon Griffths
*
*/
#include <precomp.h>
#include <mbstring.h>
extern int g_mbcp_is_multibyte;
/*
* @implemented
*/
unsigned char* _mbsncpy(unsigned char *dst, const unsigned char *src, size_t n)
{
unsigned char* ret = dst;
if(!n)
return dst;
if (g_mbcp_is_multibyte)
{
while (*src && n)
{
n--;
if (_ismbblead(*src))
{
if (!*(src+1))
{
*dst++ = 0;
*dst++ = 0;
break;
}
*dst++ = *src++;
}
*dst++ = *src++;
}
}
else
{
while (n)
{
n--;
if (!(*dst++ = *src++)) break;
}
}
while (n--) *dst++ = 0;
return ret;
}
/*
* The _mbsnbcpy function copies count bytes from src to dest. If src is shorter
* than dest, the string is padded with null characters. If dest is less than or
* equal to count it is not terminated with a null character.
*
* @implemented
*/
unsigned char * _mbsnbcpy(unsigned char *dst, const unsigned char *src, size_t n)
{
unsigned char* ret = dst;
if(!n)
return dst;
if(g_mbcp_is_multibyte)
{
int is_lead = 0;
while (*src && n)
{
is_lead = (!is_lead && _ismbblead(*src));
n--;
*dst++ = *src++;
}
if (is_lead) /* if string ends with a lead, remove it */
*(dst - 1) = 0;
}
else
{
while (n)
{
n--;
if (!(*dst++ = *src++)) break;
}
}
while (n--) *dst++ = 0;
return ret;
}
/*
* Unlike _mbsnbcpy this function does not pad the rest of the dest
* string with 0
*/
int CDECL _mbsnbcpy_s(unsigned char* dst, size_t size, const unsigned char* src, size_t n)
{
size_t pos = 0;
if(!dst || size == 0)
return EINVAL;
if(!src)
{
dst[0] = '\0';
return EINVAL;
}
if(!n)
return 0;
if(g_mbcp_is_multibyte)
{
int is_lead = 0;
while (*src && n)
{
if(pos == size)
{
dst[0] = '\0';
return ERANGE;
}
is_lead = (!is_lead && _ismbblead(*src));
n--;
dst[pos++] = *src++;
}
if (is_lead) /* if string ends with a lead, remove it */
dst[pos - 1] = 0;
}
else
{
while (n)
{
n--;
if(pos == size)
{
dst[0] = '\0';
return ERANGE;
}
if(!(*src)) break;
dst[pos++] = *src++;
}
}
if(pos < size)
dst[pos] = '\0';
else
{
dst[0] = '\0';
return ERANGE;
}
return 0;
}

View file

@ -0,0 +1,23 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/mbsnextc.c
* PURPOSE: Finds the next character in a string
* PROGRAMERS:
* Copyright 1999 Alexandre Julliard
* Copyright 2000 Jon Griffths
*
*/
#include <precomp.h>
#include <mbstring.h>
/*
* @implemented
*/
unsigned int _mbsnextc (const unsigned char *str)
{
if(_ismbblead(*str))
return *str << 8 | str[1];
return *str;
}

View file

@ -0,0 +1,47 @@
#include <mbstring.h>
size_t _mbclen2(const unsigned int s);
unsigned int _mbbtoupper(unsigned int c);
/*
* @implemented
*/
int _mbsnicmp(const unsigned char *s1, const unsigned char *s2, size_t n)
{
if (n == 0)
return 0;
do {
if (_mbbtoupper(*s1) != _mbbtoupper(*s2))
return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);
s1 += _mbclen2(*s1);
s2 += _mbclen2(*s2);
if (*s1 == 0)
break;
if (!_ismbblead(*s1))
n--;
} while (n > 0);
return 0;
}
/*
* @implemented
*/
int _mbsnbicmp(const unsigned char *s1, const unsigned char *s2, size_t n)
{
if (n == 0)
return 0;
do {
if (_mbbtoupper(*s1) != _mbbtoupper(*s2))
return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);
s1 += _mbclen2(*s1);
s2 += _mbclen2(*s2);
if (*s1 == 0)
break;
n--;
} while (n > 0);
return 0;
}

View file

@ -0,0 +1,21 @@
#include <precomp.h>
#include <mbstring.h>
/*
* @unimplemented
*/
int _mbsnicoll(const unsigned char *s1, const unsigned char *s2, size_t n)
{
WARN("_mbsnicoll unimplemented\n");
return 0;
}
/*
* @unimplemented
*/
int _mbsnbicoll(const unsigned char *s1, const unsigned char *s2, size_t n)
{
WARN("_mbsnbicoll unimplemented\n");
return 0;
}

View file

@ -0,0 +1,37 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/mbsninc.c
* PURPOSE:
* PROGRAMERS:
* Copyright 1999 Alexandre Julliard
* Copyright 2000 Jon Griffths
*
*/
#include <precomp.h>
#include <mbstring.h>
/*
* @implemented
*/
unsigned char * _mbsninc(const unsigned char *str, size_t n)
{
if(!str)
return NULL;
while (n > 0 && *str)
{
if (_ismbblead(*str))
{
if (!*(str+1))
break;
str++;
}
str++;
n--;
}
return (unsigned char*)str;
}

View file

@ -0,0 +1,70 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsnset.c
* PURPOSE: Fills a string with a multibyte character
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <mbstring.h>
size_t _mbclen2(const unsigned int s);
/*
* @implemented
*/
unsigned char * _mbsnset(unsigned char *src, unsigned int val, size_t count)
{
unsigned char *char_src = (unsigned char *)src;
unsigned short *short_src = (unsigned short *)src;
if ( _mbclen2(val) == 1 ) {
while(count > 0) {
*char_src = val;
char_src++;
count--;
}
*char_src = 0;
}
else {
while(count > 0) {
*short_src = val;
short_src++;
count-=2;
}
*short_src = 0;
}
return src;
}
/*
* @implemented
*/
unsigned char * _mbsnbset(unsigned char *src, unsigned int val, size_t count)
{
unsigned char *char_src = (unsigned char *)src;
unsigned short *short_src = (unsigned short *)src;
if ( _mbclen2(val) == 1 ) {
while(count > 0) {
*char_src = val;
char_src++;
count--;
}
*char_src = 0;
}
else {
while(count > 0) {
*short_src = val;
short_src++;
count-=2;
}
*short_src = 0;
}
return src;
}

View file

@ -0,0 +1,26 @@
#include <stdlib.h>
#include <mbstring.h>
int isleadbyte(int byte);
/*
* not correct
*
* @implemented
*/
unsigned char * _mbspbrk(const unsigned char *s1, const unsigned char *s2)
{
const unsigned char* p;
while (*s1)
{
for (p = s2; *p; p += (isleadbyte(*p) ? 2 : 1))
{
if (*p == *s1)
if (!isleadbyte(*p) || (*(p+1) == *(s1 + 1)))
return (unsigned char*)s1;
}
s1 += (isleadbyte(*s1) ? 2 : 1);
}
return NULL;
}

View file

@ -0,0 +1,33 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsrchr.c
* PURPOSE: Searches for a character in reverse
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <stdlib.h>
#include <mbstring.h>
/*
* @implemented
*/
unsigned char * _mbsrchr(const unsigned char *src, unsigned int val)
{
unsigned int c;
unsigned char *match = NULL;
if (!src)
return NULL;
while (1)
{
c = _mbsnextc(src);
if (c == val)
match = (unsigned char*)src;
if (!c)
return match;
src += (c > 255) ? 2 : 1;
}
}

View file

@ -0,0 +1,33 @@
#include <mbstring.h>
/*
* @implemented
*/
unsigned char * _mbsrev(unsigned char *s)
{
unsigned char *e;
unsigned char a;
unsigned char *e2;
e=s;
while (*e) {
if ( _ismbblead(*e) ) {
a = *e;
e2 = e;
*e2 = *++e;
if ( *e == 0 )
break;
*e = a;
}
e++;
}
while (s<e) {
a=*s;
*s=*e;
*e=a;
s++;
e--;
}
return s;
}

View file

@ -0,0 +1,40 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsset.c
* PURPOSE: Fills a string with a multibyte character
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <mbstring.h>
size_t _mbclen2(const unsigned int s);
/*
* @implemented
*/
unsigned char * _mbsset(unsigned char *src, unsigned int c)
{
unsigned char *char_src = src;
unsigned short *short_src = (unsigned short *)src;
if ( _mbclen2(c) == 1 ) {
while(*char_src != 0) {
*char_src = c;
char_src++;
}
*char_src = 0;
}
else {
while(*short_src != 0) {
*short_src = c;
short_src++;
}
*short_src = 0;
}
return src;
}

View file

@ -0,0 +1,33 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/ismbpun.c
* PURPOSE:
* PROGRAMER:
* UPDATE HISTORY:
* 05/30/08: Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
#include <mbstring.h>
/*
* @implemented
*/
size_t _mbsspn (const unsigned char *str1, const unsigned char *str2)
{
int c;
const unsigned char *save = str1;
while ((c = _mbsnextc (str1))) {
if (_mbschr (str2, c) == 0)
break;
str1 = _mbsinc ((unsigned char *) str1);
}
return str1 - save;
}

View file

@ -0,0 +1,21 @@
#include <precomp.h>
#include <mbstring.h>
/*
* @implemented
*/
unsigned char *_mbsspnp (const unsigned char *str1, const unsigned char *str2)
{
int c;
while ((c = _mbsnextc (str1))) {
if (_mbschr (str2, c) == 0)
return (unsigned char *) str1;
str1 = _mbsinc ((unsigned char *) str1);
}
return 0;
}

View file

@ -0,0 +1,23 @@
#include <mbstring.h>
#include <stdlib.h>
/*
* @implemented
*/
unsigned char *_mbsstr(const unsigned char *src1,const unsigned char *src2)
{
int len;
if (src2 ==NULL || *src2 == 0)
return (unsigned char *)src1;
len = _mbslen(src2);
while(*src1)
{
if ((*src1 == *src2) && (_mbsncmp(src1,src2,len) == 0))
return (unsigned char *)src1;
src1 = (unsigned char *)_mbsinc(src1);
}
return NULL;
}

View file

@ -0,0 +1,57 @@
#include <stdlib.h>
#include <mbstring.h>
/*
* @implemented
*/
unsigned char * _mbstok(unsigned char *s, const unsigned char *delim)
{
const unsigned char *spanp;
int c, sc;
unsigned char *tok;
static unsigned char *last;
if (s == NULL && (s = last) == NULL)
return (NULL);
/*
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
*/
cont:
c = *s;
s = _mbsinc(s);
for (spanp = delim; (sc = *spanp) != 0; spanp = _mbsinc(spanp)) {
if (c == sc)
goto cont;
}
if (c == 0) { /* no non-delimiter characters */
last = NULL;
return (NULL);
}
tok = s - 1;
/*
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
* Note that delim must have one NUL; we stop if we see that, too.
*/
for (;;) {
c = *s;
s = _mbsinc(s);
spanp = delim;
do {
if ((sc = *spanp) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
last = s;
return (tok);
}
spanp = _mbsinc(spanp);
} while (sc != 0);
}
/* NOTREACHED */
}

View file

@ -0,0 +1,32 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/mbstring/mbstrlen.c
* PURPOSE: Determines the length of a multi byte string, current locale
* PROGRAMERS:
* Copyright 1999 Alexandre Julliard
* Copyright 2000 Jon Griffths
*
*/
#include <mbstring.h>
#include <stdlib.h>
int isleadbyte(int byte);
/*
* @implemented
*/
size_t _mbstrlen( const char *str )
{
size_t len = 0;
while(*str)
{
/* FIXME: According to the documentation we are supposed to test for
* multi-byte character validity. Whatever that means
*/
str += isleadbyte(*str) ? 2 : 1;
len++;
}
return len;
}

View file

@ -0,0 +1,76 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsupr.c
* PURPOSE:
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <precomp.h>
#include <mbstring.h>
#include <ctype.h>
unsigned int _mbbtoupper(unsigned int c)
{
if (!_ismbblead(c) )
return toupper(c);
return c;
}
/*
* @implemented
*/
unsigned int _mbctoupper(unsigned int c)
{
return _ismbclower (c) ? c - 0x21 : c;
}
unsigned char *_mbset (unsigned char *string, int c)
{
unsigned char *save = string;
if (_MBIS16 (c)) {
if (_MBLMASK (c) == 0) {
*string++ = '\0';
*string++ = '\0';
}
else {
*string++ = _MBGETH (c);
*string++ = _MBGETL (c);
}
}
else {
*string++ = c;
}
return save;
}
/*
* @implemented
*/
unsigned char *_mbsupr (unsigned char *string)
{
int c;
unsigned char *save = string;
while ((c = _mbsnextc (string))) {
if (_MBIS16 (c) == 0)
c = toupper (c);
_mbset (string, c);
string = _mbsinc (string);
}
return save;
}