Magellan Linux

Contents of /trunk/ttmkfdir/patches/ttmkfdir-3.0.9-zlib.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 153 - (show annotations) (download)
Tue May 8 20:52:56 2007 UTC (17 years ago) by niro
File size: 1913 byte(s)
-import

1 --- ttmkfdir-3.0.9/encoding.cpp 2002-12-09 03:52:48.000000000 -0500
2 +++ ttmkfdir-3.0.9/encoding.cpp 2003-09-12 12:32:29.000000000 -0400
3 @@ -2,6 +2,8 @@
4 #include <cstdio>
5 #include <cstdlib>
6 #include <cstring>
7 +#include <unistd.h>
8 +#include <zlib.h>
9 #include "freetype/freetype.h"
10
11 #include "ttmkfdir.h"
12 @@ -32,9 +34,16 @@
13 NextFile (FILE *f, char *name)
14 {
15 char file_name [1024];
16 - char command[1024];
17 + char line_buf [1024];
18 + char tmp_file_name[] = "/tmp/ttmkfdir_XXXXXX";
19 + char inbuf[300000];
20 + FILE *od;
21 + gzFile fd;
22 + int rvalue, tmpfd;
23
24 - if (fscanf (f, "%*s %[^\n]\n", file_name) == 1) {
25 + if (fgets (line_buf, sizeof(line_buf), f) != NULL) {
26 +
27 + sscanf (line_buf, "%*s %[^\n]\n", file_name);
28
29 if (file_name[0] == '/') {
30 name[0] = 0;
31 @@ -44,9 +53,25 @@
32
33 strcat (name, file_name);
34
35 - sprintf (command, "exec %s < %s", (toupper(name[strlen (name) - 1]) == 'Z')
36 - ? "gzip -d" : "cat", name);
37 - return popen (command, "r");
38 + bzero(inbuf, sizeof(inbuf));
39 +
40 + fd = gzopen (name,"rb");
41 + rvalue = gzread (fd, inbuf, sizeof(inbuf));
42 +
43 + tmpfd = mkstemp (tmp_file_name);
44 + if (tmpfd == -1) {
45 + return 0;
46 + }
47 +
48 + od = fdopen (tmpfd,"w");
49 + fputs (inbuf, od);
50 + fflush (od);
51 + fclose (od);
52 +
53 + od = fopen (tmp_file_name,"r");
54 + unlink (tmp_file_name);
55 + return od;
56 +
57 }
58
59 return 0;
60 @@ -75,7 +100,7 @@
61 yyrestart (input);
62 yylex (name, *this);
63
64 - pclose (input);
65 + fclose (input);
66 }
67
68 fclose (f);
69 diff -uNr ttmkfdir-3.0.9.orig/Makefile ttmkfdir-3.0.9/Makefile
70 --- ttmkfdir-3.0.9.orig/Makefile 2003-08-21 17:43:13.000000000 +1000
71 +++ ttmkfdir-3.0.9/Makefile 2003-08-21 17:40:16.000000000 +1000
72 @@ -28,7 +28,7 @@
73 DEBUG=-ggdb
74 CXX=g++
75 CXXFLAGS=-Wall -pedantic $(FREETYPE_INCL) $(DEBUG) $(OPTFLAGS)
76 -LDFLAGS=$(FREETYPE_LIB) $(DEBUG)
77 +LDFLAGS=$(FREETYPE_LIB) $(DEBUG) -lz
78
79 DESTDIR=
80 PREFIX=/usr