MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / GetWord

Function GetWord

engine/Poseidon/IO/ParamFile/ParamFile.cpp:29–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27typedef char WordBuf[2048];
28
29static bool GetWord(char* buf, int bufSize, QIStream& in, const char* termin, bool* quot = nullptr)
30{
31 int len = 0;
32 buf[len] = 0;
33 int c = in.get();
34 // LTrim the word
35 while (isspace(c))
36 {
37 c = in.get();
38 }
39 if (c == '"')
40 {
41 if (quot)
42 {
43 *quot = true;
44 }
45 c = in.get();
46 for (;;)
47 {
48 if (c == EOF)
49 {
50 // Unterminated string: stop at end of input rather than spinning here,
51 // since QIStream::get keeps returning EOF without advancing the cursor.
52 ErrorMessage("Config: End of file encountered inside a string");
53 return len > 0;
54 }
55 if (c == '"')
56 {
57 c = in.get();
58 if (c != '"')
59 {
60 in.unget();
61 return true; // word parsed
62 }
63 }
64 if (c == '\n' || c == '\r')
65 {
66 ErrorMessage("Config: End of line encountered after %s", buf);
67 }
68 if (len < bufSize - 1)
69 {
70 buf[len++] = c, buf[len] = 0;
71 }
72 c = in.get();
73 }
74 }
75 else
76 {
77 if (quot)
78 {
79 *quot = false;
80 }
81 while (!strchr(termin, c) && c != EOF)
82 {
83 if (c == '\n' || c == '\r')
84 {
85 // word terminated - only white spaces or termin now
86 for (;;)

Callers 3

ParsePlainTextMethod · 0.85
ParseMethod · 0.85
ParamValueSpecClass · 0.85

Calls 3

ErrorMessageFunction · 0.85
getMethod · 0.45
ungetMethod · 0.45

Tested by

no test coverage detected