diff options
author | Oskar <[email protected]> | 2024-02-11 18:28:01 +0100 |
---|---|---|
committer | Oskar <[email protected]> | 2024-02-11 18:28:01 +0100 |
commit | dcc3d0e1214616ce639dfcc873650e736e6951af (patch) | |
tree | 99149c870db5b69e5cab49172cdfd338ca74acf0 /startmode.c | |
parent | 32e27cbd2d5c151e7f4805dd862c5ec18ca62b9d (diff) |
minor fixes
Diffstat (limited to 'startmode.c')
-rw-r--r-- | startmode.c | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/startmode.c b/startmode.c index 9e0daf1..8f75069 100644 --- a/startmode.c +++ b/startmode.c @@ -146,39 +146,9 @@ int startmode(char filename[]) { break; case 'n': case 'N': { - // The "focus" that the newline will be inserted afterwards - uint64_t new_line_pos_temp = 0; // temp - char buf[1024]; - int success; - - do { - fprintf(stdout, "Create a new line after: "); - if (!fgets(buf, 1024, stdin)) { // take input from user - fprintf(stderr, "Too many characters\n"); - break; - } - char *endptr; - - new_line_pos_temp = strtol(buf, &endptr, 10); - errno = 0; - if (errno == ERANGE) { - fprintf(stderr, "Sorry, this number is too small or too large.\n"); - success = 0; - } - else if (endptr == buf) { - // no character was read - success = 0; - } - else if (*endptr && *endptr != '\n') { - success = 0; - } - - else { - success = 1; - } + + new_line(filename, focus); // create new line after the current focus - } while (!success); - new_line(filename, new_line_pos_temp); break; } case 'X': case 'x': |