tex: expect a non-NULL string in ex_command() - neatvi - [fork] simple vi-type … | |
git clone git://src.adamsgaard.dk/neatvi | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit bc9dd7dfbc434e6260ca5002cbc6501ced9adcb6 | |
parent 0a858aba4cababc83b862da41aa8c8c07a564ea9 | |
Author: Ali Gholami Rudi <[email protected]> | |
Date: Tue, 12 May 2015 16:42:53 +0430 | |
ex: expect a non-NULL string in ex_command() | |
Diffstat: | |
M ex.c | 24 +++++++++++++----------- | |
1 file changed, 13 insertions(+), 11 deletions(-) | |
--- | |
diff --git a/ex.c b/ex.c | |
t@@ -17,7 +17,8 @@ static char *ex_read(char *msg) | |
char c; | |
if (xled) { | |
char *s = led_prompt(msg, ""); | |
- printf("\n"); | |
+ if (s) | |
+ printf("\n"); | |
return s; | |
} | |
sb = sbuf_make(); | |
t@@ -36,10 +37,12 @@ static char *ex_read(char *msg) | |
/* print an output line; ex's output function */ | |
static void ex_show(char *msg) | |
{ | |
- if (xled) | |
+ if (xled) { | |
led_print(msg, -1); | |
- else | |
+ term_chr('\n'); | |
+ } else { | |
printf("%s", msg); | |
+ } | |
} | |
/* read ex command location */ | |
t@@ -447,13 +450,10 @@ static struct excmd { | |
}; | |
/* execute a single ex command */ | |
-void ex_command(char *ln0) | |
+void ex_command(char *ln) | |
{ | |
char cmd[EXLEN]; | |
- char *ln = ln0 ? ln0 : ex_read(":"); | |
int i; | |
- if (!ln) | |
- return; | |
ex_cmd(ln, cmd); | |
for (i = 0; i < LEN(excmds); i++) { | |
if (!strcmp(excmds[i].abbr, cmd) || !strcmp(excmds[i].name, cm… | |
t@@ -461,8 +461,6 @@ void ex_command(char *ln0) | |
break; | |
} | |
} | |
- if (!ln0) | |
- free(ln); | |
lbuf_undomark(xb); | |
} | |
t@@ -471,8 +469,12 @@ void ex(void) | |
{ | |
if (xled) | |
term_init(); | |
- while (!xquit) | |
- ex_command(NULL); | |
+ while (!xquit) { | |
+ char *ln = ex_read(":"); | |
+ if (ln) | |
+ ex_command(ln); | |
+ free(ln); | |
+ } | |
if (xled) | |
term_done(); | |
} |