From a24e39c9c1022a37cab2a6f877f61373812a6c98 Mon Sep 17 00:00:00 2001 From: Oskar Date: Thu, 4 Apr 2024 14:05:20 +0200 Subject: call_L_immediate now implemented. L with immediate numbers seem to work pretty well now. Not comprehensively tested yet. Will do later. --- process_multiples.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/process_multiples.c b/process_multiples.c index 8af048c..a472e5b 100644 --- a/process_multiples.c +++ b/process_multiples.c @@ -17,6 +17,34 @@ int check_L_linecount(uint64_t Flines, uint64_t focus) { return _VALID; } +uint64_t call_L_immediate(char *multiple, uint64_t focus, uint64_t Flines) { + + char new_multiple[32] = { '\0' }; + + int i = 0; + int j = 1; + for( ; multiple[j] != '\n' ; i++, j++) { + new_multiple[i] = multiple[j]; + } + + char *endptr; + uint64_t new_focus = strtol(new_multiple, &endptr, 10); + errno = 0; + if (errno == ERANGE) { + return focus; + } + if (endptr == new_multiple) { + return focus; + } + + if(check_L_linecount(Flines, new_focus) == _INVALID) { + return focus; + } + + return new_focus; + +} + uint64_t call_L_plus_minus_continue(char *multiple, uint64_t focus, uint64_t Flines) { char new_multiple[32] = { '\0' }; @@ -130,6 +158,8 @@ 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; } -- cgit v1.2.3