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