Move edit logic to an individual function

It is better to separate this logic from
the parameter logic in main().
This commit is contained in:
Roberto E. Vargas Caballero 2015-12-16 21:21:55 +01:00 committed by sin
parent 05af2156b6
commit 6135cad495
1 changed files with 17 additions and 10 deletions

27
ed.c
View File

@ -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;