MCPcopy Create free account
hub / github.com/agraef/pure-lang / parse_cmd

Function parse_cmd

pure/runtime.cc:6913–6964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6911}
6912
6913static void parse_cmd(string& cmdline, string& cmd, string& arg, char escape_mode)
6914{
6915 // strip trailing whitespace
6916 size_t p = cmdline.find_last_not_of(" \t");
6917 if (p != string::npos)
6918 cmdline.erase(p+1);
6919 else
6920 cmdline.clear();
6921 // strip leading whitespace
6922 p = cmdline.find_first_not_of(" \t");
6923 if (p != string::npos)
6924 cmdline.erase(0, p);
6925 else
6926 cmdline.clear();
6927 // tokenize
6928 if (!cmdline.empty()) {
6929 if (cmdline[0] == '?' || cmdline[0] == '.') {
6930 cmd = cmdline.substr(0, 1);
6931 arg = cmdline.substr(1);
6932 return;
6933 }
6934 if (!escape_mode || escape_mode == '!') {
6935 if (cmdline[0] == '!') {
6936 cmd = "!";
6937 arg = cmdline.substr(1);
6938 return;
6939 }
6940 } else if (cmdline[0] == escape_mode) {
6941 cmd = "!";
6942 arg = cmdline.substr(1);
6943 return;
6944 } else if (cmdline[0] == '!') {
6945 cmd = "!";
6946 arg = cmdline;
6947 return;
6948 }
6949 }
6950 if (cmdline.substr(0, 2) == "//") {
6951 cmd = cmdline.substr(0, 2);
6952 arg = cmdline.substr(2);
6953 return;
6954 }
6955 p = cmdline.find_first_of(" \t");
6956 if (p != string::npos) {
6957 cmd = cmdline.substr(0, p);
6958 p = cmdline.find_first_not_of(" \t", p);
6959 assert(p != string::npos);
6960 arg = cmdline.substr(p);
6961 } else {
6962 cmd = cmdline; arg = "";
6963 }
6964}
6965
6966static const char *stacklab(interpreter& interp,
6967 list<DebugInfo>::reverse_iterator it,

Callers 1

pure_debug_ruleFunction · 0.85

Calls 2

eraseMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected