commit 6135cad495e562b0d3108942ca8de2b285699e0e
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Wed Dec 16 21:21:55 2015 +0100
Commit:     sin <[email protected]>
CommitDate: Wed Dec 16 20:25:50 2015 +0000

    Move edit logic to an individual function
    
    It is better to separate this logic from
    the parameter logic in main().

diff --git a/ed.c b/ed.c
index 3d90d4d..a3de436 100644
--- 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;

Reply via email to