sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit f57002724c227fa1a7829dfdff2600f5843c6765
parent 74f773295d565b9c014de866db617b3d2dc631d7
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed Dec 16 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:
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;