Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 145ed2bcded6e2e19f9a48dbb56c1843 > files > 2

libedit-3.0-3.20110227cvs.fc15.src.rpm

diff -durp libedit-20110227-3.0.orig/examples/fileman.c libedit-20110227-3.0/examples/fileman.c
--- libedit-20110227-3.0.orig/examples/fileman.c	2010-04-22 13:13:17.000000000 -0600
+++ libedit-20110227-3.0/examples/fileman.c	2011-03-24 15:48:02.492809146 -0600
@@ -279,7 +279,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 -durp libedit-20110227-3.0.orig/examples/wtc1.c libedit-20110227-3.0/examples/wtc1.c
--- libedit-20110227-3.0.orig/examples/wtc1.c	2010-04-22 13:13:17.000000000 -0600
+++ libedit-20110227-3.0/examples/wtc1.c	2011-03-24 15:48:02.493809075 -0600
@@ -60,7 +60,7 @@ complete(EditLine *el, int ch)
 	char *buf, *bptr;
 	const LineInfoW *lf = el_wline(el);
 	int len, mblen, i;
-	unsigned char res;
+	unsigned char res = CC_NORM;
 
 	/* Find the last word */
 	for (ptr = lf->cursor -1; !iswspace(*ptr) && ptr > lf->buffer; --ptr)
diff -durp libedit-20110227-3.0.orig/src/readline.c libedit-20110227-3.0/src/readline.c
--- libedit-20110227-3.0.orig/src/readline.c	2011-02-26 15:42:59.000000000 -0700
+++ libedit-20110227-3.0/src/readline.c	2011-03-24 15:48:02.500808588 -0600
@@ -1280,8 +1280,8 @@ history_truncate_file (const char *filen
 		}
 	}
 	fflush(fp);
-	if((off = ftello(fp)) > 0)
-		(void)ftruncate(fileno(fp), off);
+	if((off = ftello(fp)) > 0 && ftruncate(fileno(fp), off) < 0)
+		ret = errno;
 out3:
 	fclose(tp);
 out2:
diff -durp libedit-20110227-3.0.orig/src/vi.c libedit-20110227-3.0/src/vi.c
--- libedit-20110227-3.0.orig/src/vi.c	2011-02-26 15:42:59.000000000 -0700
+++ libedit-20110227-3.0/src/vi.c	2011-03-24 15:48:02.501808516 -0600
@@ -1009,6 +1009,7 @@ vi_histedit(EditLine *el, Int c)
 	char *cp;
 	size_t len;
 	Char *line;
+	el_action_t rv = CC_ERROR;
 
 	if (el->el_state.doingarg) {
 		if (vi_to_history_line(el, 0) == CC_ERROR)
@@ -1036,16 +1037,14 @@ vi_histedit(EditLine *el, Int c)
 	ct_wcstombs(cp, line, TMP_BUFSIZ - 1);
 	cp[TMP_BUFSIZ - 1] = '\0';
 	len = strlen(cp);
-	write(fd, cp, len);
-	write(fd, "\n", 1);
+	if (write(fd, cp, len) < 0 || write(fd, "\n", 1) < 0)
+		/* FIXME: handle EAGAIN somehow? */
+		goto fail;
+
 	pid = fork();
 	switch (pid) {
 	case -1:
-		close(fd);
-		unlink(tempfile);
-		el_free(cp);
-                el_free(line);
-		return CC_ERROR;
+		goto fail;
 	case 0:
 		close(fd);
 		execlp("vi", "vi", tempfile, (char *)NULL);
@@ -1067,15 +1066,17 @@ vi_histedit(EditLine *el, Int c)
 			len = 0;
                 el->el_line.cursor = el->el_line.buffer;
                 el->el_line.lastchar = el->el_line.buffer + len;
-		el_free(cp);
-                el_free(line);
 		break;
 	}
 
+	/* return CC_REFRESH; */
+	rv = ed_newline(el, 0);
+fail:
 	close(fd);
 	unlink(tempfile);
-	/* return CC_REFRESH; */
-	return ed_newline(el, 0);
+	el_free(cp);
+	el_free(line);
+	return rv;
 }
 
 /* vi_history_word():