[hackers] [sbase] Move edit logic to an individual function || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Wed, 16 Dec 2015 21:25:55 +0100 (CET)

commit 6135cad495e562b0d3108942ca8de2b285699e0e
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Dec 16 21:21:55 2015 +0100
Commit: sin <sin_AT_2f30.org>
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
_AT_@ -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[])
 {
_AT_@ -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;
Received on Wed Dec 16 2015 - 21:25:55 CET

This archive was generated by hypermail 2.3.0 : Wed Dec 16 2015 - 21:36:15 CET