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