tex: read EXINIT environment variable - neatvi - [fork] simple vi-type editor with UTF-8 support
 (HTM) git clone git://src.adamsgaard.dk/neatvi
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit 5da6bb0629bff3c69de6f99671fde70a29ba0ca9
 (DIR) parent 9f5b9af976acf7fb6f88d89e3ec5a6fb1c649c4a
 (HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
       Date:   Sat, 27 Jun 2015 20:23:09 +0430
       
       ex: read EXINIT environment variable
       
       Suggested by Peter Aronoff <telemachus@arpinum.org>.
       
       Diffstat:
         M ex.c                                |      29 ++++++++++++++++++++++-------
       
       1 file changed, 22 insertions(+), 7 deletions(-)
       ---
 (DIR) diff --git a/ex.c b/ex.c
       t@@ -154,6 +154,14 @@ static char *ex_argeol(char *ec)
                return s;
        }
        
       +static char *ex_line(char *s, char *ln)
       +{
       +        while (*s && *s != '|' && *s != '\n')
       +                *ln++ = *s++;
       +        *ln = '\0';
       +        return *s ? s + 1 : s;
       +}
       +
        static int ex_search(char *pat)
        {
                struct sbuf *kw;
       t@@ -769,17 +777,22 @@ static struct excmd {
        /* execute a single ex command */
        void ex_command(char *ln)
        {
       +        char ec[EXLEN];
                char cmd[EXLEN];
                int i;
       -        ex_cmd(ln, cmd);
       -        for (i = 0; i < LEN(excmds); i++) {
       -                if (!strcmp(excmds[i].abbr, cmd) || !strcmp(excmds[i].name, cmd)) {
       -                        excmds[i].ec(ln);
       -                        break;
       +        while (*ln) {
       +                ln = ex_line(ln, ec);
       +                ex_cmd(ec, cmd);
       +                for (i = 0; i < LEN(excmds); i++) {
       +                        if (!strcmp(excmds[i].abbr, cmd) ||
       +                                        !strcmp(excmds[i].name, cmd)) {
       +                                excmds[i].ec(ec);
       +                                break;
       +                        }
                        }
       +                if (!xvis && !cmd[0])
       +                        ec_print(ec);
                }
       -        if (!xvis && !cmd[0])
       -                ec_print(ln);
                lbuf_modified(xb);
        }
        
       t@@ -799,6 +812,8 @@ void ex_init(char **files)
                char cmd[EXLEN];
                snprintf(cmd, sizeof(cmd), "e %s", files[0] ? files[0] : "");
                ec_edit(cmd);
       +        if (getenv("EXINIT"))
       +                ex_command(getenv("EXINIT"));
        }
        
        void ex_done(void)