]> Nishi Git Mirror - serenade.git/commitdiff
works
authornishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Sat, 27 Apr 2024 00:18:22 +0000 (00:18 +0000)
committernishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Sat, 27 Apr 2024 00:18:22 +0000 (00:18 +0000)
git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@59 0f02c867-ac3d-714e-8a88-971ba1f6efcf

Serenade/main.c
Tool/configgen.c

index d1a7a6df2a9e7580a6782277c6317da496eb9b8b..0321f7d103ea0803f61940c520fefe3ebeae68a2 100644 (file)
@@ -42,8 +42,8 @@
 #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;
@@ -117,30 +117,31 @@ int main(int argc, char** argv) {
 #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);
@@ -150,7 +151,7 @@ int main(int argc, char** argv) {
                        free(line);
 #else
                        if(cbuf[0] == '\n') {
-                               if(strcmp(str, ":quit") == 0){
+                               if(strcmp(str, ":quit") == 0) {
                                        break;
                                }
                                if(br == 0 && strlen(str) > 0) {
@@ -181,6 +182,7 @@ int main(int argc, char** argv) {
                        }
 #endif
                }
+               write_history(".serenade_history");
                free(str);
                sn_interpreter_free(sn);
        }
index 9c60e60c7bcc27165af18e87cf5eb7219e7b44b9..4b4f12c4e3bcdc7b270ef6a66e9ff7f30e8e4acf 100644 (file)
@@ -35,9 +35,7 @@
 
 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};