1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
/*++
Copyright (c) 1993 Microsoft Corporation
Module Name:
dlldbcs.c
Abstract:
This module contains the multibyte string functions.
Author:
Akihiko Sasaki (V-AkihiS) 23-June-1993
Revision History:
--*/
#ifdef DBCS
#include "os2dll.h"
#include "dlldbcs.h"
#include "conrqust.h"
#include "os2win.h"
unsigned char * _CRTAPI1
Od2MultiByteStrchr(
const unsigned char *string,
unsigned short c
)
{
const unsigned char ch = (unsigned char)c;
while (*string != ch) {
if (Ow2NlsIsDBCSLeadByte(*string, SesGrp->DosCP)) {
string++;
}
if (*string == '\0')
return NULL;
string++;
}
return (unsigned char *)string;
}
unsigned char * _CRTAPI1
Od2MultiByteStrrchr(
const unsigned char *string,
unsigned short c
)
{
const unsigned char ch = (unsigned char)c;
const unsigned char *lastoccurence = NULL;
while (1) {
if (Ow2NlsIsDBCSLeadByte(*string, SesGrp->DosCP)) {
string++;
} else {
if (*string == ch)
lastoccurence = string;
}
if (*string == '\0')
return (unsigned char *)lastoccurence;
string++;
}
}
unsigned char * _CRTAPI1
Od2MultiByteStrstr(
const unsigned char *string1,
const unsigned char *string2
)
{
if (*string2 == '\0')
return (unsigned char *)string1;
while((string1 = Od2MultiByteStrchr(string1, *string2)) != NULL) {
const unsigned char *substring1 = string1;
const unsigned char *substring2 = string2;
while (1) {
if (Ow2NlsIsDBCSLeadByte(*substring1, SesGrp->DosCP)) {
if (Ow2NlsIsDBCSLeadByte(*substring2, SesGrp->DosCP)) {
if (*substring1++ == *substring2++) {
if (*substring2 == '\0')
if (*substring1 == '\0')
return (unsigned char *)string1;
else
return NULL;
else if (*substring1++ != *substring2++)
break;
} else {
if (*substring1 == '\0' || *substring2 == '\0')
return NULL;
substring1 +=2;
substring2 +=2;
}
} else {
if (*substring2 == '\0') {
return (unsigned char *)string1;
} else {
substring1++;
if (*substring1 == '\0')
return NULL;
substring1++;
substring2++;
}
}
} else {
if (Ow2NlsIsDBCSLeadByte(*substring2, SesGrp->DosCP)) {
if (*substring1 == '\0') {
return NULL;
} else {
substring2++;
if (*substring2 == '\0')
return NULL;
substring1++;
substring2++;
}
} else {
if (*substring2 == '\0')
return (unsigned char *)string1;
else if (*substring1 == '\0')
return NULL;
else if (*substring1++ != *substring2++)
break;
}
}
}
string1++;
}
return NULL;
}
unsigned char * _CRTAPI1
Od2MultiByteStrpbrk(
const unsigned char *string1,
const unsigned char *string2
)
{
const unsigned char *substring1, *substring2;
substring1 = string1;
while (*substring1 != '\0') {
substring2 = string2;
if (Ow2NlsIsDBCSLeadByte(*substring1, SesGrp->DosCP)) {
substring1++;
if (*substring1 == '\0')
return NULL;
} else {
while (*substring2 != '\0') {
if (*substring1 == *substring2)
return (unsigned char *)substring1;
substring2++;
}
}
substring1++;
}
return NULL;
}
#endif
|