bore

Unnamed repository
Log | Files | Refs | README

commit 353e8f211d5e6cc1afab847120b2b20ca626197b
parent 65888c38d15644619b08fcadbc995bd0d4ad434a
Author: phoebos <ben@bvnf.space>
Date:   Fri, 24 Sep 2021 00:06:22 +0100

ed: allow prefixing commands with (single digit) line number

Diffstat:
Med.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ed.c b/ed.c @@ -209,6 +209,7 @@ ed(char *startfile) { fprintf(stderr, "ed: getline: %s\n", strerror(errno)); return 1; } + char *c_initial = c; if (isdigit(*c)) { char new_c = *c - '0'; if (new_c <= num_lines) @@ -217,9 +218,9 @@ ed(char *startfile) { printf("?\n"); continue; } -// c++; + c++; } - else switch (*c) { + switch (*c) { case '=': printf("%d\n", cur_line); break; @@ -259,7 +260,7 @@ ed(char *startfile) { printf("?\n"); break; } - free(c); + free(c_initial); } return 0; }