summaryrefslogtreecommitdiffstats
path: root/private/crt32/mbstring
diff options
context:
space:
mode:
Diffstat (limited to 'private/crt32/mbstring')
-rw-r--r--private/crt32/mbstring/i386/ismbbyte.sav205
-rw-r--r--private/crt32/mbstring/i386/mbcsinit.os255
-rw-r--r--private/crt32/mbstring/i386/mbscat.asm18
-rw-r--r--private/crt32/mbstring/i386/mbsdup.asm16
-rw-r--r--private/crt32/mbstring/ismbalph.c67
-rw-r--r--private/crt32/mbstring/ismbbyte.c148
-rw-r--r--private/crt32/mbstring/ismbdgt.c60
-rw-r--r--private/crt32/mbstring/ismbknj.c93
-rw-r--r--private/crt32/mbstring/ismblgl.c42
-rw-r--r--private/crt32/mbstring/ismblwr.c63
-rw-r--r--private/crt32/mbstring/ismbprn.c60
-rw-r--r--private/crt32/mbstring/ismbsle.c58
-rw-r--r--private/crt32/mbstring/ismbspc.c61
-rw-r--r--private/crt32/mbstring/ismbstr.c58
-rw-r--r--private/crt32/mbstring/ismbupr.c63
-rw-r--r--private/crt32/mbstring/makefile6
-rw-r--r--private/crt32/mbstring/makefile.knj508
-rw-r--r--private/crt32/mbstring/mbascii0.c33
-rw-r--r--private/crt32/mbstring/mbascii1.opt19
-rw-r--r--private/crt32/mbstring/mbbtype.c70
-rw-r--r--private/crt32/mbstring/mbccpy.c47
-rw-r--r--private/crt32/mbstring/mbclen.c42
-rw-r--r--private/crt32/mbstring/mbclevel.c92
-rw-r--r--private/crt32/mbstring/mbctype.c318
-rw-r--r--private/crt32/mbstring/mbsbtype.c64
-rw-r--r--private/crt32/mbstring/mbscat.c21
-rw-r--r--private/crt32/mbstring/mbschr.c67
-rw-r--r--private/crt32/mbstring/mbscmp.c61
-rw-r--r--private/crt32/mbstring/mbscspn.c105
-rw-r--r--private/crt32/mbstring/mbsdec.c84
-rw-r--r--private/crt32/mbstring/mbsdup.c18
-rw-r--r--private/crt32/mbstring/mbsicmp.c90
-rw-r--r--private/crt32/mbstring/mbsinc.c48
-rw-r--r--private/crt32/mbstring/mbslen.c51
-rw-r--r--private/crt32/mbstring/mbslwr.c76
-rw-r--r--private/crt32/mbstring/mbsnbcat.c99
-rw-r--r--private/crt32/mbstring/mbsnbcmp.c75
-rw-r--r--private/crt32/mbstring/mbsnbcnt.c62
-rw-r--r--private/crt32/mbstring/mbsnbcpy.c79
-rw-r--r--private/crt32/mbstring/mbsnbicm.c101
-rw-r--r--private/crt32/mbstring/mbsnbset.c102
-rw-r--r--private/crt32/mbstring/mbsncat.c95
-rw-r--r--private/crt32/mbstring/mbsnccnt.c59
-rw-r--r--private/crt32/mbstring/mbsncmp.c69
-rw-r--r--private/crt32/mbstring/mbsncpy.c74
-rw-r--r--private/crt32/mbstring/mbsnextc.c50
-rw-r--r--private/crt32/mbstring/mbsnicmp.c97
-rw-r--r--private/crt32/mbstring/mbsninc.c50
-rw-r--r--private/crt32/mbstring/mbsnset.c110
-rw-r--r--private/crt32/mbstring/mbspbrk.c18
-rw-r--r--private/crt32/mbstring/mbsrchr.c67
-rw-r--r--private/crt32/mbstring/mbsrev.c72
-rw-r--r--private/crt32/mbstring/mbsset.c76
-rw-r--r--private/crt32/mbstring/mbsspn.c101
-rw-r--r--private/crt32/mbstring/mbsspnp.c18
-rw-r--r--private/crt32/mbstring/mbsstr.c80
-rw-r--r--private/crt32/mbstring/mbstok.c174
-rw-r--r--private/crt32/mbstring/mbsupr.c72
-rw-r--r--private/crt32/mbstring/mbtohira.c53
-rw-r--r--private/crt32/mbstring/mbtokata.c51
-rw-r--r--private/crt32/mbstring/mbtolwr.c72
-rw-r--r--private/crt32/mbstring/mbtoupr.c72
-rw-r--r--private/crt32/mbstring/sources105
-rw-r--r--private/crt32/mbstring/strdec.c46
-rw-r--r--private/crt32/mbstring/strinc.c44
-rw-r--r--private/crt32/mbstring/strncnt.c52
-rw-r--r--private/crt32/mbstring/strnextc.c44
-rw-r--r--private/crt32/mbstring/strninc.c47
-rw-r--r--private/crt32/mbstring/strspnp.c65
-rw-r--r--private/crt32/mbstring/tojisjms.c116
-rw-r--r--private/crt32/mbstring/tombbmbc.c312
71 files changed, 5766 insertions, 0 deletions
diff --git a/private/crt32/mbstring/i386/ismbbyte.sav b/private/crt32/mbstring/i386/ismbbyte.sav
new file mode 100644
index 000000000..7953a7886
--- /dev/null
+++ b/private/crt32/mbstring/i386/ismbbyte.sav
@@ -0,0 +1,205 @@
+ page ,132
+ title ismbbyte - Function versions of MBCS ctype macros
+;***
+;ismbbyte.asm - Function versions of MBCS ctype macros.
+;
+; Copyright (c) 1988-1992, Microsoft Corporation. All rights reserved.
+;
+;Purpose:
+; This files provides function versions of the character
+; classification and conversion macros in mbctype.h.
+;
+;Revision History:
+; 06-12-90 YSO Created
+; 06-13-90 YSO Added support for model-independent function
+; (internal function)
+; 04-24-91 JCR MBCS generalization/enhancement
+; 07-17-91 JLM Generalized _MK (Kana moji bit mask) to _MS (MBCS
+; single byte symbol).
+; 08-09-91 JLM Changed file name from _mbctype.asm to mbscfcn.asm
+; 08-15-91 JLM Standardized ifdefs for model-independent function.
+; 08-20-91 JLM Changed ismb* to ismbb*.
+; 08-28-91 JLM Changed file/function names to MBCS spec.
+;
+;*******************************************************************************
+
+.xlist
+include version.inc
+include cmacros.inc
+.list
+
+
+; Define masks
+
+; set bit masks for the possible kanji character types
+; (all MBCS bit masks start with "_M")
+
+_MS equ 01h ; MBCS non-ascii single byte char
+_MP equ 02h ; MBCS punct
+_M1 equ 04h ; MBCS 1st (lead) byte
+_M2 equ 08h ; MBCS 2nd byte
+
+; set bit masks for the possible character types
+
+_UPPER equ 01h ; upper case letter
+_LOWER equ 02h ; lower case letter
+_DIGIT equ 04h ; digit[0-9]
+_SPACE equ 08h ; tab, carriage return, newline,
+ ; vertical tab or form feed
+_PUNCT equ 10h ; punctuation character
+_CONTROL equ 20h ; control character
+_BLANK equ 40h ; space char
+_HEX equ 80h ; hexadecimal digit
+
+sBegin data
+ assumes ds,data
+ extrn __mbctype:byte ; MBCS ctype table
+ extrn __ctype_:byte ; ANSI/ASCII ctype table
+sEnd
+
+
+sBegin code
+
+ assumes cs,code
+ assumes ds,data
+
+page
+;***
+; ismbbyte - Function versions of mbctype macros
+;
+;Purpose:
+;
+;Entry:
+; int = character to be tested
+;Exit:
+; ax = non-zero = character is of the requested type
+; = 0 = character is NOT of the requested type
+;
+;Uses:
+;
+;Exceptions:
+;
+;*******************************************************************************
+
+ifndef MODELINDEP
+
+ifdef _KANJI
+
+ public __ismbbkalnum
+__ismbbkalnum:
+ mov ax, _MS
+ jmp short mbctype
+
+ public __ismbbkpunct
+__ismbbkpunct:
+ mov ax, _MP
+ jmp short mbctype
+
+ public __ismbbkana
+__ismbbkana:
+ mov ax, (_MS OR _MP)
+ jmp short mbctype
+
+endif
+
+
+ public __ismbbalpha
+__ismbbalpha:
+ mov ah, (_UPPER OR _LOWER)
+ mov al, _MS
+ jmp short mbctype
+
+ public __ismbbpunct
+__ismbbpunct:
+ mov ah, _PUNCT
+ mov al, _MP
+ jmp short mbctype
+
+ public __ismbbalnum
+__ismbbalnum:
+ mov ah, (_UPPER OR _LOWER OR _DIGIT)
+ mov al, _MS
+ jmp short mbctype
+
+ public __ismbbprint
+__ismbbprint:
+ mov ah, (_BLANK OR _PUNCT OR _UPPER OR _LOWER OR _DIGIT)
+ mov al, (_MS OR _MP)
+ jmp short mbctype
+
+ public __ismbbgraph
+__ismbbgraph:
+ mov ah, (_PUNCT OR _UPPER OR _LOWER OR _DIGIT)
+ mov al, (_MS OR _MP)
+ jmp short mbctype
+
+ public __ismbblead
+__ismbblead:
+ mov ax,_M1
+ jmp short mbctype
+
+ public __ismbbtrail
+__ismbbtrail:
+ mov ax,_M2
+ jmp short mbctype
+
+else ; MODELINDEP
+
+ public __fismbblead
+__fismbblead:
+ mov ax,_M1
+ jmp short mbctype
+
+ public __fismbbtrail
+__fismbbtrail:
+ mov ax,_M2
+ jmp short mbctype
+
+endif ; MODELINDEP
+
+;
+; Common code
+;
+; ax = character mask
+;
+; al = mask for _mbctype[] table
+; ah = mask for _ctype[] table
+;
+
+cProc mbctype,<LOCAL>,<>
+
+ parmW char
+
+cBegin
+
+ifdef _LOAD_DGROUP
+ push ds
+ mov bx,DGROUP
+ mov ds,bx
+else
+ifdef MODELINDEP
+ push ds
+ mov bx,DGROUP
+ mov ds,bx
+endif
+endif
+
+ mov bx,[char] ; get input character
+ cmp ah, 0 ; any non-MBCS comparison?
+ jz @F ; jump, if not
+ and ah, [bx + __ctype_ + 1] ; test _ctype[] entry
+@@:
+ and al, [bx + __mbctype + 1] ; test _mbctype[] entry
+ifdef _LOAD_DGROUP
+ pop ds
+else
+ifdef MODELINDEP
+ pop ds
+endif
+endif
+
+cEnd <nolocals>
+
+sEnd
+
+ end
diff --git a/private/crt32/mbstring/i386/mbcsinit.os2 b/private/crt32/mbstring/i386/mbcsinit.os2
new file mode 100644
index 000000000..cb8efab35
--- /dev/null
+++ b/private/crt32/mbstring/i386/mbcsinit.os2
@@ -0,0 +1,55 @@
+ page ,132
+ title mbcsinit - Initialize MBCS
+;***
+;mbcsinit.asm - Initialize MBCS
+;
+; Copyright (c) 1991-1992, Microsoft Corporation. All Rights Reserved.
+;
+;Purpose:
+; This routine is necessary for the startup code to save the
+; initial the MBCS package (get lead byte table from OS, etc.).
+;
+; [Only used in _MBCS_OS builds.]
+;
+;Revision History:
+; 02-05-92 JCR Module created
+;
+;*******************************************************************************
+
+IFDEF _MBCS_OS
+
+?DF = 1 ; tell cmacros.inc we want to define our own segments
+
+include version.inc
+.xlist
+include cmacros.inc
+include defsegs.inc
+.list
+
+CrtDefSegs <code, data>
+CrtDefSegs <xiseg>
+
+page
+
+sBegin data
+assumes ds,data
+
+ globalW _mbcsflag,0
+
+sEnd
+
+externP _mbcsinit
+
+sBegin xiseg
+
+if sizeC
+ dd _mbcsinit
+else
+ dw _mbcsinit
+endif
+
+sEnd
+
+ENDIF ;_MBCS_OS
+
+ end
diff --git a/private/crt32/mbstring/i386/mbscat.asm b/private/crt32/mbstring/i386/mbscat.asm
new file mode 100644
index 000000000..b0c042fe9
--- /dev/null
+++ b/private/crt32/mbstring/i386/mbscat.asm
@@ -0,0 +1,18 @@
+;***
+;mbscat.asm - contains mbscat() and mbscpy() routines
+;
+; Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+;
+;Purpose:
+; STRCAT concatenates (appends) a copy of the source string to the
+; end of the destination string, returning the destination string.
+;
+;Revision History:
+; 11-18-92 KRS Identical to strcat/strcpy. Could use alias records.
+;
+;*******************************************************************************
+
+strcat EQU <_mbscat>
+strcpy EQU <_mbscpy>
+ include ..\string\i386\strcat.asm
+ end
diff --git a/private/crt32/mbstring/i386/mbsdup.asm b/private/crt32/mbstring/i386/mbsdup.asm
new file mode 100644
index 000000000..e818a4cde
--- /dev/null
+++ b/private/crt32/mbstring/i386/mbsdup.asm
@@ -0,0 +1,16 @@
+;***
+;mbsdup.asm - duplicate a string in malloc'd memory
+;
+; Copyright (c) 1985-1991, Microsoft Corporation. All rights reserved.
+;
+;Purpose:
+; defines _mbsdup() - grab new memory, and duplicate the string into it.
+;
+;Revision History:
+; 11-18-92 KRS Identical to strdup. Could just use alias records.
+;
+;*******************************************************************************
+
+_strdup EQU <_mbsdup>
+ include ..\string\i386\strdup.asm
+ end
diff --git a/private/crt32/mbstring/ismbalph.c b/private/crt32/mbstring/ismbalph.c
new file mode 100644
index 000000000..28c8b1cd3
--- /dev/null
+++ b/private/crt32/mbstring/ismbalph.c
@@ -0,0 +1,67 @@
+/***
+*ismbalph.c - Test if character is alphabetic (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Test if character is alphabetic (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _ismbcalpha - Test if character is alphabetic (MBCS)
+*
+*Purpose:
+* Test if character is alphabetic.
+* Handles MBCS chars correctly.
+*
+* Note: Use test against 0x00FF instead of _ISLEADBYTE
+* to ensure that we don't call SBCS routine with a two-byte
+* value.
+*
+*Entry:
+* unsigned int c = character to test
+*
+*Exit:
+* Returns TRUE if c is alphabetic, else FALSE
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbcalpha(c)
+unsigned int c;
+{
+ if (c > 0x00FF)
+
+#ifdef _MBCS_OS
+ return (0);
+#else
+ {
+ if (_mbascii)
+ return (
+ ((c >= _MBLOWERLOW) && (c <= _MBLOWERHIGH)) ||
+ ((c >= _MBUPPERLOW) && (c <= _MBUPPERHIGH))
+ );
+ else
+ return (0);
+ }
+#endif
+
+ else
+
+ return (isalpha(c)); // macro version
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/ismbbyte.c b/private/crt32/mbstring/ismbbyte.c
new file mode 100644
index 000000000..b494284d3
--- /dev/null
+++ b/private/crt32/mbstring/ismbbyte.c
@@ -0,0 +1,148 @@
+/***
+*ismbbyte.c - Function versions of MBCS ctype macros
+*
+* Copyright (c) 1988-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* This files provides function versions of the character
+* classification a*d conversion macros in mbctype.h.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit assembler sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+#if (_MSC_VER<800)
+#define __fastcall _CRTAPI3
+#endif
+
+/* defined in mbctype.h
+; Define masks
+
+; set bit masks for the possible kanji character types
+; (all MBCS bit masks start with "_M")
+
+_MS equ 01h ; MBCS non-ascii single byte char
+_MP equ 02h ; MBCS punct
+_M1 equ 04h ; MBCS 1st (lead) byte
+_M2 equ 08h ; MBCS 2nd byte
+
+*/
+
+/* defined in ctype.h
+; set bit masks for the possible character types
+
+_UPPER equ 01h ; upper case letter
+_LOWER equ 02h ; lower case letter
+_DIGIT equ 04h ; digit[0-9]
+_SPACE equ 08h ; tab, carriage return, newline,
+ ; vertical tab or form feed
+_PUNCT equ 10h ; punctuation character
+_CONTROL equ 20h ; control character
+_BLANK equ 40h ; space char
+_HEX equ 80h ; hexadecimal digit
+
+*/
+
+/* defined in ctype.h, mbdata.h
+ extrn __mbctype:byte ; MBCS ctype table
+ extrn __ctype_:byte ; ANSI/ASCII ctype table
+*/
+
+
+/***
+* ismbbyte - Function versions of mbctype macros
+*
+*Purpose:
+*
+*Entry:
+* int = character to be tested
+*Exit:
+* ax = non-zero = character is of the requested type
+* = 0 = character is NOT of the requested type
+*
+*Uses:
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+#ifdef _KANJI
+
+int __fastcall x_ismbctype(unsigned int, int, int);
+
+int (_CRTAPI1 _ismbbkalnum) (unsigned int tst)
+{
+ return x_ismbctype(tst,0,_MS);
+}
+
+int (_CRTAPI1 _ismbbkpunct) (unsigned int tst)
+{
+ return x_ismbctype(tst,0,_MP);
+}
+
+int (_CRTAPI1 _ismbbkana) (unsigned int tst)
+{
+ return x_ismbctype(tst,0,(_MS | _MP));
+}
+
+int (_CRTAPI1 _ismbbalpha) (unsigned int tst)
+{
+ return x_ismbctype(tst,_ALPHA, _MS);
+}
+
+int (_CRTAPI1 _ismbbpunct) (unsigned int tst)
+{
+ return x_ismbctype(tst,_PUNCT, _MP);
+}
+
+int (_CRTAPI1 _ismbbalnum) (unsigned int tst)
+{
+ return x_ismbctype(tst,(_ALPHA | _DIGIT), _MS);
+}
+
+int (_CRTAPI1 _ismbbprint) (unsigned int tst)
+{
+ return x_ismbctype(tst,(_BLANK | _PUNCT | _ALPHA | _DIGIT),(_MS | _MP));
+}
+
+int (_CRTAPI1 _ismbbgraph) (unsigned int tst)
+{
+ return x_ismbctype(tst,(_PUNCT | _ALPHA | _DIGIT),(_MS | _MP));
+}
+
+int (_CRTAPI1 _ismbblead) (unsigned int tst)
+{
+ return x_ismbctype(tst,0,_M1);
+}
+
+int (_CRTAPI1 _ismbbtrail) (unsigned int tst)
+{
+ return x_ismbctype(tst,0,_M2);
+}
+
+/***
+* Common code
+*
+* cmask = mask for _ctype[] table
+* kmask = mask for _mbctype[] table
+*
+*******************************************************************************/
+
+static int __fastcall x_ismbctype (unsigned int tst, int cmask, int kmask)
+{
+ tst = (unsigned int)(unsigned char)tst; /* get input character
+ and make sure < 256 */
+ return ((*(_mbctype+1+tst)) & kmask) ||
+ ((cmask) ? ((*(_ctype+1+tst)) & cmask) : 0);
+}
+#endif /* _KANJI */
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/ismbdgt.c b/private/crt32/mbstring/ismbdgt.c
new file mode 100644
index 000000000..e5733261e
--- /dev/null
+++ b/private/crt32/mbstring/ismbdgt.c
@@ -0,0 +1,60 @@
+/***
+*ismbdgt.c - Test if character is a digit (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Test if character is a digit (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* _ismbcdigit - Test if character is a digit (MBCS)
+*
+*Purpose:
+* Tests the character to see if it is a digit.
+* Handles MBCS chars correctly.
+*
+* Note: Use test against 0x00FF instead of _ISLEADBYTE
+* to ensure that we don't call SBCS routine with a two-byte
+* value.
+*
+*Entry:
+* unsigned int *c = character to test
+*
+*Exit:
+* Returns TRUE if character is a digit, else FALSE
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbcdigit(c)
+unsigned int c;
+{
+
+ if (c > 0x00FF)
+
+#ifdef _MBCS_OS
+ return (0);
+#else
+ if (_mbascii)
+ return ((c >= _MBDIGITLOW) && (c <= _MBDIGITHIGH));
+ else
+ return (0);
+#endif
+
+ else
+ return (isdigit(c));
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/ismbknj.c b/private/crt32/mbstring/ismbknj.c
new file mode 100644
index 000000000..f71f55674
--- /dev/null
+++ b/private/crt32/mbstring/ismbknj.c
@@ -0,0 +1,93 @@
+/***
+*ismbcknj.c - contains the Kanji specific is* functions.
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Provide non-portable Kanji support for MBCS libs.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#ifdef _KANJI
+
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+
+
+/***
+*int _ismbchira(c) - test character for hiragana (Japanese)
+*
+*Purpose:
+* Test if the character c is a hiragana character.
+*
+*Entry:
+* unsigned int c - character to test
+*
+*Exit:
+* returns TRUE if character is hiragana, else FALSE
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbchira(c)
+unsigned int c;
+{
+ return(c >= 0x829f && c <= 0x82f1);
+}
+
+
+/***
+*int _ismbckata(c) - test character for katakana (Japanese)
+*
+*Purpose:
+* Tests to see if the character c is a katakana character.
+*
+*Entry:
+* unsigned int c - character to test
+*
+*Exit:
+* Returns TRUE if c is a katakana character, else FALSE.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbckata(c)
+unsigned int c;
+{
+ return(c >= 0x8340 && c <= 0x8396 && c != 0x837f);
+}
+
+
+/***
+*int _ismbcsymbol(c) - Tests if char is punctuation or symbol of Microsoft Kanji
+* code.
+*
+*Purpose:
+* Returns non-zero if the character is kanji punctuation.
+*
+*Entry:
+* unsigned int c - character to be tested
+*
+*Exit:
+* Returns non-zero if the specified char is punctuation or symbol of
+* Microsoft Kanji code, else 0.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbcsymbol(c)
+unsigned int c;
+{
+ return(c >= 0x8141 && c <= 0x81ac && c != 0x817f);
+}
+
+#endif /* _KANJI */
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/ismblgl.c b/private/crt32/mbstring/ismblgl.c
new file mode 100644
index 000000000..d08249b7a
--- /dev/null
+++ b/private/crt32/mbstring/ismblgl.c
@@ -0,0 +1,42 @@
+/***
+*ismblgl.c - Tests to see if a given character is a legal MBCS char.
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Tests to see if a given character is a legal MBCS character.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+*int _ismbclegal(c) - tests for a valid MBCS character.
+*
+*Purpose:
+* Tests to see if a given character is a legal MBCS character.
+*
+*Entry:
+* unsigned int c - character to test
+*
+*Exit:
+* returns non-zero if Microsoft Kanji code, else 0
+*
+*Exceptions:
+*
+******************************************************************************/
+
+int _CRTAPI1 _ismbclegal(c)
+unsigned int c;
+{
+ return((_ISLEADBYTE(c>>8)) && (_ISTRAILBYTE(c&0377)));
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/ismblwr.c b/private/crt32/mbstring/ismblwr.c
new file mode 100644
index 000000000..e88658ad4
--- /dev/null
+++ b/private/crt32/mbstring/ismblwr.c
@@ -0,0 +1,63 @@
+/***
+*ismblwr - Test if character is lower case (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Test if character is lower case (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _ismbclower - Test if character is lower case (MBCS)
+*
+*Purpose:
+* Test if the supplied character is lower case or not.
+* Handles MBCS characters correctly.
+*
+* Note: Use test against 0x00FF instead of _ISLEADBYTE
+* to ensure that we don't call SBCS routine with a two-byte
+* value.
+*
+*Entry:
+* unsigned int c = character to test
+*
+*Exit:
+* returns TRUE if character is lower case, else FALSE
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbclower(c)
+unsigned int c;
+{
+
+ if (c > 0x00FF)
+
+#ifdef _MBCS_OS
+ return (0);
+#else
+ {
+ if (_mbascii)
+ return ((c >= _MBLOWERLOW) && (c <= _MBLOWERHIGH));
+ else
+ return (0);
+ }
+#endif
+
+ else
+ return (islower(c));
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/ismbprn.c b/private/crt32/mbstring/ismbprn.c
new file mode 100644
index 000000000..8bd2b858a
--- /dev/null
+++ b/private/crt32/mbstring/ismbprn.c
@@ -0,0 +1,60 @@
+/***
+*ismbprn.c - Test character for display character (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Test character for display character (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _ismbcprint - Test character for display character (MBCS)
+*
+*Purpose:
+* Test if the character is a display character.
+* Handles MBCS chars correctly.
+*
+* Note: Use test against 0x00FF to ensure that we don't
+* call SBCS routine with a two-byte value.
+*
+*Entry:
+* unsigned int c = character to test
+*
+*Exit:
+* Returns TRUE if character is display character, else FALSE
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbcprint(c)
+unsigned int c;
+{
+
+ if (_ISLEADBYTE(c>>8))
+ return (_ISTRAILBYTE(c&0x00ff));
+
+ else {
+ if (c > 0x00FF)
+ return(0);
+ else
+#ifdef _KANJI
+ return ((isprint(c)) || (_ismbbkana(c)));
+#else
+ return (isprint(c));
+#endif
+ }
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/ismbsle.c b/private/crt32/mbstring/ismbsle.c
new file mode 100644
index 000000000..c4f9a0d02
--- /dev/null
+++ b/private/crt32/mbstring/ismbsle.c
@@ -0,0 +1,58 @@
+/***
+*ismbslead.c - True _ismbslead function
+*
+* Copyright (c) 1987-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Contains the function _ismbslead, which is a true context-sensitive
+* MBCS lead-byte function. While much less efficient than _ismbblead,
+* it is also much more sophisticated, in that it determines whether a
+* given sub-string pointer points to a lead byte or not, taking into
+* account the context in the string.
+*
+*Revision History:
+*
+* 08-03-93 KRS Ported from 16-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <stddef.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* int _ismbslead(const unsigned char *string, const unsigned char *current);
+*
+*Purpose:
+*
+* _ismbslead - Check, in context, for MBCS lead byte
+*
+*Entry:
+* unsigned char *string - ptr to start of string or previous known lead byte
+* unsigned char *current - ptr to position in string to be tested
+*
+*Exit:
+* TRUE : -1
+* FALSE : 0
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbslead(const unsigned char *string, const unsigned char *current)
+{
+ while (string <= current && *string) {
+ if (_ISLEADBYTE((*string))) {
+ if (string++ == current) /* check lead byte */
+ return -1;
+ if (!(*string))
+ return 0;
+ }
+ ++string;
+ }
+ return 0;
+}
+#endif
diff --git a/private/crt32/mbstring/ismbspc.c b/private/crt32/mbstring/ismbspc.c
new file mode 100644
index 000000000..8cdfdf158
--- /dev/null
+++ b/private/crt32/mbstring/ismbspc.c
@@ -0,0 +1,61 @@
+/***
+*ismbspc.c - Test is character is whitespace (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Test is character is whitespace (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _ismbcspace - Test is character is whitespace (MBCS)
+*
+*Purpose:
+* Test if the character is a whitespace character.
+* Handles MBCS chars correctly.
+*
+* Note: Use test against 0x00FF instead of _ISLEADBYTE
+* to ensure that we don't call SBCS routine with a two-byte
+* value.
+*
+*Entry:
+* unsigned int c = character to test
+*
+*Exit:
+* Returns TRUE if character is whitespace, else FALSE
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbcspace(c)
+unsigned int c;
+{
+
+ if (c > 0x00FF)
+
+#ifdef _MBCS_OS
+ return (0);
+#else
+ if (_mbascii)
+ return (c == _MBSPACECHAR);
+ else
+ return (0);
+#endif
+
+ else
+ return (isspace(c));
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/ismbstr.c b/private/crt32/mbstring/ismbstr.c
new file mode 100644
index 000000000..628296702
--- /dev/null
+++ b/private/crt32/mbstring/ismbstr.c
@@ -0,0 +1,58 @@
+/***
+*ismbstrail.c - True _ismbstrail function
+*
+* Copyright (c) 1987-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Contains the function _ismbstrail, which is a true context-sensitive
+* MBCS trail-byte function. While much less efficient than _ismbbtrail,
+* it is also much more sophisticated, in that it determines whether a
+* given sub-string pointer points to a trail byte or not, taking into
+* account the context in the string.
+*
+*Revision History:
+*
+* 08-03-93 KRS Ported from 16-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <stddef.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* int _ismbstrail(const unsigned char *string, const unsigned char *current);
+*
+*Purpose:
+*
+* _ismbstrail - Check, in context, for MBCS trail byte
+*
+*Entry:
+* unsigned char *string - ptr to start of string or previous known lead byte
+* unsigned char *current - ptr to position in string to be tested
+*
+*Exit:
+* TRUE : -1
+* FALSE : 0
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbstrail(const unsigned char *string, const unsigned char *current)
+{
+ while (string <= current && *string) {
+ if (_ISLEADBYTE((*string))) {
+ if (++string == current) /* check trail byte */
+ return -1;
+ if (!(*string))
+ return 0;
+ }
+ ++string;
+ }
+ return 0;
+}
+#endif
diff --git a/private/crt32/mbstring/ismbupr.c b/private/crt32/mbstring/ismbupr.c
new file mode 100644
index 000000000..3286754d0
--- /dev/null
+++ b/private/crt32/mbstring/ismbupr.c
@@ -0,0 +1,63 @@
+/***
+*ismbupr - Test if character is upper case (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Test if character is upper case (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _ismbcupper - Test if character is upper case (MBCS)
+*
+*Purpose:
+* Test if the supplied character is upper case or not.
+* Handles MBCS characters correctly.
+*
+* Note: Use test against 0x00FF instead of _ISLEADBYTE
+* to ensure that we don't call SBCS routine with a two-byte
+* value.
+*
+*Entry:
+* unsigned int c = character to test
+*
+*Exit:
+* Returns TRUE if c is an upper case character; else FALSE
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbcupper(c)
+unsigned int c;
+{
+
+ if (c > 0x00FF)
+
+#ifdef _MBCS_OS
+ return (0);
+#else
+ {
+ if (_mbascii)
+ return ((c >= _MBUPPERLOW) && (c <= _MBUPPERHIGH));
+ else
+ return (0);
+ }
+#endif
+
+ else
+ return (isupper(c));
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/makefile b/private/crt32/mbstring/makefile
new file mode 100644
index 000000000..6ee4f43fa
--- /dev/null
+++ b/private/crt32/mbstring/makefile
@@ -0,0 +1,6 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
+# file to this component. This file merely indirects to the real make file
+# that is shared by all the components of NT OS/2
+#
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/crt32/mbstring/makefile.knj b/private/crt32/mbstring/makefile.knj
new file mode 100644
index 000000000..b16e9fd9d
--- /dev/null
+++ b/private/crt32/mbstring/makefile.knj
@@ -0,0 +1,508 @@
+#################################################
+# #
+# MBSTRING Directory Makefile #
+# #
+#################################################
+
+#################################################
+# #
+# Macros defining the C compiler and its flags #
+# #
+#################################################
+
+
+# Common objects
+COMM_O= \
+ $(LIBC)\mbcsinit.obj \
+ $(LIBC)\mbascii0.obj \
+ ..\mbascii1.obj \
+ \
+ $(LIBC)\ismbbyt.obj \
+ $(LIBC)\mbbtype.obj \
+ $(LIBC)\mbsbtyp.obj \
+ $(LIBC)\mbscat.obj \
+ $(LIBC)\mbschr.obj \
+ $(LIBC)\mbscmp.obj \
+ $(LIBC)\mbscpy.obj \
+ $(LIBC)\mbscspn.obj \
+ $(LIBC)\mbsdec.obj \
+ $(LIBC)\mbsdup.obj \
+ $(LIBC)\mbsicmp.obj \
+ $(LIBC)\mbsinc.obj \
+ $(LIBC)\mbslen.obj \
+ $(LIBC)\mbslwr.obj \
+ $(LIBC)\mbsnbcn.obj \
+ $(LIBC)\mbsncat.obj \
+ $(LIBC)\mbsnccn.obj \
+ $(LIBC)\mbsncmp.obj \
+ $(LIBC)\mbsncpy.obj \
+ $(LIBC)\mbsnext.obj \
+ $(LIBC)\mbsnicm.obj \
+ $(LIBC)\mbsninc.obj \
+ $(LIBC)\mbsnset.obj \
+ $(LIBC)\mbsrchr.obj \
+ $(LIBC)\mbsrev.obj \
+ $(LIBC)\mbsset.obj \
+ $(LIBC)\mbsspn.obj \
+ $(LIBC)\mbsspnp.obj \
+ $(LIBC)\mbspbrk.obj \
+ $(LIBC)\mbsstr.obj \
+ $(LIBC)\mbstok.obj \
+ $(LIBC)\mbsupr.obj \
+ \
+ $(LIBC)\strdec.obj \
+ $(LIBC)\strinc.obj \
+ $(LIBC)\strncnt.obj \
+ $(LIBC)\strspnp.obj \
+ $(LIBC)\strnext.obj \
+ $(LIBC)\strninc.obj \
+ \
+ $(LIBC)\ismbalph.obj \
+ $(LIBC)\ismbdgt.obj \
+ $(LIBC)\ismblgl.obj \
+ $(LIBC)\ismblwr.obj \
+ $(LIBC)\ismbprn.obj \
+ $(LIBC)\ismbspc.obj \
+ $(LIBC)\ismbupr.obj \
+ \
+ $(LIBC)\mbtolwr.obj \
+ $(LIBC)\mbtoupr.obj \
+ \
+ $(LIBC)\ismbknj.obj \
+ $(LIBC)\tojisjms.obj \
+ $(LIBC)\mbclevel.obj \
+ $(LIBC)\mbtohira.obj \
+ $(LIBC)\mbtokata.obj \
+ \
+ $(LIBC)\tombbmbc.obj
+
+# The following functions are Kanji specific, but at this time, the build
+# process will not allow a switch:
+# ismbknj.obj
+# tojisjms.obj
+# mbclevel.obj
+# mbtohira.obj
+# mbtokata.obj
+
+
+LIBH_O= \
+ $(LIBC)\fismbbyt.obj \
+ $(LIBC)\fmbbtype.obj \
+ $(LIBC)\fmbsbtyp.obj \
+ $(LIBC)\fmbscat.obj \
+ $(LIBC)\fmbschr.obj \
+ $(LIBC)\fmbscmp.obj \
+ $(LIBC)\fmbscpy.obj \
+ $(LIBC)\fmbscspn.obj \
+ $(LIBC)\fmbsdec.obj \
+ $(LIBC)\fmbsdup.obj \
+ $(LIBC)\fmbsicmp.obj \
+ $(LIBC)\fmbsinc.obj \
+ $(LIBC)\fmbslen.obj \
+ $(LIBC)\fmbslwr.obj \
+ $(LIBC)\fmbsnbcn.obj \
+ $(LIBC)\fmbsncat.obj \
+ $(LIBC)\fmbsnccn.obj \
+ $(LIBC)\fmbsncmp.obj \
+ $(LIBC)\fmbsncpy.obj \
+ $(LIBC)\fmbsnext.obj \
+ $(LIBC)\fmbsnicm.obj \
+ $(LIBC)\fmbsninc.obj \
+ $(LIBC)\fmbsnset.obj \
+ $(LIBC)\fmbsrchr.obj \
+ $(LIBC)\fmbsrev.obj \
+ $(LIBC)\fmbsset.obj \
+ $(LIBC)\fmbsspn.obj \
+ $(LIBC)\fmbsspnp.obj \
+ $(LIBC)\fmbspbrk.obj \
+ $(LIBC)\fmbsstr.obj \
+ $(LIBC)\fmbstok.obj \
+ $(LIBC)\fmbsupr.obj \
+ \
+ $(LIBC)\fstrdec.obj \
+ $(LIBC)\fstrinc.obj \
+ $(LIBC)\fstrncnt.obj \
+ $(LIBC)\fstrnext.obj \
+ $(LIBC)\fstrninc.obj \
+ $(LIBC)\fstrspnp.obj
+
+# DOS 3.x objects
+DOS_O= \
+ $(LIBC)\dos\mbctype.obj
+
+# Model-Independent Objects not specially built for libhcrt
+MI_O= \
+
+####### OS/2 BEGIN #######
+
+# OS/2 objects
+OS2_O= \
+ $(LIBC)\os2\mbctype.obj
+
+####### OS/2 END #######
+
+####### MTHREAD BEGIN #######
+
+# Multi-Thread and CRTDLL objects
+MTCRT_O= \
+# $(LIBC)\mbstok.obj \ ## Not supported yet. ##
+
+# Multi-Thread objects
+MT_O=
+
+# CRTDLL objects
+CRT_O= \
+ $(LIBC)\ismbbyt.obj \
+# $(LIBC)\mbstok.obj \ ## Not supported yet. ##
+
+
+####### MTHREAD END #######
+
+####### WINDOWS BEGIN #######
+
+# Windows objects
+WIN_O= \
+ $(LIBC)\mbcsinit.obj \
+ $(LIBC)\mbascii0.obj \
+ ..\mbascii1.obj \
+ \
+ $(LIBC)\mbbtype.obj \
+ $(LIBC)\mbsbtyp.obj \
+ $(LIBC)\mbscat.obj \
+ $(LIBC)\mbschr.obj \
+ $(LIBC)\mbscmp.obj \
+ $(LIBC)\mbscpy.obj \
+ $(LIBC)\mbscspn.obj \
+ $(LIBC)\mbsdec.obj \
+ $(LIBC)\mbsdup.obj \
+ $(LIBC)\mbsicmp.obj \
+ $(LIBC)\mbsinc.obj \
+ $(LIBC)\mbslen.obj \
+ $(LIBC)\mbslwr.obj \
+ $(LIBC)\mbsnbcn.obj \
+ $(LIBC)\mbsncat.obj \
+ $(LIBC)\mbsnccn.obj \
+ $(LIBC)\mbsnext.obj \
+ $(LIBC)\mbsnicm.obj \
+ $(LIBC)\mbsninc.obj \
+ $(LIBC)\mbsncmp.obj \
+ $(LIBC)\mbsncpy.obj \
+ $(LIBC)\mbsnset.obj \
+ $(LIBC)\mbsrchr.obj \
+ $(LIBC)\mbsrev.obj \
+ $(LIBC)\mbsset.obj \
+ $(LIBC)\mbsspn.obj \
+ $(LIBC)\mbsspnp.obj \
+ $(LIBC)\mbspbrk.obj \
+ $(LIBC)\mbsstr.obj \
+ $(LIBC)\mbstok.obj \
+ $(LIBC)\mbsupr.obj \
+ \
+ $(LIBC)\strdec.obj \
+ $(LIBC)\strinc.obj \
+ $(LIBC)\strncnt.obj \
+ $(LIBC)\strnext.obj \
+ $(LIBC)\strninc.obj \
+ $(LIBC)\strspnp.obj \
+ \
+ $(LIBC)\ismbalph.obj \
+ $(LIBC)\ismbdgt.obj \
+ $(LIBC)\ismblwr.obj \
+ $(LIBC)\ismbprn.obj \
+ $(LIBC)\ismbspc.obj \
+ $(LIBC)\ismbupr.obj \
+ \
+ $(LIBC)\ismbknj.obj \
+ $(LIBC)\mbclevel.obj \
+ $(LIBC)\mbtohira.obj \
+ $(LIBC)\mbtokata.obj \
+ $(LIBC)\tojisjms.obj \
+ \
+ $(LIBC)\mbtolwr.obj \
+ $(LIBC)\mbtoupr.obj \
+ \
+ $(LIBC)\tombbmbc.obj
+
+#
+# The functions/files
+# ismbknj.obj
+# mbclevel.obj
+# mbtohira.obj
+# mbtokata.obj
+# tojisjms.obj
+# are Kanji specific, and should not be included in other natural language
+# builds.
+#
+
+WINDLL_O=
+
+####### WINDOWS END #######
+
+#########################################################
+# #
+# Target Dependency listings #
+# #
+#########################################################
+
+libc: $(COMM_O) $(DOS_O) $(OS2_O)
+
+libh: $(LIBH_O) $(MI_O)
+
+libhcrt: $(LIBH_O)
+
+####### MTHREAD BEGIN #######
+
+libcmt: $(MT_O) $(MTCRT_O)
+
+libccrt: $(CRT_O) $(MTCRT_O)
+
+####### MTHREAD END #######
+
+####### WINDOWS BEGIN #######
+
+libcw: $(WIN_O) $(DOS_O)
+
+libcwdll: $(WINDLL_O)
+
+####### WINDOWS END #######
+
+#########################################################
+# #
+# Dependencies and rules for making local objects #
+# #
+#########################################################
+
+# Note: Some of the obj names are abbreviated so that
+# "f" versions will fit in the 8.3 filename space.
+
+#
+# MBCS init modules
+#
+
+$(LIBC)\mbcsinit.obj: mbcsinit.asm $(ASMSTD) $(ASMINC)\defsegs.inc
+ $(MM) -Fo$(LIBC)\mbcsinit.obj mbcsinit.asm
+
+$(LIBC)\mbascii0.obj: mbascii0.c $(INCLUDE)\mbdata.h
+ $(CC) $(MEM) -Fo$(LIBC)\mbascii0.obj mbascii0.c
+
+..\mbascii1.obj: mbascii1.c $(INCLUDE)\mbdata.h
+ $(CC) $(MEM) -Fo..\mbascii1.obj mbascii1.c
+
+#
+# MBCS "is" routines
+#
+
+$(LIBC)\ismbalph.obj: ismbalph.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\ctype.h
+ $(CC) $(MEM) -Fo$(LIBC)\ismbalph.obj ismbalph.c
+
+$(LIBC)\ismbdgt.obj: ismbdgt.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\ctype.h
+ $(CC) $(MEM) -Fo$(LIBC)\ismbdgt.obj ismbdgt.c
+
+$(LIBC)\ismblwr.obj: ismblwr.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\ctype.h
+ $(CC) $(MEM) -Fo$(LIBC)\ismblwr.obj ismblwr.c
+
+$(LIBC)\ismbprn.obj: ismbprn.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\ctype.h
+ $(CC) $(MEM) -Fo$(LIBC)\ismbprn.obj ismbprn.c
+
+$(LIBC)\ismbspc.obj: ismbspc.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\ctype.h
+ $(CC) $(MEM) -Fo$(LIBC)\ismbspc.obj ismbspc.c
+
+$(LIBC)\ismbupr.obj: ismbupr.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\ctype.h
+ $(CC) $(MEM) -Fo$(LIBC)\ismbupr.obj ismbupr.c
+
+#
+# Kanji specific "is" routines
+#
+
+$(LIBC)\ismbknj.obj: ismbknj.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\ctype.h
+ $(CC) $(MEM) -Fo$(LIBC)\ismbknj.obj ismbknj.c
+
+$(LIBC)\mbclevel.obj: mbclevel.c $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\mbclevel.obj mbclevel.c
+
+$(LIBC)\tojisjms.obj: tojisjms.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\tojisjms.obj tojisjms.c
+
+$(LIBC)\ismblgl.obj: ismblgl.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\ismblgl.obj ismblgl.c
+
+
+#
+# MBCS "to" routines
+#
+
+$(LIBC)\mbtolwr.obj: mbtolwr.c mbtolwr.c $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\mbtolwr.obj mbtolwr.c
+
+$(LIBC)\mbtoupr.obj: mbtoupr.c mbtoupr.c $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\mbtoupr.obj mbtoupr.c
+
+$(LIBC)\mbtohira.obj: mbtohira.c ismbknj.c $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\mbtohira.obj mbtohira.c
+
+$(LIBC)\mbtokata.obj: mbtokata.c ismbknj.c $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\mbtokata.obj mbtokata.c
+
+$(LIBC)\tombbmbc.obj: tombbmbc.c $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\tombbmbc.obj tombbmbc.c
+
+
+#
+# MBCS string routines
+#
+
+$(LIBC)\$(F)ismbbyt.obj: ismbbyte.asm $(ASMSTD)
+ $(MM) -Fo$(LIBC)\$(F)ismbbyt.obj ismbbyte.asm
+
+$(LIBC)\$(F)mbbtype.obj: mbbtype.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbbtype.obj mbbtype.c
+
+$(LIBC)\$(F)mbsbtyp.obj: mbsbtype.c $(INCLUDE)\mbstring.h $(INCLUDE)\mbctype.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsbtyp.obj mbsbtype.c
+
+$(LIBC)\$(F)mbscat.obj: mbscat.asm $(ASMSTD)
+ $(MM) -Fo$(LIBC)\$(F)mbscat.obj mbscat.asm
+
+$(LIBC)\$(F)mbschr.obj: mbschr.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbschr.obj mbschr.c
+
+$(LIBC)\$(F)mbscmp.obj: mbscmp.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbscmp.obj mbscmp.c
+
+$(LIBC)\$(F)mbscpy.obj: mbscpy.asm $(ASMSTD)
+ $(MM) -Fo$(LIBC)\$(F)mbscpy.obj mbscpy.asm
+
+$(LIBC)\$(F)mbscspn.obj: mbscspn.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbscspn.obj mbscspn.c
+
+$(LIBC)\$(F)mbsdec.obj: mbsdec.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsdec.obj mbsdec.c
+
+$(LIBC)\$(F)mbsdup.obj: mbsdup.asm $(ASMSTD)
+ $(MM) -Fo$(LIBC)\$(F)mbsdup.obj mbsdup.asm
+
+$(LIBC)\$(F)mbsicmp.obj: mbsicmp.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsicmp.obj mbsicmp.c
+
+$(LIBC)\$(F)mbsinc.obj: mbsinc.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsinc.obj mbsinc.c
+
+$(LIBC)\$(F)mbslen.obj: mbslen.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbslen.obj mbslen.c
+
+$(LIBC)\$(F)mbslwr.obj: mbslwr.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbslwr.obj mbslwr.c
+
+$(LIBC)\$(F)mbsncat.obj: mbsncat.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsncat.obj mbsncat.c
+
+$(LIBC)\$(F)mbsnbcn.obj: mbsnbcnt.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsnbcn.obj mbsnbcnt.c
+
+$(LIBC)\$(F)mbsnccn.obj: mbsnccnt.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsnccn.obj mbsnccnt.c
+
+$(LIBC)\$(F)mbsncmp.obj: mbsncmp.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsncmp.obj mbsncmp.c
+
+$(LIBC)\$(F)mbsncpy.obj: mbsncpy.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsncpy.obj mbsncpy.c
+
+$(LIBC)\$(F)mbsnext.obj: mbsnextc.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsnext.obj mbsnextc.c
+
+$(LIBC)\$(F)mbsnicm.obj: mbsnicmp.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsnicm.obj mbsnicmp.c
+
+$(LIBC)\$(F)mbsninc.obj: mbsninc.c $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsninc.obj mbsninc.c
+
+$(LIBC)\$(F)mbsnset.obj: mbsnset.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsnset.obj mbsnset.c
+
+$(LIBC)\$(F)mbsrchr.obj: mbsrchr.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsrchr.obj mbsrchr.c
+
+$(LIBC)\$(F)mbsrev.obj: mbsrev.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsrev.obj mbsrev.c
+
+$(LIBC)\$(F)mbsset.obj: mbsset.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsset.obj mbsset.c
+
+$(LIBC)\$(F)mbsspn.obj: mbsspn.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsspn.obj mbsspn.c
+
+$(LIBC)\$(F)mbsspnp.obj: mbsspn.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -D_RETURN_PTR -Fo$(LIBC)\$(F)mbsspnp.obj mbsspn.c
+
+$(LIBC)\$(F)mbspbrk.obj: mbscspn.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h
+ $(CC) $(MEM) -D_RETURN_PTR -Fo$(LIBC)\$(F)mbspbrk.obj mbscspn.c
+
+$(LIBC)\$(F)mbsstr.obj: mbsstr.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h $(INCLUDE)\string.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsstr.obj mbsstr.c
+
+$(LIBC)\$(F)mbstok.obj: mbstok.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbstok.obj mbstok.c
+
+$(LIBC)\$(F)mbsupr.obj: mbsupr.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)mbsupr.obj mbsupr.c
+
+#
+# SBCS equivilent MBCS-mapped routines
+#
+
+$(LIBC)\$(F)strdec.obj: strdec.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)strdec.obj strdec.c
+
+$(LIBC)\$(F)strinc.obj: strinc.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)strinc.obj strinc.c
+
+$(LIBC)\$(F)strncnt.obj: strncnt.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)strncnt.obj strncnt.c
+
+$(LIBC)\$(F)strnext.obj: strnextc.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)strnext.obj strnextc.c
+
+$(LIBC)\$(F)strninc.obj: strninc.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)strninc.obj strninc.c
+
+$(LIBC)\$(F)strspnp.obj: strspnp.c $(INCLUDE)\mbctype.h $(INCLUDE)\mbstring.h \
+ $(INCLUDE)\stddef.h
+ $(CC) $(MEM) -Fo$(LIBC)\$(F)strspnp.obj strspnp.c
+
+####### DOS BEGIN #######
+
+$(LIBC)\dos\mbctype.obj: mbctype.c $(INCLUDE)\mbctype.h
+ $(CC) $(MEM) -Fo$(LIBC)\dos\mbctype.obj mbctype.c
+
+####### DOS END #######
+
+####### OS2 BEGIN #######
+
+$(LIBC)\os2\mbctype.obj: mbctype.c $(INCLUDE)\mbctype.h $(INCLUDE)\doscalls.h
+ $(CC) $(MEM) -DOS2 -Fo$(LIBC)\os2\mbctype.obj mbctype.c
+
+####### OS2 END #######
diff --git a/private/crt32/mbstring/mbascii0.c b/private/crt32/mbstring/mbascii0.c
new file mode 100644
index 000000000..ca9a3bcf4
--- /dev/null
+++ b/private/crt32/mbstring/mbascii0.c
@@ -0,0 +1,33 @@
+/***
+*mbascii0.c - Disable MB ASCII Support
+*
+* Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Disable MB ASCII support (set _mbascii flag to 0).
+*
+* The _mbascii flag indicates whether the lib routines and
+* macros should operate on MB ASCII characters (i.e., the
+* double-byte versions of the ASCII characters that exist
+* in certain MBCS representations such as Kanji).
+*
+* In some cases, people want these to be worked on by the
+* various MB is/to/cmp routines. However, in most cases,
+* you do NOT want to do this (e.g., when modifying filenames,
+* you do NOT want to change the case of the MB ASCII chars
+* even though you DO want to change the case of the SB
+* ASCII chars.)
+*
+* [Also see mbascii1.C.]
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+
+unsigned int _mbascii = 0; /* 0 = do NOT operate on MB ASCII chars */
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbascii1.opt b/private/crt32/mbstring/mbascii1.opt
new file mode 100644
index 000000000..ef702d389
--- /dev/null
+++ b/private/crt32/mbstring/mbascii1.opt
@@ -0,0 +1,19 @@
+/***
+*mbascii1.c - Enable MB ASCII Support
+*
+* Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Enable MB ASCII support (set _mbascii flag to 1).
+*
+* [For complete description, see mbascii0.c.]
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#include <cruntime.h>
+#include <mbdata.h>
+
+unsigned int _mbascii = 1; /* !0 = operate on MB ASCII chars */
diff --git a/private/crt32/mbstring/mbbtype.c b/private/crt32/mbstring/mbbtype.c
new file mode 100644
index 000000000..4527b3a2d
--- /dev/null
+++ b/private/crt32/mbstring/mbbtype.c
@@ -0,0 +1,70 @@
+/***
+*mbbtype.c - Return type of byte based on previous byte (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Return type of byte based on previous byte (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+*int _mbbtype(c, ctype) - Return type of byte based on previous byte (MBCS)
+*
+*Purpose:
+* Returns type of supplied byte. This decision is context
+* sensitive so a control test condition is supplied. Normally,
+* this is the type of the previous byte in the string.
+*
+*Entry:
+* unsigned char c = character to be checked
+* int ctype = control test condition (i.e., type of previous char)
+*
+*Exit:
+* _MBC_LEAD = if 1st byte of MBCS char
+* _MBC_TRAIL = if 2nd byte of MBCS char
+* _MBC_SINGLE = valid single byte char
+*
+* _MBC_ILLEGAL = if illegal char
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _mbbtype(c, ctype)
+unsigned char c;
+int ctype;
+{
+
+ switch(ctype) {
+
+ case(_MBC_LEAD):
+ if (_ISTRAILBYTE(c))
+ return(_MBC_TRAIL);
+ else
+ return(_MBC_ILLEGAL);
+
+ case(_MBC_TRAIL):
+ case(_MBC_SINGLE):
+ case(_MBC_ILLEGAL):
+ if (_ISLEADBYTE(c))
+ return(_MBC_LEAD);
+ else if (_ismbbprint(c))
+ return(_MBC_SINGLE);
+ else
+ return(_MBC_ILLEGAL);
+
+
+ }
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbccpy.c b/private/crt32/mbstring/mbccpy.c
new file mode 100644
index 000000000..e2fccb169
--- /dev/null
+++ b/private/crt32/mbstring/mbccpy.c
@@ -0,0 +1,47 @@
+/***
+*mbccpy.c - Copy one character to another (MBCS)
+*
+* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Copy one MBCS character to another (1 or 2 bytes)
+*
+*Revision History:
+* 04-12-93 KRS Created.
+* 06-03-93 KRS Change return type to void.
+*
+*******************************************************************************/
+
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+#include <stddef.h>
+
+/***
+* _mbccpy - Copy one character to another (MBCS)
+*
+*Purpose:
+* Copies exactly one MBCS character from src to dst. Copies _mbclen(src)
+* bytes from src to dst.
+*
+*Entry:
+* unsigned char *dst = destination for copy
+* unsigned char *src = source for copy
+*
+*Exit:
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+void _CRTAPI1 _mbccpy(dst, src)
+unsigned char *dst;
+const unsigned char *src;
+{
+ *dst = *src;
+ if (_ISLEADBYTE(*src))
+ {
+ *++dst = *++src;
+ }
+}
diff --git a/private/crt32/mbstring/mbclen.c b/private/crt32/mbstring/mbclen.c
new file mode 100644
index 000000000..4d67a8e81
--- /dev/null
+++ b/private/crt32/mbstring/mbclen.c
@@ -0,0 +1,42 @@
+/***
+*mbclen.c - Find length of MBCS character
+*
+* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Find length of MBCS character
+*
+*Revision History:
+* 04-12-93 KRS Created.
+*
+*******************************************************************************/
+
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+#include <stddef.h>
+
+
+/***
+* _mbclen - Find length of MBCS character
+*
+*Purpose:
+* Find the length of the MBCS character (in bytes).
+*
+*Entry:
+* unsigned char *c = MBCS character
+*
+*Exit:
+* Returns the number of bytes in the MBCS character
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+size_t _CRTAPI1 _mbclen(c)
+const unsigned char *c;
+
+{
+ return (_ISLEADBYTE(*c)) ? 2 : 1;
+}
diff --git a/private/crt32/mbstring/mbclevel.c b/private/crt32/mbstring/mbclevel.c
new file mode 100644
index 000000000..340f734d1
--- /dev/null
+++ b/private/crt32/mbstring/mbclevel.c
@@ -0,0 +1,92 @@
+/***
+*mbclevel.c - Tests if char is hiragana, katakana, alphabet or digit.
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Tests for the various industry defined levels of Microsoft Kanji
+* Code.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#ifdef _KANJI
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+
+
+/***
+*int _ismbcl0(c) - Tests if char is hiragana, katakana, alphabet or digit.
+*
+*Purpose:
+* Tests if a given char is hiragana, katakana, alphabet, digit or symbol
+* of Microsoft Kanji code.
+*
+*Entry:
+* unsigned int c - Character to test.
+*
+*Exit:
+* Returns non-zero if 0x8140 <= c <= 0x889E, else 0.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbcl0(c)
+unsigned int c;
+{
+ return(_ismbclegal(c) && c < 0x889f);
+}
+
+
+/***
+*int _ismbcl1(c) - Tests for 1st-level Microsoft Kanji code set.
+*
+*Purpose:
+* Tests if a given char belongs to Microsoft 1st-level Kanji code set.
+*
+*Entry:
+* unsigned int c - character to test.
+*
+*Exit:
+* Returns non-zero if 1st-level, else 0.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbcl1(c)
+unsigned int c;
+{
+ return(_ismbclegal(c) && c >= 0x889f && c <= 0x9872);
+}
+
+
+/***
+*int _ismbcl2(c) - Tests for a 2nd-level Microsoft Kanji code character.
+*
+*Purpose:
+* Tests if a given char belongs to the Microsoft 2nd-level Kanji code set.
+*
+*Entry:
+* unsigned int c - character to test.
+*
+*Exit:
+* Returns non-zero if 2nd-level, else 0.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _ismbcl2(c)
+unsigned int c;
+{
+ return(_ismbclegal(c) && c >= 0x989f && c <= 0xea9e);
+}
+
+#endif /* _KANJI */
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbctype.c b/private/crt32/mbstring/mbctype.c
new file mode 100644
index 000000000..7abdb1d34
--- /dev/null
+++ b/private/crt32/mbstring/mbctype.c
@@ -0,0 +1,318 @@
+/***
+*mbctype.c - MBCS table used by the functions that test for types of char
+*
+* Copyright (c) 1987-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* table used to determine the type of char
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-12-93 CFW Change _mbctype to _VARTYPE1 to allow DLL export.
+* 08-13-93 CFW Remove OS2 and rework for _WIN32_.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+
+#include <cruntime.h>
+#include <mbdata.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#ifdef _MBCS_OS
+
+#ifdef _WIN32_
+#include <windows.h>
+#endif /* _WIN32_ */
+
+/* local routines */
+static char * _mbcs_getlead(void);
+
+#endif /* _MBCS_OS */
+
+
+/*
+ * make sure this is being compiled correctly
+ */
+
+#if (!defined(_KANJI) && !defined(_MBCS_OS))
+#error Must specify MBCS locale.
+#endif
+
+#if (defined(_KANJI) && defined(_MBCS_OS))
+#error Can't define _KANJI and _MBCS_OS together.
+#endif
+
+
+/*
+ * set bit masks for the possible MBCS types
+ * (all MBCS bit masks start with "_M")
+ */
+
+#define _MS 0x01 /* MBCS single byte symbol */
+#define _MP 0x02 /* MBCS punct */
+#define _M1 0x04 /* MBCS 1st (lead) byte */
+#define _M2 0x08 /* MBCS 2nd byte*/
+
+/*
+ * MBCS ctype array
+ */
+
+#ifdef _KANJI
+
+/*
+ * Kanji Table: PreInitialized
+ */
+
+unsigned char _VARTYPE1 _mbctype[257] = {
+
+ 0,
+
+/* 0 1 2 3 4 5 6 7 */
+/*--------------+-------+-------+-------+-------+-------+-------+-------*/
+/*00*/ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+/*10*/ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+/*20*/ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+/*30*/ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+/*40*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*50*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*60*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*70*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, 0,
+/*80*/ _M2,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,
+ _M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,
+/*90*/ _M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,
+ _M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,
+/*A0*/ _M2,_M2|_MP,_M2|_MP,_M2|_MP,_M2|_MP,_M2|_MP,_M2|_MS,_M2|_MS,
+ _M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,
+/*B0*/ _M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,
+ _M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,
+/*C0*/ _M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,
+ _M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,
+/*D0*/ _M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,
+ _M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,_M2|_MS,
+/*E0*/ _M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,
+ _M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,
+/*F0*/ _M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,
+ _M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1,_M2|_M1, 0, 0, 0,
+
+};
+
+#endif
+
+
+#ifdef _MBCS_OS
+
+/*
+ * Generic Table - All bytes except NUL are legal trailing bytes
+ */
+
+unsigned char _VARTYPE1 _mbctype[257] = {
+
+ 0,
+
+/* 0 1 2 3 4 5 6 7 */
+/*--------------+-------+-------+-------+-------+-------+-------+-------*/
+/*00*/ 0, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*10*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*20*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*30*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*40*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*50*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*60*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*70*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*80*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*90*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*A0*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*B0*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*C0*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*D0*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*E0*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+/*F0*/ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+ _M2, _M2, _M2, _M2, _M2, _M2, _M2, _M2,
+
+};
+
+
+/***
+*_mbcsinit() - Init MBCS data
+*
+*Purpose:
+* Get MBCS data from the OS and init our table with it.
+*
+* (1) DOS: check for version 3.3 or later.
+* (2) call OS to get table
+*
+* This routine is meant to be called once (and only once)
+* at startup time.
+*Entry:
+* void
+*Exit:
+* void
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+void _mbcsinit(void)
+{
+
+ unsigned char * lbtab;
+ unsigned char first, last, curr;
+
+
+#ifndef _WIN32_
+ /*
+ * DOS version must be 3.3 or better
+ */
+
+ if ( (_osmajor < 3) ||
+ (_osmajor == 3) && (_osminor < 3)
+ )
+ _mbfatal();
+#endif
+
+ /*
+ * get the lead byte table from OS
+ */
+
+ if ((lbtab = _mbcs_getlead()) == NULL)
+ return; // leave table all zeroes
+
+ /*
+ * walk through OS lead byte table flipping bits
+ * in the _mbctype[] table appropriately.
+ */
+
+ for (;;) {
+ first = *lbtab++;
+ last = *lbtab++;
+ if ((first == 0) && (last == 0))
+ break;
+
+ for (curr=first; curr<=last; curr++)
+ _mbctype[curr+1] |= _M1;
+
+ }
+}
+
+/***
+*_mbcs_getlead() - Get lead byte pairs from OS
+*
+*Purpose:
+* Gets the pairs of lead byte values from the OS.
+*
+*Entry:
+* void
+*
+*Exit:
+* void * = pointer to lead byte pairs
+* = NULL = error
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+static char * _mbcs_getlead(void)
+{
+
+#ifdef _WIN32_
+
+ /* maximum # of leadbyte values */
+ #define _MAXLBVALS 12
+
+ static CPINFO info;
+ char *ev;
+ int cp;
+
+ if ((ev = getenv("MBCS_CP")) == NULL) {
+ cp = CP_ACP;
+ } else {
+ cp = atoi(ev);
+ }
+
+ /*
+ * get lead byte table from OS
+ */
+
+ if (!GetCPInfo(cp, &info))
+ return(NULL); /* failure */
+
+ return((unsigned char *)info.LeadByte); /* success */
+
+#else /* DOS */
+
+ _asm {
+ push ds
+
+ xor si,si
+ mov ds,si
+ mov ax,6300h
+ int 21h ; get lead byte table
+ jnc ok
+
+ xor si,si ; error: return NULL
+ mov ds,si
+ ok:
+ mov ax,si ; success: return ptr to table
+ mov dx,ds
+
+ pop ds
+ }
+
+#endif
+
+}
+
+#ifndef _WIN32_
+
+/***
+*_mbfatal() - Fatal MBCS error
+*
+*Purpose:
+* Terminate program
+*
+*Entry:
+* void
+*Exit:
+* void
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+static void _CRTAPI3 _mbfatal(void)
+{
+
+_asm {
+ mov ax,_RT_ABORT
+ jmp _amsg_exit
+ }
+}
+
+#endif /* _WIN32_ */
+#endif /* _MBCS_OS */
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsbtype.c b/private/crt32/mbstring/mbsbtype.c
new file mode 100644
index 000000000..cd87b273a
--- /dev/null
+++ b/private/crt32/mbstring/mbsbtype.c
@@ -0,0 +1,64 @@
+/***
+*mbsbtype.c - Return type of byte within a string (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Return type of byte within a string (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+#include <mbctype.h>
+
+#define _MBBTYPE(p,c) _mbbtype(p,c)
+
+/***
+* _mbsbtype - Return type of byte within a string
+*
+*Purpose:
+* Test byte within a string for MBCS char type.
+* This function requires the start of the string because
+* context must be taken into account.
+*
+*Entry:
+* const unsigned char *string = pointer to string
+* size_t len = position of the char in string
+*
+*Exit:
+* returns one of the following values:
+*
+* _MBC_LEAD = if 1st byte of MBCS char
+* _MBC_TRAIL = if 2nd byte of MBCS char
+* _MBC_SINGLE = valid single byte char
+*
+* _MBC_ILLEGAL = if illegal char
+*
+*Exceptions:
+* returns _MBC_ILLEGAL if len is bigger than string length
+*
+*******************************************************************************/
+
+int _CRTAPI1 _mbsbtype( string, len )
+const unsigned char *string;
+size_t len;
+{
+ int chartype = _MBC_ILLEGAL;
+
+ do {
+ if (*string == '\0')
+ return(_MBC_ILLEGAL);
+
+ chartype = _MBBTYPE(*string++, chartype);
+
+ } while (len--);
+
+ return(chartype);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbscat.c b/private/crt32/mbstring/mbscat.c
new file mode 100644
index 000000000..21430a5b3
--- /dev/null
+++ b/private/crt32/mbstring/mbscat.c
@@ -0,0 +1,21 @@
+/***
+*mbscat.c - contains mbscat() and mbscpy()
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* mbscpy() copies one string onto another.
+*
+* mbscat() concatenates (appends) a copy of the source string to the
+* end of the destination string, returning the destination string.
+*
+*Revision History:
+* 11-18-92 KRS Identical to strcat/strcpy--could use alias records.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#define strcat _mbscat
+#define strcpy _mbscpy
+#include "..\string\strcat.c"
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbschr.c b/private/crt32/mbstring/mbschr.c
new file mode 100644
index 000000000..a42109344
--- /dev/null
+++ b/private/crt32/mbstring/mbschr.c
@@ -0,0 +1,67 @@
+/***
+* mbschr.c - Search MBCS string for character
+*
+* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Search MBCS string for a character
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 05-12-93 KRS Fix handling of c=='\0'.
+* 08-20-93 CFW Change param type to int, use new style param declarators.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+#include <stddef.h>
+
+/***
+* _mbschr - Search MBCS string for character
+*
+*Purpose:
+* Search the given string for the specified character.
+* MBCS characters are handled correctly.
+*
+*Entry:
+* unsigned char *string = string to search
+* int c = character to search for
+*
+*Exit:
+* returns a pointer to the first occurence of the specified char
+* within the string.
+*
+* returns NULL if the character is not found n the string.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+
+unsigned char * _CRTAPI1 _mbschr(
+ const unsigned char *string,
+ unsigned int c
+ )
+{
+ unsigned short cc;
+
+ for (; (cc = *string); string++) {
+
+ if (_ISLEADBYTE(cc)) {
+ if (*++string == '\0')
+ return NULL; /* error */
+ if ( c == (unsigned int)((cc << 8) | *string) ) /* DBCS match */
+ return (unsigned char *)(string - 1);
+ }
+ else if (c == (unsigned int)cc)
+ break; /* SBCS match */
+ }
+ if (c == (unsigned int)cc) /* check for SBCS match--handles NUL char */
+ return (unsigned char *)(string);
+ return NULL;
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbscmp.c b/private/crt32/mbstring/mbscmp.c
new file mode 100644
index 000000000..8011f1dda
--- /dev/null
+++ b/private/crt32/mbstring/mbscmp.c
@@ -0,0 +1,61 @@
+/***
+*mbscmp.c - Compare MBCS strings
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Compare MBCS strings
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* _mbscmp - Compare MBCS strings
+*
+*Purpose:
+* Compares two strings for lexical order. Strings
+* are compared on a character basis, not a byte basis.
+*
+*Entry:
+* char *s1, *s2 = strings to compare
+*
+*Exit:
+* returns <0 if s1 < s2
+* returns 0 if s1 == s2
+* returns >0 if s1 > s2
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _mbscmp( s1, s2 )
+const unsigned char *s1;
+const unsigned char *s2;
+{
+ unsigned short c1, c2;
+
+ for (;;) {
+ c1 = *s1++;
+ if (_ISLEADBYTE(c1))
+ c1 = ( (*s1 == '\0') ? 0 : ((c1<<8) | *s1++) );
+
+ c2 = *s2++;
+ if (_ISLEADBYTE(c2))
+ c2 = ( (*s2 == '\0') ? 0 : ((c2<<8) | *s2++) );
+
+ if (c1 != c2)
+ return( (c1 > c2) ? 1 : -1);
+ if (c1 == 0)
+ return(0);
+ }
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbscspn.c b/private/crt32/mbstring/mbscspn.c
new file mode 100644
index 000000000..083e20033
--- /dev/null
+++ b/private/crt32/mbstring/mbscspn.c
@@ -0,0 +1,105 @@
+/***
+*mbscspn.c - Find first string char in charset (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Find first string char in charset (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+#include <stddef.h>
+
+
+/***
+#ifndef _RETURN_PTR
+* _mbscspn - Find first string char in charset (MBCS)
+#else
+* _mbspbrk - Find first string char in charset, pointer return (MBCS)
+#endif
+*
+*Purpose:
+* Returns maximum leading segment of string
+* which consists solely of characters NOT from charset.
+* Handles MBCS chars correctly.
+*
+*Entry:
+* char *string = string to search in
+* char *charset = set of characters to scan over
+*
+*Exit:
+*
+#ifndef _RETURN_PTR
+* Returns the index of the first char in string
+* that is in the set of characters specified by control.
+*
+* Returns 0, if string begins with a character in charset.
+#else
+* Returns pointer to first character in charset.
+*
+* Returns NULL if string consists entirely of characters
+* not from charset.
+#endif
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+#ifndef _RETURN_PTR
+
+size_t _mbscspn( string, charset )
+const unsigned char *string;
+const unsigned char *charset;
+
+#else
+
+unsigned char * _CRTAPI1 _mbspbrk( string, charset )
+const unsigned char *string;
+const unsigned char *charset;
+
+#endif
+
+{
+ unsigned char *p, *q;
+
+ /* loop through the string to be inspected */
+ for (q = (char *)string; *q ; q++) {
+
+ /* loop through the charset */
+ for (p = (char *)charset; *p ; p++) {
+
+ if (_ISLEADBYTE(*p)) {
+ if (((*p == *q) && (p[1] == q[1])) || p[1] == '\0')
+ break;
+ p++;
+ }
+
+ else
+ if (*p == *q)
+ break;
+ }
+
+ if (*p != '\0') /* end of charset? */
+ break; /* no, match on this char */
+
+ if (_ISLEADBYTE(*q))
+ if (*++q == '\0')
+ break;
+ }
+
+#ifndef _RETURN_PTR
+ return((size_t) (q - string)); /* index */
+#else
+ return((*q) ? q : NULL); /* pointer */
+#endif
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsdec.c b/private/crt32/mbstring/mbsdec.c
new file mode 100644
index 000000000..c678f6492
--- /dev/null
+++ b/private/crt32/mbstring/mbsdec.c
@@ -0,0 +1,84 @@
+/***
+*mbsdec.c - Move MBCS string pointer backward one charcter.
+*
+* Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Move MBCS string pointer backward one character.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-03-93 KRS Fix prototypes.
+* 08-20-93 CFW Remove test for NULL string, use new function parameters.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+#include <mbctype.h>
+#include <stddef.h>
+
+/***
+*_mbsdec - Move MBCS string pointer backward one charcter.
+*
+*Purpose:
+* Move the supplied string pointer backwards by one
+* character. MBCS characters are handled correctly.
+*
+*Entry:
+* const unsigned char *string = pointer to beginning of string
+* const unsigned char *current = current char pointer (legal MBCS boundary)
+*
+*Exit:
+* Returns pointer after moving it.
+* Returns NULL if string >= current.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsdec(
+ const unsigned char *string,
+ const unsigned char *current
+ )
+{
+ const unsigned char *temp;
+
+ if (string >= current)
+ return(NULL);
+
+ temp = current - 1;
+
+/*
+ * If (current-1) returns true from _ISLEADBTYE, it is a trail byte, because
+ * it is not a legal single byte MBCS character. Therefore, is so, return
+ * (current-2) because it is the trailbyte's lead.
+ */
+
+ if (_ISLEADBYTE(*temp))
+ return (unsigned char *)(temp - 1);
+
+/*
+ * It is unknown whether (current - 1) is a single byte character or a
+ * trail. Now decrement temp until
+ * a) The beginning of the string is reached, or
+ * b) A non-lead byte (either single or trail) is found.
+ * The difference between (current-1) and temp is the number of non-single
+ * byte characters preceding (current-1). There are two cases for this:
+ * a) (current - temp) is odd, and
+ * b) (current - temp) is even.
+ * If odd, then there are an odd number of "lead bytes" preceding the
+ * single/trail byte (current - 1), indicating that it is a trail byte.
+ * If even, then there are an even number of "lead bytes" preceding the
+ * single/trail byte (current - 1), indicating a single byte character.
+ */
+
+ while ((string <= --temp) && (_ISLEADBYTE(*temp)))
+ ;
+
+ return (unsigned char *)(current - 1 - ((current - temp) & 0x01) );
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsdup.c b/private/crt32/mbstring/mbsdup.c
new file mode 100644
index 000000000..0e283a04e
--- /dev/null
+++ b/private/crt32/mbstring/mbsdup.c
@@ -0,0 +1,18 @@
+/***
+*mbsdup.c - duplicate a string in malloc'd memory
+*
+* Copyright (c) 1985-1991, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* defines _mbsdup() - grab new memory, and duplicate the string into it.
+*
+*Revision History:
+* 11-18-92 KRS Identical to strdup--could just use alias record.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#define _strdup _mbsdup
+#include <..\string\strdup.c>
+
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsicmp.c b/private/crt32/mbstring/mbsicmp.c
new file mode 100644
index 000000000..ef2007b7a
--- /dev/null
+++ b/private/crt32/mbstring/mbsicmp.c
@@ -0,0 +1,90 @@
+/***
+*mbsicmp.c - Case-insensitive string comparision routine (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Case-insensitive string comparision routine (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 10-12-93 CFW Compare lower case, not upper.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _mbsicmp - Case-insensitive string comparision routine (MBCS)
+*
+*Purpose:
+* Compares two strings for lexical order without regard to case.
+* Strings are compared on a character basis, not a byte basis.
+*
+*Entry:
+* char *s1, *s2 = strings to compare
+*
+*Exit:
+* returns <0 if s1 < s2
+* returns 0 if s1 == s2
+* returns >0 if s1 > s2
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _mbsicmp(s1, s2)
+const unsigned char *s1, *s2;
+{
+ unsigned short c1, c2;
+
+ for (;;) {
+
+ c1 = *s1++;
+ if (_ISLEADBYTE(c1)) {
+ if (*s1 == '\0')
+ c1 = 0;
+ else {
+ c1 = ((c1<<8) | *s1++);
+#ifndef _MBCS_OS
+ if ( (_mbascii) &&
+ ((c1 >= _MBUPPERLOW) && (c1 <= _MBUPPERHIGH))
+ )
+ c1 += _MBCASEDIFF;
+#endif
+ }
+ }
+ else
+ c1 = tolower(c1);
+
+ c2 = *s2++;
+ if (_ISLEADBYTE(c2)) {
+ if (*s2 == '\0')
+ c2 = 0;
+ else {
+ c2 = ((c2<<8) | *s2++);
+#ifndef _MBCS_OS
+ if ( (_mbascii) &&
+ ((c2 >= _MBUPPERLOW) && (c2 <= _MBUPPERHIGH))
+ )
+ c2 += _MBCASEDIFF;
+#endif
+ }
+ }
+ else
+ c2 = tolower(c2);
+
+ if (c1 != c2)
+ return( (c1 > c2) ? 1 : -1);
+ if (c1 == 0)
+ return(0);
+
+ }
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsinc.c b/private/crt32/mbstring/mbsinc.c
new file mode 100644
index 000000000..451810485
--- /dev/null
+++ b/private/crt32/mbstring/mbsinc.c
@@ -0,0 +1,48 @@
+/***
+*mbsinc.c - Move MBCS string pointer ahead one charcter.
+*
+* Copyright (c) 1991-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Move MBCS string pointer ahead one character.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-03-93 KRS Fix prototypes.
+* 08-20-93 CFW Remove test for NULL string, use new function parameters.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+#include <mbctype.h>
+#include <stddef.h>
+
+/***
+*_mbsinc - Move MBCS string pointer ahead one charcter.
+*
+*Purpose:
+* Move the supplied string pointer ahead by one
+* character. MBCS characters are handled correctly.
+*
+*Entry:
+* const unsigned char *current = current char pointer (legal MBCS boundary)
+*
+*Exit:
+* Returns pointer after moving it.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsinc(
+ const unsigned char *current
+ )
+{
+ if (_ISLEADBYTE(*(current++)))
+ current++;
+ return (unsigned char *)current;
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbslen.c b/private/crt32/mbstring/mbslen.c
new file mode 100644
index 000000000..fbea20ce8
--- /dev/null
+++ b/private/crt32/mbstring/mbslen.c
@@ -0,0 +1,51 @@
+/***
+*mbslen.c - Find length of MBCS string
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Find length of MBCS string
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _mbslen - Find length of MBCS string
+*
+*Purpose:
+* Find the length of the MBCS string (in characters).
+*
+*Entry:
+* unsigned char *s = string
+*
+*Exit:
+* Returns the number of MBCS chars in the string
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+size_t _CRTAPI1 _mbslen(s)
+const unsigned char *s;
+{
+ int n;
+
+ for (n = 0; *s; n++, s++) {
+ if (_ISLEADBYTE(*s)) {
+ if (*++s == '\0')
+ break;
+ }
+ }
+
+ return(n);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbslwr.c b/private/crt32/mbstring/mbslwr.c
new file mode 100644
index 000000000..f25f5e409
--- /dev/null
+++ b/private/crt32/mbstring/mbslwr.c
@@ -0,0 +1,76 @@
+/***
+*mbslwr.c - Convert string lower case (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Convert string lower case (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbstring.h>
+#include <mbctype.h>
+
+/***
+* _mbslwr - Convert string lower case (MBCS)
+*
+*Purpose:
+* Convrts all the upper case characters in a string
+* to lower case in place. MBCS chars are handled
+* correctly.
+*
+* Note: Use test against 0x00FF instead of _ISLEADBYTE
+* to ensure that we don't call SBCS routine with a two-byte
+* value.
+*
+*Entry:
+* unsigned char *string = pointer to string
+*
+*Exit:
+* Returns a pointer to the input string; no error return.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbslwr( string )
+unsigned char *string;
+{
+ unsigned char *cp;
+
+ for (cp=string; *cp; cp++) {
+
+ if (_ISLEADBYTE(*cp)) {
+
+#ifdef _MBCS_OS
+ cp++; /* bump pointer */
+#else
+ if ((_mbascii) && (*cp == _MBASCIILEAD)) {
+
+ if ( (*(cp+1) >= (_MBUPPERLOW & 0x00FF))
+ && (*(cp+1) <= (_MBUPPERHIGH & 0x00FF))
+ )
+ *(cp+1) += _MBCASEDIFF;
+ }
+
+ cp++;
+#endif
+
+ }
+
+ else
+ /* single byte, macro version */
+ *cp = (unsigned char) tolower(*cp);
+
+ }
+
+ return( string );
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsnbcat.c b/private/crt32/mbstring/mbsnbcat.c
new file mode 100644
index 000000000..b2da5d812
--- /dev/null
+++ b/private/crt32/mbstring/mbsnbcat.c
@@ -0,0 +1,99 @@
+/***
+*mbsnbcat.c - concatenate string2 onto string1, max length n bytes
+*
+* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* defines mbsnbcat() - concatenate maximum of n bytes
+*
+*Revision History:
+* 08-03-93 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Update _MBCS_OS support.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+#define _MBSBTYPE(str,len) _mbsbtype(str,len)
+
+/***
+* _mbsnbcat - concatenate max cnt bytes onto dst
+*
+*Purpose:
+* Concatenates src onto dst, with a maximum of cnt bytes copied.
+* Handles 2-byte MBCS characters correctly.
+*
+*Entry:
+* unsigned char *dst - string to concatenate onto
+* unsigned char *src - string to concatenate from
+* int cnt - number of bytes to copy
+*
+*Exit:
+* returns dst, with src (at least part) concatenated on
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsnbcat(dst, src, cnt)
+unsigned char *dst;
+const unsigned char *src;
+size_t cnt;
+{
+ unsigned char *start;
+
+ if (!cnt)
+ return(dst);
+
+ start = dst;
+ while (*dst++)
+ ;
+ --dst; // dst now points to end of dst string
+
+
+ /* if last char in string is a lead byte, back up pointer */
+
+#ifdef _KANJI
+ if (_MBSBTYPE(start, (int) ((dst - start) - 1)) == _MBC_LEAD)
+ --dst;
+#else /* _MBCS_OS */
+ if (_ismbslead(start, dst))
+ --dst;
+#endif
+
+ /* copy over the characters */
+
+ while (cnt--) {
+
+ if (_ISLEADBYTE(*src)) {
+ *dst++ = *src++;
+ if (!cnt--) { /* write nul if cnt exhausted */
+ dst[-1] = '\0';
+ break;
+ }
+ if ((*dst++ = *src++)=='\0') { /* or if no trail byte */
+ dst[-2] = '\0';
+ break;
+ }
+ }
+
+ else if ((*dst++ = *src++) == '\0')
+ break;
+
+ }
+
+ /* enter final nul, if necessary */
+
+ if (_MBSBTYPE(start, (int) ((dst - start) - 1)) == _MBC_LEAD)
+ dst[-1] = '\0';
+ else
+ *dst = '\0';
+
+
+ return(start);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsnbcmp.c b/private/crt32/mbstring/mbsnbcmp.c
new file mode 100644
index 000000000..f9aa9521a
--- /dev/null
+++ b/private/crt32/mbstring/mbsnbcmp.c
@@ -0,0 +1,75 @@
+/***
+*mbsnbcmp.c - Compare n bytes of two MBCS strings
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Compare n bytes of two MBCS strings
+*
+*Revision History:
+* 08-03-93 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+*int mbsnbcmp(s1, s2, n) - Compare n bytes of two MBCS strings
+*
+*Purpose:
+* Compares up to n bytes of two strings for lexical order.
+* Strings are compared on a character basis, not a byte basis.
+*
+*Entry:
+* unsigned char *s1, *s2 = strings to compare
+* size_t n = maximum number of bytes to compare
+*
+*Exit:
+* returns <0 if s1 < s2
+* returns 0 if s1 == s2
+* returns >0 if s1 > s2
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _mbsnbcmp( s1, s2, n )
+const unsigned char *s1;
+const unsigned char *s2;
+size_t n;
+{
+ unsigned short c1, c2;
+
+ if (n==0)
+ return(0);
+
+ while (n--) {
+
+ c1 = *s1++;
+ if (_ISLEADBYTE(c1)) {
+ if (n==0)
+ break;
+ c1 = ( (*s1 == '\0') ? 0 : ((c1<<8) | *s1++) );
+ }
+
+ c2 = *s2++;
+ if (_ISLEADBYTE(c2)) {
+ if (n--==0)
+ break;
+ c2 = ( (*s2 == '\0') ? 0 : ((c2<<8) | *s2++) );
+ }
+
+ if (c1 != c2)
+ return( (c1 > c2) ? 1 : -1);
+
+ if (c1 == 0)
+ return(0);
+ }
+
+ return(0);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsnbcnt.c b/private/crt32/mbstring/mbsnbcnt.c
new file mode 100644
index 000000000..196eb02c7
--- /dev/null
+++ b/private/crt32/mbstring/mbsnbcnt.c
@@ -0,0 +1,62 @@
+/***
+*mbsnbcnt.c - Returns byte count of MBCS string
+*
+* Copyright (c) 1987-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Returns byte count of MBCS string
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _mbsnbcnt - Returns byte count of MBCS string
+*
+*Purpose:
+* Returns the number of bytes between the start of the supplied
+* string and the char count supplied. That is, this routine
+* indicates how many bytes are in the first "ccnt" characters
+* of the string.
+*
+*Entry:
+* unsigned char *string = pointer to string
+* unsigned int ccnt = number of characters to scan
+*
+*Exit:
+* Returns number of bytes between string and ccnt.
+*
+* If the end of the string is encountered before ccnt chars were
+* scanned, then the length of the string in bytes is returned.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+size_t _CRTAPI1 _mbsnbcnt(string, ccnt)
+const unsigned char *string;
+size_t ccnt;
+{
+ unsigned char *p;
+
+ for (p = (char *)string; (ccnt-- && *p); p++) {
+
+ if (_ISLEADBYTE(*p)) {
+ if (*++p == '\0') {
+ --p;
+ break;
+ }
+ }
+ }
+
+ return ((size_t) ((char *)p - (char *)string));
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsnbcpy.c b/private/crt32/mbstring/mbsnbcpy.c
new file mode 100644
index 000000000..1f193f5a5
--- /dev/null
+++ b/private/crt32/mbstring/mbsnbcpy.c
@@ -0,0 +1,79 @@
+/***
+*mbsnbcpy.c - Copy one string to another, n bytes only (MBCS)
+*
+* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Copy one string to another, n bytes only (MBCS)
+*
+*Revision History:
+* 05-19-93 KRS Created from mbsncpy.
+* 08-03-93 KRS Fix logic bug.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* _mbsnbcpy - Copy one string to another, n bytes only (MBCS)
+*
+*Purpose:
+* Copies exactly cnt bytes from src to dst. If strlen(src) < cnt, the
+* remaining character are padded with null bytes. If strlen >= cnt, no
+* terminating null byte is added. 2-byte MBCS characters are handled
+* correctly.
+*
+*Entry:
+* unsigned char *dst = destination for copy
+* unsigned char *src = source for copy
+* int cnt = number of characters to copy
+*
+*Exit:
+* returns dst = destination of copy
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsnbcpy(dst, src, cnt)
+unsigned char *dst;
+const unsigned char *src;
+size_t cnt;
+{
+
+ unsigned char *start = dst;
+
+ while (cnt) {
+
+ cnt--;
+ if (_ISLEADBYTE(*src)) {
+ *dst++ = *src++;
+ if (!cnt) {
+ dst[-1] = '\0';
+ break;
+ }
+ cnt--;
+ if ((*dst++ = *src++) == '\0') {
+ dst[-2] = '\0';
+ break;
+ }
+ }
+
+ else
+ if ((*dst++ = *src++) == '\0')
+ break;
+
+ }
+
+ /* pad with nulls as needed */
+
+ while (cnt--)
+ *dst++ = '\0';
+
+ return start;
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsnbicm.c b/private/crt32/mbstring/mbsnbicm.c
new file mode 100644
index 000000000..3ee1d9ba9
--- /dev/null
+++ b/private/crt32/mbstring/mbsnbicm.c
@@ -0,0 +1,101 @@
+/***
+*mbsnbicmp.c - Compare n bytes of strings, ignoring case (MBCS)
+*
+* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Compare n bytes of strings, ignoring case (MBCS)
+*
+*Revision History:
+* 08-03-93 KRS Ported from 16-bit sources.
+* 10-12-93 CFW Compare lower case, not upper.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _mbsnbicmp - Compare n bytes of strings, ignoring case (MBCS)
+*
+*Purpose:
+* Compares up to n bytes of two strings for lexical order.
+* Strings are compared on a character basis, not a byte basis.
+* Case of characters is not considered.
+*
+*Entry:
+* unsigned char *s1, *s2 = strings to compare
+* size_t n = maximum number of bytes to compare
+*
+*Exit:
+* returns <0 if s1 < s2
+* returns 0 if s1 == s2
+* returns >0 if s1 > s2
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _mbsnbicmp(s1, s2, n)
+const unsigned char *s1, *s2;
+size_t n;
+{
+ unsigned short c1, c2;
+
+ if (n==0)
+ return(0);
+
+ while (n--) {
+
+ c1 = *s1++;
+ if (_ISLEADBYTE(c1)) {
+ if (n==0)
+ break;
+ if (*s1 == '\0')
+ c1 = 0;
+ else {
+ c1 = ((c1<<8) | *s1++);
+#ifndef _MBCS_OS
+ if ( (_mbascii) &&
+ ((c1 >= _MBUPPERLOW) && (c1 <= _MBUPPERHIGH))
+ )
+ c1 += _MBCASEDIFF;
+#endif
+ }
+ }
+ else
+ c1 = tolower(c1);
+
+ c2 = *s2++;
+ if (_ISLEADBYTE(c2)) {
+ if (n--==0)
+ break;
+ if (*s2 == '\0')
+ c2 = 0;
+ else {
+ c2 = ((c2<<8) | *s2++);
+#ifndef _MBCS_OS
+ if ( (_mbascii) &&
+ ((c2 >= _MBUPPERLOW) && (c2 <= _MBUPPERHIGH))
+ )
+ c2 += _MBCASEDIFF;
+#endif
+ }
+ }
+ else
+ c2 = tolower(c2);
+
+ if (c1 != c2)
+ return( (c1 > c2) ? 1 : -1);
+
+ if (c1 == 0)
+ return(0);
+ }
+
+ return(0);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsnbset.c b/private/crt32/mbstring/mbsnbset.c
new file mode 100644
index 000000000..36efbb26a
--- /dev/null
+++ b/private/crt32/mbstring/mbsnbset.c
@@ -0,0 +1,102 @@
+/***
+*mbsnbset.asm - Sets first n bytes of string to given character (MBCS)
+*
+* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Sets first n bytes of string to given character (MBCS)
+*
+*Revision History:
+* 08-03-93 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Change short params to int for 32-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* _mbsnbset - Sets first n bytes of string to given character (MBCS)
+*
+*Purpose:
+* Sets the first n bytes of string to the supplied
+* character value. If the length of string is less than n,
+* the length of string is used in place of n. Handles
+* MBCS chars correctly.
+*
+* There are several factors that make this routine complicated:
+* (1) The fill value may be 1 or 2 bytes long.
+* (2) The fill operation may end by hitting the count value
+* or by hitting the end of the string.
+* (3) A null terminating char is NOT placed at the end of
+* the string.
+*
+* Cases to be careful of (both of these can occur at once):
+* (1) Leaving an "orphaned" trail byte in the string (e.g.,
+* overwriting a lead byte but not the corresponding trail byte).
+* (2) Writing only the 1st byte of a 2-byte fill value because the
+* end of string was encountered.
+*
+*Entry:
+* unsigned char *string = string to modify
+* unsigned int val = value to fill string with
+* size_t count = count of characters to fill
+*
+*
+*Exit:
+* Returns string = now filled with char val
+*
+*Uses:
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsnbset(
+ unsigned char *string,
+ unsigned int val,
+ size_t count
+ )
+{
+ unsigned char *start = string;
+ unsigned char highval, lowval;
+
+ /*
+ * leadbyte flag indicates if the last byte we overwrote was
+ * a lead byte or not.
+ */
+
+ if (highval = (unsigned char)(val>>8)) {
+
+ /* double byte value */
+
+ lowval = (unsigned char)(val & 0x00ff);
+
+ while ((count--) && *string) {
+
+ /* pad with ' ' if no room for both bytes -- odd len */
+ if ((!count--) || (!*(string+1))) {
+ *string = ' ';
+ break;
+ }
+
+ *string++ = highval;
+ *string++ = lowval;
+ }
+ }
+
+ else {
+ /* single byte value */
+
+ while (count-- && *string) {
+ *string++ = (unsigned char)val;
+ }
+
+ }
+
+ return( start );
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsncat.c b/private/crt32/mbstring/mbsncat.c
new file mode 100644
index 000000000..343bf39af
--- /dev/null
+++ b/private/crt32/mbstring/mbsncat.c
@@ -0,0 +1,95 @@
+/***
+*mbsncat.c - concatenate string2 onto string1, max length n
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* defines mbsncat() - concatenate maximum of n characters
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Update _MBCS_OS support.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+#define _MBSBTYPE(str,len) _mbsbtype(str,len)
+
+/***
+* _mbsncat - concatenate max cnt characters onto dst
+*
+*Purpose:
+* Concatenates src onto dst, with a maximum of cnt characters copied.
+* Handles 2-byte MBCS characters correctly.
+*
+*Entry:
+* unsigned char *dst - string to concatenate onto
+* unsigned char *src - string to concatenate from
+* int cnt - number of characters to copy
+*
+*Exit:
+* returns dst, with src (at least part) concatenated on
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsncat(dst, src, cnt)
+unsigned char *dst;
+const unsigned char *src;
+size_t cnt;
+{
+ unsigned char *start;
+
+ if (!cnt)
+ return(dst);
+
+ start = dst;
+ while (*dst++)
+ ;
+ --dst; // dst now points to end of dst string
+
+
+ /* if last char in string is a lead byte, back up pointer */
+
+#ifdef _KANJI
+ if (_MBSBTYPE(start, (int) ((dst - start) - 1)) == _MBC_LEAD)
+ --dst;
+#else /* _MBCS_OS */
+ if (_ismbslead(start, dst))
+ --dst;
+#endif
+
+ /* copy over the characters */
+
+ while (cnt--) {
+
+ if (_ISLEADBYTE(*src)) {
+ *dst++ = *src++;
+ if ((*dst++ = *src++) == '\0') {
+ dst[-2] = '\0';
+ break;
+ }
+ }
+
+ else if ((*dst++ = *src++) == '\0')
+ break;
+
+ }
+
+ /* enter final nul, if necessary */
+
+ if (_MBSBTYPE(start, (int) ((dst - start) - 1)) == _MBC_LEAD)
+ dst[-1] = '\0';
+ else
+ *dst = '\0';
+
+
+ return(start);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsnccnt.c b/private/crt32/mbstring/mbsnccnt.c
new file mode 100644
index 000000000..f6e87f0bc
--- /dev/null
+++ b/private/crt32/mbstring/mbsnccnt.c
@@ -0,0 +1,59 @@
+/***
+*mbsnccnt.c - Return char count of MBCS string
+*
+* Copyright (c) 1987-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Return char count of MBCS string
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* _mbsnccnt - Return char count of MBCS string
+*
+*Purpose:
+* Returns the number of chars between the start of the supplied
+* string and the byte count supplied. That is, this routine
+* indicates how many chars are in the first "bcnt" bytes
+* of the string.
+*
+*Entry:
+* const unsigned char *string = pointer to string
+* unsigned int bcnt = number of bytes to scan
+*
+*Exit:
+* Returns number of chars between string and bcnt.
+*
+* If the end of the string is encountered before bcnt chars were
+* scanned, then the length of the string in chars is returned.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+size_t _CRTAPI1 _mbsnccnt(string, bcnt)
+const unsigned char *string;
+size_t bcnt;
+{
+ unsigned int n;
+
+ for (n = 0; (bcnt-- && *string); n++, string++) {
+
+ if (_ISLEADBYTE(*string)) {
+ if ( (!bcnt--) || (*++string == '\0'))
+ break;
+ }
+ }
+
+ return(n);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsncmp.c b/private/crt32/mbstring/mbsncmp.c
new file mode 100644
index 000000000..d9bbcdfaa
--- /dev/null
+++ b/private/crt32/mbstring/mbsncmp.c
@@ -0,0 +1,69 @@
+/***
+*mbsncmp.c - Compare n characters of two MBCS strings
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Compare n characters of two MBCS strings
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+*int mbsncmp(s1, s2, n) - Compare n characters of two MBCS strings
+*
+*Purpose:
+* Compares up to n charcters of two strings for lexical order.
+* Strings are compared on a character basis, not a byte basis.
+*
+*Entry:
+* unsigned char *s1, *s2 = strings to compare
+* size_t n = maximum number of characters to compare
+*
+*Exit:
+* returns <0 if s1 < s2
+* returns 0 if s1 == s2
+* returns >0 if s1 > s2
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _mbsncmp( s1, s2, n )
+const unsigned char *s1;
+const unsigned char *s2;
+size_t n;
+{
+ unsigned short c1, c2;
+
+ if (n==0)
+ return(0);
+
+ while (n--) {
+
+ c1 = *s1++;
+ if (_ISLEADBYTE(c1))
+ c1 = ( (*s1 == '\0') ? 0 : ((c1<<8) | *s1++) );
+
+ c2 = *s2++;
+ if (_ISLEADBYTE(c2))
+ c2 = ( (*s2 == '\0') ? 0 : ((c2<<8) | *s2++) );
+
+ if (c1 != c2)
+ return( (c1 > c2) ? 1 : -1);
+
+ if (c1 == 0)
+ return(0);
+ }
+
+ return(0);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsncpy.c b/private/crt32/mbstring/mbsncpy.c
new file mode 100644
index 000000000..0ce2b471b
--- /dev/null
+++ b/private/crt32/mbstring/mbsncpy.c
@@ -0,0 +1,74 @@
+/***
+*mbsncpy.c - Copy one string to another, n chars only (MBCS)
+*
+* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Copy one string to another, n chars only (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-03-93 KRS Fix logic bug.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* _mbsncpy - Copy one string to another, n chars only (MBCS)
+*
+*Purpose:
+* Copies exactly cnt character from src to dst. If strlen(src) < cnt, the
+* remaining character are padded with null bytes. If strlen >= cnt, no
+* terminating null byte is added. 2-byte MBCS characters are handled
+* correctly.
+*
+*Entry:
+* unsigned char *dst = destination for copy
+* unsigned char *src = source for copy
+* int cnt = number of characters to copy
+*
+*Exit:
+* returns dst = destination of copy
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsncpy(dst, src, cnt)
+unsigned char *dst;
+const unsigned char *src;
+size_t cnt;
+{
+
+ unsigned char *start = dst;
+
+ while (cnt) {
+
+ cnt--;
+ if (_ISLEADBYTE(*src)) {
+ *dst++ = *src++;
+ if ((*dst++ = *src++) == '\0') {
+ dst[-2] = '\0';
+ break;
+ }
+ }
+
+ else
+ if ((*dst++ = *src++) == '\0')
+ break;
+
+ }
+
+ /* pad with nulls as needed */
+
+ while (cnt--)
+ *dst++ = '\0';
+
+ return start;
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsnextc.c b/private/crt32/mbstring/mbsnextc.c
new file mode 100644
index 000000000..6ab8f9b12
--- /dev/null
+++ b/private/crt32/mbstring/mbsnextc.c
@@ -0,0 +1,50 @@
+/***
+*mbsnextc.c - Get the next character in an MBCS string.
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* To return the value of the next character in an MBCS string.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+*_mbsnextc: Returns the next character in a string.
+*
+*Purpose:
+* To return the value of the next character in an MBCS string.
+* Does not advance pointer to the next character.
+*
+*Entry:
+* unsigned char *s = string
+*
+*Exit:
+* unsigned int next = next character.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned int _CRTAPI1 _mbsnextc(s)
+const unsigned char *s;
+{
+ unsigned int next = 0;
+
+ if (_ISLEADBYTE(*s))
+ next = ((unsigned int) *s++) << 8;
+
+ next += (unsigned int) *s;
+
+ return(next);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsnicmp.c b/private/crt32/mbstring/mbsnicmp.c
new file mode 100644
index 000000000..4cc335dac
--- /dev/null
+++ b/private/crt32/mbstring/mbsnicmp.c
@@ -0,0 +1,97 @@
+/***
+*mbsnicmp.c - Compare n characters of strings, ignoring case (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Compare n characters of strings, ignoring case (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 10-12-93 CFW Compare lower case, not upper.
+N*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _mbsnicmp - Compare n characters of strings, ignoring case (MBCS)
+*
+*Purpose:
+* Compares up to n charcters of two strings for lexical order.
+* Strings are compared on a character basis, not a byte basis.
+* Case of characters is not considered.
+*
+*Entry:
+* unsigned char *s1, *s2 = strings to compare
+* size_t n = maximum number of characters to compare
+*
+*Exit:
+* returns <0 if s1 < s2
+* returns 0 if s1 == s2
+* returns >0 if s1 > s2
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CRTAPI1 _mbsnicmp(s1, s2, n)
+const unsigned char *s1, *s2;
+size_t n;
+{
+ unsigned short c1, c2;
+
+ if (n==0)
+ return(0);
+
+ while (n--) {
+
+ c1 = *s1++;
+ if (_ISLEADBYTE(c1)) {
+ if (*s1 == '\0')
+ c1 = 0;
+ else {
+ c1 = ((c1<<8) | *s1++);
+#ifndef _MBCS_OS
+ if ( (_mbascii) &&
+ ((c1 >= _MBUPPERLOW) && (c1 <= _MBUPPERHIGH))
+ )
+ c1 += _MBCASEDIFF;
+#endif
+ }
+ }
+ else
+ c1 = tolower(c1);
+
+ c2 = *s2++;
+ if (_ISLEADBYTE(c2)) {
+ if (*s2 == '\0')
+ c2 = 0;
+ else {
+ c2 = ((c2<<8) | *s2++);
+#ifndef _MBCS_OS
+ if ( (_mbascii) &&
+ ((c2 >= _MBUPPERLOW) && (c2 <= _MBUPPERHIGH))
+ )
+ c2 += _MBCASEDIFF;
+#endif
+ }
+ }
+ else
+ c2 = tolower(c2);
+
+ if (c1 != c2)
+ return( (c1 > c2) ? 1 : -1);
+
+ if (c1 == 0)
+ return(0);
+ }
+
+ return(0);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsninc.c b/private/crt32/mbstring/mbsninc.c
new file mode 100644
index 000000000..8cb30313c
--- /dev/null
+++ b/private/crt32/mbstring/mbsninc.c
@@ -0,0 +1,50 @@
+/***
+*mbsninc.c - Increment MBCS string pointer by specified char count.
+*
+* Copyright (c) 1987-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Increment MBCS string pointer by specified char count.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-03-93 KRS Fix return value logic.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+#include <stddef.h>
+
+/***
+*_mbsninc - Increment MBCS string pointer by specified char count.
+*
+*Purpose:
+* Increment the supplied string pointer by the specified number
+* of characters. MBCS characters are handled correctly.
+*
+*Entry:
+* const unsigned char *string = pointer to string
+* unsigned int ccnt = number of char to advance the pointer
+*
+*Exit:
+* Returns pointer after advancing it.
+* Returns pointer to end of string if string is not ccnt chars long.
+* Returns NULL is supplied pointer is NULL.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsninc(string, ccnt)
+const unsigned char *string;
+size_t ccnt;
+{
+ if (string == NULL)
+ return(NULL);
+
+ return((char *)string + (unsigned int)_mbsnbcnt(string, ccnt));
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsnset.c b/private/crt32/mbstring/mbsnset.c
new file mode 100644
index 000000000..4b24cd5c1
--- /dev/null
+++ b/private/crt32/mbstring/mbsnset.c
@@ -0,0 +1,110 @@
+/***
+*mbsnset.asm - Sets first n charcaters of string to given character (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Sets first n charcaters of string to given character (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Change short params to int for 32-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* _mbsnset - Sets first n charcaters of string to given character (MBCS)
+*
+*Purpose:
+* Sets the first n characters of string to the supplied
+* character value. If the length of string is less than n,
+* the length of string is used in place of n. Handles
+* MBCS chars correctly.
+*
+* There are several factors that make this routine complicated:
+* (1) The fill value may be 1 or 2 bytes long.
+* (2) The fill operation may end by hitting the count value
+* or by hitting the end of the string.
+* (3) A null terminating char is NOT placed at the end of
+* the string.
+*
+* Cases to be careful of (both of these can occur at once):
+* (1) Leaving an "orphaned" trail byte in the string (e.g.,
+* overwriting a lead byte but not the corresponding trail byte).
+* (2) Writing only the 1st byte of a 2-byte fill value because the
+* end of string was encountered.
+*
+*Entry:
+* unsigned char *string = string to modify
+* unsigned int val = value to fill string with
+* size_t count = count of characters to fill
+*
+*
+*Exit:
+* Returns string = now filled with char val
+*
+*Uses:
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsnset(
+ unsigned char *string,
+ unsigned int val,
+ size_t count
+ )
+{
+ unsigned char *start = string;
+ unsigned int leadbyte = 0;
+ unsigned char highval, lowval;
+
+ /*
+ * leadbyte flag indicates if the last byte we overwrote was
+ * a lead byte or not.
+ */
+
+ if (highval = (unsigned char)(val>>8)) {
+
+ /* double byte value */
+
+ lowval = (unsigned char)(val & 0x00ff);
+
+ while (count-- && *string) {
+
+ leadbyte = _ismbbtruelead(leadbyte, *string);
+ *string++ = highval;
+
+ if (*string) {
+ leadbyte = _ismbbtruelead(leadbyte, *string);
+ *string++ = lowval;
+ }
+ else
+ /* overwrite orphaned highval byte */
+ *(string-1) = ' ';
+ }
+ }
+
+ else {
+ /* single byte value */
+
+ while (count-- && *string) {
+ leadbyte = _ismbbtruelead(leadbyte, *string);
+ *string++ = (unsigned char)val;
+ }
+
+ }
+
+ /* overwrite orphaned trailing byte, if necessary */
+ if(leadbyte && *string)
+ *string = ' ';
+
+ return( start );
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbspbrk.c b/private/crt32/mbstring/mbspbrk.c
new file mode 100644
index 000000000..3bae1f375
--- /dev/null
+++ b/private/crt32/mbstring/mbspbrk.c
@@ -0,0 +1,18 @@
+/***
+*mbspbrk.c - Find first string char in charset, pointer return (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Find first string char in charset, pointer return (MBCS)
+* Shares common source file with mbscspn.c.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#define _RETURN_PTR
+#include "mbscspn.c"
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsrchr.c b/private/crt32/mbstring/mbsrchr.c
new file mode 100644
index 000000000..bbbcc8c51
--- /dev/null
+++ b/private/crt32/mbstring/mbsrchr.c
@@ -0,0 +1,67 @@
+/***
+*mbsrchr.c - Search for last occurence of character (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Search for last occurence of character (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Change short params to int for 32-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+#include <stddef.h>
+
+/***
+* _mbsrchr - Search for last occurence of character (MBCS)
+*
+*Purpose:
+* Find the last occurrence of the specified character in
+* the supplied string. Handles MBCS chars/strings correctly.
+*
+*Entry:
+* unsigned char *str = string to search in
+* unsigned int c = character to search for
+*
+*Exit:
+* returns pointer to last occurrence of c in str
+* returns NULL if c not found
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsrchr(
+ const unsigned char *str,
+ unsigned int c
+ )
+{
+ char *r = NULL;
+ unsigned int cc;
+
+ do {
+ cc = *str;
+ if (_ISLEADBYTE(cc)) {
+ if(*++str) {
+ if (c == ((cc<<8)|*str))
+ r = (char *)str - 1;
+ }
+ else if(!r)
+ /* return pointer to '\0' */
+ r = (char *)str;
+ }
+ else if (c == cc)
+ r = (char *)str;
+ }
+ while (*str++);
+
+ return(r);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsrev.c b/private/crt32/mbstring/mbsrev.c
new file mode 100644
index 000000000..8c0a0f62a
--- /dev/null
+++ b/private/crt32/mbstring/mbsrev.c
@@ -0,0 +1,72 @@
+/***
+*mbsrev.c - Reverse a string in place (MBCS)
+*
+* Copyright (c) 1988-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Reverse a string in place (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _mbsrev - Reverse a string in place (MBCS)
+*
+*Purpose:
+* Reverses the order of characters in the string. The terminating
+* null character remains in place. The order of MBCS characters
+* is not changed.
+*
+*Entry:
+* unsigned char *string = string to reverse
+*
+*Exit:
+* returns string - now with reversed characters
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsrev(string)
+unsigned char *string;
+{
+
+ unsigned char *start = string;
+ unsigned char *left = string;
+ unsigned char c;
+
+ /* first go through and reverse the bytes in MBCS chars */
+ while ( *string ) {
+
+ if ( _ISLEADBYTE(*string++) ) {
+ if ( *string ) {
+ c = *string;
+ *string = *(string - 1);
+ *(string - 1) = c;
+ string++;
+ }
+ else /* second byte is EOS */
+ break;
+ }
+ }
+
+ /* now reverse the whole string */
+ string--;
+ while ( left < string ) {
+ c = *left;
+ *left++ = *string;
+ *string-- = c;
+ }
+
+ return ( start );
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsset.c b/private/crt32/mbstring/mbsset.c
new file mode 100644
index 000000000..0884f0e6a
--- /dev/null
+++ b/private/crt32/mbstring/mbsset.c
@@ -0,0 +1,76 @@
+/***
+*mbsset.asm - Sets all charcaters of string to given character (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Sets all charcaters of string to given character (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Change short params to int for 32-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* mbsset - Sets all charcaters of string to given character (MBCS)
+*
+*Purpose:
+* Sets all of characters in string (except the terminating '/0'
+* character) equal to the supplied character. Handles MBCS
+* chars correctly.
+*
+*Entry:
+* unsigned char *string = string to modify
+* unsigned int val = value to fill string with
+*
+*Exit:
+* returns string = now filled with the specified char
+*
+*Uses:
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsset( string, val )
+unsigned char *string;
+unsigned int val;
+{
+ unsigned char *start = string;
+ unsigned char highval, lowval;
+
+ if (highval = (unsigned char) (val>>8)) {
+
+ /* 2-byte value */
+
+ lowval = (unsigned char)(val & 0x00ff);
+
+ while (*string) {
+
+ *string++ = highval;
+ if (*string)
+ *string++ = lowval;
+ else
+ /* don't orphan lead byte */
+ string[-1] = ' ';
+ }
+
+ }
+
+ else {
+ /* single byte value */
+
+ while (*string)
+ *string++ = (unsigned char)val;
+ }
+
+ return(start);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsspn.c b/private/crt32/mbstring/mbsspn.c
new file mode 100644
index 000000000..40cdb662e
--- /dev/null
+++ b/private/crt32/mbstring/mbsspn.c
@@ -0,0 +1,101 @@
+/***
+*mbsspn.c - Search for init substring of chars from control string (MBCS).
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Search for init substring of chars from control string (MBCS).
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+#include <stddef.h>
+
+
+/***
+#ifndef _RETURN_PTR
+* _mbsspn - Find first string char not in charset (MBCS)
+#else
+* _mbsspnp - Find first string char not in charset, return pointer (MBCS)
+#endif
+*
+*Purpose:
+* Returns maximum leading segment of string consisting solely
+* of characters from charset. Handles MBCS characters correctly.
+*
+*Entry:
+* unsigned char *string = string to search in
+* unsigned char *charset = set of characters to scan over
+*
+*Exit:
+*
+#ifndef _RETURN_PTR
+* Returns index of first char in string not in control.
+* Returns 0, if string begins with a character not in charset.
+#else
+* Returns pointer to first character not in charset.
+* Returns NULL if string consists entirely of characters from charset.
+#endif
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+#ifndef _RETURN_PTR
+
+size_t _CRTAPI1 _mbsspn( string, charset )
+const unsigned char *string;
+const unsigned char *charset;
+
+#else
+
+unsigned char * _CRTAPI1 _mbsspnp( string, charset )
+const unsigned char *string;
+const unsigned char *charset;
+
+#endif
+
+{
+ unsigned char *p, *q;
+
+ /* loop through the string to be inspected */
+ for (q = (char *)string; *q; q++) {
+
+ /* loop through the charset */
+ for (p = (char *)charset; *p; p++) {
+
+ if (_ISLEADBYTE(*p)) {
+ if (((*p == *q) && (p[1] == q[1])) || p[1] == '\0')
+ break;
+ p++;
+ }
+
+ else
+ if (*p == *q)
+ break;
+ }
+
+ if (*p == '\0') /* end of charset? */
+ break; /* yes, no match on this char */
+
+ if (_ISLEADBYTE(*q))
+ if (*++q == '\0')
+ break;
+ }
+
+#ifndef _RETURN_PTR
+ return((size_t) (q - string)); /* index */
+#else
+ return((*q) ? q : NULL); /* pointer */
+#endif
+
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsspnp.c b/private/crt32/mbstring/mbsspnp.c
new file mode 100644
index 000000000..cf410ca4a
--- /dev/null
+++ b/private/crt32/mbstring/mbsspnp.c
@@ -0,0 +1,18 @@
+/***
+*mbsspnp.c - Find first string char in charset, pointer return (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Returns maximum leading segment of string consisting solely
+* of characters from charset. Handles MBCS characters correctly.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#define _RETURN_PTR
+#include "mbsspn.c"
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsstr.c b/private/crt32/mbstring/mbsstr.c
new file mode 100644
index 000000000..b2ca4881d
--- /dev/null
+++ b/private/crt32/mbstring/mbsstr.c
@@ -0,0 +1,80 @@
+/***
+* mbsstr.c - Search for one MBCS string inside another
+*
+* Copyright (c) 1988-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Search for one MBCS string inside another
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+#include <stddef.h>
+#include <string.h>
+
+#define _BYTELEN(s) (strlen(s))
+#define _MBSINC(s) (_mbsinc(s))
+#define PCHAR char *
+
+/***
+* _mbsstr - Search for one MBCS string inside another
+*
+*Purpose:
+* Find the first occurrence of str2 in str1.
+*
+*Entry:
+* unsigned char *str1 = beginning of string
+* unsigned char *str2 = string to search for
+*
+*Exit:
+* Returns a pointer to the first occurrence of str2 in
+* str1, or NULL if str2 does not occur in str1
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsstr( str1, str2 )
+const unsigned char *str1;
+const unsigned char *str2;
+{
+ unsigned char *cp = (unsigned char *) str1;
+ unsigned char *s1, *s2, *endp;
+
+ endp = (unsigned PCHAR) (str1 + (_BYTELEN(str1) - _BYTELEN(str2)));
+
+ while (*cp && (cp <= endp))
+ {
+ s1 = cp;
+ s2 = (PCHAR) str2;
+
+ /*
+ * MBCS: ok to ++ since doing equality comparison.
+ * [This depends on MBCS strings being "legal".]
+ */
+
+ while ( *s1 && *s2 && (*s1 == *s2) )
+ s1++, s2++;
+
+ if (!(*s2))
+ return(cp); /* success! */
+
+ /*
+ * bump pointer to next char
+ */
+
+ cp = _MBSINC(cp);
+
+ }
+
+ return(NULL);
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbstok.c b/private/crt32/mbstring/mbstok.c
new file mode 100644
index 000000000..9c1093fb6
--- /dev/null
+++ b/private/crt32/mbstring/mbstok.c
@@ -0,0 +1,174 @@
+/***
+*mbstok.c - Break string into tokens (MBCS)
+*
+* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Break string into tokens (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 12-04-92 KRS Added MTHREAD support.
+* 02-17-93 GJF Changed for new _getptd().
+* 07-14-93 KRS Fix: all references should be to _mtoken, not _token.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+#include <stddef.h>
+#ifdef MTHREAD
+#include <os2dll.h>
+#endif
+
+#define _MBSSPNP(p,s) _mbsspnp(p,s)
+#define _MBSPBRK(q,s) _mbspbrk(q,s);
+
+/***
+* _mbstok - Break string into tokens (MBCS)
+*
+*Purpose:
+* strtok considers the string to consist of a sequence of zero or more
+* text tokens separated by spans of one or more control chars. the first
+* call, with string specified, returns a pointer to the first char of the
+* first token, and will write a null char into string immediately
+* following the returned token. subsequent calls with zero for the first
+* argument (string) will work thru the string until no tokens remain. the
+* control string may be different from call to call. when no tokens remain
+* in string a NULL pointer is returned. remember the control chars with a
+* bit map, one bit per ascii char. the null char is always a control char.
+*
+* MBCS chars supported correctly.
+*
+*Entry:
+* char *string = string to break into tokens.
+* char *sepset = set of characters to use as seperators
+*
+*Exit:
+* returns pointer to token, or NULL if no more tokens
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbstok( string, sepset )
+unsigned char * string;
+const unsigned char * sepset;
+
+{
+ unsigned char *nextsep;
+
+#ifdef MTHREAD
+#ifdef _CRUISER_
+
+ struct _tiddata * tdata;
+
+ tdata = _gettidtab(); /* init tid's data address */
+
+#else /* ndef _CRUISER_ */
+#ifdef _WIN32_
+
+ _ptiddata ptd = _getptd();
+
+#else /* ndef _WIN32_ */
+
+#error ERROR - ONLY CRUISER OR WIN32 TARGET SUPPORTED!
+
+#endif /* _WIN32_ */
+#endif /* _CRUISER_ */
+
+ unsigned char *nextoken;
+
+#else /* MTHREAD */
+
+ static unsigned char *nextoken;
+
+#endif /* MTHREAD */
+
+
+ /* init start of scan */
+
+ if (string)
+ nextoken = string;
+ else
+ /* If string==NULL, continue with previous string */
+ {
+
+#ifdef MTHREAD
+#ifdef _CRUISER_
+
+ nextoken = tdata->_mtoken;
+
+#else /* ndef _CRUISER_ */
+#ifdef _WIN32_
+
+ nextoken = ptd->_mtoken;
+
+#else /* ndef _WIN32_ */
+
+#error ERROR - ONLY CRUISER OR WIN32 TARGET SUPPORTED!
+
+#endif /* _WIN32_ */
+#endif /* _CRUISER_ */
+#endif /* MTHREAD */
+
+ if (!nextoken)
+ return NULL;
+ }
+
+ /* skip over lead seperators */
+
+ if ((string = _MBSSPNP(nextoken, sepset)) == NULL)
+ return(NULL);
+
+
+ /* test for end of string */
+
+ if ( (*string == '\0') ||
+ ( (_ISLEADBYTE(*string)) && (string[1] == '\0') )
+ )
+ return(NULL);
+
+
+ /* find next seperator */
+
+ nextsep = _MBSPBRK(string, sepset);
+
+ if ((nextsep == NULL) || (*nextsep == '\0'))
+ nextoken = NULL;
+ else {
+ if (_ISLEADBYTE(*nextsep))
+ *nextsep++ = '\0';
+ *nextsep = '\0';
+ nextoken = ++nextsep;
+ }
+
+#ifdef MTHREAD
+ /* Update the corresponding field in the per-thread data * structure */
+
+#ifdef _CRUISER_
+
+ tdata->_mtoken = nextoken;
+
+#else /* _CRUISER_ */
+
+#ifdef _WIN32_
+
+ ptd->_mtoken = nextoken;
+
+#else /* ndef _WIN32_ */
+
+#error ERROR - ONLY CRUISER OR WIN32 TARGET SUPPORTED!
+
+#endif /* _WIN32_ */
+
+#endif /* _CRUISER_ */
+
+#endif /* MTHREAD */
+
+ return(string);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbsupr.c b/private/crt32/mbstring/mbsupr.c
new file mode 100644
index 000000000..36032c1b1
--- /dev/null
+++ b/private/crt32/mbstring/mbsupr.c
@@ -0,0 +1,72 @@
+/***
+*mbsupr.c - Convert string upper case (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Convert string upper case (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbstring.h>
+#include <mbctype.h>
+
+
+/***
+* _mbsupr - Convert string upper case (MBCS)
+*
+*Purpose:
+* Converts all the lower case characters in a string
+* to upper case in place. Handles MBCS chars correctly.
+*
+*Entry:
+* unsigned char *string = pointer to string
+*
+*Exit:
+* Returns a pointer to the input string; no error return.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _mbsupr( string )
+unsigned char *string;
+{
+ unsigned char *cp;
+
+ for (cp=string; *cp; cp++) {
+
+ if (_ISLEADBYTE(*cp)) {
+
+#ifdef _MBCS_OS
+ cp++; /* bump pointer */
+#else
+ if ((_mbascii) && (*cp == _MBASCIILEAD)) {
+
+ if ( (*(cp+1) >= (_MBLOWERLOW & 0x00FF))
+ && (*(cp+1) <= (_MBLOWERHIGH & 0x00FF))
+ )
+ *(cp+1) -= _MBCASEDIFF;
+ }
+
+ cp++;
+#endif
+
+ }
+
+ else
+ /* single byte, macro version */
+ *cp = (unsigned char) toupper(*cp);
+
+ }
+
+ return( string );
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbtohira.c b/private/crt32/mbstring/mbtohira.c
new file mode 100644
index 000000000..d031dc770
--- /dev/null
+++ b/private/crt32/mbstring/mbtohira.c
@@ -0,0 +1,53 @@
+#ifdef _KANJI
+
+/***
+*mbtohira.c - Convert character from katakana to hiragana (Japanese).
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* defines _jtohira() - convert character to hiragana.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Change short params to int for 32-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+
+
+/***
+*unsigned int _mbctohira(c) - Converts character to hiragana.
+*
+*Purpose:
+* Converts the character c from katakana to hiragana, if possible.
+*
+*Entry:
+* unsigned int c - Character to convert.
+*
+*Exit:
+* Returns the converted character.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned int _CRTAPI1 _mbctohira(
+ unsigned int c
+ )
+{
+ if (_ismbckata(c) && c <= 0x8393) {
+ if (c < 0x837f)
+ c -= 0xa1;
+ else
+ c -= 0xa2;
+ }
+ return(c);
+}
+
+#endif /* _KANJI */
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbtokata.c b/private/crt32/mbstring/mbtokata.c
new file mode 100644
index 000000000..f86d6d2c5
--- /dev/null
+++ b/private/crt32/mbstring/mbtokata.c
@@ -0,0 +1,51 @@
+/***
+*mbtokata.c - Converts character to katakana.
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Converts a character from hiragana to katakana.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Change short params to int for 32-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#ifdef _KANJI
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+
+
+/***
+*unsigned short _mbctokata(c) - Converts character to katakana.
+*
+*Purpose:
+* If the character c is hiragana, convert to katakana.
+*
+*Entry:
+* unsigned int c - Character to convert.
+*
+*Exit:
+* Returns converted character.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned int _CRTAPI1 _mbctokata(
+ unsigned int c
+ )
+{
+ if (_ismbchira(c)) {
+ c += 0xa1;
+ if (c >= 0x837f)
+ c++;
+ }
+ return(c);
+}
+
+#endif /* _KANJI */
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbtolwr.c b/private/crt32/mbstring/mbtolwr.c
new file mode 100644
index 000000000..997fdb322
--- /dev/null
+++ b/private/crt32/mbstring/mbtolwr.c
@@ -0,0 +1,72 @@
+/***
+*mbtolwr.c - Convert character to lower case (MBCS).
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Convert character to lower case (MBCS).
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Change short params to int for 32-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _mbctolower - Convert character to lower case (MBCS)
+*
+*Purpose:
+* If the given character is upper case, convert it to lower case.
+* Handles MBCS characters correctly.
+*
+* Note: Use test against 0x00FF instead of _ISLEADBYTE
+* to ensure that we don't call SBCS routine with a two-byte
+* value.
+*
+*Entry:
+* unsigned int c = character to convert
+*
+*Exit:
+* Returns converted character
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned int _CRTAPI1 _mbctolower(
+ unsigned int c
+ )
+{
+
+#ifdef _MBCS_OS
+
+ if (c > 0x00FF)
+ return(c);
+ else
+ return((unsigned int)tolower((int)c));
+
+#else
+
+ if (c > 0x00FF) {
+
+ if ( (_mbascii) &&
+ ((c >= _MBUPPERLOW) && (c <= _MBUPPERHIGH))
+ )
+ c += _MBCASEDIFF;
+ }
+
+ else
+ return((unsigned int)tolower((int)c));
+
+#endif
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/mbtoupr.c b/private/crt32/mbstring/mbtoupr.c
new file mode 100644
index 000000000..515e7163b
--- /dev/null
+++ b/private/crt32/mbstring/mbtoupr.c
@@ -0,0 +1,72 @@
+/***
+*mbtoupr.c - Convert character to upper case (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Convert character to upper case (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Change short params to int for 32-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <ctype.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+* _mbctoupper - Convert character to upper case (MBCS)
+*
+*Purpose:
+* If the given character is lower case, convert to upper case.
+* Handles MBCS chars correctly.
+*
+* Note: Use test against 0x00FF instead of _ISLEADBYTE
+* to ensure that we don't call SBCS routine with a two-byte
+* value.
+*
+*Entry:
+* unsigned int c = character to convert
+*
+*Exit:
+* Returns converted character
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned int _CRTAPI1 _mbctoupper(
+ unsigned int c
+ )
+{
+
+#ifdef _MBCS_OS
+
+ if (c > 0x00FF)
+ return(c);
+ else
+ return((unsigned int)toupper((int)c));
+
+#else
+
+ if (c > 0x00FF) {
+
+ if ( (_mbascii) &&
+ ((c >= _MBLOWERLOW) && (c <= _MBLOWERHIGH))
+ )
+ c -= _MBCASEDIFF;
+ }
+
+ else
+ return((unsigned int)toupper((int)c));
+
+#endif
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/sources b/private/crt32/mbstring/sources
new file mode 100644
index 000000000..a25531c5a
--- /dev/null
+++ b/private/crt32/mbstring/sources
@@ -0,0 +1,105 @@
+!IF 0
+
+Copyright (c) 1989 - 1992, Microsoft Corporation. All rights reserved.
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1990
+ jeffrob 29-sep-1990, use crt32.def
+ karlsi 15-Nov-1992, Port mb functions from 16-bit sources
+
+NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl
+
+!ENDIF
+
+MAJORCOMP=crt
+MINORCOMP=mbstring
+
+TARGETNAME=mbstring
+TARGETPATH=..\obj
+TARGETTYPE=LIBRARY
+386_STDCALL=0
+
+!INCLUDE ..\crt32.def
+
+SOURCES=ISMBALPH.C \
+ ISMBDGT.C \
+ ISMBKNJ.C \
+ ISMBLGL.C \
+ ISMBLWR.C \
+ ISMBPRN.C \
+ ISMBSLE.C \
+ ISMBSPC.C \
+ ISMBSTR.C \
+ ISMBUPR.C \
+ MBASCII0.C \
+ MBBTYPE.C \
+ MBCCPY.C \
+ MBCLEN.C \
+ MBCLEVEL.C \
+ MBCTYPE.C \
+ MBSBTYPE.C \
+ MBSCHR.C \
+ MBSCMP.C \
+ MBSCSPN.C \
+ MBSDEC.C \
+ MBSICMP.C \
+ MBSINC.C \
+ MBSLEN.C \
+ MBSLWR.C \
+ MBSNBCAT.C \
+ MBSNBCMP.C \
+ MBSNBCNT.C \
+ MBSNBCPY.C \
+ MBSNBICM.C \
+ MBSNBSET.C \
+ MBSNCAT.C \
+ MBSNCCNT.C \
+ MBSNCMP.C \
+ MBSNCPY.C \
+ MBSNEXTC.C \
+ MBSNICMP.C \
+ MBSNINC.C \
+ MBSNSET.C \
+ MBSPBRK.C \
+ MBSRCHR.C \
+ MBSREV.C \
+ MBSSET.C \
+ MBSSPN.C \
+ MBSSPNP.C \
+ MBSSTR.C \
+ MBSUPR.C \
+ MBTOHIRA.C \
+ MBTOKATA.C \
+ MBTOLWR.C \
+ MBTOUPR.C \
+ STRDEC.C \
+ STRINC.C \
+ STRNCNT.C \
+ STRNEXTC.C \
+ STRNINC.C \
+ STRSPNP.C \
+ TOJISJMS.C \
+ TOMBBMBC.C \
+ ISMBBYTE.C \
+ MBSCAT.C \
+ MBSDUP.C \
+ MBSTOK.C
+
+i386_SOURCES=i386\MBSCAT.ASM \
+ i386\MBSDUP.ASM
+
+MIPS_SOURCES=
+
diff --git a/private/crt32/mbstring/strdec.c b/private/crt32/mbstring/strdec.c
new file mode 100644
index 000000000..d9c41e5f3
--- /dev/null
+++ b/private/crt32/mbstring/strdec.c
@@ -0,0 +1,46 @@
+/***
+*strdec.c - Move string pointer back one char (SBCS mapping of MBCS function).
+*
+* Copyright (c) 1991-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Move string pointer backward one character (SBCS mapping for MBCS lib).
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 06-03-93 KRS Remove pointer checks.
+* 08-03-93 KRS Fix prototype.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+#include <mbctype.h>
+#include <stddef.h>
+
+/***
+*_strdec - Move SBCS string pointer backward one charcter (MBCS mapping).
+*
+*Purpose:
+* Move the supplied string pointer backwards by one character.
+*
+*Entry:
+* const unsigned char *string = pointer to beginning of string
+* const unsigned char *current = current char pointer
+*
+*Exit:
+* Returns pointer after moving it.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _strdec(string, current)
+const unsigned char *string;
+const unsigned char *current;
+{
+ return (unsigned char *)(--current);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/strinc.c b/private/crt32/mbstring/strinc.c
new file mode 100644
index 000000000..01f17efd4
--- /dev/null
+++ b/private/crt32/mbstring/strinc.c
@@ -0,0 +1,44 @@
+/***
+*strinc.c - Move SBCS string pointer ahead one charcter (MBCS mapping).
+*
+* Copyright (c) 1991-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Move SBCS string pointer ahead one character (MBCS mapping).
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 06-03-93 KRS Remove NULL pointer check.
+* 08-03-93 KRS Fix prototype.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+#include <mbctype.h>
+#include <stddef.h>
+
+/***
+*_mbsinc - Move SBCS string pointer ahead one charcter (MBCS mapping).
+*
+*Purpose:
+* Move the supplied string pointer ahead by one character.
+*
+*Entry:
+* const unsigned char *current = current char pointer
+*
+*Exit:
+* Returns pointer after moving it.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _strinc(current)
+const unsigned char *current;
+{
+ return (unsigned char *)(++current);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/strncnt.c b/private/crt32/mbstring/strncnt.c
new file mode 100644
index 000000000..cce09115e
--- /dev/null
+++ b/private/crt32/mbstring/strncnt.c
@@ -0,0 +1,52 @@
+/***
+*strncnt.c - Return char count of string.
+*
+* Copyright (c) 1987-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Return char count of MBCS string
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* _strncnt - Return char count of string
+*
+*Purpose:
+* Used for mapping _mbsnbcnt and _mbsnccnt to an equivilent non-MBCS
+* implementation when _MBCS is not defined. Returns the minimum of
+* strlen and bcnt.
+*
+*Entry:
+* const unsigned char *string = pointer to string
+* unsigned int bcnt = number of bytes to scan
+*
+*Exit:
+* Returns number of chars/bytes between string and bcnt.
+*
+* If the end of the string is encountered before bcnt chars were
+* scanned, then the length of the string in chars is returned.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+size_t _CRTAPI1 _strncnt(string, bcnt)
+const unsigned char *string;
+size_t bcnt;
+{
+ size_t len;
+
+ len = strlen (string);
+
+ return( (len > bcnt) ? (bcnt) : (len) );
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/strnextc.c b/private/crt32/mbstring/strnextc.c
new file mode 100644
index 000000000..ef2231ccc
--- /dev/null
+++ b/private/crt32/mbstring/strnextc.c
@@ -0,0 +1,44 @@
+/***
+*strnextc.c - Find the next character of a non-MBCS string.
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* To return the value of the next character in a non-MBCS string.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+
+/***
+*_strnextc: Returns the next character in a string.
+*
+*Purpose:
+* To return the value of the next character in an non-MBCS string.
+* Needed for mapping _mbsnextc to the non-MBCS case. Does not
+* advance pointer.
+*
+*Entry:
+* unsigned char *s = string
+*
+*Exit:
+* unsigned int next = next character.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned int _CRTAPI1 _strnextc(s)
+const unsigned char *s;
+{
+ return ((unsigned int) *s);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/strninc.c b/private/crt32/mbstring/strninc.c
new file mode 100644
index 000000000..211fdbc99
--- /dev/null
+++ b/private/crt32/mbstring/strninc.c
@@ -0,0 +1,47 @@
+/***
+*strninc.c - Increment non-MBCS string pointer by specified char count.
+*
+* Copyright (c) 1987-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Increment non-MBCS string pointer by specified char count.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 06-03-93 KRS Remove NULL pointer check.
+* 08-03-93 KRS Fix return value arithmetic.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+#include <stddef.h>
+
+/***
+*_strninc - Increment a SBCS string pointer by specified char count, used
+* for mapping _[f]mbsninc to the non-MBCS case.
+*
+*Purpose:
+* Increment the supplied string pointer by the specified number
+* of characters.
+*
+*Entry:
+* const unsigned char *string = pointer to string
+* unsigned int ccnt = number of char to advance the pointer
+*
+*Exit:
+* Returns pointer after advancing it.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned char * _CRTAPI1 _strninc(string, ccnt)
+const unsigned char *string;
+size_t ccnt;
+{
+ return((char *)string + (unsigned)ccnt);
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/strspnp.c b/private/crt32/mbstring/strspnp.c
new file mode 100644
index 000000000..2e6b9232e
--- /dev/null
+++ b/private/crt32/mbstring/strspnp.c
@@ -0,0 +1,65 @@
+/***
+*strspnp.c - Search for init substring of chars from control string (MBCS)
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Search for init substring of chars from control string (MBCS)
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+#include <stddef.h>
+
+
+/***
+* _strspnp - Find first string char not in charset, return pointer (MBCS)
+*
+*Purpose:
+* Returns maximum leading segment of string consisting solely
+* of characters from charset.
+*
+*Entry:
+* unsigned char *string = string to search in
+* unsigned char *charset = set of characters to scan over
+*
+*Exit:
+*
+* Returns pointer to first character not in charset.
+* Returns NULL if string consists entirely of characters from charset.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+
+unsigned char * _CRTAPI1 _strspnp( string, charset )
+const unsigned char *string;
+const unsigned char *charset;
+{
+ unsigned char *p, *q;
+
+ /* loop through the string to be inspected */
+ for (q = (char *)string; *q; q++) {
+
+ /* loop through the charset */
+ for (p = (char *)charset; *p; p++)
+ if (*p == *q)
+ break;
+
+ if (*p == '\0') /* end of charset? */
+ break; /* yes, no match on this char */
+
+ }
+
+ return((*q) ? q : NULL); /* pointer */
+
+}
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/tojisjms.c b/private/crt32/mbstring/tojisjms.c
new file mode 100644
index 000000000..1f6f71f07
--- /dev/null
+++ b/private/crt32/mbstring/tojisjms.c
@@ -0,0 +1,116 @@
+/***
+*tojisjms.c: Converts JIS to JMS code, and JMS to JIS code.
+*
+* Copyright (c) 1988-1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Convert JIS code into Microsoft Kanji code, and vice versa.
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 05-28-93 KRS Ikura #27: Validate output is legal JIS.
+* 08-20-93 CFW Change short params to int for 32-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#ifdef _KANJI
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+#include <mbctype.h>
+
+
+/***
+*unsigned int _mbcjistojms(c) - Converts JIS code to Microsoft Kanji Code.
+*
+*Purpose:
+* Convert JIS code to Microsoft Kanji code.
+*
+*Entry:
+* unsigned int c - JIS code to be converted. First byte is the upper
+* 8 bits, and second is the lower 8 bits.
+*
+*Exit:
+* Returns related Microsoft Kanji Code. First byte is the upper 8 bits
+* and second byte is the lower 8 bits.
+*
+*Exceptions:
+* If c is out of range, _mbcjistojms returns zero.
+*
+*******************************************************************************/
+
+unsigned int _CRTAPI1 _mbcjistojms(
+ unsigned int c
+ )
+{
+ unsigned int h, l;
+
+ h = (c >> 8) & 0xff;
+ l = c & 0xff;
+ if (h < 0x21 || h > 0x7e || l < 0x21 || l > 0x7e)
+ return 0;
+ if (h & 0x01) { /* first byte is odd */
+ if (l <= 0x5f)
+ l += 0x1f;
+ else
+ l += 0x20;
+ }
+ else
+ l += 0x7e;
+
+ h = ((h - 0x21) >> 1) + 0x81;
+ if (h > 0x9f)
+ h += 0x40;
+ return (h << 8) | l;
+}
+
+
+/***
+*unsigned int _mbcjmstojis(c) - Converts Microsoft Kanji code into JIS code.
+*
+*Purpose:
+* To convert Microsoft Kanji code into JIS code.
+*
+*Entry:
+* unsigned int c - Microsoft Kanji code to be converted. First byte is
+* the upper 8 bits, and the second is the lower 8 bits.
+*
+*Exit:
+* Returns related JIS Code. First byte is the upper 8 bits and the second
+* byte is the lower 8 bits. If c is out of range, return zero.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+unsigned int _CRTAPI1 _mbcjmstojis(c)
+unsigned int c;
+{
+ unsigned int h, l;
+
+ h = (c >> 8) & 0xff;
+ l = c & 0xff;
+
+ /* make sure input is valid shift-JIS */
+ if ((!(_ISLEADBYTE(h))) || (!(_ISTRAILBYTE(l))))
+ return 0;
+
+ h -= (h >= 0xa0) ? 0xc1 : 0x81;
+ if(l >= 0x9f) {
+ c = (h << 9) + 0x2200;
+ c |= l - 0x7e;
+ } else {
+ c = (h << 9) + 0x2100;
+ c |= l - ((l <= 0x7e) ? 0x1f : 0x20);
+ }
+
+ /* not all shift-JIS maps to JIS, so make sure output is valid */
+ if ( (c>0x7E7E) || (c<0x2121) || ((c&0xFF)>0x7E) || ((c&0xFF)<0x21) )
+ return 0;
+
+ return c;
+}
+
+#endif /* _KANJI */
+#endif /* _MBCS */
diff --git a/private/crt32/mbstring/tombbmbc.c b/private/crt32/mbstring/tombbmbc.c
new file mode 100644
index 000000000..6abd94b04
--- /dev/null
+++ b/private/crt32/mbstring/tombbmbc.c
@@ -0,0 +1,312 @@
+/***
+*tombbmbc.c - convert 1-byte code to and from 2-byte code
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* _mbbtombc() - converts 1-byte code to corresponding 2-byte code
+* _mbctombb() - converts 2-byte code to corresponding 1-byte code
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+* 08-20-93 CFW Change short params to int for 32-bit tree.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#ifdef _KANJI
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbstring.h>
+
+
+#define ASCLOW 0x20
+#define ASCHIGH 0x7e
+
+#define SBLOW 0xA1
+#define SBHIGH 0xDF
+
+#define MBLIMIT 0x8396
+
+static unsigned short mbbtable[] = {
+ /*20*/ 0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166,
+ 0x8169, 0x816a, 0x8196, 0x817b, 0x8143, 0x817c, 0x8144, 0x815e,
+ /*30*/ 0x824f, 0x8250, 0x8251, 0x8252, 0x8253, 0x8254, 0x8255, 0x8256,
+ 0x8257, 0x8258, 0x8146, 0x8147, 0x8183, 0x8181, 0x8184, 0x8148,
+ /*40*/ 0x8197, 0x8260, 0x8261, 0x8262, 0x8263, 0x8264, 0x8265, 0x8266,
+ 0x8267, 0x8268, 0x8269, 0x826a, 0x826b, 0x826c, 0x826d, 0x826e,
+ /*50*/ 0x826f, 0x8270, 0x8271, 0x8272, 0x8273, 0x8274, 0x8275, 0x8276,
+ 0x8277, 0x8278, 0x8279, 0x816d, 0x818f, 0x816e, 0x814f, 0x8151,
+ /*60*/ 0x8165, 0x8281, 0x8282, 0x8283, 0x8284, 0x8285, 0x8286, 0x8287,
+ 0x8288, 0x8289, 0x828a, 0x828b, 0x828c, 0x828d, 0x828e, 0x828f,
+ /*70*/ 0x8290, 0x8291, 0x8292, 0x8293, 0x8294, 0x8295, 0x8296, 0x8297,
+ 0x8298, 0x8299, 0x829a, 0x816f, 0x8162, 0x8170, 0x8150,
+};
+
+static struct {
+ unsigned char asc;
+ char synonym;
+ unsigned short mbccode;
+} mbctable[] = {
+ // ASCII Code | Synonym | KANJI Code
+//Katakana Table
+ { 0xA7, 1, 0x8340 }, // 'a'
+ { 0xB1, 1, 0x8341 }, // 'A'
+ { 0xA8, 1, 0x8342 }, // 'i'
+ { 0xB2, 1, 0x8343 }, // 'I'
+ { 0xA9, 1, 0x8344 }, // 'u'
+ { 0xB3, 1, 0x8345 }, // 'U'
+ { 0xAA, 1, 0x8346 }, // 'e'
+ { 0xB4, 1, 0x8347 }, // 'E'
+ { 0xAB, 1, 0x8348 }, // 'o'
+ { 0xB5, 1, 0x8349 }, // 'O'
+
+ { 0xB6, 2, 0x834A }, // 'KA'
+ { 0xB7, 2, 0x834C }, // 'KI'
+ { 0xB8, 2, 0x834E }, // 'KU'
+ { 0xB9, 2, 0x8350 }, // 'KE'
+ { 0xBA, 2, 0x8352 }, // 'KO'
+
+ { 0xBB, 2, 0x8354 }, // 'SA'
+ { 0xBC, 2, 0x8356 }, // 'SI'
+ { 0xBD, 2, 0x8358 }, // 'SU'
+ { 0xBE, 2, 0x835A }, // 'SE'
+ { 0xBF, 2, 0x835C }, // 'SO'
+
+ { 0xC0, 2, 0x835E }, // 'TA'
+ { 0xC1, 2, 0x8360 }, // 'CHI'
+ { 0xAF, 1, 0x8362 }, // 'tsu'
+ { 0xC2, 2, 0x8363 }, // 'TSU'
+ { 0xC3, 2, 0x8365 }, // 'TE''
+ { 0xC4, 2, 0x8367 }, // 'TO''
+
+ { 0xC5, 1, 0x8369 }, // 'NA'
+ { 0xC6, 1, 0x836A }, // 'NI'
+ { 0xC7, 1, 0x836B }, // 'NU'
+ { 0xC8, 1, 0x836C }, // 'NE'
+ { 0xC9, 1, 0x836D }, // 'NO'
+
+ { 0xCA, 3, 0x836E }, // 'HA'
+ { 0xCB, 3, 0x8371 }, // 'HI'
+ { 0xCC, 3, 0x8374 }, // 'FU'
+ { 0xCD, 3, 0x8377 }, // 'HE'
+ { 0xCE, 3, 0x837A }, // 'HO'
+
+ { 0xCF, 1, 0x837D }, // 'MA'
+ { 0xD0, 1, 0x837E }, // 'MI'
+ { 0xD1, 1, 0x8380 }, // 'MU'
+ { 0xD2, 1, 0x8381 }, // 'ME'
+ { 0xD3, 1, 0x8382 }, // 'MO'
+
+ { 0xAC, 1, 0x8383 }, // 'ya'
+ { 0xD4, 1, 0x8384 }, // 'YA'
+ { 0xAD, 1, 0x8385 }, // 'yu'
+ { 0xD5, 1, 0x8386 }, // 'YU'
+ { 0xAE, 1, 0x8387 }, // 'yo'
+ { 0xD6, 1, 0x8388 }, // 'YO'
+
+ { 0xD7, 1, 0x8389 }, // 'RA'
+ { 0xD8, 1, 0x838A }, // 'RI'
+ { 0xD9, 1, 0x838B }, // 'RU'
+ { 0xDA, 1, 0x838C }, // 'RE'
+ { 0xDB, 1, 0x838D }, // 'RO'
+
+ { 0xDC, 2, 0x838E }, // 'WA'
+ { 0xB2, 1, 0x8390 }, // 'I'
+ { 0xB4, 1, 0x8391 }, // 'E'
+
+ { 0xA6, 1, 0x8392 }, // 'WO'
+ { 0xDD, 1, 0x8393 }, // 'N'
+
+ { 0xB3, 1, 0x8394 }, // 'U'
+ { 0xB6, 1, 0x8395 }, // 'KA'
+ { 0xB9, 1, 0x8396 }, // 'KE'
+
+// Hiragana Table
+ { 0xA7, 1, 0x829F }, // 'a'
+ { 0xB1, 1, 0x82A0 }, // 'A'
+ { 0xA8, 1, 0x82A1 }, // 'i'
+ { 0xB2, 1, 0x82A2 }, // 'I'
+ { 0xA9, 1, 0x82A3 }, // 'u'
+ { 0xB3, 1, 0x82A4 }, // 'U'
+ { 0xAA, 1, 0x82A5 }, // 'e'
+ { 0xB4, 1, 0x82A6 }, // 'E'
+ { 0xAB, 1, 0x82A7 }, // 'o'
+ { 0xB5, 1, 0x82A8 }, // 'O'
+
+ { 0xB6, 2, 0x82A9 }, // 'KA'
+ { 0xB7, 2, 0x82AB }, // 'KI'
+ { 0xB8, 2, 0x82AD }, // 'KU'
+ { 0xB9, 2, 0x82AF }, // 'KE'
+ { 0xBA, 2, 0x82B1 }, // 'KO'
+
+ { 0xBB, 2, 0x82B3 }, // 'SA'
+ { 0xBC, 2, 0x82B5 }, // 'SI'
+ { 0xBD, 2, 0x82B7 }, // 'SU'
+ { 0xBE, 2, 0x82B9 }, // 'SE'
+ { 0xBF, 2, 0x82BB }, // 'SO'
+
+ { 0xC0, 2, 0x82BD }, // 'TA'
+ { 0xC1, 2, 0x82BF }, // 'CHI'
+ { 0xAF, 1, 0x82C1 }, // 'tsu'
+ { 0xC2, 2, 0x82C2 }, // 'TSU'
+ { 0xC3, 2, 0x82C4 }, // 'TE'
+ { 0xC4, 2, 0x82C6 }, // 'TO'
+
+ { 0xC5, 1, 0x82C8 }, // 'NA'
+ { 0xC6, 1, 0x82C9 }, // 'NI'
+ { 0xC7, 1, 0x82CA }, // 'NU'
+ { 0xC8, 1, 0x82CB }, // 'NE'
+ { 0xC9, 1, 0x82CC }, // 'NO'
+
+ { 0xCA, 3, 0x82CD }, // 'HA'
+ { 0xCB, 3, 0x82D0 }, // 'HI'
+ { 0xCC, 3, 0x82D3 }, // 'FU'
+ { 0xCD, 3, 0x82D6 }, // 'HE'
+ { 0xCE, 3, 0x82D9 }, // 'HO'
+
+ { 0xCF, 1, 0x82DC }, // 'MA'
+ { 0xD0, 1, 0x82DD }, // 'MI'
+ { 0xD1, 1, 0x82DE }, // 'MU'
+ { 0xD2, 1, 0x82DF }, // 'ME'
+ { 0xD3, 1, 0x82E0 }, // 'MO'
+
+ { 0xAC, 1, 0x82E1 }, // 'ya'
+ { 0xD4, 1, 0x82E2 }, // 'YA'
+ { 0xAD, 1, 0x82E3 }, // 'yu'
+ { 0xD5, 1, 0x82E4 }, // 'YU'
+ { 0xAE, 1, 0x82E5 }, // 'yo'
+ { 0xD6, 1, 0x82E6 }, // 'YO'
+
+ { 0xD7, 1, 0x82E7 }, // 'RA'
+ { 0xD8, 1, 0x82E8 }, // 'RI'
+ { 0xD9, 1, 0x82E9 }, // 'RU'
+ { 0xDA, 1, 0x82EA }, // 'RE'
+ { 0xDB, 1, 0x82EB }, // 'RO'
+
+ { 0xDC, 2, 0x82EC }, // 'WA'
+ { 0xB2, 1, 0x82EE }, // 'I'
+ { 0xB4, 1, 0x82EF }, // 'E'
+
+ { 0xA6, 1, 0x82F0 }, // 'WO'
+ { 0xDD, 1, 0x82F1 }, // 'N'
+
+ { 0x20, 1, 0x8140 }, // ' '
+// { 0xA0, 1, 0x8140 }, // ' '
+ { 0xA1, 1, 0x8142 }, //
+ { 0xA2, 1, 0x8175 }, //
+ { 0xA3, 1, 0x8176 }, //
+ { 0xA4, 1, 0x8141 }, //
+ { 0xA5, 1, 0x8145 }, //
+ { 0xB0, 1, 0x815b }, // '-'
+ { 0xDE, 1, 0x814a }, //
+ { 0xDF, 1, 0x814b }, //
+
+ { 0, 0, 0 } // == End of Table
+
+};
+
+/***
+*unsigned int _mbbtombc(c) - convert mbbvalue to mbcvalue.
+*
+*Purpose:
+* Converts mbbvalue (1-byte) to corresponding mbcvalue code (2-byte).
+*
+*Entry:
+* unsigned int c - mbbvalue character code to be converted.
+*
+*Exit:
+* Returns corresponding mbbvalue (2-byte).
+*
+*Exceptions:
+* Returns c if corresponding 2-byte code does not exist.
+*
+*******************************************************************************/
+
+unsigned int _CRTAPI1 _mbbtombc(
+ unsigned int c
+ )
+{
+ int i;
+
+ /* If c is in the ASCII range, then look up the corresponding value
+ * in the mbbtable. */
+
+ if (c >= ASCLOW && c <= ASCHIGH)
+ return (mbbtable[c-ASCLOW]);
+
+ /* Exception for KANJI */
+
+ if (c == 0xdc)
+ return( 0x838f );
+
+ /* If c is a Katakana character, lookup in mbctable. */
+
+ if (c >= SBLOW && c <= SBHIGH)
+ {
+ for(i = 0; mbctable[i].asc != 0; i++)
+ {
+ if ( c == (unsigned int)mbctable[i].asc ) {
+ c = (unsigned int)mbctable[i].mbccode ;
+ break;
+ }
+ }
+ }
+
+ return(c);
+}
+
+
+/***
+*unsigned int _mbctombb(c) - convert mbcvalue to mbbvalue.
+*
+*Purpose:
+* Converts mbcvalue (2-byte) to corresponding mbbvalue (1-byte).
+*
+*Entry:
+* unsigned int c - mbcvalue character code to convert.
+*
+*Exit:
+* Returns corresponding mbbvalue (1-byte).
+*
+*Exceptions:
+* Returns c if corresponding 1-byte code does not exist.
+*
+*******************************************************************************/
+
+unsigned int _CRTAPI1 _mbctombb(
+ unsigned int c
+ )
+{
+ int i;
+ int result;
+
+ /* Check to see if c is in the ASCII range. */
+
+ for (i = 0; i <= ASCHIGH - ASCLOW; i++)
+ {
+ if (c == (unsigned int)mbbtable[i])
+ return((unsigned int)i + ASCLOW);
+ }
+
+
+ /* If c is a valid MBCS value, search the mbctable for value. */
+
+ if ( c <= MBLIMIT )
+ {
+ for (i = 0; mbctable[i].asc ; i++)
+ {
+ if ( !(result = (int)c - (int)mbctable[i].mbccode) )
+ return( (unsigned int)mbctable[i].asc );
+ else if (((c & 0xff00) == (unsigned int)(mbctable[i].mbccode & 0xff00))
+ && (result > 0)
+ && ((result - mbctable[i].synonym) < 0))
+ return( (unsigned int)mbctable[i].asc );
+ }
+ }
+
+ return(c);
+}
+
+#endif /* _KANJI */
+#endif /* _MBCS */