You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.9 KiB

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