summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-04-01 18:33:53 +0200
committerOskar <[email protected]>2024-04-01 18:33:53 +0200
commitf5af9591856569c39d718059b3dbbc69c6e5f8d5 (patch)
tree11821ebe1e96bbd80e240dff7867b97c50482828
parent10f241cce53c8a8da122728ec1577c1472149b85 (diff)
Implemented call_L_only. This makes the program behave like 7ed v1 and
asks for a line number after pressing enter. I still want old functionality to work because there really isnt any reason not to have it.
-rw-r--r--process_multiples.c36
-rw-r--r--test/testgrounds/newlinetest1
2 files changed, 35 insertions, 2 deletions
diff --git a/process_multiples.c b/process_multiples.c
index 80f18c5..61adcb3 100644
--- a/process_multiples.c
+++ b/process_multiples.c
@@ -17,12 +17,43 @@ int check_L_linecount(uint64_t Flines, uint64_t focus) {
return _VALID;
}
-int call_L_plus_continue(char *multiple) {
+uint64_t call_L_plus_continue(char *multiple) {
fprintf(stdout, "+ or - CONTINUE %s\n", multiple);
return 0;
}
+uint64_t call_L_only(uint64_t focus, uint64_t Flines) {
+
+ char buf[32] = { '\0' };
+ fprintf(stdout, "(L): ");
+ fgets(buf, 30, stdin);
+
+ if (buf[0] == '\n') {
+ return focus;
+ }
+
+ char *endptr;
+ uint64_t new_focus = strtol(buf, &endptr, 10);
+ errno = 0;
+ if (errno == ERANGE) {
+ return focus;
+ }
+ if (endptr == buf) {
+ return focus;
+ }
+ if (*endptr != '\n') {
+ return focus;
+ }
+
+ int cll = check_L_linecount(Flines, new_focus);
+ if (cll == _INVALID) {
+ return focus;
+ }
+
+ return new_focus;
+}
+
uint64_t call_L_plus_minus_only(uint64_t focus, char p_or_m, uint64_t Flines) {
switch (p_or_m) {
case '+': {
@@ -50,7 +81,8 @@ uint64_t call_L(char *multiple, uint64_t focus, uint64_t Flines) {
if (multiple[1] == '\n') {
imm = _NA;
- fprintf(stdout, "L only\n");
+ focus = call_L_only(focus, Flines);
+ return focus;
}
if (multiple[1] == '+' || multiple[1] == '-') {
diff --git a/test/testgrounds/newlinetest b/test/testgrounds/newlinetest
index f00c965..766a493 100644
--- a/test/testgrounds/newlinetest
+++ b/test/testgrounds/newlinetest
@@ -8,3 +8,4 @@
8
9
10
+WOW!