05191a
--- ttmkfdir-3.0.9/encoding.cpp	2002-12-09 03:52:48.000000000 -0500
05191a
+++ ttmkfdir-3.0.9/encoding.cpp	2003-09-12 12:32:29.000000000 -0400
05191a
@@ -2,6 +2,8 @@
05191a
 #include <cstdio>
05191a
 #include <cstdlib>
05191a
 #include <cstring>
05191a
+#include <unistd.h>
05191a
+#include <zlib.h>
05191a
 #include "freetype/freetype.h"
05191a
 
05191a
 #include "ttmkfdir.h"
05191a
@@ -32,9 +34,16 @@
05191a
     NextFile (FILE *f, char *name)
05191a
     {
05191a
 	char file_name [1024];
05191a
-	char command[1024];
05191a
+	char line_buf [1024];
05191a
+	char tmp_file_name[] = "/tmp/ttmkfdir_XXXXXX";
05191a
+	char inbuf[300000];
05191a
+	FILE *od;
05191a
+	gzFile fd;
05191a
+	int rvalue, tmpfd;
05191a
 
05191a
-	if (fscanf (f, "%*s %[^\n]\n", file_name) == 1) {
05191a
+	if (fgets (line_buf, sizeof(line_buf), f) != NULL) {
05191a
+
05191a
+	    sscanf (line_buf, "%*s %[^\n]\n", file_name);
05191a
 
05191a
 	    if (file_name[0] == '/') {
05191a
 		name[0] = 0;
05191a
@@ -44,9 +53,25 @@
05191a
 	
05191a
 	    strcat (name, file_name);
05191a
 
05191a
-	    sprintf (command, "exec %s < %s", (toupper(name[strlen (name) - 1]) == 'Z')
05191a
-		     ? "gzip -d" : "cat", name);
05191a
-	    return popen (command, "r");
05191a
+	    bzero(inbuf, sizeof(inbuf));
05191a
+
05191a
+	    fd = gzopen (name,"rb");
05191a
+	    rvalue = gzread (fd, inbuf, sizeof(inbuf));
05191a
+
05191a
+	    tmpfd = mkstemp (tmp_file_name);
05191a
+	    if (tmpfd == -1) {
05191a
+		return 0;
05191a
+	    }
05191a
+
05191a
+	    od = fdopen (tmpfd,"w");
05191a
+	    fputs (inbuf, od);
05191a
+	    fflush (od);
05191a
+	    fclose (od);
05191a
+
05191a
+	    od = fopen (tmp_file_name,"r");
05191a
+	    unlink (tmp_file_name);
05191a
+	    return od;
05191a
+
05191a
 	}
05191a
 
05191a
 	return 0;
05191a
@@ -75,7 +100,7 @@
05191a
 	yyrestart (input);
05191a
 	yylex (name, *this);
05191a
 
05191a
-	pclose (input);
05191a
+	fclose (input);
05191a
     }
05191a
 
05191a
     fclose (f);
05191a
diff -uNr ttmkfdir-3.0.9.orig/Makefile ttmkfdir-3.0.9/Makefile
05191a
--- ttmkfdir-3.0.9.orig/Makefile	2003-08-21 17:43:13.000000000 +1000
05191a
+++ ttmkfdir-3.0.9/Makefile	2003-08-21 17:40:16.000000000 +1000
05191a
@@ -28,7 +28,7 @@
05191a
 DEBUG=-ggdb
05191a
 CXX=g++
05191a
 CXXFLAGS=-Wall -pedantic $(FREETYPE_INCL) $(DEBUG) $(OPTFLAGS)
05191a
-LDFLAGS=$(FREETYPE_LIB) $(DEBUG)
05191a
+LDFLAGS=$(FREETYPE_LIB) $(DEBUG) -lz
05191a
 
05191a
 DESTDIR=
05191a
 PREFIX=/usr