patches with some tiny fixes for wily and 9libs

Tommy Pettersson <[email protected]> Tue, 30 Nov 2004 23:37:04 +0100
Newsgroups gmane.editors.wily
Message-ID <[email protected]>
I've been hacking on wily some more.  Oh no!!, I hear people
scream.  ;-)  Relax, no more features ... this time.

Patches are against 9libs-1.0 and wily-9libs 0.13.41.


A simple one for 9libs, a typo:

diff -rN -u diff-old/9libs-1.0/libframe/frinsert.c diff-new/9libs-1.0/libframe/frinsert.c
--- diff-old/9libs-1.0/libframe/frinsert.c	Tue Nov 30 22:35:55 2004
+++ diff-new/9libs-1.0/libframe/frinsert.c	Tue Nov 30 22:35:27 2004
@@ -133,7 +133,7 @@
 	 * Find point where old and new x's line up
 	 * Invariants:
 	 *	pt0 is where the next box (b, n0) is now
-	 *	pt1 is where it will be after then insertion
+	 *	pt1 is where it will be after the insertion
 	 * If pt1 goes off the rectangle, we can toss everything from there on
 	 */
 	for(b = &f->box[n0],npts=0;



The function error() doesn't terminate debug output to stderr
with a new line, so multiple messages are hard to read.

diff -rN -u diff-old/wily-9libs/wily/util.c diff-new/wily-9libs/wily/util.c
--- diff-old/wily-9libs/wily/util.c	Tue Nov 30 22:35:55 2004
+++ diff-new/wily-9libs/wily/util.c	Tue Nov 30 22:35:27 2004
@@ -351,6 +351,7 @@
 	va_start(args,fmt);
 	vfprintf(stderr, fmt, args);
 	va_end(args);
+	fprintf(stderr, "\n");
 }
 
 /* Error we cannot recover from */



Compilation with assertions fails because of a misnamed
variable.

diff -rN -u diff-old/wily-9libs/wily/win.c diff-new/wily-9libs/wily/win.c
--- diff-old/wily-9libs/wily/win.c	Tue Nov 30 22:35:55 2004
+++ diff-new/wily-9libs/wily/win.c	Tue Nov 30 22:35:27 2004
@@ -34,7 +34,7 @@
 win_clone(Tile *win) {
 	Text *tag, *body;
 	
-	assert(ISWIN(w));
+	assert(ISWIN(win));
 	
 	tag = view_text(win->tag);
 	body = view_text(win->body);



I have rewritten text_fd(), since it had a path of execution
where the file descriptors where opened but never closed.

diff -rN -u diff-old/wily-9libs/wily/text2.c diff-new/wily-9libs/wily/text2.c
--- diff-old/wily-9libs/wily/text2.c	Tue Nov 30 22:35:55 2004
+++ diff-new/wily-9libs/wily/text2.c	Tue Nov 30 22:35:27 2004
@@ -137,20 +137,18 @@
 text_fd(Text *t, Range sel)
 {
 	char	*file = tmpnam(0);
-	int	fd;
-	int	input;
+	int	fd = -1;
+	int	input = -1;
 
 	if ((fd = open(file, O_WRONLY|O_CREAT, 0600)) < 0) {
 		perror("open temp file");
-		(void) unlink(file);
-		return(-1);
+		goto fail;
 	}
 
 	/* Now for the child's end.  Do it quick so we can unlink. */
 	if ((input = open(file, O_RDONLY)) < 0) {
 		perror("open temp file");
-		(void) unlink(file);
-		return(-1);
+		goto fail;
 	}
 
 	if (unlink(file) < 0)
@@ -163,12 +161,21 @@
 	 */
 	if (text_write_range(t, sel, fd)) {
 		perror("write temp file");
-		return(-1);
+		goto fail;
 	}
 	if (close(fd) <  0)
 		perror("close temp file");
 
 	return input;
+
+ fail:
+	if (input >= 0)
+		(void) close(input);
+	if (fd >= 0) {
+		(void) close(fd);
+		(void) unlink(file);
+	}
+	return(-1);
 }
 
 /****************************************************



Oh my, here is a new feature after all.  Really it's an old
feature coming back.  It was in wily pre-9libs, and I liked it.
Click in a window or column tag, B21 on Font (in the global
tag) and see the font in the window/column toggle.  It's still
possible to sweep a font name and B21 to choose that font.
Toggle happens when the arg is "", as it is after a click.

diff -rN -u diff-old/wily-9libs/wily/view.c diff-new/wily-9libs/wily/view.c
--- diff-old/wily-9libs/wily/view.c	Tue Nov 30 22:35:55 2004
+++ diff-new/wily-9libs/wily/view.c	Tue Nov 30 22:35:27 2004
@@ -217,7 +217,7 @@
 }
 
 /*
- * Change v's font.  If 'arg' is not null, use it, otherwise
+ * Change v's font.  If 'arg' is not null or empty, use it, otherwise
  * toggle between Fonts 'fixed' and 'font'
  */
 void
@@ -226,7 +226,7 @@
 	FontUse *oldfont = v->font;
 	FontUse *newfont;
 
-	if (arg != 0) {
+	if ((arg != 0) && (*arg != 0)) {
 		newfont = findfont(arg);
 		if (!newfont)
 			return;



-- 
Tommy Pettersson <[email protected]>