#include <sys/stat.h>
#ifdef HAS_READLINE_SUPPORT
-#include <readline/readline.h>
#include <readline/history.h>
+#include <readline/readline.h>
#endif
extern bool is_repl;
#ifdef HAS_READLINE_SUPPORT
char* line = NULL;
using_history();
+ read_history(".serenade_history");
#endif
while(1) {
#ifdef HAS_READLINE_SUPPORT
line = readline("> ");
- if(line == NULL){
+ if(line == NULL) {
free(line);
break;
}
int i;
- for(i = 0; line[i] != 0; i++){
- if(line[i] == '('){
+ for(i = 0; line[i] != 0; i++) {
+ if(line[i] == '(') {
br++;
- }else if(line[i] == ')'){
+ } else if(line[i] == ')') {
br--;
}
}
- if(strcmp(line, ":quit") == 0){
+ if(strcmp(line, ":quit") == 0) {
free(line);
break;
}
char* tmp = str;
str = sn_strcat(tmp, line);
free(tmp);
- if(br == 0){
+ if(br == 0) {
sn_eval(sn, str, strlen(str));
add_history(str);
free(str);
free(line);
#else
if(cbuf[0] == '\n') {
- if(strcmp(str, ":quit") == 0){
+ if(strcmp(str, ":quit") == 0) {
break;
}
if(br == 0 && strlen(str) > 0) {
}
#endif
}
+ write_history(".serenade_history");
free(str);
sn_interpreter_free(sn);
}
char choice[256];
-char* asks[] = {"repl", "y", "HAS_REPL_SUPPORT", "Do you want the REPL support?",
- "ffi", "y", "HAS_FFI_SUPPORT", "Do you want the FFI support?",
- "readline", "n", "HAS_READLINE_SUPPORT", "Do you want the readline support for the REPL?",
+char* asks[] = {"repl", "y", "HAS_REPL_SUPPORT", "Do you want the REPL support?", "ffi", "y", "HAS_FFI_SUPPORT", "Do you want the FFI support?", "readline", "n", "HAS_READLINE_SUPPORT", "Do you want the readline support for the REPL?",
NULL};