5c537528d1
- fix to not break the read loop on SIGWINCH (#575383)
92 lines
2.2 KiB
Diff
92 lines
2.2 KiB
Diff
examples/fileman.c | 3 ++-
|
|
src/readline.c | 6 ++++--
|
|
src/vi.c | 18 +++++++++++-------
|
|
3 files changed, 17 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/examples/fileman.c b/examples/fileman.c
|
|
index f1d81af..026a4f4 100644
|
|
--- a/examples/fileman.c
|
|
+++ b/examples/fileman.c
|
|
@@ -16,6 +16,7 @@
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
+#include <time.h>
|
|
|
|
/* GNU readline
|
|
#include <readline/readline.h>
|
|
@@ -275,7 +276,7 @@ command_generator (text, state)
|
|
|
|
/* Return the next name which partially matches from the
|
|
command list. */
|
|
- while (name = commands[list_index].name)
|
|
+ while ((name = commands[list_index].name))
|
|
{
|
|
list_index++;
|
|
|
|
diff --git a/src/readline.c b/src/readline.c
|
|
index 842ab44..b692e3f 100644
|
|
--- a/src/readline.c
|
|
+++ b/src/readline.c
|
|
@@ -1270,8 +1270,10 @@ history_truncate_file (const char *filename, int nlines)
|
|
}
|
|
}
|
|
fflush(fp);
|
|
- if((off = ftello(fp)) > 0)
|
|
- (void)ftruncate(fileno(fp), off);
|
|
+ if((off = ftello(fp)) > 0) {
|
|
+ int sink = ftruncate(fileno(fp), off);
|
|
+ (void) sink;
|
|
+ }
|
|
out3:
|
|
fclose(tp);
|
|
out2:
|
|
diff --git a/src/vi.c b/src/vi.c
|
|
index 438aad4..a8e5e85 100644
|
|
--- a/src/vi.c
|
|
+++ b/src/vi.c
|
|
@@ -1004,6 +1004,7 @@ vi_histedit(EditLine *el, int c)
|
|
int status;
|
|
char tempfile[] = "/tmp/histedit.XXXXXXXXXX";
|
|
char *cp;
|
|
+ el_action_t rv = CC_ERROR;
|
|
|
|
if (el->el_state.doingarg) {
|
|
if (vi_to_history_line(el, 0) == CC_ERROR)
|
|
@@ -1014,14 +1015,15 @@ vi_histedit(EditLine *el, int c)
|
|
if (fd < 0)
|
|
return CC_ERROR;
|
|
cp = el->el_line.buffer;
|
|
- write(fd, cp, (size_t)(el->el_line.lastchar - cp));
|
|
- write(fd, "\n", 1);
|
|
+ if (write(fd, cp, (size_t)(el->el_line.lastchar - cp)) < 0
|
|
+ || write(fd, "\n", 1) < 0)
|
|
+ /* FIXME: handle EAGAIN somehow? */
|
|
+ goto fail;
|
|
+
|
|
pid = fork();
|
|
switch (pid) {
|
|
case -1:
|
|
- close(fd);
|
|
- unlink(tempfile);
|
|
- return CC_ERROR;
|
|
+ goto fail;
|
|
case 0:
|
|
close(fd);
|
|
execlp("vi", "vi", tempfile, (char *)NULL);
|
|
@@ -1039,10 +1041,12 @@ vi_histedit(EditLine *el, int c)
|
|
break;
|
|
}
|
|
|
|
+ /* return CC_REFRESH; */
|
|
+ rv = ed_newline(el, 0);
|
|
+fail:
|
|
close(fd);
|
|
unlink(tempfile);
|
|
- /* return CC_REFRESH; */
|
|
- return ed_newline(el, 0);
|
|
+ return rv;
|
|
}
|
|
|
|
/* vi_history_word():
|