]> git.draconx.ca Git - cdecl99.git/blobdiff - src/execute.gperf
libcdecl: Fully remove snprintf requirement from the library.
[cdecl99.git] / src / execute.gperf
index de8b1364c7cf44c953b8f9983ca6d0aed1bbf2a9..bf9a080748764b886117152b01fbaa9cb36c1c8d 100644 (file)
@@ -83,7 +83,7 @@ static int run_cmd_help(void)
        return 0;
 }
 
-int run_command(const char *line, int interactive)
+int run_command(const char *line, int batch)
 {
        const char *cmd = line + strspn(line, " \t");
        const char *arg = cmd + strcspn(cmd, " \t");
@@ -96,7 +96,7 @@ int run_command(const char *line, int interactive)
        c = in_word_set(cmd, arg-cmd);
        if (!c) {
                print_error(_("unknown command %.*s"), (int)(arg-cmd), cmd);
-               if (interactive) {
+               if (!batch) {
                        fprintf(stderr, "%s\n",
                                _("Try \"help\" for a list of possible commands."));
                }
@@ -104,11 +104,16 @@ int run_command(const char *line, int interactive)
        }
 
        switch (c->cmd) {
-       case cmd_help: return run_cmd_help();
-       case cmd_declare: case cmd_type: return run_command_declare(cmd);
-       case cmd_simplify: return run_command_simplify(arg);
-       case cmd_explain: return run_command_explain(arg);
-       case cmd_quit: return 1;
+       case cmd_help:
+               return run_cmd_help();
+       case cmd_declare: case cmd_type:
+               return run_command_cdecl(cmd, INPUT_ENGLISH, OUTPUT_C);
+       case cmd_simplify:
+               return run_command_cdecl(arg, INPUT_C, OUTPUT_C);
+       case cmd_explain:
+               return run_command_cdecl(arg, INPUT_C, OUTPUT_ENGLISH);
+       case cmd_quit:
+               return 1;
        }
 
        assert(0);