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