MCPcopy Create free account
hub / github.com/demoth/jake2 / TokenizeString

Method TokenizeString

qcommon/src/main/java/jake2/qcommon/exec/Cmd.java:198–229  ·  view source on GitHub ↗

Cmd_TokenizeString Parses the given string into command line tokens. $Cvars will be expanded unless they are in a quoted token.

(String text, boolean macroExpand)

Source from the content-addressed store, hash-verified

196 * unless they are in a quoted token.
197 */
198 public static List<String> TokenizeString(String text, boolean macroExpand) {
199 List<String> result = new ArrayList<>();
200
201 // macro expand the text
202 if (macroExpand)
203 text = MacroExpandString(text);
204
205 if (text == null || text.isEmpty())
206 return result;
207
208 Com.ParseHelp ph = new Com.ParseHelp(text);
209
210 while (true) {
211
212 // skip whitespace up to a \n
213 char c = ph.skipwhitestoeol();
214
215 if (c == '\n') { // a newline separates commands in the buffer
216 c = ph.nextchar();
217 break;
218 }
219
220 if (c == 0)
221 return result;
222
223 String word = Com.Parse(ph);
224
225 result.add(word);
226
227 }
228 return result;
229 }
230
231 public static void AddCommand(String cmd_name, Command function) {
232 AddCommand(cmd_name, function, false);

Calls 5

MacroExpandStringMethod · 0.95
skipwhitestoeolMethod · 0.95
nextcharMethod · 0.95
ParseMethod · 0.95
addMethod · 0.45