Lines 1-11
Link Here
|
1 |
--- encoding.cpp.orig Tue Mar 12 15:40:09 2002 |
1 |
--- encoding.cpp.orig Wed Jul 19 11:30:05 2006 |
2 |
+++ encoding.cpp Sun Mar 21 22:33:00 2004 |
2 |
+++ encoding.cpp Wed Jul 19 11:30:28 2006 |
3 |
@@ -2,7 +2,7 @@ |
3 |
@@ -2,7 +2,9 @@ |
4 |
#include <cstdio> |
4 |
#include <cstdio> |
5 |
#include <cstdlib> |
5 |
#include <cstdlib> |
6 |
#include <cstring> |
6 |
#include <cstring> |
7 |
-#include "freetype/freetype.h" |
7 |
-#include "freetype/freetype.h" |
|
|
8 |
+#include <unistd.h> |
9 |
+#include <zlib.h> |
8 |
+#include <ft2build.h> |
10 |
+#include <ft2build.h> |
9 |
|
11 |
|
10 |
#include "ttmkfdir.h" |
12 |
#include "ttmkfdir.h" |
11 |
#include "encoding.h" |
13 |
#include "encoding.h" |
|
|
14 |
@@ -32,9 +34,16 @@ |
15 |
NextFile (FILE *f, char *name) |
16 |
{ |
17 |
char file_name [1024]; |
18 |
- char command[1024]; |
19 |
+ char line_buf [1024]; |
20 |
+ char tmp_file_name[] = "/tmp/ttmkfdir_XXXXXX"; |
21 |
+ char inbuf[300000]; |
22 |
+ FILE *od; |
23 |
+ gzFile fd; |
24 |
+ int rvalue, tmpfd; |
25 |
|
26 |
- if (fscanf (f, "%*s %[^\n]\n", file_name) == 1) { |
27 |
+ if (fgets (line_buf, sizeof(line_buf), f) != NULL) { |
28 |
+ |
29 |
+ sscanf (line_buf, "%*s %[^\n]\n", file_name); |
30 |
|
31 |
if (file_name[0] == '/') { |
32 |
name[0] = 0; |
33 |
@@ -44,9 +53,25 @@ |
34 |
|
35 |
strcat (name, file_name); |
36 |
|
37 |
- sprintf (command, "exec %s < %s", (toupper(name[strlen (name) - 1]) == 'Z') |
38 |
- ? "gzip -d" : "cat", name); |
39 |
- return popen (command, "r"); |
40 |
+ bzero(inbuf, sizeof(inbuf)); |
41 |
+ |
42 |
+ fd = gzopen (name,"rb"); |
43 |
+ rvalue = gzread (fd, inbuf, sizeof(inbuf)); |
44 |
+ |
45 |
+ tmpfd = mkstemp (tmp_file_name); |
46 |
+ if (tmpfd == -1) { |
47 |
+ return 0; |
48 |
+ } |
49 |
+ |
50 |
+ od = fdopen (tmpfd,"w"); |
51 |
+ fputs (inbuf, od); |
52 |
+ fflush (od); |
53 |
+ fclose (od); |
54 |
+ |
55 |
+ od = fopen (tmp_file_name,"r"); |
56 |
+ unlink (tmp_file_name); |
57 |
+ return od; |
58 |
+ |
59 |
} |
60 |
|
61 |
return 0; |
62 |
@@ -75,7 +100,7 @@ |
63 |
yyrestart (input); |
64 |
yylex (name, *this); |
65 |
|
66 |
- pclose (input); |
67 |
+ fclose (input); |
68 |
} |
69 |
|
70 |
fclose (f); |
71 |
@@ -97,7 +122,7 @@ |
72 |
|
73 |
NumericMapping *m = new NumericMapping (size, b->mapdata.platform, b->mapdata.encoding); |
74 |
|
75 |
- for (int i = 0; i < size; i++) |
76 |
+ for (unsigned int i = 0; i < size; i++) |
77 |
(*m)[i] = b->mapdata.mappingtable[i]; |
78 |
|
79 |
AddMapping (m); |