MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / next

Method next

src/3rdparty/icu/scriptrun.cpp:117–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117UBool ScriptRun::next()
118{
119 int32_t startSP = parenSP; // used to find the first new open character
120 UErrorCode error = U_ZERO_ERROR;
121
122 // if we've fallen off the end of the text, we're done
123 if (scriptEnd >= charLimit) {
124 return false;
125 }
126
127 scriptCode = USCRIPT_COMMON;
128
129 for (scriptStart = scriptEnd; scriptEnd < charLimit; scriptEnd += 1) {
130 char16_t high = charArray[scriptEnd];
131 UChar32 ch = high;
132
133 // if the character is a high surrogate and it's not the last one
134 // in the text, see if it's followed by a low surrogate
135 if (high >= 0xD800 && high <= 0xDBFF && scriptEnd < charLimit - 1)
136 {
137 char16_t low = charArray[scriptEnd + 1];
138
139 // if it is followed by a low surrogate,
140 // consume it and form the full character
141 if (low >= 0xDC00 && low <= 0xDFFF) {
142 ch = (high - 0xD800) * 0x0400 + low - 0xDC00 + 0x10000;
143 scriptEnd += 1;
144 }
145 }
146
147 UScriptCode sc = uscript_getScript(ch, &error);
148 int32_t pairIndex = getPairIndex(ch);
149
150 // Paired character handling:
151 //
152 // if it's an open character, push it onto the stack.
153 // if it's a close character, find the matching open on the
154 // stack, and use that script code. Any non-matching open
155 // characters above it on the stack will be poped.
156 if (pairIndex >= 0) {
157 if ((pairIndex & 1) == 0) {
158 parenStack[++parenSP].pairIndex = pairIndex;
159 parenStack[parenSP].scriptCode = scriptCode;
160 } else if (parenSP >= 0) {
161 int32_t pi = pairIndex & ~1;
162
163 while (parenSP >= 0 && parenStack[parenSP].pairIndex != pi) {
164 parenSP -= 1;
165 }
166
167 if (parenSP < startSP) {
168 startSP = parenSP;
169 }
170
171 if (parenSP >= 0) {
172 sc = parenStack[parenSP].scriptCode;
173 }
174 }

Callers 3

NextMethod · 0.45
ItemizeScriptFunction · 0.45
TestScriptRunFunction · 0.45

Calls

no outgoing calls

Tested by 1

TestScriptRunFunction · 0.36