tex: without arguments, :s repeats the previous substitution - 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 8d920bf3b193961749c1490708fd135167f74a59
 (DIR) parent b4991eb46ce9f36f73591c62ef1cf20e4f915b7d
 (HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
       Date:   Sat, 13 Feb 2016 21:57:03 +0330
       
       ex: without arguments, :s repeats the previous substitution
       
       Diffstat:
         M ex.c                                |      16 +++++++++++-----
       
       1 file changed, 11 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/ex.c b/ex.c
       t@@ -20,6 +20,7 @@ int xdir = +1;                        /* current direction context */
        int xshape = 1;                        /* perform letter shaping */
        int xorder = 1;                        /* change the order of characters */
        char xfindkwd[EXLEN];                /* the last searched keyword */
       +char xfindrep[EXLEN];                /* the last replacement */
        int xfinddir = +1;                /* the last search direction */
        static char *xkmap = "en";        /* the current keymap */
        static char xkmap2[8] = "fa";        /* the alternate keymap */
       t@@ -634,7 +635,7 @@ static int ec_substitute(char *ec)
                int offs[32];
                int beg, end;
                char *pats[1];
       -        char *pat, *rep;
       +        char *pat = NULL, *rep = NULL;
                char *s;
                int i;
                ex_loc(ec, loc);
       t@@ -642,10 +643,15 @@ static int ec_substitute(char *ec)
                        return 1;
                s = ex_argeol(ec);
                pat = re_read(&s);
       -        s--;
       -        rep = re_read(&s);
       -        if (pat[0])
       +        if (pat && pat[0])
                        snprintf(xfindkwd, sizeof(xfindkwd), "%s", pat);
       +        if (pat && *s) {
       +                s--;
       +                rep = re_read(&s);
       +        }
       +        if (!rep)
       +                rep = uc_dup(pat ? "" : xfindrep);
       +        snprintf(xfindrep, sizeof(xfindrep), "%s", rep);
                free(pat);
                pats[0] = xfindkwd;
                re = rset_make(1, pats, xic ? RE_ICASE : 0);
       t@@ -742,7 +748,7 @@ static int ec_glob(char *ec)
                not = strchr(cmd, '!') || cmd[0] == 'v';
                s = ex_argeol(ec);
                pat = re_read(&s);
       -        if (pat[0])
       +        if (pat && pat[0])
                        snprintf(xfindkwd, sizeof(xfindkwd), "%s", pat);
                free(pat);
                pats[0] = xfindkwd;