MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / get_next_command

Function get_next_command

samples/fun_call_performance.cpp:194–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194std::string get_next_command() {
195 std::string retval("quit");
196 if (!std::cin.eof()) {
197 char *input_raw = readline("eval> ");
198 if (input_raw) {
199 add_history(input_raw);
200
201 std::string val(input_raw);
202 size_t pos = val.find_first_not_of("\t \n");
203 if (pos != std::string::npos)
204 {
205 val.erase(0, pos);
206 }
207 pos = val.find_last_not_of("\t \n");
208 if (pos != std::string::npos)
209 {
210 val.erase(pos + 1, std::string::npos);
211 }
212
213 retval = val;
214
215 ::free(input_raw);
216 }
217 }
218 if (retval == "quit"
219 || retval == "exit"
220 || retval == "help"
221 || retval == "version")
222 {
223 retval += "(0)";
224 }
225 return retval;
226}
227
228// We have to wrap exit with our own because Clang has a hard time with
229// function pointers to functions with special attributes (system exit being marked NORETURN)

Callers 1

interactiveFunction · 0.70

Calls 2

readlineFunction · 0.70
add_historyFunction · 0.70

Tested by

no test coverage detected