paredeyes commited on
Commit
480b980
·
verified ·
1 Parent(s): 9c0e023

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. miniCUDA124/bin/cusparse64_12.dll +3 -0
  3. miniMSVC/Windows Kits/10/Lib/10.0.26100.0/um/x64/OneCore_apiset.Lib +3 -0
  4. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbscpy_s_l.cpp +76 -0
  5. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbscspn.cpp +143 -0
  6. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsdec.cpp +109 -0
  7. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsicmp.cpp +142 -0
  8. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsicoll.cpp +79 -0
  9. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsinc.cpp +76 -0
  10. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbslen.cpp +61 -0
  11. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbslen_s.cpp +84 -0
  12. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbslwr.cpp +136 -0
  13. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcat.cpp +116 -0
  14. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcat_s.cpp +16 -0
  15. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcat_s_l.cpp +21 -0
  16. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcmp.cpp +107 -0
  17. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcnt.cpp +71 -0
  18. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcol.cpp +86 -0
  19. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcpy.cpp +103 -0
  20. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcpy_s.cpp +16 -0
  21. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcpy_s_l.cpp +21 -0
  22. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbicm.cpp +133 -0
  23. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbico.cpp +82 -0
  24. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbset.cpp +136 -0
  25. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbset_s.cpp +17 -0
  26. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbset_s_l.cpp +21 -0
  27. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncat.cpp +110 -0
  28. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncat_s.cpp +16 -0
  29. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncat_s.inl +203 -0
  30. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncat_s_l.cpp +21 -0
  31. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnccnt.cpp +67 -0
  32. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncmp.cpp +92 -0
  33. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncoll.cpp +91 -0
  34. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncpy.cpp +96 -0
  35. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncpy_s.cpp +16 -0
  36. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncpy_s.inl +208 -0
  37. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncpy_s_l.cpp +21 -0
  38. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnextc.cpp +64 -0
  39. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnicmp.cpp +115 -0
  40. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnicol.cpp +93 -0
  41. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsninc.cpp +56 -0
  42. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnset.cpp +143 -0
  43. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnset_s.cpp +17 -0
  44. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnset_s.inl +132 -0
  45. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnset_s_l.cpp +21 -0
  46. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbspbrk.cpp +16 -0
  47. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsrchr.cpp +83 -0
  48. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsrev.cpp +108 -0
  49. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsset.cpp +110 -0
  50. miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsset_s.cpp +16 -0
.gitattributes CHANGED
@@ -231,3 +231,5 @@ miniMSVC/Windows[[:space:]]Kits/10/Lib/10.0.26100.0/um/x64/OneCoreUAP_apiset.Lib
231
  miniMSVC/Windows[[:space:]]Kits/10/Lib/10.0.26100.0/um/x64/OneCoreUAP_downlevel.Lib filter=lfs diff=lfs merge=lfs -text
232
  miniMSVC/Windows[[:space:]]Kits/10/Lib/10.0.26100.0/um/x64/OneCore.Lib filter=lfs diff=lfs merge=lfs -text
233
  miniMSVC/Windows[[:space:]]Kits/10/Lib/10.0.26100.0/um/x64/OneCoreUAP.Lib filter=lfs diff=lfs merge=lfs -text
 
 
 
231
  miniMSVC/Windows[[:space:]]Kits/10/Lib/10.0.26100.0/um/x64/OneCoreUAP_downlevel.Lib filter=lfs diff=lfs merge=lfs -text
232
  miniMSVC/Windows[[:space:]]Kits/10/Lib/10.0.26100.0/um/x64/OneCore.Lib filter=lfs diff=lfs merge=lfs -text
233
  miniMSVC/Windows[[:space:]]Kits/10/Lib/10.0.26100.0/um/x64/OneCoreUAP.Lib filter=lfs diff=lfs merge=lfs -text
234
+ miniMSVC/Windows[[:space:]]Kits/10/Lib/10.0.26100.0/um/x64/OneCore_apiset.Lib filter=lfs diff=lfs merge=lfs -text
235
+ miniCUDA124/bin/cusparse64_12.dll filter=lfs diff=lfs merge=lfs -text
miniCUDA124/bin/cusparse64_12.dll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f082a4b3896d1b9a3874834fd1385a18b895190d85e8da5ba3187c8c9eea75be
3
+ size 275632128
miniMSVC/Windows Kits/10/Lib/10.0.26100.0/um/x64/OneCore_apiset.Lib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f9af7885991e573fd0e1393e8adfe1f1fad8d4c0d0ecd8b2a3651599c6c80d0
3
+ size 2195416
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbscpy_s_l.cpp ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbscpy_s_l.c - Copy one string to another (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Copy one string to another (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <corecrt_internal_securecrt.h>
16
+
17
+ errno_t __cdecl _mbscpy_s_l(unsigned char *_Dst, size_t _SizeInBytes, const unsigned char *_Src, _LOCALE_ARG_DECL)
18
+ {
19
+ unsigned char *p;
20
+ size_t available;
21
+ BOOL fIsLeadPrefix;
22
+
23
+ /* validation section */
24
+ _VALIDATE_STRING(_Dst, _SizeInBytes);
25
+ _VALIDATE_POINTER_RESET_STRING(_Src, _Dst, _SizeInBytes);
26
+
27
+ _LOCALE_UPDATE;
28
+ if (_LOCALE_SHORTCUT_TEST)
29
+ {
30
+ return strcpy_s((char *)_Dst, _SizeInBytes, (const char *)_Src);
31
+ }
32
+
33
+ p = _Dst;
34
+ available = _SizeInBytes;
35
+ while ((*p++ = *_Src++) != 0 && --available > 0)
36
+ {
37
+ }
38
+
39
+ /*
40
+ * If we ran out of destination bytes then we did so before copying null.
41
+ * Only exception to that is if last mbc was invalid (leadbyte+null), which
42
+ * is treated as null. In that case clear the copied lead byte and return ok.
43
+ */
44
+
45
+ if (available == 0)
46
+ {
47
+ if (*_Src == 0) {
48
+ _ISMBBLEADPREFIX(fIsLeadPrefix,_Dst,p-1);
49
+ if (fIsLeadPrefix)
50
+ {
51
+ p[-1] = 0;
52
+ _RETURN_MBCS_ERROR;
53
+ }
54
+ }
55
+ _RESET_STRING(_Dst, _SizeInBytes);
56
+ _RETURN_BUFFER_TOO_SMALL(_Dst, _SizeInBytes);
57
+ }
58
+
59
+ /*
60
+ * Otherwise we have space left in the dst buffer and stopped copying because
61
+ * we saw a null in the src. If null is part of invalid MBC (lead byte + null)
62
+ * then clear the lead byte also.
63
+ */
64
+
65
+ _ISMBBLEADPREFIX(fIsLeadPrefix, _Dst, p-2);
66
+ if (fIsLeadPrefix && (p - 2) >= _Dst)
67
+ {
68
+ p[-2] = 0;
69
+ available++;
70
+ _FILL_STRING(_Dst, _SizeInBytes, _SizeInBytes - available + 1);
71
+ _RETURN_MBCS_ERROR;
72
+ }
73
+
74
+ _FILL_STRING(_Dst, _SizeInBytes, _SizeInBytes - available + 1);
75
+ _RETURN_NO_ERROR;
76
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbscspn.cpp ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbscspn.c - Find first string char in charset (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Find first string char in charset (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal.h>
15
+ #include <corecrt_internal_mbstring.h>
16
+ #include <locale.h>
17
+ #include <stddef.h>
18
+ #include <string.h>
19
+
20
+ /***
21
+ *ifndef _RETURN_PTR
22
+ * _mbscspn - Find first string char in charset (MBCS)
23
+ *else
24
+ * _mbspbrk - Find first string char in charset, pointer return (MBCS)
25
+ *endif
26
+ *
27
+ *Purpose:
28
+ * Returns maximum leading segment of string
29
+ * which consists solely of characters NOT from charset.
30
+ * Handles MBCS chars correctly.
31
+ *
32
+ *Entry:
33
+ * char *string = string to search in
34
+ * char *charset = set of characters to scan over
35
+ *
36
+ *Exit:
37
+ *
38
+ *ifndef _RETURN_PTR
39
+ * Returns the index of the first char in string
40
+ * that is in the set of characters specified by control.
41
+ *
42
+ * Returns 0, if string begins with a character in charset.
43
+ *else
44
+ * Returns pointer to first character in charset.
45
+ *
46
+ * Returns nullptr if string consists entirely of characters
47
+ * not from charset.
48
+ *endif
49
+ *
50
+ *Exceptions:
51
+ * Input parameters are validated. Refer to the validation section of the function.
52
+ *
53
+ *******************************************************************************/
54
+
55
+ #ifndef _RETURN_PTR
56
+
57
+ extern "C" size_t __cdecl _mbscspn_l(
58
+ const unsigned char *string,
59
+ const unsigned char *charset,
60
+ _locale_t plocinfo
61
+ )
62
+ #else /* _RETURN_PTR */
63
+
64
+ extern "C" const unsigned char * __cdecl _mbspbrk_l(
65
+ const unsigned char *string,
66
+ const unsigned char *charset,
67
+ _locale_t plocinfo
68
+ )
69
+ #endif /* _RETURN_PTR */
70
+
71
+ {
72
+ unsigned char *p, *q;
73
+ _LocaleUpdate _loc_update(plocinfo);
74
+
75
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
76
+ #ifndef _RETURN_PTR
77
+ return strcspn((const char *)string, (const char *)charset);
78
+ #else /* _RETURN_PTR */
79
+ return (const unsigned char *)strpbrk((const char *)string, (const char *)charset);
80
+ #endif /* _RETURN_PTR */
81
+
82
+ /* validation section */
83
+ #ifndef _RETURN_PTR
84
+ _VALIDATE_RETURN(string != nullptr, EINVAL, 0);
85
+ _VALIDATE_RETURN(charset != nullptr, EINVAL, 0);
86
+ #else /* _RETURN_PTR */
87
+ _VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
88
+ _VALIDATE_RETURN(charset != nullptr, EINVAL, nullptr);
89
+ #endif /* _RETURN_PTR */
90
+
91
+ /* loop through the string to be inspected */
92
+ for (q = (unsigned char *)string; *q ; q++) {
93
+
94
+ /* loop through the charset */
95
+ for (p = (unsigned char *)charset; *p ; p++) {
96
+
97
+ if ( _ismbblead_l(*p, _loc_update.GetLocaleT()) ) {
98
+ if (((*p == *q) && (p[1] == q[1])) || p[1] == '\0')
99
+ break;
100
+ p++;
101
+ }
102
+ else
103
+ if (*p == *q)
104
+ break;
105
+ }
106
+
107
+ if (*p != '\0') /* end of charset? */
108
+ break; /* no, match on this char */
109
+
110
+ if ( _ismbblead_l(*q, _loc_update.GetLocaleT()) )
111
+ if (*++q == '\0')
112
+ break;
113
+ }
114
+
115
+ #ifndef _RETURN_PTR
116
+ return((size_t) (q - string)); /* index */
117
+ #else /* _RETURN_PTR */
118
+ return((*q) ? q : nullptr); /* pointer */
119
+ #endif /* _RETURN_PTR */
120
+
121
+ }
122
+
123
+ #ifndef _RETURN_PTR
124
+
125
+ extern "C" size_t (__cdecl _mbscspn)(
126
+ const unsigned char *string,
127
+ const unsigned char *charset
128
+ )
129
+ #else /* _RETURN_PTR */
130
+
131
+ extern "C" const unsigned char * (__cdecl _mbspbrk)(
132
+ const unsigned char *string,
133
+ const unsigned char *charset
134
+ )
135
+ #endif /* _RETURN_PTR */
136
+
137
+ {
138
+ #ifndef _RETURN_PTR
139
+ return _mbscspn_l(string, charset, nullptr);
140
+ #else /* _RETURN_PTR */
141
+ return _mbspbrk_l(string, charset, nullptr);
142
+ #endif /* _RETURN_PTR */
143
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsdec.cpp ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsdec.c - Move MBCS string pointer backward one charcter.
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Move MBCS string pointer backward one character.
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal.h>
15
+ #include <corecrt_internal_mbstring.h>
16
+ #include <locale.h>
17
+ #include <stddef.h>
18
+
19
+ /***
20
+ *_mbsdec - Move MBCS string pointer backward one charcter.
21
+ *
22
+ *Purpose:
23
+ * Move the supplied string pointer backwards by one
24
+ * character. MBCS characters are handled correctly.
25
+ *
26
+ *Entry:
27
+ * const unsigned char *string = pointer to beginning of string
28
+ * const unsigned char *current = current char pointer (legal MBCS boundary)
29
+ *
30
+ *Exit:
31
+ * Returns pointer after moving it.
32
+ * Returns nullptr if string >= current.
33
+ *
34
+ *Exceptions:
35
+ * Input parameters are validated. Refer to the validation section of the function.
36
+ *
37
+ *******************************************************************************/
38
+
39
+ extern "C" unsigned char * __cdecl _mbsdec_l(
40
+ const unsigned char *string,
41
+ const unsigned char *current,
42
+ _locale_t plocinfo
43
+ )
44
+ {
45
+ const unsigned char *temp;
46
+
47
+ /* validation section */
48
+ _VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
49
+ _VALIDATE_RETURN(current != nullptr, EINVAL, nullptr);
50
+
51
+ if (string >= current)
52
+ return(nullptr);
53
+
54
+ _LocaleUpdate _loc_update(plocinfo);
55
+
56
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
57
+ return (unsigned char *)--current;
58
+
59
+ temp = current - 1;
60
+
61
+ /* There used to be an optimisation here:
62
+ *
63
+ * If (current-1) returns true from _ismbblead, it is a trail byte, because
64
+ * current is a known character start point, and so current-1 would have to be a
65
+ * legal single byte MBCS character, which a lead byte is not. Therefore, if so,
66
+ * return (current-2) because it must be the trailbyte's lead.
67
+ *
68
+ * if ( _ismbblead(*temp) )
69
+ * return (unsigned char *)(temp - 1);
70
+ *
71
+ * But this is not a valid optimisation if you want to cope correctly with an
72
+ * MBCS string which is terminated by a leadbyte and a 0 byte, when you are passed
73
+ * an initial position pointing to the \0 at the end of the string.
74
+ *
75
+ * This optimisation is also invalid if you are passed a pointer to half-way
76
+ * through an MBCS pair.
77
+ *
78
+ * Neither of these are truly valid input conditions, but to ensure predictably
79
+ * correct behaviour in the presence of these conditions, we have removed
80
+ * the optimisation.
81
+ */
82
+
83
+ /*
84
+ * It is unknown whether (current - 1) is a single byte character or a
85
+ * trail. Now decrement temp until
86
+ * a) The beginning of the string is reached, or
87
+ * b) A non-lead byte (either single or trail) is found.
88
+ * The difference between (current-1) and temp is the number of non-single
89
+ * byte characters preceding (current-1). There are two cases for this:
90
+ * a) (current - temp) is odd, and
91
+ * b) (current - temp) is even.
92
+ * If odd, then there are an odd number of "lead bytes" preceding the
93
+ * single/trail byte (current - 1), indicating that it is a trail byte.
94
+ * If even, then there are an even number of "lead bytes" preceding the
95
+ * single/trail byte (current - 1), indicating a single byte character.
96
+ */
97
+ while ( (string <= --temp) && (_ismbblead_l(*temp, _loc_update.GetLocaleT())) )
98
+ ;
99
+
100
+ return (unsigned char *)(current - 1 - ((current - temp) & 0x01) );
101
+ }
102
+
103
+ extern "C" unsigned char * (__cdecl _mbsdec)(
104
+ const unsigned char *string,
105
+ const unsigned char *current
106
+ )
107
+ {
108
+ return _mbsdec_l(string, current, nullptr);
109
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsicmp.cpp ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsicmp.c - Case-insensitive string comparision routine (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Case-insensitive string comparision routine (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal.h>
15
+ #include <corecrt_internal_mbstring.h>
16
+ #include <locale.h>
17
+ #include <string.h>
18
+
19
+ #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
20
+
21
+ /***
22
+ * _mbsicmp - Case-insensitive string comparision routine (MBCS)
23
+ *
24
+ *Purpose:
25
+ * Compares two strings for ordinal order without regard to case.
26
+ * Strings are compared on a character basis, not a byte basis.
27
+ *
28
+ *Entry:
29
+ * char *s1, *s2 = strings to compare
30
+ *
31
+ *Exit:
32
+ * Returns <0 if s1 < s2
33
+ * Returns 0 if s1 == s2
34
+ * Returns >0 if s1 > s2
35
+ * Returns _NLSCMPERROR if something went wrong
36
+ *
37
+ *Exceptions:
38
+ * Input parameters are validated. Refer to the validation section of the function.
39
+ *
40
+ *******************************************************************************/
41
+
42
+ extern "C" int __cdecl _mbsicmp_l(
43
+ const unsigned char *s1,
44
+ const unsigned char *s2,
45
+ _locale_t plocinfo
46
+ )
47
+ {
48
+ unsigned short c1, c2;
49
+ _LocaleUpdate _loc_update(plocinfo);
50
+ int retval;
51
+ unsigned char szResult[4];
52
+
53
+ /* validation section */
54
+ _VALIDATE_RETURN(s1 != nullptr, EINVAL, _NLSCMPERROR);
55
+ _VALIDATE_RETURN(s2 != nullptr, EINVAL, _NLSCMPERROR);
56
+
57
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
58
+ return _stricmp_l((const char *)s1, (const char *)s2, _loc_update.GetLocaleT());
59
+
60
+ for (;;)
61
+ {
62
+ c1 = *s1++;
63
+ if ( _ismbblead_l(c1, _loc_update.GetLocaleT()) )
64
+ {
65
+ if (*s1 == '\0')
66
+ c1 = 0;
67
+ else
68
+ {
69
+ retval = __acrt_LCMapStringA(
70
+ _loc_update.GetLocaleT(),
71
+ _loc_update.GetLocaleT()->mbcinfo->mblocalename,
72
+ LCMAP_UPPERCASE,
73
+ (LPCSTR)s1 - 1,
74
+ 2,
75
+ (LPSTR)szResult,
76
+ 2,
77
+ _loc_update.GetLocaleT()->mbcinfo->mbcodepage,
78
+ TRUE );
79
+
80
+ if (retval == 1)
81
+ c1 = szResult[0];
82
+ else if (retval == 2)
83
+ c1 = (szResult[0] << 8) + szResult[1];
84
+ else
85
+ {
86
+ errno = EINVAL;
87
+ return _NLSCMPERROR;
88
+ }
89
+ s1++;
90
+ }
91
+ }
92
+ else
93
+ c1 = _mbbtolower_l(c1, _loc_update.GetLocaleT());
94
+
95
+ c2 = *s2++;
96
+ if ( _ismbblead_l(c2, _loc_update.GetLocaleT()) )
97
+ {
98
+ if (*s2 == '\0')
99
+ c2 = 0;
100
+ else
101
+ {
102
+ retval = __acrt_LCMapStringA(
103
+ _loc_update.GetLocaleT(),
104
+ _loc_update.GetLocaleT()->mbcinfo->mblocalename,
105
+ LCMAP_UPPERCASE,
106
+ (LPCSTR)s2 - 1,
107
+ 2,
108
+ (LPSTR)szResult,
109
+ 2,
110
+ _loc_update.GetLocaleT()->mbcinfo->mbcodepage,
111
+ TRUE );
112
+
113
+ if (retval == 1)
114
+ c2 = szResult[0];
115
+ else if (retval == 2)
116
+ c2 = (szResult[0] << 8) + szResult[1];
117
+ else
118
+ {
119
+ errno = EINVAL;
120
+ return _NLSCMPERROR;
121
+ }
122
+ s2++;
123
+ }
124
+ }
125
+ else
126
+ c2 = _mbbtolower_l(c2, _loc_update.GetLocaleT());
127
+
128
+ if (c1 != c2)
129
+ return( (c1 > c2) ? 1 : -1 );
130
+
131
+ if (c1 == 0)
132
+ return(0);
133
+ }
134
+ }
135
+
136
+ extern "C" int (__cdecl _mbsicmp)(
137
+ const unsigned char *s1,
138
+ const unsigned char *s2
139
+ )
140
+ {
141
+ return _mbsicmp_l(s1, s2, nullptr);
142
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsicoll.cpp ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsicoll.c - Collate MBCS strings, ignoring case
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Collate MBCS strings, ignoring case
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal.h>
15
+ #include <corecrt_internal_mbstring.h>
16
+ #include <locale.h>
17
+
18
+ /***
19
+ * _mbsicoll - Collate MBCS strings, ignoring case
20
+ *
21
+ *Purpose:
22
+ * Collates two strings for lexical order (ignoring case).
23
+ * Strings are collated on a character basis, not a byte basis.
24
+ *
25
+ *Entry:
26
+ * char *s1, *s2 = strings to collate
27
+ *
28
+ *Exit:
29
+ * Returns <0 if s1 < s2
30
+ * Returns 0 if s1 == s2
31
+ * Returns >0 if s1 > s2
32
+ * Returns _NLSCMPERROR is something went wrong
33
+ *
34
+ *Exceptions:
35
+ * Input parameters are validated. Refer to the validation section of the function.
36
+ *
37
+ *******************************************************************************/
38
+
39
+ extern "C" int __cdecl _mbsicoll_l(
40
+ const unsigned char *s1,
41
+ const unsigned char *s2,
42
+ _locale_t plocinfo
43
+ )
44
+ {
45
+ int ret;
46
+ _LocaleUpdate _loc_update(plocinfo);
47
+
48
+ /* validation section */
49
+ _VALIDATE_RETURN(s1 != nullptr, EINVAL, _NLSCMPERROR);
50
+ _VALIDATE_RETURN(s2 != nullptr, EINVAL, _NLSCMPERROR);
51
+
52
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
53
+ return _stricoll_l((const char *)s1, (const char *)s2, plocinfo);
54
+
55
+ if ( 0 == (ret = __acrt_CompareStringA(
56
+ _loc_update.GetLocaleT(),
57
+ _loc_update.GetLocaleT()->mbcinfo->mblocalename,
58
+ SORT_STRINGSORT | NORM_IGNORECASE,
59
+ (LPCSTR)s1,
60
+ -1,
61
+ (LPSTR)s2,
62
+ -1,
63
+ _loc_update.GetLocaleT()->mbcinfo->mbcodepage )) )
64
+ {
65
+ errno = EINVAL;
66
+ return _NLSCMPERROR;
67
+ }
68
+
69
+ return ret - 2;
70
+
71
+ }
72
+
73
+ extern "C" int (__cdecl _mbsicoll)(
74
+ const unsigned char *s1,
75
+ const unsigned char *s2
76
+ )
77
+ {
78
+ return _mbsicoll_l(s1, s2, nullptr);
79
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsinc.cpp ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsinc.c - Move MBCS string pointer ahead one charcter.
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Move MBCS string pointer ahead one character.
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal.h>
15
+ #include <corecrt_internal_mbstring.h>
16
+ #include <stddef.h>
17
+
18
+ #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
19
+
20
+ /***
21
+ *_mbsinc - Move MBCS string pointer ahead one charcter.
22
+ *
23
+ *Purpose:
24
+ * Move the supplied string pointer ahead by one
25
+ * character. MBCS characters are handled correctly.
26
+ *
27
+ *Entry:
28
+ * const unsigned char *current = current char pointer (legal MBCS boundary)
29
+ *
30
+ *Exit:
31
+ * Returns pointer after moving it.
32
+ *
33
+ *Exceptions:
34
+ * Input parameters are validated. Refer to the validation section of the function.
35
+ *
36
+ *******************************************************************************/
37
+
38
+ extern "C" unsigned char * __cdecl _mbsinc_l(
39
+ const unsigned char *current,
40
+ _locale_t plocinfo
41
+ )
42
+ {
43
+ if ( (_ismbblead_l)(*(current++),plocinfo))
44
+ {
45
+ /* don't move forward two if we get leadbyte, EOS
46
+ also don't assert here as we are too low level
47
+ */
48
+ if(*current!='\0')
49
+ {
50
+ current++;
51
+ }
52
+ }
53
+
54
+ return (unsigned char *)current;
55
+ }
56
+
57
+ extern "C" unsigned char * (__cdecl _mbsinc)(
58
+ const unsigned char *current
59
+ )
60
+ {
61
+ /* validation section */
62
+ _VALIDATE_RETURN(current != nullptr, EINVAL, nullptr);
63
+
64
+ if ( _ismbblead(*(current++)))
65
+ {
66
+ /* don't move forward two if we get leadbyte, EOS
67
+ also don't assert here as we are too low level
68
+ */
69
+ if(*current!='\0')
70
+ {
71
+ current++;
72
+ }
73
+ }
74
+
75
+ return (unsigned char *)current;
76
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbslen.cpp ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbslen.c - Find length of MBCS string
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Find length of MBCS string
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal.h>
15
+ #include <corecrt_internal_mbstring.h>
16
+ #include <locale.h>
17
+ #include <string.h>
18
+
19
+ /***
20
+ * _mbslen - Find length of MBCS string
21
+ *
22
+ *Purpose:
23
+ * Find the length of the MBCS string (in characters).
24
+ *
25
+ *Entry:
26
+ * unsigned char *s = string
27
+ *
28
+ *Exit:
29
+ * Returns the number of MBCS chars in the string.
30
+ *
31
+ *Exceptions:
32
+ *
33
+ *******************************************************************************/
34
+
35
+ extern "C" size_t __cdecl _mbslen_l(
36
+ const unsigned char *s,
37
+ _locale_t plocinfo
38
+ )
39
+ {
40
+ int n;
41
+ _LocaleUpdate _loc_update(plocinfo);
42
+
43
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
44
+ return strlen((const char *)s);
45
+
46
+ for (n = 0; *s; n++, s++) {
47
+ if ( _ismbblead_l(*s, _loc_update.GetLocaleT()) ) {
48
+ if (*++s == '\0')
49
+ break;
50
+ }
51
+ }
52
+
53
+ return(n);
54
+ }
55
+
56
+ extern "C" size_t (__cdecl _mbslen)(
57
+ const unsigned char *s
58
+ )
59
+ {
60
+ return _mbslen_l(s, nullptr);
61
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbslen_s.cpp ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbslen_s.c - Find length of MBCS string
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Find length of MBCS string
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal.h>
15
+ #include <corecrt_internal_mbstring.h>
16
+ #include <locale.h>
17
+ #include <string.h>
18
+
19
+ /***
20
+ * _mbsnlen - Find length of MBCS string
21
+ *
22
+ *Purpose:
23
+ * Find the length of the MBCS string (in characters).
24
+ *
25
+ *Entry:
26
+ * unsigned char *s = string
27
+ * size_t maxsize
28
+ *
29
+ *Exit:
30
+ * Returns the number of MBCS chars in the string.
31
+ * Only the first sizeInBytes bytes of the string are inspected: if the null
32
+ * terminator is not found, sizeInBytes is returned.
33
+ * If the string is null terminated in sizeInBytes bytes, the return value
34
+ * will always be less than sizeInBytes.
35
+ * Returns (size_t)-1 if something went wrong.
36
+ *
37
+ *Exceptions:
38
+ * Input parameters are validated. Refer to the validation section of the function.
39
+ *
40
+ *******************************************************************************/
41
+
42
+ size_t __cdecl _mbsnlen_l(
43
+ const unsigned char *s,
44
+ size_t sizeInBytes,
45
+ _locale_t plocinfo
46
+ )
47
+ {
48
+ size_t n, size;
49
+ _LocaleUpdate _loc_update(plocinfo);
50
+
51
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
52
+ return strnlen((const char *)s, sizeInBytes);
53
+
54
+ /* Note that we do not check if s == nullptr, because we do not
55
+ * return errno_t...
56
+ */
57
+
58
+ /* Note that sizeInBytes here is the number of bytes, not mb characters! */
59
+ for (n = 0, size = 0; size < sizeInBytes && *s; n++, s++, size++)
60
+ {
61
+ if ( _ismbblead_l(*s, _loc_update.GetLocaleT()) )
62
+ {
63
+ size++;
64
+ if (size >= sizeInBytes)
65
+ {
66
+ break;
67
+ }
68
+ if (*++s == '\0')
69
+ {
70
+ break;
71
+ }
72
+ }
73
+ }
74
+
75
+ return (size >= sizeInBytes ? sizeInBytes : n);
76
+ }
77
+
78
+ size_t __cdecl _mbsnlen(
79
+ const unsigned char *s,
80
+ size_t maxsize
81
+ )
82
+ {
83
+ return _mbsnlen_l(s,maxsize, nullptr);
84
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbslwr.cpp ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbslwr.c - Convert string lower case (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Convert string lower case (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal.h>
15
+ #include <corecrt_internal_mbstring.h>
16
+ #include <corecrt_internal_securecrt.h>
17
+ #include <locale.h>
18
+ #include <string.h>
19
+
20
+ #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
21
+
22
+ /***
23
+ * _mbslwr - Convert string lower case (MBCS)
24
+ *
25
+ *Purpose:
26
+ * Convrts all the upper case characters in a string
27
+ * to lower case in place. MBCS chars are handled
28
+ * correctly.
29
+ *
30
+ *Entry:
31
+ * unsigned char *string = pointer to string
32
+ *
33
+ *Exit:
34
+ * Returns a pointer to the input string.
35
+ * Returns nullptr on error.
36
+ *
37
+ *Exceptions:
38
+ * Input parameters are validated. Refer to the validation section of the function.
39
+ *
40
+ *******************************************************************************/
41
+
42
+ errno_t __cdecl _mbslwr_s_l(
43
+ unsigned char *string,
44
+ size_t sizeInBytes,
45
+ _locale_t plocinfo
46
+ )
47
+ {
48
+ size_t stringlen;
49
+
50
+ /* validation section */
51
+ _VALIDATE_RETURN_ERRCODE((string != nullptr && sizeInBytes > 0) || (string == nullptr && sizeInBytes == 0), EINVAL);
52
+
53
+ if (string == nullptr)
54
+ {
55
+ /* nothing to do */
56
+ return 0;
57
+ }
58
+
59
+ stringlen = strnlen((char *)string, sizeInBytes);
60
+ if (stringlen >= sizeInBytes)
61
+ {
62
+ _RESET_STRING(string, sizeInBytes);
63
+ _RETURN_DEST_NOT_NULL_TERMINATED(string, sizeInBytes);
64
+ }
65
+ _FILL_STRING(string, sizeInBytes, stringlen + 1);
66
+
67
+ unsigned char *cp, *dst;
68
+ _LocaleUpdate _loc_update(plocinfo);
69
+
70
+ for (cp = string, dst = string; *cp != '\0'; ++cp)
71
+ {
72
+ if (_ismbblead_l(*cp, _loc_update.GetLocaleT()))
73
+ {
74
+
75
+
76
+ int retval;
77
+ unsigned char ret[4];
78
+ if ((retval = __acrt_LCMapStringA(
79
+ _loc_update.GetLocaleT(),
80
+ _loc_update.GetLocaleT()->mbcinfo->mblocalename,
81
+ LCMAP_LOWERCASE,
82
+ (const char *)cp,
83
+ 2,
84
+ (char *)ret,
85
+ 2,
86
+ _loc_update.GetLocaleT()->mbcinfo->mbcodepage,
87
+ TRUE )) == 0 )
88
+ {
89
+ errno = EILSEQ;
90
+ _RESET_STRING(string, sizeInBytes);
91
+ return errno;
92
+ }
93
+
94
+ *(dst++) = ret[0];
95
+ ++cp;
96
+ if (retval > 1)
97
+ {
98
+ *(dst++) = ret[1];
99
+ }
100
+
101
+
102
+ }
103
+ else
104
+ {
105
+ /* single byte, macro version */
106
+ *(dst++) = (unsigned char) _mbbtolower_l(*cp, _loc_update.GetLocaleT());
107
+ }
108
+ }
109
+ /* null terminate the string */
110
+ *dst = '\0';
111
+
112
+ return 0;
113
+ }
114
+
115
+ errno_t (__cdecl _mbslwr_s)(
116
+ unsigned char *string,
117
+ size_t sizeInBytes
118
+ )
119
+ {
120
+ return _mbslwr_s_l(string, sizeInBytes, nullptr);
121
+ }
122
+
123
+ unsigned char * (__cdecl _mbslwr_l)(
124
+ unsigned char *string,
125
+ _locale_t plocinfo
126
+ )
127
+ {
128
+ return (_mbslwr_s_l(string, (string == nullptr ? 0 : (size_t)-1), plocinfo) == 0 ? string : nullptr);
129
+ }
130
+
131
+ unsigned char * (__cdecl _mbslwr)(
132
+ unsigned char *string
133
+ )
134
+ {
135
+ return (_mbslwr_s_l(string, (string == nullptr ? 0 : (size_t)-1), nullptr) == 0 ? string : nullptr);
136
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcat.cpp ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbcat.c - concatenate string2 onto string1, max length n bytes
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * defines mbsnbcat() - concatenate maximum of n bytes
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal.h>
15
+ #include <corecrt_internal_mbstring.h>
16
+ #include <locale.h>
17
+ #include <string.h>
18
+
19
+
20
+ /***
21
+ * _mbsnbcat - concatenate max cnt bytes onto dst
22
+ *
23
+ *Purpose:
24
+ * Concatenates src onto dst, with a maximum of cnt bytes copied.
25
+ * Handles 2-byte MBCS characters correctly.
26
+ *
27
+ *Entry:
28
+ * unsigned char *dst - string to concatenate onto
29
+ * unsigned char *src - string to concatenate from
30
+ * int cnt - number of bytes to copy
31
+ *
32
+ *Exit:
33
+ * returns dst, with src (at least part) concatenated on
34
+ *
35
+ *Exceptions:
36
+ * Input parameters are validated. Refer to the validation section of the function.
37
+ *
38
+ *******************************************************************************/
39
+
40
+ extern "C" unsigned char * __cdecl _mbsnbcat_l(
41
+ unsigned char *dst,
42
+ const unsigned char *src,
43
+ size_t cnt,
44
+ _locale_t plocinfo
45
+ )
46
+ {
47
+ unsigned char *start;
48
+
49
+ if (!cnt)
50
+ return(dst);
51
+
52
+ /* validation section */
53
+ _VALIDATE_RETURN(dst != nullptr, EINVAL, nullptr);
54
+ _VALIDATE_RETURN(src != nullptr, EINVAL, nullptr);
55
+
56
+ _LocaleUpdate _loc_update(plocinfo);
57
+
58
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
59
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
60
+ return (unsigned char *)strncat((char *)dst, (const char *)src, cnt);
61
+ _END_SECURE_CRT_DEPRECATION_DISABLE
62
+
63
+ start = dst;
64
+ while (*dst++)
65
+ ;
66
+ --dst; // dst now points to end of dst string
67
+
68
+ /* if last char in string is a lead byte, back up pointer */
69
+ if ( dst!=start && _mbsbtype_l(start, (int) ((dst - start) - 1), _loc_update.GetLocaleT()) == _MBC_LEAD )
70
+ {
71
+ --dst;
72
+ }
73
+
74
+ /* copy over the characters */
75
+
76
+ while (cnt--) {
77
+
78
+ if ( _ismbblead_l(*src, _loc_update.GetLocaleT()) ) {
79
+ *dst++ = *src++;
80
+ if (cnt == 0) { /* write null if cnt exhausted */
81
+ dst[-1] = '\0';
82
+ break;
83
+ }
84
+ cnt--;
85
+ if ((*dst++ = *src++)=='\0') { /* or if no trail byte */
86
+ dst[-2] = '\0';
87
+ break;
88
+ }
89
+ }
90
+ else if ((*dst++ = *src++) == '\0')
91
+ break;
92
+
93
+ }
94
+
95
+ if ( dst!=start && _mbsbtype_l(start, (int) ((dst - start) - 1), _loc_update.GetLocaleT()) == _MBC_LEAD )
96
+ {
97
+ dst[-1] = '\0';
98
+ }
99
+ else
100
+ {
101
+ *dst = '\0';
102
+ }
103
+
104
+ return(start);
105
+ }
106
+
107
+ extern "C" unsigned char * (__cdecl _mbsnbcat)(
108
+ unsigned char *dst,
109
+ const unsigned char *src,
110
+ size_t cnt
111
+ )
112
+ {
113
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
114
+ return _mbsnbcat_l(dst, src, cnt, nullptr);
115
+ _END_SECURE_CRT_DEPRECATION_DISABLE
116
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcat_s.cpp ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbcat_s.c - concatenate string2 onto string1, max length n bytes
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * defines mbsnbcat_s() - concatenate maximum of n bytes
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+
16
+ _REDIRECT_TO_L_VERSION_4(errno_t, _mbsnbcat_s, unsigned char *, size_t, const unsigned char *, size_t)
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcat_s_l.cpp ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbcat_s_l.c - concatenate string2 onto string1, max length n bytes
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * defines mbsnbcat_s_l() - concatenate maximum of n bytes
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <corecrt_internal_securecrt.h>
16
+
17
+ #define _FUNC_NAME _mbsnbcat_s_l
18
+ #define _COUNT _CountInBytes
19
+ #define _COUNT_IN_BYTES 1
20
+
21
+ #include "mbsncat_s.inl"
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcmp.cpp ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbcmp.c - Compare n bytes of two MBCS strings
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Compare n bytes of two MBCS strings
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+
17
+ #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
18
+
19
+ /***
20
+ *int mbsnbcmp(s1, s2, n) - Compare n bytes of two MBCS strings
21
+ *
22
+ *Purpose:
23
+ * Compares up to n bytes of two strings for ordinal order.
24
+ *
25
+ * UTF-8 and SBCS are merely compared in byte order.
26
+ * DBCS are compared by codepoint to ensure double byte chars sort last
27
+ *
28
+ *Entry:
29
+ * unsigned char *s1, *s2 = strings to compare
30
+ * size_t n = maximum number of bytes to compare
31
+ *
32
+ *Exit:
33
+ * Returns <0 if s1 < s2
34
+ * Returns 0 if s1 == s2
35
+ * Returns >0 if s1 > s2
36
+ * Returns _NLSCMPERROR is something went wrong
37
+ *
38
+ *Exceptions:
39
+ * Input parameters are validated. Refer to the validation section of the function.
40
+ *
41
+ *******************************************************************************/
42
+
43
+ extern "C" int __cdecl _mbsnbcmp_l(
44
+ const unsigned char *s1,
45
+ const unsigned char *s2,
46
+ size_t n,
47
+ _locale_t plocinfo
48
+ )
49
+ {
50
+ unsigned short c1, c2;
51
+
52
+ if (n==0)
53
+ return(0);
54
+
55
+ _LocaleUpdate _loc_update(plocinfo);
56
+
57
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
58
+ return strncmp((const char *)s1, (const char *)s2, n);
59
+
60
+ /* validation section */
61
+ _VALIDATE_RETURN(s1 != nullptr, EINVAL, _NLSCMPERROR);
62
+ _VALIDATE_RETURN(s2 != nullptr, EINVAL, _NLSCMPERROR);
63
+
64
+ while (n--) {
65
+
66
+ c1 = *s1++;
67
+ if ( _ismbblead_l(c1, _loc_update.GetLocaleT()) )
68
+ {
69
+ if (n==0)
70
+ {
71
+ c1 = 0; /* 'naked' lead - end of string */
72
+ c2 = _ismbblead_l(*s2, _loc_update.GetLocaleT()) ? 0 : *s2;
73
+ goto test;
74
+ }
75
+ c1 = ( (*s1 == '\0') ? 0 : ((c1<<8) | *s1++) );
76
+ }
77
+
78
+ c2 = *s2++;
79
+ if ( _ismbblead_l(c2, _loc_update.GetLocaleT()) )
80
+ {
81
+ if (n==0)
82
+ {
83
+ c2 = 0; /* 'naked' lead - end of string */
84
+ goto test;
85
+ }
86
+ --n;
87
+ c2 = ( (*s2 == '\0') ? 0 : ((c2<<8) | *s2++) );
88
+ }
89
+ test:
90
+ if (c1 != c2)
91
+ return( (c1 > c2) ? 1 : -1);
92
+
93
+ if (c1 == 0)
94
+ return(0);
95
+ }
96
+
97
+ return(0);
98
+ }
99
+
100
+ extern "C" int (__cdecl _mbsnbcmp)(
101
+ const unsigned char *s1,
102
+ const unsigned char *s2,
103
+ size_t n
104
+ )
105
+ {
106
+ return _mbsnbcmp_l(s1, s2, n, nullptr);
107
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcnt.cpp ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbcnt.c - Returns byte count of MBCS string
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Returns byte count of MBCS string
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+
17
+ /***
18
+ * _mbsnbcnt - Returns byte count of MBCS string
19
+ *
20
+ *Purpose:
21
+ * Returns the number of bytes between the start of the supplied
22
+ * string and the char count supplied. That is, this routine
23
+ * indicates how many bytes are in the first "ccnt" characters
24
+ * of the string.
25
+ *
26
+ *Entry:
27
+ * unsigned char *string = pointer to string
28
+ * unsigned int ccnt = number of characters to scan
29
+ *
30
+ *Exit:
31
+ * Returns number of bytes between string and ccnt.
32
+ *
33
+ * If the end of the string is encountered before ccnt chars were
34
+ * scanned, then the length of the string in bytes is returned.
35
+ *
36
+ *Exceptions:
37
+ * Input parameters are validated. Refer to the validation section of the function.
38
+ *
39
+ *******************************************************************************/
40
+
41
+ extern "C" size_t __cdecl _mbsnbcnt_l(
42
+ const unsigned char *string,
43
+ size_t ccnt,
44
+ _locale_t plocinfo
45
+ )
46
+ {
47
+ unsigned char *p;
48
+ _LocaleUpdate _loc_update(plocinfo);
49
+
50
+ /* validation section */
51
+ _VALIDATE_RETURN(string != nullptr || ccnt == 0, EINVAL, 0);
52
+
53
+ for (p = (unsigned char *)string; (ccnt-- && *p); p++) {
54
+ if ( _ismbblead_l(*p, _loc_update.GetLocaleT()) ) {
55
+ if (*++p == '\0') {
56
+ --p;
57
+ break;
58
+ }
59
+ }
60
+ }
61
+
62
+ return ((size_t) ((char *)p - (char *)string));
63
+ }
64
+
65
+ extern "C" size_t (__cdecl _mbsnbcnt)(
66
+ const unsigned char *string,
67
+ size_t ccnt
68
+ )
69
+ {
70
+ return _mbsnbcnt_l(string, ccnt, nullptr);
71
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcol.cpp ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbcol.c - Collate n bytes of two MBCS strings
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Collate n bytes of two MBCS strings
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <limits.h>
16
+ #include <locale.h>
17
+ #include <string.h>
18
+
19
+ /***
20
+ * _mbsnbcoll(s1, s2, n) - Collate n bytes of two MBCS strings
21
+ *
22
+ *Purpose:
23
+ * Collates up to n bytes of two strings for lexical order.
24
+ *
25
+ *Entry:
26
+ * unsigned char *s1, *s2 = strings to collate
27
+ * size_t n = maximum number of bytes to collate
28
+ *
29
+ *Exit:
30
+ * Returns <0 if s1 < s2
31
+ * Returns 0 if s1 == s2
32
+ * Returns >0 if s1 > s2
33
+ * Returns _NLSCMPERROR is something went wrong
34
+ *
35
+ *Exceptions:
36
+ * Input parameters are validated. Refer to the validation section of the function.
37
+ *
38
+ *******************************************************************************/
39
+
40
+ extern "C" int __cdecl _mbsnbcoll_l(
41
+ const unsigned char *s1,
42
+ const unsigned char *s2,
43
+ size_t n,
44
+ _locale_t plocinfo
45
+ )
46
+ {
47
+ int ret;
48
+
49
+ if (n == 0)
50
+ return 0;
51
+
52
+ /* validation section */
53
+ _VALIDATE_RETURN(s1 != nullptr, EINVAL, _NLSCMPERROR);
54
+ _VALIDATE_RETURN(s2 != nullptr, EINVAL, _NLSCMPERROR);
55
+ _VALIDATE_RETURN(n <= INT_MAX, EINVAL, _NLSCMPERROR);
56
+
57
+ _LocaleUpdate _loc_update(plocinfo);
58
+
59
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
60
+ return _strncoll_l((const char *)s1, (const char *)s2, n, plocinfo);
61
+
62
+ if ( 0 == (ret = __acrt_CompareStringA(_loc_update.GetLocaleT(),
63
+ _loc_update.GetLocaleT()->mbcinfo->mblocalename,
64
+ SORT_STRINGSORT,
65
+ (const char *)s1,
66
+ (int)n,
67
+ (char *)s2,
68
+ (int)n,
69
+ _loc_update.GetLocaleT()->mbcinfo->mbcodepage )) )
70
+ {
71
+ errno = EINVAL;
72
+ return _NLSCMPERROR;
73
+ }
74
+
75
+ return ret - 2;
76
+
77
+ }
78
+
79
+ extern "C" int (__cdecl _mbsnbcoll)(
80
+ const unsigned char *s1,
81
+ const unsigned char *s2,
82
+ size_t n
83
+ )
84
+ {
85
+ return _mbsnbcoll_l(s1, s2, n, nullptr);
86
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcpy.cpp ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbcpy.c - Copy one string to another, n bytes only (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Copy one string to another, n bytes only (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <string.h>
17
+
18
+ #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
19
+
20
+ /***
21
+ * _mbsnbcpy - Copy one string to another, n bytes only (MBCS)
22
+ *
23
+ *Purpose:
24
+ * Copies exactly cnt bytes from src to dst. If strlen(src) < cnt, the
25
+ * remaining character are padded with null bytes. If strlen >= cnt, no
26
+ * terminating null byte is added. 2-byte MBCS characters are handled
27
+ * correctly.
28
+ *
29
+ *Entry:
30
+ * unsigned char *dst = destination for copy
31
+ * unsigned char *src = source for copy
32
+ * int cnt = number of bytes to copy
33
+ *
34
+ *Exit:
35
+ * returns dst = destination of copy
36
+ *
37
+ *Exceptions:
38
+ * Input parameters are validated. Refer to the validation section of the function.
39
+ *
40
+ *******************************************************************************/
41
+
42
+ #pragma warning(suppress:6101) // Returning uninitialized memory '*dst'. A successful path through the function does not set the named _Out_ parameter.
43
+ unsigned char * __cdecl _mbsnbcpy_l(
44
+ unsigned char *dst,
45
+ const unsigned char *src,
46
+ size_t cnt,
47
+ _locale_t plocinfo
48
+ )
49
+ {
50
+
51
+ unsigned char *start = dst;
52
+ _LocaleUpdate _loc_update(plocinfo);
53
+
54
+ /* validation section */
55
+ _VALIDATE_RETURN(dst != nullptr || cnt == 0, EINVAL, nullptr);
56
+ _VALIDATE_RETURN(src != nullptr || cnt == 0, EINVAL, nullptr);
57
+
58
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
59
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
60
+ #pragma warning(suppress:__WARNING_BANNED_API_USAGE)
61
+ return (unsigned char *)strncpy((char *)dst, (const char *)src, cnt);
62
+ _END_SECURE_CRT_DEPRECATION_DISABLE
63
+
64
+ while (cnt) {
65
+
66
+ cnt--;
67
+ if ( _ismbblead_l(*src, _loc_update.GetLocaleT()) ) {
68
+ *dst++ = *src++;
69
+ if (!cnt) {
70
+ dst[-1] = '\0';
71
+ break;
72
+ }
73
+ cnt--;
74
+ if ((*dst++ = *src++) == '\0') {
75
+ dst[-2] = '\0';
76
+ break;
77
+ }
78
+ }
79
+
80
+ else
81
+ if ((*dst++ = *src++) == '\0')
82
+ break;
83
+
84
+ }
85
+
86
+ /* pad with nulls as needed */
87
+
88
+ while (cnt--)
89
+ *dst++ = '\0';
90
+
91
+ #pragma warning(suppress:__WARNING_POSTCONDITION_NULLTERMINATION_VIOLATION) // 26036
92
+ return start;
93
+ }
94
+ unsigned char * (__cdecl _mbsnbcpy)(
95
+ unsigned char *dst,
96
+ const unsigned char *src,
97
+ size_t cnt
98
+ )
99
+ {
100
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
101
+ return _mbsnbcpy_l(dst, src, cnt, nullptr);
102
+ _END_SECURE_CRT_DEPRECATION_DISABLE
103
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcpy_s.cpp ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbcpy_s.c - Copy one string to another, n bytes only (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Copy one string to another, n bytes only (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+
16
+ _REDIRECT_TO_L_VERSION_4(errno_t, _mbsnbcpy_s, unsigned char *, size_t, const unsigned char *, size_t)
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbcpy_s_l.cpp ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbcpy_s_l.c - Copy one string to another, n bytes only (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Copy one string to another, n bytes only (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <corecrt_internal_securecrt.h>
16
+
17
+ #define _FUNC_NAME _mbsnbcpy_s_l
18
+ #define _COUNT _CountInBytes
19
+ #define _COUNT_IN_BYTES 1
20
+
21
+ #include "mbsncpy_s.inl"
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbicm.cpp ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbicmp.c - Compare n bytes of strings, ignoring case (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Compare n bytes of strings, ignoring case (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <string.h>
17
+
18
+ #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
19
+
20
+ /***
21
+ * _mbsnbicmp - Compare n bytes of strings, ignoring case (MBCS)
22
+ *
23
+ *Purpose:
24
+ * Compares up to n bytes of two strings for ordinal order.
25
+ * Strings are compared on a character basis, not a byte basis.
26
+ * Case of characters is not considered.
27
+ *
28
+ *Entry:
29
+ * unsigned char *s1, *s2 = strings to compare
30
+ * size_t n = maximum number of bytes to compare
31
+ *
32
+ *Exit:
33
+ * Returns <0 if s1 < s2
34
+ * Returns 0 if s1 == s2
35
+ * Returns >0 if s1 > s2
36
+ * Returns _NLSCMPERROR is something went wrong
37
+ *
38
+ *Exceptions:
39
+ * Input parameters are validated. Refer to the validation section of the function.
40
+ *
41
+ *******************************************************************************/
42
+
43
+ int __cdecl _mbsnbicmp_l(
44
+ const unsigned char *s1,
45
+ const unsigned char *s2,
46
+ size_t n,
47
+ _locale_t plocinfo
48
+ )
49
+ {
50
+ unsigned short c1, c2;
51
+ _LocaleUpdate _loc_update(plocinfo);
52
+
53
+ if (n==0)
54
+ return(0);
55
+
56
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
57
+ return _strnicmp((const char *)s1, (const char *)s2, n);
58
+
59
+ /* validation section */
60
+ _VALIDATE_RETURN(s1 != nullptr, EINVAL, _NLSCMPERROR);
61
+ _VALIDATE_RETURN(s2 != nullptr, EINVAL, _NLSCMPERROR);
62
+
63
+ while (n--) {
64
+
65
+ c1 = *s1++;
66
+ if ( _ismbblead_l(c1, _loc_update.GetLocaleT()) )
67
+ {
68
+ if (n==0)
69
+ {
70
+ c1 = 0; /* 'naked' lead - end of string */
71
+ c2 = _ismbblead_l(*s2, _loc_update.GetLocaleT()) ? 0 : *s2;
72
+ goto test;
73
+ }
74
+ if (*s1 == '\0')
75
+ c1 = 0;
76
+ else {
77
+ c1 = ((c1<<8) | *s1++);
78
+
79
+ if ( ((c1 >= _MBUPPERLOW1_MT(_loc_update.GetLocaleT())) &&
80
+ (c1 <= _MBUPPERHIGH1_MT(_loc_update.GetLocaleT()))) )
81
+ c1 += _MBCASEDIFF1_MT(_loc_update.GetLocaleT());
82
+ else if ( ((c1 >= _MBUPPERLOW2_MT(_loc_update.GetLocaleT())) &&
83
+ (c1 <= _MBUPPERHIGH2_MT(_loc_update.GetLocaleT()))) )
84
+ c1 += _MBCASEDIFF2_MT(_loc_update.GetLocaleT());
85
+ }
86
+ }
87
+ else
88
+ c1 = _mbbtolower_l(c1, _loc_update.GetLocaleT());
89
+
90
+ c2 = *s2++;
91
+ if ( _ismbblead_l(c2, _loc_update.GetLocaleT()) )
92
+ {
93
+ if (n==0)
94
+ {
95
+ c2 = 0; /* 'naked' lead - end of string */
96
+ goto test;
97
+ }
98
+ n--;
99
+ if (*s2 == '\0')
100
+ c2 = 0;
101
+ else {
102
+ c2 = ((c2<<8) | *s2++);
103
+
104
+ if ( ((c2 >= _MBUPPERLOW1_MT(_loc_update.GetLocaleT())) &&
105
+ (c2 <= _MBUPPERHIGH1_MT(_loc_update.GetLocaleT()))) )
106
+ c2 += _MBCASEDIFF1_MT(_loc_update.GetLocaleT());
107
+ else if ( ((c2 >= _MBUPPERLOW2_MT(_loc_update.GetLocaleT())) &&
108
+ (c2 <= _MBUPPERHIGH2_MT(_loc_update.GetLocaleT()))) )
109
+ c2 += _MBCASEDIFF2_MT(_loc_update.GetLocaleT());
110
+ }
111
+ }
112
+ else
113
+ c2 = _mbbtolower_l(c2, _loc_update.GetLocaleT());
114
+
115
+ test:
116
+ if (c1 != c2)
117
+ return( (c1 > c2) ? 1 : -1);
118
+
119
+ if (c1 == 0)
120
+ return(0);
121
+ }
122
+
123
+ return(0);
124
+ }
125
+
126
+ int (__cdecl _mbsnbicmp)(
127
+ const unsigned char *s1,
128
+ const unsigned char *s2,
129
+ size_t n
130
+ )
131
+ {
132
+ return _mbsnbicmp_l(s1, s2, n, nullptr);
133
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbico.cpp ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbico.c - Collate n bytes of strings, ignoring case (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Collate n bytes of strings, ignoring case (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+
17
+
18
+ /***
19
+ * _mbsnbicoll - Collate n bytes of strings, ignoring case (MBCS)
20
+ *
21
+ *Purpose:
22
+ * Collates up to n bytes of two strings for lexical order.
23
+ * Strings are collated on a character basis, not a byte basis.
24
+ * Case of characters is not considered.
25
+ *
26
+ *Entry:
27
+ * unsigned char *s1, *s2 = strings to collate
28
+ * size_t n = maximum number of bytes to collate
29
+ *
30
+ *Exit:
31
+ * Returns <0 if s1 < s2
32
+ * Returns 0 if s1 == s2
33
+ * Returns >0 if s1 > s2
34
+ * Returns _NLSCMPERROR is something went wrong
35
+ *
36
+ *Exceptions:
37
+ * Input parameters are validated. Refer to the validation section of the function.
38
+ *
39
+ *******************************************************************************/
40
+
41
+ extern "C" int __cdecl _mbsnbicoll_l(
42
+ const unsigned char *s1,
43
+ const unsigned char *s2,
44
+ size_t n,
45
+ _locale_t plocinfo
46
+ )
47
+ {
48
+ int ret;
49
+ _LocaleUpdate _loc_update(plocinfo);
50
+
51
+ if (n == 0)
52
+ return 0;
53
+
54
+ /* validation section */
55
+ _VALIDATE_RETURN(s1 != nullptr, EINVAL, _NLSCMPERROR);
56
+ _VALIDATE_RETURN(s2 != nullptr, EINVAL, _NLSCMPERROR);
57
+ _VALIDATE_RETURN(n <= INT_MAX, EINVAL, _NLSCMPERROR);
58
+
59
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
60
+ return _strnicoll_l((const char *)s1, (const char *)s2, n, plocinfo);
61
+
62
+ if ( 0 == (ret = __acrt_CompareStringA(_loc_update.GetLocaleT(),
63
+ _loc_update.GetLocaleT()->mbcinfo->mblocalename,
64
+ SORT_STRINGSORT | NORM_IGNORECASE,
65
+ (const char *)s1,
66
+ (int)n,
67
+ (char *)s2,
68
+ (int)n,
69
+ _loc_update.GetLocaleT()->mbcinfo->mbcodepage )) )
70
+ return _NLSCMPERROR;
71
+
72
+ return ret - 2;
73
+
74
+ }
75
+ extern "C" int __cdecl _mbsnbicoll(
76
+ const unsigned char *s1,
77
+ const unsigned char *s2,
78
+ size_t n
79
+ )
80
+ {
81
+ return _mbsnbicoll_l(s1, s2, n, nullptr);
82
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbset.cpp ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbset.c - Sets first n bytes of string to given character (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Sets first n bytes of string to given character (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <string.h>
17
+
18
+ /***
19
+ * _mbsnbset - Sets first n bytes of string to given character (MBCS)
20
+ *
21
+ *Purpose:
22
+ * Sets the first n bytes of string to the supplied
23
+ * character value. If the length of string is less than n,
24
+ * the length of string is used in place of n. Handles
25
+ * MBCS chars correctly.
26
+ *
27
+ * There are several factors that make this routine complicated:
28
+ * (1) The fill value may be 1 or 2 bytes long.
29
+ * (2) The fill operation may end by hitting the count value
30
+ * or by hitting the end of the string.
31
+ * (3) A null terminating char is NOT placed at the end of
32
+ * the string.
33
+ *
34
+ * Cases to be careful of (both of these can occur at once):
35
+ * (1) Leaving an "orphaned" trail byte in the string (e.g.,
36
+ * overwriting a lead byte but not the corresponding trail byte).
37
+ * (2) Writing only the 1st byte of a 2-byte fill value because the
38
+ * end of string was encountered.
39
+ *
40
+ *Entry:
41
+ * unsigned char *string = string to modify
42
+ * unsigned int val = value to fill string with
43
+ * size_t count = count of characters to fill
44
+ *
45
+ *
46
+ *Exit:
47
+ * Returns string = now filled with char val
48
+ *
49
+ *Uses:
50
+ *
51
+ *Exceptions:
52
+ * Input parameters are validated. Refer to the validation section of the function.
53
+ *
54
+ *******************************************************************************/
55
+
56
+ extern "C" unsigned char * __cdecl _mbsnbset_l(
57
+ unsigned char *string,
58
+ unsigned int val,
59
+ size_t count,
60
+ _locale_t plocinfo
61
+ )
62
+ {
63
+ unsigned char *start = string;
64
+ unsigned char highval, lowval;
65
+ _LocaleUpdate _loc_update(plocinfo);
66
+
67
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
68
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
69
+ return (unsigned char *)_strnset((char *)string, val, count);
70
+ _END_SECURE_CRT_DEPRECATION_DISABLE
71
+
72
+ /* validation section */
73
+ _VALIDATE_RETURN(string != nullptr || count == 0, EINVAL, nullptr);
74
+
75
+ /*
76
+ * leadbyte flag indicates if the last byte we overwrote was
77
+ * a lead byte or not.
78
+ */
79
+
80
+ highval = static_cast<unsigned char>(val >> 8);
81
+ if (highval)
82
+ {
83
+ /* double byte value */
84
+
85
+ lowval = (unsigned char)(val & 0x00ff);
86
+
87
+ if(lowval=='\0')
88
+ {
89
+ _ASSERTE(("invalid MBCS pair passed to mbsnbset",0));
90
+
91
+ /* Ideally we would return nullptr here and signal an error
92
+ condition. But since this function has no other
93
+ error modes, there would be a good chance of crashing
94
+ the caller. So instead we fill the string with spaces
95
+ to ensure that no information leaks through
96
+ unexpectedly. Anyway, we do set errno to EINVAL.
97
+ */
98
+ errno = EINVAL;
99
+ lowval=highval=' ';
100
+ }
101
+
102
+ while ((count--) && *string) {
103
+
104
+ /* pad with ' ' if no room for both bytes -- odd len */
105
+ if ((!count--) || (!*(string+1))) {
106
+ *string = ' ';
107
+ break;
108
+ }
109
+
110
+ *string++ = highval;
111
+ *string++ = lowval;
112
+ }
113
+ }
114
+
115
+ else {
116
+ /* single byte value */
117
+
118
+ while (count-- && *string) {
119
+ *string++ = (unsigned char)val;
120
+ }
121
+
122
+ }
123
+
124
+ return( start );
125
+ }
126
+
127
+ extern "C" unsigned char * (__cdecl _mbsnbset)(
128
+ unsigned char *string,
129
+ unsigned int val,
130
+ size_t count
131
+ )
132
+ {
133
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
134
+ return _mbsnbset_l(string, val, count, nullptr);
135
+ _END_SECURE_CRT_DEPRECATION_DISABLE
136
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbset_s.cpp ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnbset_s.c - Sets first n bytes of string to given character (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Sets first n bytes of string to given character (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <corecrt_internal.h>
16
+
17
+ _REDIRECT_TO_L_VERSION_4(errno_t, _mbsnbset_s, unsigned char *, size_t, unsigned int, size_t)
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnbset_s_l.cpp ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsset_s_l.c - Sets first n bytes of string to given character (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Sets first n bytes of string to given character (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <corecrt_internal_securecrt.h>
16
+
17
+ #define _FUNC_NAME _mbsnbset_s_l
18
+ #define _COUNT _CountInBytes
19
+ #define _COUNT_IN_BYTES 1
20
+
21
+ #include "mbsnset_s.inl"
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncat.cpp ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsncat.c - concatenate string2 onto string1, max length n
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * defines mbsncat() - concatenate maximum of n characters
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <string.h>
17
+
18
+
19
+ /***
20
+ * _mbsncat - concatenate max cnt characters onto dst
21
+ *
22
+ *Purpose:
23
+ * Concatenates src onto dst, with a maximum of cnt characters copied.
24
+ * Handles 2-byte MBCS characters correctly.
25
+ *
26
+ *Entry:
27
+ * unsigned char *dst - string to concatenate onto
28
+ * unsigned char *src - string to concatenate from
29
+ * int cnt - number of characters to copy
30
+ *
31
+ *Exit:
32
+ * returns dst, with src (at least part) concatenated on
33
+ *
34
+ *Exceptions:
35
+ *
36
+ *******************************************************************************/
37
+
38
+ extern "C" unsigned char * __cdecl _mbsncat_l(
39
+ unsigned char *dst,
40
+ const unsigned char *src,
41
+ size_t cnt,
42
+ _locale_t plocinfo
43
+ )
44
+ {
45
+ unsigned char *start;
46
+
47
+ if (!cnt)
48
+ return(dst);
49
+
50
+ /* validation section */
51
+ _VALIDATE_RETURN(dst != nullptr, EINVAL, nullptr);
52
+ _VALIDATE_RETURN(src != nullptr, EINVAL, nullptr);
53
+
54
+ _LocaleUpdate _loc_update(plocinfo);
55
+
56
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
57
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
58
+ return (unsigned char *)strncat((char *)dst, (const char *)src, cnt);
59
+ _END_SECURE_CRT_DEPRECATION_DISABLE
60
+
61
+ start = dst;
62
+ while (*dst++)
63
+ ;
64
+ --dst; // dst now points to end of dst string
65
+
66
+
67
+ /* if last char in string is a lead byte, back up pointer */
68
+
69
+ if ( _ismbslead_l(start, dst, _loc_update.GetLocaleT()) )
70
+ --dst;
71
+
72
+ /* copy over the characters */
73
+
74
+ while (cnt--) {
75
+ if ( _ismbblead_l(*src, _loc_update.GetLocaleT()) ) {
76
+ *dst++ = *src++;
77
+ if ((*dst++ = *src++) == '\0') {
78
+ dst[-2] = '\0';
79
+ break;
80
+ }
81
+ }
82
+
83
+ else if ((*dst++ = *src++) == '\0')
84
+ break;
85
+
86
+ }
87
+
88
+ /* enter final nul, if necessary */
89
+ if ( dst!=start && _mbsbtype_l(start, (int) ((dst - start) - 1), _loc_update.GetLocaleT()) == _MBC_LEAD )
90
+ {
91
+ dst[-1] = '\0';
92
+ }
93
+ else
94
+ {
95
+ *dst = '\0';
96
+ }
97
+
98
+ return(start);
99
+ }
100
+
101
+ extern "C" unsigned char * (__cdecl _mbsncat)(
102
+ unsigned char *dst,
103
+ const unsigned char *src,
104
+ size_t cnt
105
+ )
106
+ {
107
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
108
+ return _mbsncat_l(dst, src, cnt, nullptr);
109
+ _END_SECURE_CRT_DEPRECATION_DISABLE
110
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncat_s.cpp ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsncat_s.c - concatenate string2 onto string1, max length n
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * defines mbsncat_s() - concatenate maximum of n characters
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+
16
+ _REDIRECT_TO_L_VERSION_4(errno_t, _mbsncat_s, unsigned char *, size_t, const unsigned char *, size_t)
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncat_s.inl ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsncat_s.inl - general implementation of _mbsncat_s and _mbsnbcat_s
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * This file contains the general algorithm for _mbsncat_s and _mbsnbcat_s.
8
+ *
9
+ ****/
10
+
11
+ errno_t __cdecl _FUNC_NAME(unsigned char *_Dst, size_t _SizeInBytes, const unsigned char *_Src, size_t _COUNT, _LOCALE_ARG_DECL)
12
+ {
13
+ unsigned char *p;
14
+ size_t available;
15
+ BOOL fIsLeadPrefix;
16
+ BOOL fFoundInvalidMBC;
17
+
18
+ fFoundInvalidMBC = FALSE;
19
+
20
+ if (_COUNT == 0 && _Dst == nullptr && _SizeInBytes == 0)
21
+ {
22
+ /* this case is allowed; nothing to do */
23
+ _RETURN_NO_ERROR;
24
+ }
25
+
26
+ /* validation section */
27
+ _VALIDATE_STRING(_Dst, _SizeInBytes);
28
+ if (_COUNT != 0)
29
+ {
30
+ _VALIDATE_POINTER_RESET_STRING(_Src, _Dst, _SizeInBytes);
31
+ }
32
+
33
+ _LOCALE_UPDATE;
34
+ if (_LOCALE_SHORTCUT_TEST)
35
+ {
36
+ return strncat_s((char *)_Dst, _SizeInBytes, (const char *)_Src, _COUNT);
37
+ }
38
+
39
+ p = _Dst;
40
+ available = _SizeInBytes;
41
+ while (available > 0 && *p != 0)
42
+ {
43
+ p++;
44
+ available--;
45
+ }
46
+
47
+ /*
48
+ * Ran out of room while looking for end of dst string.
49
+ * p points 1 past end of buffer. We can't look past
50
+ * end of buffer so can't tell if dst ended with an
51
+ * invalid mbc.
52
+ */
53
+
54
+ if (available == 0)
55
+ {
56
+ _RESET_STRING(_Dst, _SizeInBytes);
57
+ _RETURN_DEST_NOT_NULL_TERMINATED(_Dst, _SizeInBytes);
58
+ }
59
+
60
+
61
+ if (available < _SizeInBytes)
62
+ {
63
+ /*
64
+ * Dst may have terminated with an invalid MBCS, in that case we clear
65
+ * the bogus lead byte.
66
+ */
67
+ fIsLeadPrefix = FALSE;
68
+ _ISMBBLEADPREFIX(fIsLeadPrefix, _Dst, &p[-1]);
69
+ if (fIsLeadPrefix) {
70
+ /* the original string ended with a lead byte: we remove it */
71
+ p--;
72
+ *p = 0;
73
+ available++;
74
+ fFoundInvalidMBC = TRUE;
75
+ }
76
+ }
77
+
78
+ if (_COUNT == _TRUNCATE)
79
+ {
80
+ while ((*p++ = *_Src++) != 0 && --available > 0)
81
+ {
82
+ }
83
+ }
84
+ else
85
+ {
86
+ #if _COUNT_IN_BYTES
87
+ while (_COUNT > 0 && (*p++ = *_Src++) != 0 && --available > 0)
88
+ {
89
+ _COUNT--;
90
+ }
91
+ #else /* _COUNT_IN_BYTES */
92
+ while (_COUNT > 0)
93
+ {
94
+ if (_ISMBBLEAD(*_Src))
95
+ {
96
+ if (_Src[1] == 0)
97
+ {
98
+ /* the source string ended with a lead byte: we remove it */
99
+ *p = 0;
100
+ fFoundInvalidMBC = TRUE;
101
+ break;
102
+ }
103
+ if (available <= 2)
104
+ {
105
+ /* not enough space */
106
+ available = 0;
107
+ break;
108
+ }
109
+ *p++ = *_Src++;
110
+ *p++ = *_Src++;
111
+ available -= 2;
112
+ }
113
+ else
114
+ {
115
+ if ((*p++ = *_Src++) == 0 || --available == 0)
116
+ {
117
+ break;
118
+ }
119
+ }
120
+ _COUNT--;
121
+ }
122
+ #endif /* _COUNT_IN_BYTES */
123
+ if (_COUNT == 0)
124
+ {
125
+ *p++ = 0;
126
+ }
127
+ }
128
+
129
+ if (available == 0)
130
+ {
131
+ #if _COUNT_IN_BYTES
132
+ /*
133
+ * defined(_COUNT_IN_BYTES) loop does not track mbc context,
134
+ * so we must iterate backwards to discover character context.
135
+ */
136
+ if (*_Src == 0 || _COUNT == 1)
137
+ {
138
+ _ISMBBLEADPREFIX(fIsLeadPrefix, _Dst, &p[-1]);
139
+ if (fIsLeadPrefix)
140
+ {
141
+ /* the source string ended with a lead byte: we remove it */
142
+ p[-1] = 0;
143
+ _RETURN_MBCS_ERROR;
144
+ }
145
+ }
146
+ #endif /* _COUNT_IN_BYTES */
147
+
148
+ /*
149
+ * _COUNT == _TRUNCATE loop terminated because available became 0.
150
+ * This means that we copied at least one character, and it wasn't
151
+ * a null. If this last character acted as a lead then overwrite
152
+ * it with null. Do not set the mbcs error in this case, due that the
153
+ * user cannot predict this case and he/she's only asking for truncation.
154
+ */
155
+ if (_COUNT == _TRUNCATE)
156
+ {
157
+ if (fFoundInvalidMBC)
158
+ {
159
+ _SET_MBCS_ERROR;
160
+ }
161
+
162
+ if (_SizeInBytes > 1)
163
+ {
164
+ fIsLeadPrefix = FALSE;
165
+ _ISMBBLEADPREFIX(fIsLeadPrefix, _Dst, &_Dst[_SizeInBytes - 2]);
166
+ if (fIsLeadPrefix)
167
+ {
168
+ _Dst[_SizeInBytes - 2] = 0;
169
+ _FILL_BYTE(_Dst[_SizeInBytes - 1]);
170
+ _RETURN_TRUNCATE;
171
+ }
172
+ }
173
+
174
+ _Dst[_SizeInBytes - 1] = 0;
175
+
176
+ _RETURN_TRUNCATE;
177
+ }
178
+ _RESET_STRING(_Dst, _SizeInBytes);
179
+ _RETURN_BUFFER_TOO_SMALL(_Dst, _SizeInBytes);
180
+ }
181
+ #if _COUNT_IN_BYTES
182
+ if (available < _SizeInBytes)
183
+ {
184
+ _ISMBBLEADPREFIX(fIsLeadPrefix, _Dst, &p[-2]);
185
+ if (fIsLeadPrefix)
186
+ {
187
+ /* the source string ended with a lead byte: we remove it */
188
+ p[-2] = 0;
189
+ available++;
190
+ fFoundInvalidMBC = TRUE;
191
+ }
192
+ }
193
+ #endif /* _COUNT_IN_BYTES */
194
+ _FILL_STRING(_Dst, _SizeInBytes, _SizeInBytes - available + 1);
195
+
196
+ if (fFoundInvalidMBC)
197
+ {
198
+ _RETURN_MBCS_ERROR;
199
+ }
200
+
201
+ _RETURN_NO_ERROR;
202
+ }
203
+
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncat_s_l.cpp ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsncat_s_l.c - concatenate string2 onto string1, max length n
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * defines mbsncat_s_l() - concatenate maximum of n characters
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <corecrt_internal_securecrt.h>
16
+
17
+ #define _FUNC_NAME _mbsncat_s_l
18
+ #define _COUNT _CountInChars
19
+ #define _COUNT_IN_BYTES 0
20
+
21
+ #include "mbsncat_s.inl"
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnccnt.cpp ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnccnt.c - Return char count of MBCS string
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Return char count of MBCS string
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+
17
+ /***
18
+ * _mbsnccnt - Return char count of MBCS string
19
+ *
20
+ *Purpose:
21
+ * Returns the number of chars between the start of the supplied
22
+ * string and the byte count supplied. That is, this routine
23
+ * indicates how many chars are in the first "bcnt" bytes
24
+ * of the string.
25
+ *
26
+ *Entry:
27
+ * const unsigned char *string = pointer to string
28
+ * unsigned int bcnt = number of bytes to scan
29
+ *
30
+ *Exit:
31
+ * Returns number of chars between string and bcnt.
32
+ *
33
+ * If the end of the string is encountered before bcnt chars were
34
+ * scanned, then the length of the string in chars is returned.
35
+ *
36
+ *Exceptions:
37
+ * Input parameters are validated. Refer to the validation section of the function.
38
+ *
39
+ *******************************************************************************/
40
+
41
+ extern "C" size_t __cdecl _mbsnccnt_l(
42
+ const unsigned char *string,
43
+ size_t bcnt,
44
+ _locale_t plocinfo
45
+ )
46
+ {
47
+ size_t n;
48
+ _LocaleUpdate _loc_update(plocinfo);
49
+
50
+ _VALIDATE_RETURN(string != nullptr || bcnt == 0, EINVAL, 0);
51
+
52
+ for (n = 0; (bcnt-- && *string); n++, string++) {
53
+ if ( _ismbblead_l(*string, _loc_update.GetLocaleT()) ) {
54
+ if ( (!bcnt--) || (*++string == '\0'))
55
+ break;
56
+ }
57
+ }
58
+
59
+ return(n);
60
+ }
61
+ extern "C" size_t (__cdecl _mbsnccnt)(
62
+ const unsigned char *string,
63
+ size_t bcnt
64
+ )
65
+ {
66
+ return _mbsnccnt_l(string, bcnt, nullptr);
67
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncmp.cpp ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsncmp.c - Compare n characters of two MBCS strings
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Compare n characters of two MBCS strings
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <string.h>
17
+
18
+ #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
19
+
20
+ /***
21
+ *int mbsncmp(s1, s2, n) - Compare n characters of two MBCS strings
22
+ *
23
+ *Purpose:
24
+ * Compares up to n characters of two strings for ordinal order.
25
+ * Strings are compared on a character basis, not a byte basis.
26
+ *
27
+ * UTF-8 and SBCS are merely compared in byte order.
28
+ * DBCS are compared by codepoint to ensure double byte chars sort last
29
+ *
30
+ *Entry:
31
+ * unsigned char *s1, *s2 = strings to compare
32
+ * size_t n = maximum number of characters to compare
33
+ *
34
+ *Exit:
35
+ * Returns <0 if s1 < s2
36
+ * Returns 0 if s1 == s2
37
+ * Returns >0 if s1 > s2
38
+ * Returns _NLSCMPERROR is something went wrong
39
+ *
40
+ *Exceptions:
41
+ * Input parameters are validated. Refer to the validation section of the function.
42
+ *
43
+ *******************************************************************************/
44
+
45
+ extern "C" int __cdecl _mbsncmp_l(
46
+ const unsigned char *s1,
47
+ const unsigned char *s2,
48
+ size_t n,
49
+ _locale_t plocinfo
50
+ )
51
+ {
52
+ unsigned short c1, c2;
53
+ _LocaleUpdate _loc_update(plocinfo);
54
+
55
+ if (n==0)
56
+ return(0);
57
+
58
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
59
+ return strncmp((const char *)s1, (const char *)s2, n);
60
+
61
+ /* validation section */
62
+ _VALIDATE_RETURN(s1 != nullptr, EINVAL, _NLSCMPERROR);
63
+ _VALIDATE_RETURN(s2 != nullptr, EINVAL, _NLSCMPERROR);
64
+
65
+ while (n--) {
66
+
67
+ c1 = *s1++;
68
+ if ( _ismbblead_l(c1, _loc_update.GetLocaleT()) )
69
+ c1 = ( (*s1 == '\0') ? 0 : ((c1<<8) | *s1++) );
70
+
71
+ c2 = *s2++;
72
+ if ( _ismbblead_l(c2, _loc_update.GetLocaleT()) )
73
+ c2 = ( (*s2 == '\0') ? 0 : ((c2<<8) | *s2++) );
74
+
75
+ if (c1 != c2)
76
+ return( (c1 > c2) ? 1 : -1);
77
+
78
+ if (c1 == 0)
79
+ return(0);
80
+ }
81
+
82
+ return(0);
83
+ }
84
+
85
+ extern "C" int (__cdecl _mbsncmp)(
86
+ const unsigned char *s1,
87
+ const unsigned char *s2,
88
+ size_t n
89
+ )
90
+ {
91
+ return _mbsncmp_l(s1, s2, n, nullptr);
92
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncoll.cpp ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsncol.c - Collate n characters of two MBCS strings
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Collate n characters of two MBCS strings
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <limits.h>
16
+ #include <locale.h>
17
+ #include <string.h>
18
+
19
+ /***
20
+ * _mbsncoll(s1, s2, n) - Collate n characters of two MBCS strings
21
+ *
22
+ *Purpose:
23
+ * Collates up to n charcters of two strings for lexical order.
24
+ * Strings are collated on a character basis, not a byte basis.
25
+ *
26
+ *Entry:
27
+ * unsigned char *s1, *s2 = strings to collate
28
+ * size_t n = maximum number of characters to collate
29
+ *
30
+ *Exit:
31
+ * Returns <0 if s1 < s2
32
+ * Returns 0 if s1 == s2
33
+ * Returns >0 if s1 > s2
34
+ * Returns _NLSCMPERROR is something went wrong
35
+ *
36
+ *Exceptions:
37
+ * Input parameters are validated. Refer to the validation section of the function.
38
+ *
39
+ *******************************************************************************/
40
+
41
+ extern "C" int __cdecl _mbsncoll_l(
42
+ const unsigned char *s1,
43
+ const unsigned char *s2,
44
+ size_t n,
45
+ _locale_t plocinfo
46
+ )
47
+ {
48
+ int ret;
49
+ size_t bcnt1, bcnt2;
50
+ _LocaleUpdate _loc_update(plocinfo);
51
+
52
+ if (n == 0)
53
+ return 0;
54
+
55
+ /* validation section */
56
+ _VALIDATE_RETURN(s1 != nullptr, EINVAL, _NLSCMPERROR);
57
+ _VALIDATE_RETURN(s2 != nullptr, EINVAL, _NLSCMPERROR);
58
+ _VALIDATE_RETURN(n <= INT_MAX, EINVAL, _NLSCMPERROR);
59
+
60
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
61
+ return _strncoll_l((const char *)s1, (const char *)s2, n, plocinfo);
62
+
63
+ bcnt1 = _mbsnbcnt_l(s1, n, _loc_update.GetLocaleT());
64
+ bcnt2 = _mbsnbcnt_l(s2, n, _loc_update.GetLocaleT());
65
+
66
+ if ( 0 == (ret = __acrt_CompareStringA(
67
+ _loc_update.GetLocaleT(),
68
+ _loc_update.GetLocaleT()->mbcinfo->mblocalename,
69
+ SORT_STRINGSORT,
70
+ (const char *)s1,
71
+ (int)bcnt1,
72
+ (char *)s2,
73
+ (int)bcnt2,
74
+ _loc_update.GetLocaleT()->mbcinfo->mbcodepage )) )
75
+ {
76
+ errno = EINVAL;
77
+ return _NLSCMPERROR;
78
+ }
79
+
80
+ return ret - 2;
81
+
82
+ }
83
+
84
+ extern "C" int (__cdecl _mbsncoll)(
85
+ const unsigned char *s1,
86
+ const unsigned char *s2,
87
+ size_t n
88
+ )
89
+ {
90
+ return _mbsncoll_l(s1, s2, n, nullptr);
91
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncpy.cpp ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsncpy.c - Copy one string to another, n chars only (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Copy one string to another, n chars only (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <string.h>
17
+
18
+ #pragma warning(disable:__WARNING_INCORRECT_VALIDATION __WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26014 26018
19
+
20
+ /***
21
+ * _mbsncpy - Copy one string to another, n chars only (MBCS)
22
+ *
23
+ *Purpose:
24
+ * Copies exactly cnt character from src to dst. If strlen(src) < cnt, the
25
+ * remaining character are padded with null bytes. If strlen >= cnt, no
26
+ * terminating null byte is added. 2-byte MBCS characters are handled
27
+ * correctly.
28
+ *
29
+ *Entry:
30
+ * unsigned char *dst = destination for copy
31
+ * unsigned char *src = source for copy
32
+ * int cnt = number of characters to copy
33
+ *
34
+ *Exit:
35
+ * returns dst = destination of copy
36
+ *
37
+ *Exceptions:
38
+ * Input parameters are validated. Refer to the validation section of the function.
39
+ *
40
+ *******************************************************************************/
41
+
42
+ #pragma warning(suppress:6101) // Returning uninitialized memory '*dst'. A successful path through the function does not set the named _Out_ parameter.
43
+ extern "C" unsigned char * __cdecl _mbsncpy_l(
44
+ unsigned char *dst,
45
+ const unsigned char *src,
46
+ size_t cnt,
47
+ _locale_t plocinfo
48
+ )
49
+ {
50
+ unsigned char *start = dst;
51
+ _LocaleUpdate _loc_update(plocinfo);
52
+
53
+ /* validation section */
54
+ _VALIDATE_RETURN(dst != nullptr || cnt == 0, EINVAL, nullptr);
55
+ _VALIDATE_RETURN(src != nullptr || cnt == 0, EINVAL, nullptr);
56
+
57
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
58
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
59
+ #pragma warning(suppress:__WARNING_BANNED_API_USAGE)
60
+ return (unsigned char *)strncpy((char *)dst, (const char *)src, cnt);
61
+ _END_SECURE_CRT_DEPRECATION_DISABLE
62
+
63
+ while (cnt) {
64
+
65
+ cnt--;
66
+ if ( _ismbblead_l(*src, _loc_update.GetLocaleT()) ) {
67
+ *dst++ = *src++;
68
+ if ((*dst++ = *src++) == '\0') {
69
+ dst[-2] = '\0';
70
+ break;
71
+ }
72
+ }
73
+ else
74
+ if ((*dst++ = *src++) == '\0')
75
+ break;
76
+
77
+ }
78
+
79
+ /* pad with nulls as needed */
80
+
81
+ while (cnt--)
82
+ *dst++ = '\0';
83
+
84
+ #pragma warning(suppress:__WARNING_POSTCONDITION_NULLTERMINATION_VIOLATION) // 26036 REVIEW annotation mistake?
85
+ return start;
86
+ }
87
+ extern "C" unsigned char * (__cdecl _mbsncpy)(
88
+ unsigned char *dst,
89
+ const unsigned char *src,
90
+ size_t cnt
91
+ )
92
+ {
93
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
94
+ return _mbsncpy_l(dst, src, cnt, nullptr);
95
+ _END_SECURE_CRT_DEPRECATION_DISABLE
96
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncpy_s.cpp ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsncpy_s.c - Copy one string to another, n chars only (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Copy one string to another, n chars only (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+
16
+ _REDIRECT_TO_L_VERSION_4(errno_t, _mbsncpy_s, unsigned char *, size_t, const unsigned char *, size_t)
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncpy_s.inl ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsncpy_s.inl - general implementation of _mbsncpy_s and _mbsnbcpy_s
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * This file contains the general algorithm for _mbsncpy_s and _mbsnbcpy_s.
8
+ *
9
+ * _COUNT_IN_BYTES defined to 1 implements _mbsnbcpy_s
10
+ * _COUNT_IN_BYTES defined to 0 implements _mbsncpy_s
11
+ *
12
+ ****/
13
+
14
+ errno_t __cdecl _FUNC_NAME(unsigned char *_Dst, size_t _SizeInBytes, const unsigned char *_Src, size_t _COUNT, _LOCALE_ARG_DECL)
15
+ {
16
+ unsigned char *p;
17
+ size_t available;
18
+ BOOL fFoundInvalidMBC;
19
+ BOOL fIsLeadPrefix;
20
+
21
+ fFoundInvalidMBC = FALSE;
22
+
23
+ if (_COUNT == 0 && _Dst == nullptr && _SizeInBytes == 0)
24
+ {
25
+ /* this case is allowed; nothing to do */
26
+ _RETURN_NO_ERROR;
27
+ }
28
+
29
+ /* validation section */
30
+ _VALIDATE_STRING(_Dst, _SizeInBytes);
31
+ if (_COUNT == 0)
32
+ {
33
+ /* notice that the source string pointer can be NULL in this case */
34
+ #pragma prefast(suppress:__WARNING_POTENTIAL_BUFFER_OVERFLOW_HIGH_PRIORITY) /* 26015 */
35
+ _RESET_STRING(_Dst, _SizeInBytes);
36
+ _RETURN_NO_ERROR;
37
+ }
38
+ _VALIDATE_POINTER_RESET_STRING(_Src, _Dst, _SizeInBytes);
39
+
40
+ _LOCALE_UPDATE;
41
+ if (_LOCALE_SHORTCUT_TEST)
42
+ {
43
+ return strncpy_s((char *)_Dst, _SizeInBytes, (const char *)_Src, _COUNT);
44
+ }
45
+
46
+ p = _Dst;
47
+ available = _SizeInBytes;
48
+ if (_COUNT == _TRUNCATE)
49
+ {
50
+ while ((*p++ = *_Src++) != 0 && --available > 0)
51
+ {
52
+ }
53
+
54
+ /*
55
+ * loop terminates with either:
56
+ * - src, p pointing 1 byte past null, avail includes the null
57
+ * - available == 0, p points 1 past end of dst buffer
58
+ */
59
+ }
60
+ else
61
+ {
62
+ #if _COUNT_IN_BYTES
63
+ while ((*p++ = *_Src++) != 0 && --available > 0 && --_COUNT > 0)
64
+ {
65
+ }
66
+
67
+ /*
68
+ * loop terminates with either:
69
+ * - p points 1 byte past null, avail includes null, count includes null
70
+ * - available == 0, p points 1 past end of dst buffer (inaccessible)
71
+ * - count == 0, p points 1 past last written byte, space available in dst buffer
72
+ *
73
+ * always p[-1] is written.
74
+ * sometimes p[-1] is null.
75
+ */
76
+ #else /* _COUNT_IN_BYTES */
77
+
78
+ /* at this point, avail count be 1. */
79
+
80
+ /* Need to track lead-byte context in order to track character count. */
81
+ do
82
+ {
83
+ if (_ISMBBLEAD(*_Src))
84
+ {
85
+ if (_Src[1] == 0)
86
+ {
87
+ /*
88
+ * Invalid MBC, write null to dst string, we are finished
89
+ * copying. We know that available is >= 1, so there is
90
+ * room for the null termination. If we decrement available
91
+ * then we will incorrectly report BUFFER_TOO_SMALL.
92
+ */
93
+
94
+ *p++ = 0;
95
+ fFoundInvalidMBC = TRUE;
96
+ break;
97
+ }
98
+ if (available <= 2)
99
+ {
100
+ /* not enough space for a dbc and null */
101
+ available = 0;
102
+ break;
103
+ }
104
+ *p++ = *_Src++;
105
+ *p++ = *_Src++;
106
+ available -= 2;
107
+ }
108
+ else
109
+ {
110
+ if ((*p++ = *_Src++) == 0 || --available == 0)
111
+ {
112
+ break;
113
+ }
114
+ }
115
+ }
116
+ while (--_COUNT > 0);
117
+ #endif /* _COUNT_IN_BYTES */
118
+
119
+ /* If count == 0 then at least one byte was copied and available is still > 0 */
120
+ if (_COUNT == 0)
121
+ {
122
+ *p++ = 0;
123
+ /* Note that available is not decremented here. */
124
+ }
125
+ }
126
+
127
+ if (available == 0)
128
+ {
129
+ #if _COUNT_IN_BYTES
130
+ /*
131
+ * For COUNT_IN_BYTES, the above loop copied at least one byte so src,p point
132
+ * past a written byte.
133
+ */
134
+
135
+ if (*_Src == 0 || _COUNT == 1)
136
+ {
137
+ fIsLeadPrefix = FALSE;
138
+ _ISMBBLEADPREFIX(fIsLeadPrefix, _Dst, &p[-1]);
139
+ if (fIsLeadPrefix)
140
+ {
141
+ /* the source string ended with a lead byte: we remove it */
142
+ p[-1] = 0;
143
+ _RETURN_MBCS_ERROR;
144
+ }
145
+ }
146
+ #endif /* _COUNT_IN_BYTES */
147
+
148
+ if (_COUNT == _TRUNCATE)
149
+ {
150
+ if (fFoundInvalidMBC)
151
+ {
152
+ _SET_MBCS_ERROR;
153
+ }
154
+
155
+ if (_SizeInBytes > 1)
156
+ {
157
+ fIsLeadPrefix = FALSE;
158
+ /* Check if 2nd to last copied byte acted as a lead.
159
+ * Do not set mbcs error because we are truncating.
160
+ */
161
+ _ISMBBLEADPREFIX(fIsLeadPrefix,_Dst,&_Dst[_SizeInBytes - 2]);
162
+ if (fIsLeadPrefix)
163
+ {
164
+ _Dst[_SizeInBytes - 2] = 0;
165
+ _FILL_BYTE(_Dst[_SizeInBytes - 1]);
166
+ _RETURN_TRUNCATE;
167
+ }
168
+ }
169
+
170
+ _Dst[_SizeInBytes - 1] = 0;
171
+ _RETURN_TRUNCATE;
172
+ }
173
+ _RESET_STRING(_Dst, _SizeInBytes);
174
+ _RETURN_BUFFER_TOO_SMALL(_Dst, _SizeInBytes);
175
+ }
176
+
177
+ #if _COUNT_IN_BYTES
178
+ /*
179
+ * COUNT_IN_BYTES copy loop doesn't track lead-byte context, so can't detect
180
+ * invalid mbc. Detect them here.
181
+
182
+ * available < _SizeInBytes means that at least one byte was copied so p is >= &dstBuffer[1]
183
+ */
184
+
185
+ if ((p - _Dst) >= 2)
186
+ {
187
+ _ISMBBLEADPREFIX(fIsLeadPrefix, _Dst,&p[-2]);
188
+ if (fIsLeadPrefix)
189
+ {
190
+ /* the source string ended with a lead byte: we remove it */
191
+ p[-2] = 0;
192
+ available++;
193
+ fFoundInvalidMBC = TRUE;
194
+ }
195
+ }
196
+ #endif /* _COUNT_IN_BYTES */
197
+
198
+ _FILL_STRING(_Dst, _SizeInBytes, _SizeInBytes - available + 1);
199
+
200
+ if (fFoundInvalidMBC)
201
+ {
202
+ _RETURN_MBCS_ERROR;
203
+ }
204
+
205
+ #pragma warning(suppress:__WARNING_POSTCONDITION_NULLTERMINATION_VIOLATION) /* 26036 REVIEW TODO test _mbsnbcpy_s_l */
206
+ _RETURN_NO_ERROR;
207
+ }
208
+
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsncpy_s_l.cpp ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsncpy_s_l.c - Copy one string to another, n chars only (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Copy one string to another, n chars only (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_securecrt.h>
15
+ #include <mbstring.h>
16
+
17
+ #define _FUNC_NAME _mbsncpy_s_l
18
+ #define _COUNT _CountInChars
19
+ #define _COUNT_IN_BYTES 0
20
+
21
+ #include "mbsncpy_s.inl"
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnextc.cpp ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnextc.c - Get the next character in an MBCS string.
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * To return the value of the next character in an MBCS string.
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <stdlib.h>
17
+
18
+ #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
19
+
20
+ /***
21
+ *_mbsnextc: Returns the next character in a string.
22
+ *
23
+ *Purpose:
24
+ * To return the value of the next character in an MBCS string.
25
+ * Does not advance pointer to the next character.
26
+ *
27
+ *Entry:
28
+ * unsigned char *s = string
29
+ *
30
+ *Exit:
31
+ * unsigned int next = next character.
32
+ *
33
+ *Exceptions:
34
+ * Input parameters are validated. Refer to the validation section of the function.
35
+ *
36
+ *******************************************************************************/
37
+
38
+ extern "C" unsigned int __cdecl _mbsnextc_l(
39
+ const unsigned char *s,
40
+ _locale_t plocinfo
41
+ )
42
+ {
43
+ unsigned int next = 0;
44
+ _LocaleUpdate _loc_update(plocinfo);
45
+
46
+ /* validation section */
47
+ _VALIDATE_RETURN(s != nullptr, EINVAL, 0);
48
+
49
+ /* don't skip forward 2 if the leadbyte is followed by EOS (dud string)
50
+ also don't assert as we are too low-level
51
+ */
52
+ if ( _ismbblead_l(*s, _loc_update.GetLocaleT()) && s[1]!='\0')
53
+ next = ((unsigned int) *s++) << 8;
54
+
55
+ next += (unsigned int) *s;
56
+
57
+ return(next);
58
+ }
59
+ extern "C" unsigned int (__cdecl _mbsnextc)(
60
+ const unsigned char *s
61
+ )
62
+ {
63
+ return _mbsnextc_l(s, nullptr);
64
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnicmp.cpp ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnicmp.c - Compare n characters of strings, ignoring case (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Compare n characters of strings, ignoring case (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <string.h>
17
+
18
+ /***
19
+ * _mbsnicmp - Compare n characters of strings, ignoring case (MBCS)
20
+ *
21
+ *Purpose:
22
+ * Compares up to n charcters of two strings for ordinal order.
23
+ * Strings are compared on a character basis, not a byte basis.
24
+ * Case of characters is not considered.
25
+ *
26
+ *Entry:
27
+ * unsigned char *s1, *s2 = strings to compare
28
+ * size_t n = maximum number of characters to compare
29
+ *
30
+ *Exit:
31
+ * Returns <0 if s1 < s2
32
+ * Returns 0 if s1 == s2
33
+ * Returns >0 if s1 > s2
34
+ * Returns _NLSCMPERROR is something went wrong
35
+ *
36
+ *Exceptions:
37
+ * Input parameters are validated. Refer to the validation section of the function.
38
+ *
39
+ *******************************************************************************/
40
+
41
+ extern "C" int __cdecl _mbsnicmp_l(
42
+ const unsigned char *s1,
43
+ const unsigned char *s2,
44
+ size_t n,
45
+ _locale_t plocinfo
46
+ )
47
+ {
48
+ unsigned short c1, c2;
49
+
50
+ if (n==0)
51
+ return(0);
52
+
53
+ _LocaleUpdate _loc_update(plocinfo);
54
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
55
+ return _strnicmp((const char *)s1, (const char *)s2, n);
56
+
57
+ /* validation section */
58
+ _VALIDATE_RETURN(s1 != nullptr, EINVAL, _NLSCMPERROR);
59
+ _VALIDATE_RETURN(s2 != nullptr, EINVAL, _NLSCMPERROR);
60
+
61
+ while (n--) {
62
+
63
+ c1 = *s1++;
64
+ if ( _ismbblead_l(c1, _loc_update.GetLocaleT()) ) {
65
+ if (*s1 == '\0')
66
+ c1 = 0;
67
+ else {
68
+ c1 = ((c1<<8) | *s1++);
69
+
70
+ if ( ((c1 >= _MBUPPERLOW1_MT(_loc_update.GetLocaleT())) &&
71
+ (c1 <= _MBUPPERHIGH1_MT(_loc_update.GetLocaleT()))) )
72
+ c1 += _MBCASEDIFF1_MT(_loc_update.GetLocaleT());
73
+ else if ( ((c1 >= _MBUPPERLOW2_MT(_loc_update.GetLocaleT())) &&
74
+ (c1 <= _MBUPPERHIGH2_MT(_loc_update.GetLocaleT()))) )
75
+ c1 += _MBCASEDIFF2_MT(_loc_update.GetLocaleT());
76
+ }
77
+ }
78
+ else
79
+ c1 = _mbbtolower_l(c1, _loc_update.GetLocaleT());
80
+
81
+ c2 = *s2++;
82
+ if ( _ismbblead_l(c2, _loc_update.GetLocaleT()) ) {
83
+ if (*s2 == '\0')
84
+ c2 = 0;
85
+ else {
86
+ c2 = ((c2<<8) | *s2++);
87
+ if ( ((c2 >= _MBUPPERLOW1_MT(_loc_update.GetLocaleT())) &&
88
+ (c2 <= _MBUPPERHIGH1_MT(_loc_update.GetLocaleT()))) )
89
+ c2 += _MBCASEDIFF1_MT(_loc_update.GetLocaleT());
90
+ else if ( ((c2 >= _MBUPPERLOW2_MT(_loc_update.GetLocaleT())) &&
91
+ (c2 <= _MBUPPERHIGH2_MT(_loc_update.GetLocaleT()))) )
92
+ c2 += _MBCASEDIFF2_MT(_loc_update.GetLocaleT());
93
+ }
94
+ }
95
+ else
96
+ c2 = _mbbtolower_l(c2, _loc_update.GetLocaleT());
97
+
98
+ if (c1 != c2)
99
+ return( (c1 > c2) ? 1 : -1 );
100
+
101
+ if (c1 == 0)
102
+ return(0);
103
+ }
104
+
105
+ return(0);
106
+ }
107
+
108
+ extern "C" int (__cdecl _mbsnicmp)(
109
+ const unsigned char *s1,
110
+ const unsigned char *s2,
111
+ size_t n
112
+ )
113
+ {
114
+ return _mbsnicmp_l(s1, s2, n, nullptr);
115
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnicol.cpp ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnicol.c - Collate n characters of strings, ignoring case (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Collate n characters of strings, ignoring case (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <limits.h>
16
+ #include <locale.h>
17
+ #include <string.h>
18
+
19
+
20
+ /***
21
+ * _mbsnicoll - Collate n characters of strings, ignoring case (MBCS)
22
+ *
23
+ *Purpose:
24
+ * Collates up to n charcters of two strings for lexical order.
25
+ * Strings are collated on a character basis, not a byte basis.
26
+ * Case of characters is not considered.
27
+ *
28
+ *Entry:
29
+ * unsigned char *s1, *s2 = strings to collate
30
+ * size_t n = maximum number of characters to collate
31
+ *
32
+ *Exit:
33
+ * Returns <0 if s1 < s2
34
+ * Returns 0 if s1 == s2
35
+ * Returns >0 if s1 > s2
36
+ * Returns _NLSCMPERROR is something went wrong
37
+ *
38
+ *Exceptions:
39
+ * Input parameters are validated. Refer to the validation section of the function.
40
+ *
41
+ *******************************************************************************/
42
+
43
+ extern "C" int __cdecl _mbsnicoll_l(
44
+ const unsigned char *s1,
45
+ const unsigned char *s2,
46
+ size_t n,
47
+ _locale_t plocinfo
48
+ )
49
+ {
50
+ int ret;
51
+ size_t bcnt1, bcnt2;
52
+ _LocaleUpdate _loc_update(plocinfo);
53
+
54
+ if (n == 0)
55
+ return 0;
56
+
57
+ /* validation section */
58
+ _VALIDATE_RETURN(s1 != nullptr, EINVAL, _NLSCMPERROR);
59
+ _VALIDATE_RETURN(s2 != nullptr, EINVAL, _NLSCMPERROR);
60
+ _VALIDATE_RETURN(n <= INT_MAX, EINVAL, _NLSCMPERROR);
61
+
62
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
63
+ return _strnicoll_l((const char *)s1, (const char *)s2, n, plocinfo);
64
+
65
+ bcnt1 = _mbsnbcnt_l(s1, n, _loc_update.GetLocaleT());
66
+ bcnt2 = _mbsnbcnt_l(s2, n, _loc_update.GetLocaleT());
67
+
68
+ if ( 0 == (ret = __acrt_CompareStringA(
69
+ _loc_update.GetLocaleT(),
70
+ _loc_update.GetLocaleT()->mbcinfo->mblocalename,
71
+ SORT_STRINGSORT | NORM_IGNORECASE,
72
+ (const char *)s1,
73
+ (int)bcnt1,
74
+ (char *)s2,
75
+ (int)bcnt2,
76
+ _loc_update.GetLocaleT()->mbcinfo->mbcodepage )) )
77
+ {
78
+ errno = EINVAL;
79
+ return _NLSCMPERROR;
80
+ }
81
+
82
+ return ret - 2;
83
+
84
+ }
85
+
86
+ extern "C" int (__cdecl _mbsnicoll)(
87
+ const unsigned char *s1,
88
+ const unsigned char *s2,
89
+ size_t n
90
+ )
91
+ {
92
+ return _mbsnicoll_l(s1, s2, n, nullptr);
93
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsninc.cpp ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsninc.c - Increment MBCS string pointer by specified char count.
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Increment MBCS string pointer by specified char count.
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <mbstring.h>
16
+ #include <stddef.h>
17
+
18
+ /***
19
+ *_mbsninc - Increment MBCS string pointer by specified char count.
20
+ *
21
+ *Purpose:
22
+ * Increment the supplied string pointer by the specified number
23
+ * of characters. MBCS characters are handled correctly.
24
+ *
25
+ *Entry:
26
+ * const unsigned char *string = pointer to string
27
+ * unsigned int ccnt = number of char to advance the pointer
28
+ *
29
+ *Exit:
30
+ * Returns pointer after advancing it.
31
+ * Returns pointer to end of string if string is not ccnt chars long.
32
+ * Returns nullptr is supplied pointer is nullptr.
33
+ *
34
+ *Exceptions:
35
+ *
36
+ *******************************************************************************/
37
+
38
+ extern "C" unsigned char * __cdecl _mbsninc_l(
39
+ const unsigned char *string,
40
+ size_t ccnt,
41
+ _locale_t plocinfo
42
+ )
43
+ {
44
+ if (string == nullptr)
45
+ return nullptr;
46
+
47
+ return const_cast<unsigned char*>(string) + (unsigned int)_mbsnbcnt_l(string, ccnt, plocinfo);
48
+ }
49
+
50
+ extern "C" unsigned char * (__cdecl _mbsninc)(
51
+ const unsigned char *string,
52
+ size_t ccnt
53
+ )
54
+ {
55
+ return _mbsninc_l(string, ccnt, nullptr);
56
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnset.cpp ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnset.c - Sets first n charcaters of string to given character (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Sets first n charcaters of string to given character (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <string.h>
17
+
18
+
19
+ /***
20
+ * _mbsnset - Sets first n charcaters of string to given character (MBCS)
21
+ *
22
+ *Purpose:
23
+ * Sets the first n characters of string to the supplied
24
+ * character value. If the length of string is less than n,
25
+ * the length of string is used in place of n. Handles
26
+ * MBCS chars correctly.
27
+ *
28
+ * There are several factors that make this routine complicated:
29
+ * (1) The fill value may be 1 or 2 bytes long.
30
+ * (2) The fill operation may end by hitting the count value
31
+ * or by hitting the end of the string.
32
+ * (3) A null terminating char is NOT placed at the end of
33
+ * the string.
34
+ *
35
+ * Cases to be careful of (both of these can occur at once):
36
+ * (1) Leaving an "orphaned" trail byte in the string (e.g.,
37
+ * overwriting a lead byte but not the corresponding trail byte).
38
+ * (2) Writing only the 1st byte of a 2-byte fill value because the
39
+ * end of string was encountered.
40
+ *
41
+ *Entry:
42
+ * unsigned char *string = string to modify
43
+ * unsigned int val = value to fill string with
44
+ * size_t count = count of characters to fill
45
+ *
46
+ *
47
+ *Exit:
48
+ * Returns string = now filled with char val
49
+ *
50
+ *Uses:
51
+ *
52
+ *Exceptions:
53
+ * Input parameters are validated. Refer to the validation section of the function.
54
+ *
55
+ *******************************************************************************/
56
+
57
+ extern "C" unsigned char * __cdecl _mbsnset_l(
58
+ unsigned char *string,
59
+ unsigned int val,
60
+ size_t count,
61
+ _locale_t plocinfo
62
+ )
63
+ {
64
+ unsigned char *start = string;
65
+ unsigned int leadbyte = 0;
66
+ unsigned char highval, lowval;
67
+ _LocaleUpdate _loc_update(plocinfo);
68
+
69
+ /* validation section */
70
+ _VALIDATE_RETURN(string != nullptr || count == 0, EINVAL, nullptr);
71
+
72
+ /*
73
+ * leadbyte flag indicates if the last byte we overwrote was
74
+ * a lead byte or not.
75
+ */
76
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
77
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
78
+ return (unsigned char *)_strnset((char *)string, val, count);
79
+ _END_SECURE_CRT_DEPRECATION_DISABLE
80
+
81
+ highval = static_cast<unsigned char>(val >> 8);
82
+ if (highval != 0)
83
+ {
84
+
85
+ /* double byte value */
86
+
87
+ lowval = (unsigned char)(val & 0x00ff);
88
+
89
+ if(lowval=='\0')
90
+ {
91
+ _ASSERTE(("invalid MBCS pair passed to mbsnset",0));
92
+
93
+ /* Ideally we would return nullptr here and signal an error
94
+ condition. But since this function has no other
95
+ error modes, there would be a good chance of crashing
96
+ the caller. So instead we fill the string with spaces
97
+ to ensure that no information leaks through
98
+ unexpectedly. Anyway, we do set errno to EINVAL.
99
+ */
100
+ errno = EINVAL;
101
+ lowval=highval=' ';
102
+ }
103
+
104
+ while (count-- && *string) {
105
+ leadbyte = _ismbbtruelead_l(leadbyte, *string, _loc_update.GetLocaleT());
106
+ *string++ = highval;
107
+
108
+ if (*string) {
109
+ leadbyte = _ismbbtruelead_l(leadbyte, *string, _loc_update.GetLocaleT());
110
+ *string++ = lowval;
111
+ }
112
+ else
113
+ /* overwrite orphaned highval byte */
114
+ *(string-1) = ' ';
115
+ }
116
+ }
117
+
118
+ else {
119
+ /* single byte value */
120
+
121
+ while (count-- && *string) {
122
+ leadbyte = _ismbbtruelead_l(leadbyte, *string, _loc_update.GetLocaleT());
123
+ *string++ = (unsigned char)val;
124
+ }
125
+ }
126
+
127
+ /* overwrite orphaned trailing byte, if necessary */
128
+ if(leadbyte && *string)
129
+ *string = ' ';
130
+
131
+ return( start );
132
+ }
133
+
134
+ unsigned char * (__cdecl _mbsnset)(
135
+ unsigned char *string,
136
+ unsigned int val,
137
+ size_t count
138
+ )
139
+ {
140
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
141
+ return _mbsnset_l(string, val, count, nullptr);
142
+ _END_SECURE_CRT_DEPRECATION_DISABLE
143
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnset_s.cpp ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnset_s.c - Sets first n characters of string to given character (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Sets first n characters of string to given character (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <corecrt_internal.h>
16
+
17
+ _REDIRECT_TO_L_VERSION_4(errno_t, _mbsnset_s, unsigned char*, size_t, unsigned int, size_t)
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnset_s.inl ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnset_s.inl - general implementation of _mbsnset_s and _mbsnbset_s
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * This file contains the general algorithm for _mbsnset_s and _mbsnbset_s.
8
+ *
9
+ ****/
10
+
11
+ errno_t __cdecl _FUNC_NAME(unsigned char *_Dst, size_t _SizeInBytes, unsigned int _Value, size_t _COUNT, _LOCALE_ARG_DECL)
12
+ {
13
+ int mbcs_error = 0;
14
+ unsigned char *p;
15
+ size_t available;
16
+ unsigned char highval, lowval;
17
+ int mblead = 0;
18
+
19
+ /* validation section */
20
+ if (_COUNT == 0 && _Dst == nullptr && _SizeInBytes == 0)
21
+ {
22
+ /* this case is allowed; nothing to do */
23
+ _RETURN_NO_ERROR;
24
+ }
25
+ _VALIDATE_STRING(_Dst, _SizeInBytes);
26
+
27
+ _LOCALE_UPDATE;
28
+ if (_LOCALE_SHORTCUT_TEST)
29
+ {
30
+ return _strnset_s((char *)_Dst, _SizeInBytes, (int)_Value, _COUNT);
31
+ }
32
+
33
+ p = _Dst;
34
+ available = _SizeInBytes;
35
+ highval = (unsigned char)(_Value >> 8);
36
+ lowval = (unsigned char)(_Value & 0x00ff);
37
+
38
+ /* ensure _Value is a valid mbchar */
39
+ if ((highval != 0 && (lowval == 0 || !_ISMBBLEAD(highval))) ||
40
+ (highval == 0 && _ISMBBLEAD(lowval)))
41
+ {
42
+ _RESET_STRING(_Dst, _SizeInBytes);
43
+ _RETURN_MBCS_ERROR;
44
+ }
45
+
46
+ if (highval != 0)
47
+ {
48
+ #if _COUNT_IN_BYTES
49
+ /* if _COUNT is odd, make it even subtracting 1 */
50
+ /* divide _COUNT by 2 to have a count in chars instead of bytes */
51
+ if ((_COUNT & 1) == 1)
52
+ {
53
+ --_COUNT;
54
+ mbcs_error = 1;
55
+ }
56
+ _COUNT = _COUNT / 2;
57
+ #endif /* _COUNT_IN_BYTES */
58
+ while (*p != 0 && _COUNT > 0 && --available > 0)
59
+ {
60
+ if (p[1] == 0)
61
+ {
62
+ /* do not orphan leadbyte */
63
+ *p = 0;
64
+ ++available;
65
+ mbcs_error = 1;
66
+ break;
67
+ }
68
+ /* track the mblead status in the original string */
69
+ mblead = mblead ? 0 : _ISMBBLEAD(*p);
70
+ *p++ = highval;
71
+ if (--available == 0)
72
+ {
73
+ break;
74
+ }
75
+ mblead = mblead ? 0 : _ISMBBLEAD(*p);
76
+ *p++ = lowval;
77
+ --_COUNT;
78
+ }
79
+ }
80
+ else
81
+ {
82
+ while (*p != 0 && _COUNT > 0 && --available > 0)
83
+ {
84
+ /* track the mblead status in the original string */
85
+ mblead = mblead ? 0 : _ISMBBLEAD(*p);
86
+ *p++ = lowval;
87
+ --_COUNT;
88
+ }
89
+ }
90
+
91
+ /* if the last written byte overlapps a leadbyte,
92
+ * copy a space over the corresponding trailbyte */
93
+ if (_COUNT == 0 && mblead && *p != 0 && --available > 0)
94
+ {
95
+ mbcs_error = 1;
96
+ if (p[1] == 0)
97
+ {
98
+ /* special case: if the space would be followed by 0, just put a 0 */
99
+ *p = 0;
100
+ ++available;
101
+ }
102
+ else
103
+ {
104
+ *p++ = ' ';
105
+ }
106
+ }
107
+
108
+ if (_COUNT == 0)
109
+ {
110
+ /* ensure the string is null-terminated */
111
+ while (*p != 0 && --available > 0)
112
+ {
113
+ ++p;
114
+ }
115
+ }
116
+
117
+ if (available == 0)
118
+ {
119
+ _RESET_STRING(_Dst, _SizeInBytes);
120
+ _RETURN_DEST_NOT_NULL_TERMINATED(_Dst, _SizeInBytes);
121
+ }
122
+ _FILL_STRING(_Dst, _SizeInBytes, _SizeInBytes - available + 1);
123
+ if (mbcs_error)
124
+ {
125
+ _RETURN_MBCS_ERROR;
126
+ }
127
+ else
128
+ {
129
+ _RETURN_NO_ERROR;
130
+ }
131
+ }
132
+
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsnset_s_l.cpp ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsnset_s_l.c - Sets first n characters of string to given character (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Sets first n characters of string to given character (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <corecrt_internal_securecrt.h>
16
+
17
+ #define _FUNC_NAME _mbsnset_s_l
18
+ #define _COUNT _CountInChars
19
+ #define _COUNT_IN_BYTES 0
20
+
21
+ #include "mbsnset_s.inl"
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbspbrk.cpp ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbspbrk.c - Find first string char in charset, pointer return (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Find first string char in charset, pointer return (MBCS)
8
+ * Shares common source file with mbscspn.c.
9
+ *
10
+ *******************************************************************************/
11
+ #ifndef _MBCS
12
+ #error This file should only be compiled with _MBCS defined
13
+ #endif
14
+
15
+ #define _RETURN_PTR
16
+ #include "mbscspn.cpp"
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsrchr.cpp ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsrchr.c - Search for last occurence of character (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Search for last occurence of character (MBCS)
8
+ *
9
+ *
10
+ *******************************************************************************/
11
+ #ifndef _MBCS
12
+ #error This file should only be compiled with _MBCS defined
13
+ #endif
14
+
15
+ #include <corecrt_internal_mbstring.h>
16
+ #include <locale.h>
17
+ #include <stddef.h>
18
+ #include <string.h>
19
+
20
+ #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
21
+
22
+ /***
23
+ * _mbsrchr - Search for last occurence of character (MBCS)
24
+ *
25
+ *Purpose:
26
+ * Find the last occurrence of the specified character in
27
+ * the supplied string. Handles MBCS chars/strings correctly.
28
+ *
29
+ *Entry:
30
+ * unsigned char *str = string to search in
31
+ * unsigned int c = character to search for
32
+ *
33
+ *Exit:
34
+ * returns pointer to last occurrence of c in str
35
+ * returns nullptr if c not found
36
+ *
37
+ *Exceptions:
38
+ * Input parameters are validated. Refer to the validation section of the function.
39
+ *
40
+ *******************************************************************************/
41
+
42
+ extern "C" _CONST_RETURN unsigned char * __cdecl _mbsrchr_l(
43
+ const unsigned char *str,
44
+ unsigned int c,
45
+ _locale_t plocinfo
46
+ )
47
+ {
48
+ char *r = nullptr;
49
+ unsigned int cc;
50
+ _LocaleUpdate _loc_update(plocinfo);
51
+
52
+ /* validation section */
53
+ _VALIDATE_RETURN(str != nullptr, EINVAL, 0);
54
+
55
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
56
+ return (_CONST_RETURN unsigned char *)strrchr((const char *)str, c);
57
+
58
+ do {
59
+ cc = *str;
60
+ if ( _ismbblead_l(cc, _loc_update.GetLocaleT()) ) {
61
+ if(*++str) {
62
+ if (c == ((cc<<8)|*str))
63
+ r = (char *)str - 1;
64
+ }
65
+ else if(!r)
66
+ /* return pointer to '\0' */
67
+ r = (char *)str;
68
+ }
69
+ else if (c == cc)
70
+ r = (char *)str;
71
+ }
72
+ while (*str++);
73
+
74
+ return((_CONST_RETURN unsigned char *)r);
75
+ }
76
+
77
+ extern "C" _CONST_RETURN unsigned char * (__cdecl _mbsrchr)(
78
+ const unsigned char *str,
79
+ unsigned int c
80
+ )
81
+ {
82
+ return _mbsrchr_l(str, c, nullptr);
83
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsrev.cpp ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsrev.c - Reverse a string in place (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Reverse a string in place (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <string.h>
17
+
18
+
19
+ /***
20
+ * _mbsrev - Reverse a string in place (MBCS)
21
+ *
22
+ *Purpose:
23
+ * Reverses the order of characters in the string. The terminating
24
+ * null character remains in place. The order of MBCS characters
25
+ * is not changed.
26
+ *
27
+ *Entry:
28
+ * unsigned char *string = string to reverse
29
+ *
30
+ *Exit:
31
+ * returns string - now with reversed characters
32
+ *
33
+ *Exceptions:
34
+ * Input parameters are validated. Refer to the validation section of the function.
35
+ *
36
+ *******************************************************************************/
37
+
38
+ extern "C" unsigned char * __cdecl _mbsrev_l(
39
+ unsigned char *string,
40
+ _locale_t plocinfo
41
+ )
42
+ {
43
+ unsigned char *start = string;
44
+ unsigned char *left = string;
45
+ unsigned char c;
46
+ _LocaleUpdate _loc_update(plocinfo);
47
+
48
+ /* validation section */
49
+ _VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
50
+
51
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
52
+ return (unsigned char *)_strrev((char *)string);
53
+
54
+
55
+ /* first go through and reverse the bytes in MBCS chars */
56
+ while ( *string ) {
57
+ if ( _ismbblead_l(*string++, _loc_update.GetLocaleT()) ) {
58
+ if ( *string ) {
59
+ c = *string;
60
+ *string = *(string - 1);
61
+ *(string - 1) = c;
62
+ string++;
63
+ }
64
+ else
65
+ {
66
+ /* second byte is EOS
67
+ There is nothing really satisfying to do here. We have a string
68
+ that ends in leadbyte,'\0'. Reversing this would lead to the leadbyte
69
+ becoming falsely attached to the character before it:
70
+ (XL0 -> LX0, X has suddenly become a trailbyte)
71
+
72
+ So what we choose to do is assert and purge the dud byte from within the
73
+ string.
74
+ */
75
+ errno = EINVAL;
76
+ _ASSERTE(("Bad MBCS string passed into _mbsrev",0));
77
+
78
+ /* String has at least moved once already, so this is safe */
79
+ _ASSERTE(string>start);
80
+
81
+ /* move back one to point at the dud leadbyte */
82
+ --string;
83
+
84
+ /* now truncate the string one byte earlier */
85
+ *string='\0';
86
+
87
+ break;
88
+ }
89
+ }
90
+ }
91
+
92
+ /* now reverse the whole string */
93
+ string--;
94
+ while ( left < string ) {
95
+ c = *left;
96
+ *left++ = *string;
97
+ *string-- = c;
98
+ }
99
+
100
+ return ( start );
101
+ }
102
+
103
+ extern "C" unsigned char * (__cdecl _mbsrev)(
104
+ unsigned char *string
105
+ )
106
+ {
107
+ return _mbsrev_l(string, nullptr);
108
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsset.cpp ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsset.c - Sets all charcaters of string to given character (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Sets all charcaters of string to given character (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+ #include <locale.h>
16
+ #include <string.h>
17
+
18
+ /***
19
+ * mbsset - Sets all charcaters of string to given character (MBCS)
20
+ *
21
+ *Purpose:
22
+ * Sets all of characters in string (except the terminating '/0'
23
+ * character) equal to the supplied character. Handles MBCS
24
+ * chars correctly.
25
+ *
26
+ *Entry:
27
+ * unsigned char *string = string to modify
28
+ * unsigned int val = value to fill string with
29
+ *
30
+ *Exit:
31
+ * returns string = now filled with the specified char
32
+ *
33
+ *Uses:
34
+ *
35
+ *Exceptions:
36
+ * Input parameters are validated. Refer to the validation section of the function.
37
+ *
38
+ *******************************************************************************/
39
+
40
+ extern "C" unsigned char * __cdecl _mbsset_l(
41
+ unsigned char *string,
42
+ unsigned int val,
43
+ _locale_t plocinfo
44
+ )
45
+ {
46
+ unsigned char *start = string;
47
+ unsigned char highval, lowval;
48
+ _LocaleUpdate _loc_update(plocinfo);
49
+
50
+ /* validation section */
51
+ _VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
52
+
53
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
54
+ if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
55
+ return (unsigned char *)_strset((char *)string, val);
56
+ _END_SECURE_CRT_DEPRECATION_DISABLE
57
+
58
+ highval = static_cast<unsigned char>(val >> 8);
59
+ if (highval != 0)
60
+ {
61
+ /* 2-byte value */
62
+
63
+ lowval = (unsigned char)(val & 0x00ff);
64
+
65
+ if(lowval=='\0')
66
+ {
67
+ _ASSERTE(("invalid MBCS pair passed to mbsset",0));
68
+
69
+ /* Ideally we would return nullptr here and signal an error
70
+ condition. But since this function has no other
71
+ error modes, there would be a good chance of crashing
72
+ the caller. So instead we fill the string with spaces
73
+ to ensure that no information leaks through
74
+ unexpectedly. Anyway, we do set errno to EINVAL.
75
+ */
76
+ errno = EINVAL;
77
+ lowval=highval=' ';
78
+ }
79
+
80
+ while (*string) {
81
+
82
+ *string++ = highval;
83
+ if (*string)
84
+ *string++ = lowval;
85
+ else
86
+ /* don't orphan lead byte */
87
+ string[-1] = ' ';
88
+ }
89
+
90
+ }
91
+
92
+ else {
93
+ /* single byte value */
94
+
95
+ while (*string)
96
+ *string++ = (unsigned char)val;
97
+ }
98
+
99
+ return(start);
100
+ }
101
+
102
+ extern "C" unsigned char * (__cdecl _mbsset)(
103
+ unsigned char *string,
104
+ unsigned int val
105
+ )
106
+ {
107
+ _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
108
+ return _mbsset_l(string, val, nullptr);
109
+ _END_SECURE_CRT_DEPRECATION_DISABLE
110
+ }
miniMSVC/Windows Kits/10/Source/10.0.26100.0/ucrt/mbstring/mbsset_s.cpp ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***
2
+ *mbsset_s.c - Sets all charcaters of string to given character (MBCS)
3
+ *
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ *
6
+ *Purpose:
7
+ * Sets all charcaters of string to given character (MBCS)
8
+ *
9
+ *******************************************************************************/
10
+ #ifndef _MBCS
11
+ #error This file should only be compiled with _MBCS defined
12
+ #endif
13
+
14
+ #include <corecrt_internal_mbstring.h>
15
+
16
+ _REDIRECT_TO_L_VERSION_3(errno_t, _mbsset_s, unsigned char*, size_t, unsigned int)