MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / StringParseWord

Function StringParseWord

netgames/dmfc/dmfcinputcommand.cpp:125–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123extern DMFCBase *basethis;
124
125bool StringParseWord(const char *string, char *word, int size, const char **newpos) {
126 *newpos = string;
127 word[0] = '\0';
128
129 // get through all the whitespace
130 while (*string && *string == ' ')
131 string++;
132 if (!(*string)) {
133 // nothing is left in the string
134 *newpos = string;
135 return false;
136 }
137
138 // we're at the beginning of a word
139 while (*string && *string != ' ') {
140 if (size > 1) {
141 *word = *string;
142 size--;
143 word++;
144 }
145
146 string++;
147 }
148
149 // tack on an ending \0
150 *word = '\0';
151
152 *newpos = string;
153 return true;
154}
155
156bool StringParseNumber(const char *string, int *number, const char **newpos) {
157 char temp[10];

Calls

no outgoing calls

Tested by

no test coverage detected