Skip to content

Commit 182e078

Browse files
author
Peter Kosyh
committed
fix cmd mode
1 parent a85eee6 commit 182e078

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ static char *opt_autoload = NULL;
1919
static int need_restart = 0;
2020
static int need_load = 0;
2121
static int need_save = 0;
22-
static int parser_mode = 0;
23-
static int menu_mode = 0;
2422

2523
static int luaB_menu(lua_State *L)
2624
{
@@ -155,6 +153,10 @@ int main(int argc, const char **argv)
155153
char *str;
156154
const char *game = NULL;
157155
char cmd[256 + 64];
156+
157+
int parser_mode = 0;
158+
int menu_mode = 0;
159+
158160
setlocale(LC_ALL, "");
159161
#ifdef _WIN32
160162
SetConsoleOutputCP(1251);
@@ -223,6 +225,7 @@ int main(int argc, const char **argv)
223225
need_restart = need_load = need_save = 0;
224226
while (1) {
225227
char *p;
228+
int cmd_mode = 0;
226229
printf("> "); fflush(stdout);
227230
p = get_input();
228231
if (!p)
@@ -234,8 +237,10 @@ int main(int argc, const char **argv)
234237

235238
if (*p == '/') {
236239
p++;
240+
cmd_mode = 1;
237241
snprintf(cmd, sizeof(cmd), "%s", p);
238242
str = instead_cmd(cmd, &rc);
243+
rc = 0; /* force success */
239244
} else if (!parser_mode) {
240245
snprintf(cmd, sizeof(cmd), "use %s", p); /* try use */
241246
str = instead_cmd(cmd, &rc);
@@ -262,7 +267,7 @@ int main(int argc, const char **argv)
262267
fflush(stdout);
263268
free(str);
264269
}
265-
if (!parser_mode)
270+
if (!parser_mode && !cmd_mode)
266271
footer();
267272
if (opt_log)
268273
fprintf(stderr, "%s\n", p);

0 commit comments

Comments
 (0)