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

27
ed.c
View File

@ -1343,6 +1343,22 @@ sighup(int dummy)
quit(); 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 int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@ -1373,16 +1389,7 @@ main(int argc, char *argv[])
} }
} }
for (;;) { edit();
newcmd = 1;
ocurln = curln;
cmdsiz = 0;
repidx = -1;
if (optprompt)
fputs(prompt, stdout);
getlst();
chkglobal() ? doglobal() : docmd();
}
/* not reached */ /* not reached */
return 0; return 0;