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