From 28bcb44c3690c5f58f25358341739a81e6535edc Mon Sep 17 00:00:00 2001 From: Oskar Date: Sun, 7 Apr 2024 18:57:21 +0200 Subject: N0 now works properly --- i_validation.c | 2 +- process_multiples.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/i_validation.c b/i_validation.c index 60af7aa..70762cf 100644 --- a/i_validation.c +++ b/i_validation.c @@ -147,7 +147,7 @@ int validate_imm_numbers(char *smode_buf, int mode) { int kflag = _INVALID; if (mode == MODE_N && smode_buf[1] == '0') { // Because we are on MODE_N this runs to check if there is anything after N0. We will only allow newline characters because that means theres ONLY 'N0* - printf("vimmn mode N\n"); + if (smode_buf[2] == '\n') { return _VALID; } else { diff --git a/process_multiples.c b/process_multiples.c index 74e68a9..fc648a0 100644 --- a/process_multiples.c +++ b/process_multiples.c @@ -8,7 +8,13 @@ #include "i_validation.h" #include -int check_L_linecount(uint64_t Flines, uint64_t focus) { +int check_L_linecount(uint64_t Flines, uint64_t focus, int mode) { + + if (mode == MODE_N) { // Last check that allows for N0 to work. + if (focus == 0) { + return _VALID; + } + } if (focus < 1 || focus > Flines) { fprintf(stdout, "?\n"); @@ -37,7 +43,7 @@ uint64_t call_L_immediate(char *multiple, uint64_t focus, uint64_t Flines) { return focus; } - if(check_L_linecount(Flines, new_focus) == _INVALID) { + if(check_L_linecount(Flines, new_focus, MODE_L) == _INVALID) { return focus; } @@ -75,7 +81,7 @@ uint64_t call_L_plus_minus_continue(char *multiple, uint64_t focus, uint64_t Fli new_focus = focus-new_focus; } } - if(check_L_linecount(Flines, new_focus) == _INVALID) { + if(check_L_linecount(Flines, new_focus, MODE_L) == _INVALID) { return focus; } @@ -106,7 +112,7 @@ uint64_t call_L_only(uint64_t focus, uint64_t Flines) { return focus; } - int cll = check_L_linecount(Flines, new_focus); + int cll = check_L_linecount(Flines, new_focus, MODE_L); if (cll == _INVALID) { return focus; } @@ -117,14 +123,14 @@ uint64_t call_L_only(uint64_t focus, uint64_t Flines) { uint64_t call_L_plus_minus_only(uint64_t focus, char p_or_m, uint64_t Flines) { switch (p_or_m) { case '+': { - int cll = check_L_linecount(Flines, focus+1); + int cll = check_L_linecount(Flines, focus+1, MODE_L); if (cll == _INVALID) { return focus; } return focus+1; break; } case '-': { - int cll = check_L_linecount(Flines, focus-1); + int cll = check_L_linecount(Flines, focus-1, MODE_L); if (cll == _INVALID) { return focus; } @@ -185,7 +191,7 @@ int call_N_immediate(char *multiple, uint64_t Flines, char *filename) { return 0; } - if(check_L_linecount(Flines, newline_insert_position) == _INVALID) { + if(check_L_linecount(Flines, newline_insert_position, MODE_N) == _INVALID) { return -1; } -- cgit v1.2.3