From 955edb781ccc6483a6c1684cb4128a75f850feec Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 25 Jul 2024 21:35:56 +0100 Subject: [PATCH] get new len from strcspn remove reset input buffer --- src/vmrcli.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/vmrcli.c b/src/vmrcli.c index 220c195..f2ea80e 100644 --- a/src/vmrcli.c +++ b/src/vmrcli.c @@ -266,12 +266,11 @@ static void interactive(PT_VMR vmr, bool with_prompt) printf(">> "); while (fgets(input, MAX_LINE, stdin) != NULL) { - input[strcspn(input, "\n")] = 0; - if ((len = strlen(input)) == 1 && toupper(input[0]) == 'Q') + input[(len = strcspn(input, "\n"))] = 0; + if (len == 1 && toupper(input[0]) == 'Q') break; parse_input(vmr, input); - memset(input, 0, len); /* reset input buffer */ if (with_prompt) printf(">> ");