summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--input.c8
-rw-r--r--process_multiples.c9
-rw-r--r--startmode.c4
-rw-r--r--test/testgrounds/newlinetest2
4 files changed, 13 insertions, 10 deletions
diff --git a/input.c b/input.c
index 86e0d36..c94aaa3 100644
--- a/input.c
+++ b/input.c
@@ -8,8 +8,10 @@
#include "i_validation.h"
#include <stdint.h>
+int clfstdin_doubleprint; // variable accessed via extern int in startmode so that it does not print '?' 2 times in a row
+
int check_length_fix_stdin(char *smode_buf) {
-
+
int sbl = 0;
for ( ; sbl < SMODE_MAX_INPUT_SIZE ; sbl++) {
if(smode_buf[sbl] == '\0' || smode_buf[sbl] == '\n') {
@@ -19,7 +21,9 @@ int check_length_fix_stdin(char *smode_buf) {
if (sbl >= SMODE_MAX_INPUT_SIZE) {
char c;
while ((c = getchar()) != '\n');
- //fprintf (stderr, "sbl > SMODE_MAX_SIZE\n");
+ fprintf (stdout, "?\n");
+ clfstdin_doubleprint = 0;
+ //fprintf (stderr, "sbl > SMODE_MAX_SIZE\n"); // debug code
return _FAIL;
}
diff --git a/process_multiples.c b/process_multiples.c
index a472e5b..6c3b6b7 100644
--- a/process_multiples.c
+++ b/process_multiples.c
@@ -11,7 +11,7 @@
int check_L_linecount(uint64_t Flines, uint64_t focus) {
if (focus < 1 || focus > Flines) {
- fprintf(stderr, "check_L_linecount()\n");
+ fprintf(stdout, "?\n");
return _INVALID;
}
return _VALID;
@@ -84,10 +84,10 @@ uint64_t call_L_plus_minus_continue(char *multiple, uint64_t focus, uint64_t Fli
uint64_t call_L_only(uint64_t focus, uint64_t Flines) {
- char buf[33] = { '\0' };
+ char buf[SMODE_MAX_SIZE] = { '\0' };
fprintf(stdout, "(L): ");
- fgets(buf, 32, stdin);
- if(check_length_fix_stdin(buf) == _FAIL) { return _FAIL; }
+ fgets(buf, SMODE_MAX_SIZE, stdin);
+ if(check_length_fix_stdin(buf) == _FAIL) { return focus; return _FAIL; }
if (buf[0] == '\n') {
return focus;
@@ -157,7 +157,6 @@ uint64_t call_L(char *multiple, uint64_t focus, uint64_t Flines) {
}
if (imm == _IMM_NUMBER) {
- fprintf(stdout, "immediate\n");
focus = call_L_immediate(multiple, focus, Flines);
return focus;
}
diff --git a/startmode.c b/startmode.c
index f77611b..1711d1c 100644
--- a/startmode.c
+++ b/startmode.c
@@ -113,8 +113,6 @@ int startmode(char filename[]) {
call_singles(single, focus, filename);
break;
case _MULTIPLE:
- //fprintf(stdout, "multiple\n");
- //fprintf(stdout, "%s", multiple);
switch(multiple[0]) {
case 'l':
case 'L':
@@ -137,6 +135,8 @@ int startmode(char filename[]) {
free(multiple);
break;
case _FAIL:
+ extern int clfstdin_doubleprint;
+ if (clfstdin_doubleprint == 0) { break ;}
fprintf(stdout, "?\n");
break;
case _RETURN: // if user just preses 'return' button
diff --git a/test/testgrounds/newlinetest b/test/testgrounds/newlinetest
index 766a493..da31879 100644
--- a/test/testgrounds/newlinetest
+++ b/test/testgrounds/newlinetest
@@ -1,4 +1,4 @@
-1
+1uhhhh
2
3
4