diff options
Diffstat (limited to 'src/3rdparty/freetype/src/gzip')
-rw-r--r-- | src/3rdparty/freetype/src/gzip/ftgzip.c | 147 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/gzip/inftrees.c | 10 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/gzip/rules.mk | 57 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/gzip/zconf.h | 7 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/gzip/zlib.h | 7 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/gzip/zutil.h | 2 |
6 files changed, 161 insertions, 69 deletions
diff --git a/src/3rdparty/freetype/src/gzip/ftgzip.c b/src/3rdparty/freetype/src/gzip/ftgzip.c index 6f0c515723..2d4200d9fa 100644 --- a/src/3rdparty/freetype/src/gzip/ftgzip.c +++ b/src/3rdparty/freetype/src/gzip/ftgzip.c @@ -8,7 +8,7 @@ /* parse compressed PCF fonts, as found with many X11 server */ /* distributions. */ /* */ -/* Copyright 2002, 2003, 2004, 2005, 2006, 2009 by */ +/* Copyright 2002-2006, 2009-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -32,6 +32,7 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX Gzip_Err_ #define FT_ERR_BASE FT_Mod_Err_Gzip @@ -42,7 +43,7 @@ #ifdef FT_CONFIG_OPTION_PIC #error "gzip code does not support PIC yet" -#endif +#endif #ifdef FT_CONFIG_OPTION_SYSTEM_ZLIB @@ -67,6 +68,15 @@ #undef SLOW #define SLOW 1 /* we can't use asm-optimized sources here! */ +#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ + /* We disable the warning `conversion from XXX to YYY, */ + /* possible loss of data' in order to compile cleanly with */ + /* the maximum level of warnings: zlib is non-FreeType */ + /* code. */ +#pragma warning( push ) +#pragma warning( disable : 4244 ) +#endif /* _MSC_VER */ + /* Urgh. `inflate_mask' must not be declared twice -- C++ doesn't like this. We temporarily disable it and load all necessary header files. */ #define NO_INFLATE_MASK @@ -86,6 +96,10 @@ #include "inflate.c" #include "adler32.c" +#if defined( _MSC_VER ) +#pragma warning( pop ) +#endif + #endif /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */ @@ -107,7 +121,7 @@ { FT_ULong sz = (FT_ULong)size * items; FT_Error error; - FT_Pointer p; + FT_Pointer p = NULL; (void)FT_ALLOC( p, sz ); @@ -194,12 +208,12 @@ /* head[0] && head[1] are the magic numbers; */ /* head[2] is the method, and head[3] the flags */ - if ( head[0] != 0x1f || - head[1] != 0x8b || + if ( head[0] != 0x1F || + head[1] != 0x8B || head[2] != Z_DEFLATED || (head[3] & FT_GZIP_RESERVED) ) { - error = Gzip_Err_Invalid_File_Format; + error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -261,7 +275,7 @@ FT_Stream source ) { z_stream* zstream = &zip->zstream; - FT_Error error = Gzip_Err_Ok; + FT_Error error = FT_Err_Ok; zip->stream = stream; @@ -293,7 +307,7 @@ if ( inflateInit2( zstream, -MAX_WBITS ) != Z_OK || zstream->next_in == NULL ) - error = Gzip_Err_Invalid_File_Format; + error = FT_THROW( Invalid_File_Format ); Exit: return error; @@ -364,7 +378,7 @@ size = stream->read( stream, stream->pos, zip->input, FT_GZIP_BUFFER_SIZE ); if ( size == 0 ) - return Gzip_Err_Invalid_Stream_Operation; + return FT_THROW( Invalid_Stream_Operation ); } else { @@ -373,7 +387,7 @@ size = FT_GZIP_BUFFER_SIZE; if ( size == 0 ) - return Gzip_Err_Invalid_Stream_Operation; + return FT_THROW( Invalid_Stream_Operation ); FT_MEM_COPY( zip->input, stream->base + stream->pos, size ); } @@ -382,7 +396,7 @@ zstream->next_in = zip->input; zstream->avail_in = size; - return Gzip_Err_Ok; + return FT_Err_Ok; } @@ -390,7 +404,7 @@ ft_gzip_file_fill_output( FT_GZipFile zip ) { z_stream* zstream = &zip->zstream; - FT_Error error = 0; + FT_Error error = FT_Err_Ok; zip->cursor = zip->buffer; @@ -415,12 +429,12 @@ { zip->limit = zstream->next_out; if ( zip->limit == zip->cursor ) - error = Gzip_Err_Invalid_Stream_Operation; + error = FT_THROW( Invalid_Stream_Operation ); break; } else if ( err != Z_OK ) { - error = Gzip_Err_Invalid_Stream_Operation; + error = FT_THROW( Invalid_Stream_Operation ); break; } } @@ -434,7 +448,7 @@ ft_gzip_file_skip_output( FT_GZipFile zip, FT_ULong count ) { - FT_Error error = Gzip_Err_Ok; + FT_Error error = FT_Err_Ok; FT_ULong delta; @@ -571,7 +585,7 @@ old_pos = stream->pos; if ( !FT_Stream_Seek( stream, stream->size - 4 ) ) { - result = (FT_ULong)FT_Stream_ReadLong( stream, &error ); + result = FT_Stream_ReadULong( stream, &error ); if ( error ) result = 0; @@ -582,15 +596,25 @@ } + /* documentation is in ftgzip.h */ + FT_EXPORT_DEF( FT_Error ) FT_Stream_OpenGzip( FT_Stream stream, FT_Stream source ) { FT_Error error; - FT_Memory memory = source->memory; - FT_GZipFile zip; + FT_Memory memory; + FT_GZipFile zip = NULL; + if ( !stream || !source ) + { + error = FT_THROW( Invalid_Stream_Handle ); + goto Exit; + } + + memory = source->memory; + /* * check the header right now; this prevents allocating un-necessary * objects when we don't need them @@ -628,7 +652,7 @@ if ( zip_size != 0 && zip_size < 40 * 1024 ) { - FT_Byte* zip_buff; + FT_Byte* zip_buff = NULL; if ( !FT_ALLOC( zip_buff, zip_size ) ) @@ -656,7 +680,7 @@ ft_gzip_file_io( zip, 0, NULL, 0 ); FT_FREE( zip_buff ); } - error = 0; + error = FT_Err_Ok; } } @@ -670,7 +694,69 @@ return error; } -#else /* !FT_CONFIG_OPTION_USE_ZLIB */ + + /* documentation is in ftgzip.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Gzip_Uncompress( FT_Memory memory, + FT_Byte* output, + FT_ULong* output_len, + const FT_Byte* input, + FT_ULong input_len ) + { + z_stream stream; + int err; + + + /* check for `input' delayed to `inflate' */ + + if ( !memory || ! output_len || !output ) + return FT_THROW( Invalid_Argument ); + + /* this function is modeled after zlib's `uncompress' function */ + + stream.next_in = (Bytef*)input; + stream.avail_in = (uInt)input_len; + + stream.next_out = output; + stream.avail_out = (uInt)*output_len; + + stream.zalloc = (alloc_func)ft_gzip_alloc; + stream.zfree = (free_func) ft_gzip_free; + stream.opaque = memory; + + err = inflateInit2( &stream, MAX_WBITS ); + if ( err != Z_OK ) + return FT_THROW( Invalid_Argument ); + + err = inflate( &stream, Z_FINISH ); + if ( err != Z_STREAM_END ) + { + inflateEnd( &stream ); + if ( err == Z_OK ) + err = Z_BUF_ERROR; + } + else + { + *output_len = stream.total_out; + + err = inflateEnd( &stream ); + } + + if ( err == Z_MEM_ERROR ) + return FT_THROW( Out_Of_Memory ); + + if ( err == Z_BUF_ERROR ) + return FT_THROW( Array_Too_Large ); + + if ( err == Z_DATA_ERROR ) + return FT_THROW( Invalid_Table ); + + return FT_Err_Ok; + } + + +#else /* !FT_CONFIG_OPTION_USE_ZLIB */ FT_EXPORT_DEF( FT_Error ) FT_Stream_OpenGzip( FT_Stream stream, @@ -679,7 +765,24 @@ FT_UNUSED( stream ); FT_UNUSED( source ); - return Gzip_Err_Unimplemented_Feature; + return FT_THROW( Unimplemented_Feature ); + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Gzip_Uncompress( FT_Memory memory, + FT_Byte* output, + FT_ULong* output_len, + const FT_Byte* input, + FT_ULong input_len ) + { + FT_UNUSED( memory ); + FT_UNUSED( output ); + FT_UNUSED( output_len ); + FT_UNUSED( input ); + FT_UNUSED( input_len ); + + return FT_THROW( Unimplemented_Feature ); } #endif /* !FT_CONFIG_OPTION_USE_ZLIB */ diff --git a/src/3rdparty/freetype/src/gzip/inftrees.c b/src/3rdparty/freetype/src/gzip/inftrees.c index ef53652168..56f52b1701 100644 --- a/src/3rdparty/freetype/src/gzip/inftrees.c +++ b/src/3rdparty/freetype/src/gzip/inftrees.c @@ -115,16 +115,16 @@ uIntf *v /* working area: values in order of bit length */ uInt f; /* i repeats in table every f entries */ int g; /* maximum code length */ int h; /* table level */ - register uInt i; /* counter, current code */ - register uInt j; /* counter */ - register int k; /* number of bits in current code */ + uInt i; /* counter, current code */ + uInt j; /* counter */ + int k; /* number of bits in current code */ int l; /* bits per table (returned in m) */ uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */ - register uIntf *p; /* pointer into c[], b[], or v[] */ + uIntf *p; /* pointer into c[], b[], or v[] */ inflate_huft *q; /* points to current table */ struct inflate_huft_s r; /* table entry for structure assignment */ inflate_huft *u[BMAX]; /* table stack */ - register int w; /* bits before this table == (l * h) */ + int w; /* bits before this table == (l * h) */ uInt x[BMAX+1]; /* bit offsets, then code stack */ uIntf *xp; /* pointer into x */ int y; /* number of dummy codes added */ diff --git a/src/3rdparty/freetype/src/gzip/rules.mk b/src/3rdparty/freetype/src/gzip/rules.mk index d2a43a6a89..37cd991765 100644 --- a/src/3rdparty/freetype/src/gzip/rules.mk +++ b/src/3rdparty/freetype/src/gzip/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2002, 2003 by +# Copyright 2002, 2003, 2013 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -27,49 +27,52 @@ else endif -# gzip support sources (i.e., C files) +# gzip support sources # -GZIP_DRV_SRC := $(GZIP_DIR)/ftgzip.c - -# gzip support headers +# All source and header files get loaded by `ftgzip.c' only if SYTEM_ZLIB is +# not defined (regardless whether we have a `single' or a `multi' build). +# However, it doesn't harm if we add everything as a dependency +# unconditionally. # -GZIP_DRV_H := +GZIP_DRV_SRCS := $(GZIP_DIR)/adler32.c \ + $(GZIP_DIR)/infblock.c \ + $(GZIP_DIR)/infblock.h \ + $(GZIP_DIR)/infcodes.c \ + $(GZIP_DIR)/infcodes.h \ + $(GZIP_DIR)/inffixed.h \ + $(GZIP_DIR)/inflate.c \ + $(GZIP_DIR)/inftrees.c \ + $(GZIP_DIR)/inftrees.h \ + $(GZIP_DIR)/infutil.c \ + $(GZIP_DIR)/infutil.h \ + $(GZIP_DIR)/zconf.h \ + $(GZIP_DIR)/zlib.h \ + $(GZIP_DIR)/zutil.c \ + $(GZIP_DIR)/zutil.h # gzip driver object(s) # -# GZIP_DRV_OBJ_M is used during `multi' builds -# GZIP_DRV_OBJ_S is used during `single' builds -# -ifeq ($(SYSTEM_ZLIB),) - GZIP_DRV_OBJ_M := $(GZIP_DRV_SRC:$(GZIP_DIR)/%.c=$(OBJ_DIR)/%.$O) -else - GZIP_DRV_OBJ_M := $(OBJ_DIR)/ftgzip.$O -endif -GZIP_DRV_OBJ_S := $(OBJ_DIR)/ftgzip.$O - -# gzip support source file for single build +# GZIP_DRV_OBJ is used during both `single' and `multi' builds # -GZIP_DRV_SRC_S := $(GZIP_DIR)/ftgzip.c +GZIP_DRV_OBJ := $(OBJ_DIR)/ftgzip.$O -# gzip support - single object +# gzip main source file # -$(GZIP_DRV_OBJ_S): $(GZIP_DRV_SRC_S) $(GZIP_DRV_SRC) $(FREETYPE_H) \ - $(GZIP_DRV_H) - $(GZIP_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(GZIP_DRV_SRC_S)) +GZIP_DRV_SRC := $(GZIP_DIR)/ftgzip.c -# gzip support - multiple objects +# gzip support - object # -$(OBJ_DIR)/%.$O: $(GZIP_DIR)/%.c $(FREETYPE_H) $(GZIP_DRV_H) - $(GZIP_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) +$(GZIP_DRV_OBJ): $(GZIP_DRV_SRC) $(GZIP_DRV_SRCS) $(FREETYPE_H) + $(GZIP_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(GZIP_DRV_SRC)) # update main driver object lists # -DRV_OBJS_S += $(GZIP_DRV_OBJ_S) -DRV_OBJS_M += $(GZIP_DRV_OBJ_M) +DRV_OBJS_S += $(GZIP_DRV_OBJ) +DRV_OBJS_M += $(GZIP_DRV_OBJ) # EOF diff --git a/src/3rdparty/freetype/src/gzip/zconf.h b/src/3rdparty/freetype/src/gzip/zconf.h index bdaf57e300..3abf0ba03b 100644 --- a/src/3rdparty/freetype/src/gzip/zconf.h +++ b/src/3rdparty/freetype/src/gzip/zconf.h @@ -5,11 +5,6 @@ /* @(#) $Id$ */ -#if defined(__ARMCC__) || defined(__CC_ARM) -/* Ultra ugly hack that convinces RVCT to use the systems zlib */ -#include <stdapis/zconf.h> -#else /* defined(__ARMCC__) || defined(__CC_ARM) */ - #ifndef _ZCONF_H #define _ZCONF_H @@ -287,5 +282,3 @@ typedef uLong FAR uLongf; #endif #endif /* _ZCONF_H */ - -#endif /* defined(__ARMCC__) || defined(__CC_ARM) */ diff --git a/src/3rdparty/freetype/src/gzip/zlib.h b/src/3rdparty/freetype/src/gzip/zlib.h index 0f98fdcbd3..50d0d3f146 100644 --- a/src/3rdparty/freetype/src/gzip/zlib.h +++ b/src/3rdparty/freetype/src/gzip/zlib.h @@ -28,11 +28,6 @@ (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). */ -#if defined(__ARMCC__) || defined(__CC_ARM) -/* Ultra ugly hack that convinces RVCT to use the systems zlib */ -#include <stdapis/zlib.h> -#else /* defined(__ARMCC__) || defined(__CC_ARM) */ - #ifndef _ZLIB_H #define _ZLIB_H @@ -833,5 +828,3 @@ ZEXTERN(int) inflateInit2_ OF((z_streamp strm, int windowBits, #endif #endif /* _ZLIB_H */ - -#endif /* defined(__ARMCC__) || defined(__CC_ARM) */ diff --git a/src/3rdparty/freetype/src/gzip/zutil.h b/src/3rdparty/freetype/src/gzip/zutil.h index 1949270998..c9688cd9c0 100644 --- a/src/3rdparty/freetype/src/gzip/zutil.h +++ b/src/3rdparty/freetype/src/gzip/zutil.h @@ -182,7 +182,7 @@ typedef unsigned long ulg; #endif /* Diagnostic functions */ -#if defined(DEBUG) && !defined(_WIN32_WCE) +#ifdef DEBUG # include <stdio.h> extern int z_verbose; extern void z_error OF((char *m)); |