commit 6135cad495e562b0d3108942ca8de2b285699e0e
parent 05af2156b6259ca8efc1674bc9d572a912bdba62
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 16 Dec 2015 21:21:55 +0100
Move edit logic to an individual function
It is better to separate this logic from
the parameter logic in main().
Diffstat:
M | ed.c | | | 27 | +++++++++++++++++---------- |
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/ed.c b/ed.c
@@ -1343,6 +1343,22 @@ sighup(int dummy)
quit();
}
+static void
+edit(void)
+{
+ setjmp(savesp);
+ for (;;) {
+ newcmd = 1;
+ ocurln = curln;
+ cmdsiz = 0;
+ repidx = -1;
+ if (optprompt)
+ fputs(prompt, stdout);
+ getlst();
+ chkglobal() ? doglobal() : docmd();
+ }
+}
+
int
main(int argc, char *argv[])
{
@@ -1373,16 +1389,7 @@ main(int argc, char *argv[])
}
}
- for (;;) {
- newcmd = 1;
- ocurln = curln;
- cmdsiz = 0;
- repidx = -1;
- if (optprompt)
- fputs(prompt, stdout);
- getlst();
- chkglobal() ? doglobal() : docmd();
- }
+ edit();
/* not reached */
return 0;