* 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'.
This commit is contained in:
Werner Lemberg 2004-02-16 09:38:05 +00:00
parent 9472e23a6a
commit d1d2b458e9
3 changed files with 85 additions and 9 deletions

View File

@ -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

View File

@ -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 );

View File

@ -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;