mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Added mbstring functions.
svn path=/trunk/; revision=2068
This commit is contained in:
parent
ccf31892a1
commit
5cb6979b1a
55 changed files with 1804 additions and 0 deletions
101
reactos/lib/msvcrt/mbstring/hanzen.c
Normal file
101
reactos/lib/msvcrt/mbstring/hanzen.c
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/hanzen.c
|
||||
* PURPOSE: Multibyte conversion routines formerly called hantozen and zentohan
|
||||
* PROGRAMER: Boudewijn Dekker, Taiji Yamada
|
||||
* UPDATE HISTORY:
|
||||
Modified from Taiji Yamada japanese code system utilities
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/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)
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
32
reactos/lib/msvcrt/mbstring/ischira.c
Normal file
32
reactos/lib/msvcrt/mbstring/ischira.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/ischira.c
|
||||
* PURPOSE:
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/mbctype.h>
|
||||
|
||||
int _ismbchira( unsigned int c )
|
||||
{
|
||||
return ((c>=0x829F) && (c<=0x82F1));
|
||||
}
|
||||
|
||||
int _ismbckata( unsigned int c )
|
||||
{
|
||||
return ((c>=0x8340) && (c<=0x8396));
|
||||
}
|
||||
|
||||
unsigned int _mbctohira( unsigned int c )
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
unsigned int _mbctokata( unsigned int c )
|
||||
{
|
||||
return c;
|
||||
}
|
17
reactos/lib/msvcrt/mbstring/iskana.c
Normal file
17
reactos/lib/msvcrt/mbstring/iskana.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/hanzen.c
|
||||
* PURPOSE: Checks for kana character
|
||||
* PROGRAMER: Boudewijn Dekker, Taiji Yamada
|
||||
* UPDATE HISTORY:
|
||||
Modified from Taiji Yamada japanese code system utilities
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/mbctype.h>
|
||||
|
||||
int _ismbbkana(unsigned char c)
|
||||
{
|
||||
return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_M|_KNJ_P));
|
||||
}
|
6
reactos/lib/msvcrt/mbstring/iskmoji.c
Normal file
6
reactos/lib/msvcrt/mbstring/iskmoji.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include <msvcrt/mbctype.h>
|
||||
|
||||
int _ismbbkalpha(unsigned char c)
|
||||
{
|
||||
return (0xA7 <= c <= 0xDF);
|
||||
}
|
15
reactos/lib/msvcrt/mbstring/iskpun.c
Normal file
15
reactos/lib/msvcrt/mbstring/iskpun.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/iskpun.c
|
||||
* PURPOSE:
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
#include <msvcrt/mbctype.h>
|
||||
|
||||
int _ismbbkpunct( unsigned int c )
|
||||
{
|
||||
return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P));
|
||||
}
|
8
reactos/lib/msvcrt/mbstring/islead.c
Normal file
8
reactos/lib/msvcrt/mbstring/islead.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/mbstring.h>
|
||||
|
||||
int isleadbyte(char *mbstr)
|
||||
{
|
||||
return 0;
|
||||
//return IsDBCSLeadByteEx(0,*c);
|
||||
}
|
23
reactos/lib/msvcrt/mbstring/islwr.c
Normal file
23
reactos/lib/msvcrt/mbstring/islwr.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbsncmp.c
|
||||
* PURPOSE:
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbctype.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
// code page 952 only
|
||||
int _ismbclower( unsigned int c )
|
||||
{
|
||||
if ((c & 0xFF00) != 0) {
|
||||
if ( c >= 0x829A && c<= 0x829A )
|
||||
return 1;
|
||||
}
|
||||
|
||||
return islower(c);
|
||||
}
|
16
reactos/lib/msvcrt/mbstring/ismbal.c
Normal file
16
reactos/lib/msvcrt/mbstring/ismbal.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/hanzen.c
|
||||
* PURPOSE: Checks for alphabetic multibyte character
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
#include <crtdll/mbctype.h>
|
||||
#include <crtdll/ctype.h>
|
||||
|
||||
int _ismbbalpha(unsigned char c)
|
||||
{
|
||||
return (isalpha(c) || _ismbbkalnum(c));
|
||||
}
|
8
reactos/lib/msvcrt/mbstring/ismbaln.c
Normal file
8
reactos/lib/msvcrt/mbstring/ismbaln.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <msvcrt/mbctype.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
|
||||
int _ismbbalnum(unsigned char c)
|
||||
{
|
||||
return (isalnum(c) || _ismbbkalnum(c));
|
||||
}
|
105
reactos/lib/msvcrt/mbstring/ismbc.c
Normal file
105
reactos/lib/msvcrt/mbstring/ismbc.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
int _ismbbalpha(unsigned char c);
|
||||
int _ismbbalnum(unsigned char c);
|
||||
|
||||
int _ismbcalnum( unsigned int c )
|
||||
{
|
||||
if ((c & 0xFF00) != 0) {
|
||||
// true multibyte character
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return _ismbbalnum(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ismbcalpha( unsigned int c )
|
||||
{
|
||||
if ((c & 0xFF00) != 0) {
|
||||
// true multibyte character
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return _ismbbalpha(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ismbcdigit( unsigned int c )
|
||||
{
|
||||
if ((c & 0xFF00) != 0) {
|
||||
// true multibyte character
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
// return _ismbbdigit(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ismbcprint( unsigned int c )
|
||||
{
|
||||
if ((c & 0xFF00) != 0) {
|
||||
// true multibyte character
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
// return _ismbbdigit(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ismbcsymbol( unsigned int c )
|
||||
{
|
||||
if ((c & 0xFF00) != 0) {
|
||||
// true multibyte character
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
// return _ismbbdigit(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ismbcspace( unsigned int c )
|
||||
{
|
||||
if ((c & 0xFF00) != 0) {
|
||||
// true multibyte character
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
// return _ismbbdigit(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
int _ismbclegal(unsigned int c)
|
||||
{
|
||||
if ((c & 0xFF00) != 0) {
|
||||
return _ismbblead(c>>8) && _ismbbtrail(c&0xFF);
|
||||
}
|
||||
else
|
||||
return _ismbbtrail(c&0xFF);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ismbcl0(unsigned int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ismbcl1(unsigned int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ismbcl2(unsigned int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
8
reactos/lib/msvcrt/mbstring/ismbgra.c
Normal file
8
reactos/lib/msvcrt/mbstring/ismbgra.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/mbctype.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
int _ismbbgraph(unsigned char c)
|
||||
{
|
||||
return (isgraph(c) || _ismbbkana(c));
|
||||
}
|
16
reactos/lib/msvcrt/mbstring/ismbkaln.c
Normal file
16
reactos/lib/msvcrt/mbstring/ismbkaln.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/iskpun.c
|
||||
* PURPOSE:
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
#include <msvcrt/mbctype.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
int _ismbbkalnum( unsigned int c )
|
||||
{
|
||||
return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P));
|
||||
}
|
59
reactos/lib/msvcrt/mbstring/ismblead.c
Normal file
59
reactos/lib/msvcrt/mbstring/ismblead.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/ismblead.c
|
||||
* PURPOSE: Checks for a lead byte
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* Modified from Taiji Yamada japanese code system utilities
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/mbctype.h>
|
||||
|
||||
size_t _mbclen2(const unsigned int s);
|
||||
|
||||
char _jctype[257] = {
|
||||
/*-1*/ ___,
|
||||
/*0x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
|
||||
/*1x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
|
||||
/*2x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
|
||||
/*3x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
|
||||
/*4x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
|
||||
/*5x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
|
||||
/*6x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
|
||||
/*7x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,___,
|
||||
/*8x*/ __2,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
|
||||
/*9x*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
|
||||
/*Ax*/ __2,_P2,_P2,_P2,_P2,_P2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
|
||||
/*Bx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
|
||||
/*Cx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
|
||||
/*Dx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
|
||||
/*Ex*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
|
||||
/*Fx*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,___,___,___
|
||||
};
|
||||
|
||||
char *_mbctype = _jctype;
|
||||
int _ismbblead(unsigned int c)
|
||||
{
|
||||
return ((_jctype+1)[(unsigned char)(c)] & _KNJ_1);
|
||||
}
|
||||
//int _ismbblead(unsigned int byte)
|
||||
//{
|
||||
//
|
||||
// return (int)IsDBCSLeadByte(byte)
|
||||
//}
|
||||
|
||||
int _ismbslead( const unsigned char *str, const unsigned char *t)
|
||||
{
|
||||
unsigned char *s = (unsigned char *)str;
|
||||
while(*s != 0 && s != t)
|
||||
{
|
||||
|
||||
s+= _mbclen2(*s);
|
||||
}
|
||||
return _ismbblead( *s);
|
||||
}
|
||||
|
8
reactos/lib/msvcrt/mbstring/ismbpri.c
Normal file
8
reactos/lib/msvcrt/mbstring/ismbpri.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/mbctype.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
int _ismbbprint(unsigned char c)
|
||||
{
|
||||
return (isprint(c) || _ismbbkana(c));
|
||||
}
|
13
reactos/lib/msvcrt/mbstring/ismbpun.c
Normal file
13
reactos/lib/msvcrt/mbstring/ismbpun.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
//iskana() :(0xA1 <= c <= 0xDF)
|
||||
//iskpun() :(0xA1 <= c <= 0xA6)
|
||||
//iskmoji() :(0xA7 <= c <= 0xDF)
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/mbctype.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
int _ismbbpunct(unsigned char c)
|
||||
{
|
||||
// (0xA1 <= c <= 0xA6)
|
||||
return (ispunct(c) || _ismbbkana(c));
|
||||
}
|
39
reactos/lib/msvcrt/mbstring/ismbtrl.c
Normal file
39
reactos/lib/msvcrt/mbstring/ismbtrl.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/ismbtrail.c
|
||||
* PURPOSE: Checks for a trailing byte
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/mbctype.h>
|
||||
|
||||
size_t _mbclen2(const unsigned int s);
|
||||
|
||||
// iskanji2() : (0x40 <= c <= 0x7E 0x80 <= c <= 0xFC)
|
||||
|
||||
int _ismbbtrail(unsigned int c)
|
||||
{
|
||||
return ((_jctype+1)[(unsigned char)(c)] & _KNJ_2);
|
||||
}
|
||||
|
||||
//int _ismbbtrail( unsigned int b)
|
||||
//{
|
||||
// return ((b >= 0x40 && b <= 0x7e ) || (b >= 0x80 && b <= 0xfc ) );
|
||||
//}
|
||||
|
||||
|
||||
int _ismbstrail( const unsigned char *str, const unsigned char *t)
|
||||
{
|
||||
unsigned char *s = (unsigned char *)str;
|
||||
while(*s != 0 && s != t)
|
||||
{
|
||||
|
||||
s+= _mbclen2(*s);
|
||||
}
|
||||
|
||||
return _ismbbtrail(*s);
|
||||
}
|
23
reactos/lib/msvcrt/mbstring/isuppr.c
Normal file
23
reactos/lib/msvcrt/mbstring/isuppr.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbsncmp.c
|
||||
* PURPOSE:
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbctype.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
// code page 952 only
|
||||
int _ismbcupper( unsigned int c )
|
||||
{
|
||||
if ((c & 0xFF00) != 0) {
|
||||
if ( c >= 0x8260 && c<= 0x8279 )
|
||||
return 1;
|
||||
}
|
||||
|
||||
return isupper(c);
|
||||
}
|
24
reactos/lib/msvcrt/mbstring/jistojms.c
Normal file
24
reactos/lib/msvcrt/mbstring/jistojms.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
unsigned short _mbcjistojms(unsigned short c)
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
c2 = (unsigned char)c;
|
||||
c1 = c >> 8;
|
||||
if (c1 >= 0x21 && c1 <= 0x7e && c2 >= 0x21 && c2 <= 0x7e) {
|
||||
if (c1 & 0x01) {
|
||||
c2 += 0x1f;
|
||||
if (c2 >= 0x7f)
|
||||
c2 ++;
|
||||
} else {
|
||||
c2 += 0x7e;
|
||||
}
|
||||
c1 += 0xe1;
|
||||
c1 >>= 1;
|
||||
if (c1 >= 0xa0)
|
||||
c1 += 0x40;
|
||||
return ((c1 << 8) | c2);
|
||||
}
|
||||
return 0;
|
||||
}
|
25
reactos/lib/msvcrt/mbstring/jmstojis.c
Normal file
25
reactos/lib/msvcrt/mbstring/jmstojis.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
unsigned short _mbcjmstojis(unsigned short 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;
|
||||
}
|
48
reactos/lib/msvcrt/mbstring/mbbtype.c
Normal file
48
reactos/lib/msvcrt/mbstring/mbbtype.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbbtype.c
|
||||
* PURPOSE: Determines the type of a multibyte character
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <crtdll/mbstring.h>
|
||||
#include <crtdll/mbctype.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int _mbsbtype( const unsigned char *str, size_t n )
|
||||
{
|
||||
if (str == NULL)
|
||||
return -1;
|
||||
return _mbbtype(*(str+n),1);
|
||||
}
|
12
reactos/lib/msvcrt/mbstring/mbccpy.c
Normal file
12
reactos/lib/msvcrt/mbstring/mbccpy.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
size_t _mbclen2(const unsigned int s);
|
||||
|
||||
void _mbccpy(unsigned char *dst, const unsigned char *src)
|
||||
{
|
||||
if (!_ismbblead(*src) )
|
||||
return;
|
||||
|
||||
memcpy(dst,src,_mbclen2(*src));
|
||||
}
|
30
reactos/lib/msvcrt/mbstring/mbclen.c
Normal file
30
reactos/lib/msvcrt/mbstring/mbclen.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
|
||||
size_t _mbclen(const unsigned char *s)
|
||||
{
|
||||
return (_ismbblead(*s>>8) && _ismbbtrail(*s&0x00FF)) ? 2 : 1;
|
||||
}
|
||||
|
||||
size_t _mbclen2(const unsigned int s)
|
||||
{
|
||||
return (_ismbblead(s>>8) && _ismbbtrail(s&0x00FF)) ? 2 : 1;
|
||||
}
|
||||
|
||||
// assume MB_CUR_MAX == 2
|
||||
int mblen( const char *s, size_t count )
|
||||
{
|
||||
size_t l;
|
||||
if ( s == NULL )
|
||||
return 0;
|
||||
|
||||
l = _mbclen(s);
|
||||
if ( l < count )
|
||||
return -1;
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
|
6
reactos/lib/msvcrt/mbstring/mbscat.c
Normal file
6
reactos/lib/msvcrt/mbstring/mbscat.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include <msvcrt/string.h>
|
||||
|
||||
unsigned char * _mbscat(unsigned char *dst, const unsigned char *src)
|
||||
{
|
||||
return strcat(dst,src);
|
||||
}
|
6
reactos/lib/msvcrt/mbstring/mbschr.c
Normal file
6
reactos/lib/msvcrt/mbstring/mbschr.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include <msvcrt/string.h>
|
||||
|
||||
unsigned char * _mbschr(const unsigned char *str, unsigned int c)
|
||||
{
|
||||
return strchr(str,c);
|
||||
}
|
7
reactos/lib/msvcrt/mbstring/mbscmp.c
Normal file
7
reactos/lib/msvcrt/mbstring/mbscmp.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
int _mbscmp(const unsigned char *str1, const unsigned char *str2)
|
||||
{
|
||||
return strcmp(str1,str2);
|
||||
}
|
97
reactos/lib/msvcrt/mbstring/mbscoll.c
Normal file
97
reactos/lib/msvcrt/mbstring/mbscoll.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbscoll.c
|
||||
* PURPOSE:
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbstring.h>
|
||||
|
||||
int colldif(unsigned short c1, unsigned short c2);
|
||||
|
||||
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
|
7
reactos/lib/msvcrt/mbstring/mbscpy.c
Normal file
7
reactos/lib/msvcrt/mbstring/mbscpy.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
unsigned char * _mbscpy(unsigned char *dst, const unsigned char *str)
|
||||
{
|
||||
return strcpy(dst,str);
|
||||
}
|
19
reactos/lib/msvcrt/mbstring/mbscspn.c
Normal file
19
reactos/lib/msvcrt/mbstring/mbscspn.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
// not correct
|
||||
size_t _mbscspn(const unsigned char *s1, const unsigned char *s2)
|
||||
{
|
||||
const char *p, *spanp;
|
||||
char c, sc;
|
||||
|
||||
for (p = s1;;)
|
||||
{
|
||||
c = *p++;
|
||||
spanp = s2;
|
||||
do {
|
||||
if ((sc = *spanp++) == c)
|
||||
return (size_t)(p - 1) - (size_t)s1;
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
14
reactos/lib/msvcrt/mbstring/mbsdec.c
Normal file
14
reactos/lib/msvcrt/mbstring/mbsdec.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
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;
|
||||
}
|
25
reactos/lib/msvcrt/mbstring/mbsdup.c
Normal file
25
reactos/lib/msvcrt/mbstring/mbsdup.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/hanzen.c
|
||||
* PURPOSE: Duplicates a multi byte string
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
Modified from DJGPP strdup
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
unsigned char * _mbsdup(const unsigned char *_s)
|
||||
{
|
||||
char *rv;
|
||||
if (_s == 0)
|
||||
return 0;
|
||||
rv = (char *)malloc(_mbslen(_s) + 1);
|
||||
if (rv == 0)
|
||||
return 0;
|
||||
_mbscpy(rv, _s);
|
||||
return rv;
|
||||
}
|
62
reactos/lib/msvcrt/mbstring/mbsicmp.c
Normal file
62
reactos/lib/msvcrt/mbstring/mbsicmp.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbsicmp.c
|
||||
* PURPOSE: Duplicates a multi byte string
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/mbctype.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
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));
|
||||
}
|
55
reactos/lib/msvcrt/mbstring/mbsicoll.c
Normal file
55
reactos/lib/msvcrt/mbstring/mbsicoll.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/iskpun.c
|
||||
* PURPOSE:
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/mbctype.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
int colldif(unsigned short c1, unsigned short c2);
|
||||
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;
|
||||
}
|
10
reactos/lib/msvcrt/mbstring/mbsinc.c
Normal file
10
reactos/lib/msvcrt/mbstring/mbsinc.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
unsigned char * _mbsinc(const unsigned char *s)
|
||||
{
|
||||
unsigned char *c = (unsigned char *)s;
|
||||
if (_ismbblead(*s) )
|
||||
c++;
|
||||
c++;
|
||||
return c;
|
||||
}
|
15
reactos/lib/msvcrt/mbstring/mbslen.c
Normal file
15
reactos/lib/msvcrt/mbstring/mbslen.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
size_t _mbclen2(const unsigned int s);
|
||||
|
||||
size_t _mbslen(const unsigned char *str)
|
||||
{
|
||||
int i = 0;
|
||||
unsigned char *s;
|
||||
|
||||
if (str == 0)
|
||||
return 0;
|
||||
|
||||
for (s = (unsigned char *)str; *s; s+=_mbclen2(*s),i++);
|
||||
return i;
|
||||
}
|
45
reactos/lib/msvcrt/mbstring/mbslwr.c
Normal file
45
reactos/lib/msvcrt/mbstring/mbslwr.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
unsigned int _mbbtolower(unsigned int c)
|
||||
{
|
||||
if (!_ismbblead(c) )
|
||||
return tolower(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
// code page 952
|
||||
#define CASE_DIFF (0x8281 - 0x8260)
|
||||
|
||||
unsigned int _mbctolower(unsigned int c)
|
||||
{
|
||||
if ((c & 0xFF00) != 0)
|
||||
{
|
||||
// true multibyte case conversion needed
|
||||
if (_ismbclower(c))
|
||||
return c + CASE_DIFF;
|
||||
}
|
||||
else
|
||||
return _mbbtolower(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char * _mbslwr(unsigned char *x)
|
||||
{
|
||||
unsigned char *y=x;
|
||||
|
||||
while (*y)
|
||||
{
|
||||
if (!_ismbblead(*y))
|
||||
{
|
||||
*y = tolower(*y);
|
||||
}
|
||||
else
|
||||
{
|
||||
*y=_mbctolower(*(unsigned short *)y);
|
||||
y++;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
58
reactos/lib/msvcrt/mbstring/mbsncat.c
Normal file
58
reactos/lib/msvcrt/mbstring/mbsncat.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbsset.c
|
||||
* PURPOSE: Concatenate two multi byte string to maximum of n characters or bytes
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
size_t _mbclen2(const unsigned int s);
|
||||
|
||||
unsigned char * _mbsncat(unsigned char *dst, const unsigned char *src, size_t n)
|
||||
{
|
||||
char *d = (char *)dst;
|
||||
char *s = (char *)src;
|
||||
if (n != 0) {
|
||||
d = dst + strlen(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 (!_ismbblead(*s) )
|
||||
n--;
|
||||
} while (n > 0);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
unsigned char * _mbsnbcat(unsigned char *dst, const unsigned char *src, size_t n)
|
||||
{
|
||||
char *d;
|
||||
char *s = (char *)src;
|
||||
if (n != 0) {
|
||||
d = dst + strlen(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;
|
||||
}
|
29
reactos/lib/msvcrt/mbstring/mbsnccnt.c
Normal file
29
reactos/lib/msvcrt/mbstring/mbsnccnt.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
103
reactos/lib/msvcrt/mbstring/mbsncmp.c
Normal file
103
reactos/lib/msvcrt/mbstring/mbsncmp.c
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbsncmp.c
|
||||
* PURPOSE: Compares two strings to a maximum of n bytes or characters
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbstring.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
109
reactos/lib/msvcrt/mbstring/mbsncoll.c
Normal file
109
reactos/lib/msvcrt/mbstring/mbsncoll.c
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbsncoll.c
|
||||
* PURPOSE:
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
#include <msvcrt/mbstring.h>
|
||||
|
||||
int colldif(unsigned short c1, unsigned short c2);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
77
reactos/lib/msvcrt/mbstring/mbsncpy.c
Normal file
77
reactos/lib/msvcrt/mbstring/mbsncpy.c
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbsncpy.c
|
||||
* PURPOSE: Copies a string to a maximum of n bytes or characters
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbstring.h>
|
||||
|
||||
unsigned char *_mbsncpy(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;
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
do {
|
||||
|
||||
if (*s2 == 0)
|
||||
break;
|
||||
|
||||
if ( !_ismbblead(*s2) ) {
|
||||
|
||||
*s1 = *s2;
|
||||
s1 += 1;
|
||||
s2 += 1;
|
||||
n--;
|
||||
}
|
||||
else {
|
||||
short_s1 = (unsigned short *)s1;
|
||||
short_s2 = (unsigned short *)s2;
|
||||
*short_s1 = *short_s2;
|
||||
s1 += 2;
|
||||
s2 += 2;
|
||||
n--;
|
||||
}
|
||||
} while (n > 0);
|
||||
return str1;
|
||||
}
|
||||
|
||||
unsigned char * _mbsnbcpy(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;
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
do {
|
||||
|
||||
if (*s2 == 0)
|
||||
break;
|
||||
|
||||
if ( !_ismbblead(*s2) ) {
|
||||
|
||||
*s1 = *s2;
|
||||
s1 += 1;
|
||||
s2 += 1;
|
||||
n--;
|
||||
}
|
||||
else {
|
||||
short_s1 = (unsigned short *)s1;
|
||||
short_s2 = (unsigned short *)s2;
|
||||
*short_s1 = *short_s2;
|
||||
s1 += 2;
|
||||
s2 += 2;
|
||||
n-=2;
|
||||
}
|
||||
} while (n > 0);
|
||||
return str1;
|
||||
}
|
16
reactos/lib/msvcrt/mbstring/mbsnextc.c
Normal file
16
reactos/lib/msvcrt/mbstring/mbsnextc.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
unsigned int _mbsnextc (const unsigned char *src)
|
||||
{
|
||||
unsigned char *char_src = (unsigned char *)src;
|
||||
unsigned short *short_src = (unsigned short *)src;
|
||||
|
||||
if (src == NULL)
|
||||
return 0;
|
||||
|
||||
if (!_ismbblead(*src))
|
||||
return *char_src;
|
||||
else
|
||||
return *short_src;
|
||||
return 0;
|
||||
}
|
39
reactos/lib/msvcrt/mbstring/mbsnicmp.c
Normal file
39
reactos/lib/msvcrt/mbstring/mbsnicmp.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
size_t _mbclen2(const unsigned int s);
|
||||
unsigned int _mbbtoupper(unsigned int c);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
11
reactos/lib/msvcrt/mbstring/mbsnicoll.c
Normal file
11
reactos/lib/msvcrt/mbstring/mbsnicoll.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
int _mbsnicoll(const unsigned char *s1, const unsigned char *s2, size_t n)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _mbsnbicoll(const unsigned char *s1, const unsigned char *s2, size_t n)
|
||||
{
|
||||
return 0;
|
||||
}
|
13
reactos/lib/msvcrt/mbstring/mbsninc.c
Normal file
13
reactos/lib/msvcrt/mbstring/mbsninc.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
unsigned char * _mbsninc(const unsigned char *str, size_t n)
|
||||
{
|
||||
unsigned char *s = (unsigned char *)str;
|
||||
while(*s != 0 && n > 0) {
|
||||
if (!_ismbblead(*s) )
|
||||
n--;
|
||||
s++;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
64
reactos/lib/msvcrt/mbstring/mbsnset.c
Normal file
64
reactos/lib/msvcrt/mbstring/mbsnset.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbsset.c
|
||||
* PURPOSE: Fills a string with a multibyte character
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
#include <msvcrt/mbstring.h>
|
||||
|
||||
size_t _mbclen2(const unsigned int s);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
16
reactos/lib/msvcrt/mbstring/mbspbrk.c
Normal file
16
reactos/lib/msvcrt/mbstring/mbspbrk.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
// not correct
|
||||
unsigned char * _mbspbrk(const unsigned char *s1, const unsigned char *s2)
|
||||
{
|
||||
const char *scanp;
|
||||
int c, sc;
|
||||
|
||||
while ((c = *s1++) != 0)
|
||||
{
|
||||
for (scanp = s2; (sc = *scanp++) != 0;)
|
||||
if (sc == c)
|
||||
return (unsigned char *)((char *)s1 - (char *)1);
|
||||
}
|
||||
return 0;
|
||||
}
|
30
reactos/lib/msvcrt/mbstring/mbsrchr.c
Normal file
30
reactos/lib/msvcrt/mbstring/mbsrchr.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbsrchr.c
|
||||
* PURPOSE: Searches for a character in reverse
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbstring.h>
|
||||
|
||||
size_t _mbclen2(const unsigned int s);
|
||||
|
||||
unsigned char * _mbsrchr(const unsigned char *src, unsigned int val)
|
||||
{
|
||||
char *s = (char *)src;
|
||||
short cc = val;
|
||||
const char *sp=(char *)0;
|
||||
|
||||
while (*s)
|
||||
{
|
||||
if (*(short *)s == cc)
|
||||
sp = s;
|
||||
s+= _mbclen2(*s);
|
||||
}
|
||||
if (cc == 0)
|
||||
sp = s;
|
||||
return (char *)sp;
|
||||
}
|
28
reactos/lib/msvcrt/mbstring/mbsrev.c
Normal file
28
reactos/lib/msvcrt/mbstring/mbsrev.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
unsigned char * _mbsrev(unsigned char *s)
|
||||
{
|
||||
unsigned char *e;
|
||||
unsigned char a;
|
||||
e=s;
|
||||
while (*e) {
|
||||
if ( _ismbblead(*e) ) {
|
||||
a = *e;
|
||||
*e = *++e;
|
||||
if ( *e == 0 )
|
||||
break;
|
||||
*e = a;
|
||||
}
|
||||
e++;
|
||||
}
|
||||
while (s<e) {
|
||||
a=*s;
|
||||
*s=*e;
|
||||
*e=a;
|
||||
s++;
|
||||
e--;
|
||||
}
|
||||
|
||||
|
||||
return s;
|
||||
}
|
37
reactos/lib/msvcrt/mbstring/mbsset.c
Normal file
37
reactos/lib/msvcrt/mbstring/mbsset.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/mbstring/mbsset.c
|
||||
* PURPOSE: Fills a string with a multibyte character
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/mbstring.h>
|
||||
|
||||
size_t _mbclen2(const unsigned int s);
|
||||
|
||||
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;
|
||||
}
|
16
reactos/lib/msvcrt/mbstring/mbsspn.c
Normal file
16
reactos/lib/msvcrt/mbstring/mbsspn.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
// not correct
|
||||
size_t _mbsspn(const unsigned char *s1, const unsigned char *s2)
|
||||
{
|
||||
const char *p = s1, *spanp;
|
||||
char c, sc;
|
||||
|
||||
cont:
|
||||
c = *p++;
|
||||
for (spanp = s2; (sc = *spanp++) != 0;)
|
||||
if (sc == c)
|
||||
goto cont;
|
||||
return (size_t)(p - 1) - (size_t)s1;
|
||||
// - (char *)s1);
|
||||
}
|
15
reactos/lib/msvcrt/mbstring/mbsspnp.c
Normal file
15
reactos/lib/msvcrt/mbstring/mbsspnp.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
// not correct
|
||||
unsigned char * _mbsspnp(const unsigned char *s1, const unsigned char *s2)
|
||||
{
|
||||
const char *p = s1, *spanp;
|
||||
char c, sc;
|
||||
|
||||
cont:
|
||||
c = *p++;
|
||||
for (spanp = s2; (sc = *spanp++) != 0;)
|
||||
if (sc == c)
|
||||
goto cont;
|
||||
return (unsigned char *)p;
|
||||
}
|
20
reactos/lib/msvcrt/mbstring/mbsstr.c
Normal file
20
reactos/lib/msvcrt/mbstring/mbsstr.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
unsigned char *_mbsstr(const unsigned char *src1,const unsigned char *src2)
|
||||
{
|
||||
int len;
|
||||
|
||||
if (src2 ==NULL || *src2 == 0)
|
||||
return (unsigned char *)src1;
|
||||
|
||||
len = _mbstrlen(src2);
|
||||
|
||||
while(*src1)
|
||||
{
|
||||
if ((*src1 == *src2) && (_mbsncmp(src1,src2,len) == 0))
|
||||
return (unsigned char *)src1;
|
||||
src1 = (unsigned char *)_mbsinc(src1);
|
||||
}
|
||||
return NULL;
|
||||
}
|
53
reactos/lib/msvcrt/mbstring/mbstok.c
Normal file
53
reactos/lib/msvcrt/mbstring/mbstok.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
|
||||
unsigned char * _mbstok(unsigned char *s, const unsigned char *delim)
|
||||
{
|
||||
const char *spanp;
|
||||
int c, sc;
|
||||
char *tok;
|
||||
static 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 */
|
||||
}
|
16
reactos/lib/msvcrt/mbstring/mbstrlen.c
Normal file
16
reactos/lib/msvcrt/mbstring/mbstrlen.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
size_t _mbstrlen( const char *string )
|
||||
{
|
||||
char *s = (char *)string;
|
||||
size_t i = 0;
|
||||
|
||||
while ( *s != 0 ) {
|
||||
if ( _ismbblead(*s) )
|
||||
s++;
|
||||
s++;
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
50
reactos/lib/msvcrt/mbstring/mbsupr.c
Normal file
50
reactos/lib/msvcrt/mbstring/mbsupr.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/mbstring/mbsupr.c
|
||||
* PURPOSE:
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 12/04/99: Created
|
||||
*/
|
||||
#include <msvcrt/mbstring.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
unsigned int _mbbtoupper(unsigned int c)
|
||||
{
|
||||
if (!_ismbblead(c) )
|
||||
return toupper(c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
// codepage 952
|
||||
#define CASE_DIFF (0x8281 - 0x8260)
|
||||
|
||||
unsigned int _mbctoupper(unsigned int c)
|
||||
{
|
||||
|
||||
if ((c & 0xFF00) != 0) {
|
||||
// true multibyte case conversion needed
|
||||
if ( _ismbcupper(c) )
|
||||
return c + CASE_DIFF;
|
||||
|
||||
} else
|
||||
return _mbbtoupper(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char * _mbsupr(unsigned char *x)
|
||||
{
|
||||
unsigned char *y=x;
|
||||
while (*y) {
|
||||
if (!_ismbblead(*y) )
|
||||
*y = toupper(*y);
|
||||
else {
|
||||
*y=_mbctoupper(*(unsigned short *)y);
|
||||
y++;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
Loading…
Reference in a new issue