* builds/unix/ftsystem.c: Include errno.h. (ft_close_stream): Renamed to... (ft_close_stream_by_munmap): This. (ft_close_stream_by_free): New function. (FT_Stream_Open): Use fallback method if mmap fails. Use proper function for closing the stream. * src/type1/t1load.c (parse_dict): Initialize `start_binary'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
diff --git a/ChangeLog b/ChangeLog
index cd198bc..ead214a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-02-14 Masatake YAMATO <jet@gyve.org>
+
+ * builds/unix/ftsystem.c: Include errno.h.
+ (ft_close_stream): Renamed to...
+ (ft_close_stream_by_munmap): This.
+ (ft_close_stream_by_free): New function.
+ (FT_Stream_Open): Use fallback method if mmap fails.
+ Use proper function for closing the stream.
+
+2004-02-14 Werner Lemberg <wl@gnu.org>
+
+ * src/type1/t1load.c (parse_dict): Initialize `start_binary'.
+
2004-02-13 Robert Etheridge <roberte@stcc.cc.tx.us>
* src/type42/t42objs.c (T42_Face_Init), src/type1/t1objs.c
diff --git a/builds/unix/ftsystem.c b/builds/unix/ftsystem.c
index 4ae260c..c7a34ad 100644
--- a/builds/unix/ftsystem.c
+++ b/builds/unix/ftsystem.c
@@ -4,7 +4,7 @@
/* */
/* Unix-specific FreeType low-level system interface (body). */
/* */
-/* Copyright 1996-2001, 2002 by */
+/* Copyright 1996-2001, 2002, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -67,6 +67,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
/*************************************************************************/
@@ -182,16 +183,16 @@
/*************************************************************************/
/* */
/* <Function> */
- /* ft_close_stream */
+ /* ft_close_stream_by_munmap */
/* */
/* <Description> */
- /* The function to close a stream. */
+ /* The function to close a stream which is opened by mmap. */
/* */
/* <Input> */
/* stream :: A pointer to the stream object. */
/* */
FT_CALLBACK_DEF( void )
- ft_close_stream( FT_Stream stream )
+ ft_close_stream_by_munmap( FT_Stream stream )
{
munmap( (MUNMAP_ARG_CAST)stream->descriptor.pointer, stream->size );
@@ -201,6 +202,28 @@
}
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* ft_close_stream_by_free */
+ /* */
+ /* <Description> */
+ /* The function to close a stream which is created by ft_alloc. */
+ /* */
+ /* <Input> */
+ /* stream :: A pointer to the stream object. */
+ /* */
+ FT_CALLBACK_DEF( void )
+ ft_close_stream_by_free( FT_Stream stream )
+ {
+ ft_free( NULL, stream->descriptor.pointer );
+
+ stream->descriptor.pointer = NULL;
+ stream->size = 0;
+ stream->base = 0;
+ }
+
+
/* documentation is in ftobjs.h */
FT_EXPORT_DEF( FT_Error )
@@ -252,11 +275,49 @@
file,
0 );
- if ( (long)stream->base == -1 )
+ if ( (long)stream->base != -1 )
+ stream->close = ft_close_stream_by_munmap;
+ else
{
+ ssize_t total_read_count;
+
+
FT_ERROR(( "FT_Stream_Open:" ));
FT_ERROR(( " could not `mmap' file `%s'\n", filepathname ));
- goto Fail_Map;
+
+ stream->base = ft_alloc( NULL, stream->size );
+
+ if ( !stream->base )
+ {
+ FT_ERROR(( "FT_Stream_Open:" ));
+ FT_ERROR(( " could not `alloc' memory\n" ));
+ goto Fail_Map;
+ }
+
+ total_read_count = 0;
+ do {
+ ssize_t read_count;
+
+
+ read_count = read( file,
+ stream->base + total_read_count,
+ stream->size - total_read_count );
+
+ if ( ( read_count == -1 ) )
+ {
+ if ( errno == EINTR )
+ continue;
+
+ FT_ERROR(( "FT_Stream_Open:" ));
+ FT_ERROR(( " error while `read'ing file `%s'\n", filepathname ));
+ goto Fail_Read;
+ }
+
+ total_read_count += read_count;
+
+ } while ( total_read_count != stream->size );
+
+ stream->close = ft_close_stream_by_free;
}
close( file );
@@ -264,8 +325,7 @@
stream->descriptor.pointer = stream->base;
stream->pathname.pointer = (char*)filepathname;
- stream->close = ft_close_stream;
- stream->read = 0;
+ stream->read = 0;
FT_TRACE1(( "FT_Stream_Open:" ));
FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
@@ -273,6 +333,9 @@
return FT_Err_Ok;
+ Fail_Read:
+ ft_free( NULL, stream->base );
+
Fail_Map:
close( file );
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index c5bc2a8..3065443 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -1504,7 +1504,7 @@
FT_Byte* keyword_flags )
{
T1_Parser parser = &loader->parser;
- FT_Byte *limit, *start_binary;
+ FT_Byte *limit, *start_binary = NULL;
FT_Bool have_integer = 0;