MCPcopy Create free account
hub / github.com/ZDoom/Raze / PrepareScript

Method PrepareScript

source/common/engine/sc_man.cpp:222–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220//==========================================================================
221
222void FScanner::PrepareScript ()
223{
224 // If the file got a UTF-8 byte order mark, remove that.
225 if (ScriptBuffer.Len() > 3 && ScriptBuffer[0] == (char)0xEF && ScriptBuffer[1] == (char)0xBB && ScriptBuffer[2] == (char)0xBF)
226 {
227 ScriptBuffer = ScriptBuffer.Mid(3);
228 }
229
230 // The scanner requires the file to end with a '\n', so add one if
231 // it doesn't already.
232 if (ScriptBuffer.Len() == 0 || ScriptBuffer.Back() != '\n')
233 {
234 // If the last character in the buffer is a null character, change
235 // it to a newline. Otherwise, append a newline to the end.
236 if (ScriptBuffer.Len() > 0 && ScriptBuffer.Back() == '\0')
237 {
238 ScriptBuffer.LockBuffer()[ScriptBuffer.Len() - 1] = '\n';
239 ScriptBuffer.UnlockBuffer();
240 }
241 else
242 {
243 ScriptBuffer += '\n';
244 }
245 }
246
247 ScriptPtr = &ScriptBuffer[0];
248 ScriptEndPtr = &ScriptBuffer[ScriptBuffer.Len()];
249 Line = 1;
250 End = false;
251 ScriptOpen = true;
252 String = StringBuffer;
253 AlreadyGot = false;
254 LastGotToken = false;
255 LastGotPtr = NULL;
256 LastGotLine = 1;
257 CMode = false;
258 Escape = true;
259 StateMode = 0;
260 StateOptions = false;
261 StringBuffer[0] = '\0';
262 BigStringBuffer = "";
263 ParseError = false;
264}
265
266//==========================================================================
267//

Callers

nothing calls this directly

Calls 5

LenMethod · 0.80
MidMethod · 0.80
LockBufferMethod · 0.80
UnlockBufferMethod · 0.80
BackMethod · 0.45

Tested by

no test coverage detected