shithub: libacme

Download patch

ref: 27e08900d5716c2b3bb909fdc6cbe0bcfbb137ee
parent: 0f90115ff87e5866726c8c7d615f8293c39f21c5
author: james palmer <foura@biobuf.link>
date: Mon Jun 7 12:53:34 EDT 2021

awincat: take an fd not a path

--- a/acme.h
+++ b/acme.h
@@ -43,7 +43,7 @@
 
 void	awinctl(AWin *, char *, ...);
 void	awinclear(AWin *);
-int		awincat(AWin *, char *);
+int		awincat(AWin *, int fd);
 void	awinprint(AWin *, char *, ...);
 void	awinerror(AWin *, char *, ...);
 void	awinfatal(AWin *, char *, ...);
--- a/window.c
+++ b/window.c
@@ -104,19 +104,14 @@
 }
 
 int
-awincat(AWin *w, char *file)
+awincat(AWin *w, int fd)
 {
-	int body, fd;
+	int body;
 	char *buf;
 	long n;
 	
 	buf = malloc(8*1024);
 	body = awinfsopen(w, "body", OWRITE);
-	fd = open(file, OREAD);
-	if(fd < 0) {
-		awinerror(w, "awincat read: %r");
-		return -1;
-	}
 		
 	while((n=read(fd, buf, 8*1024)) > 0) {
 		if(write(body, buf, n) != n) {