misc/libfreetype/src/lzw/ftzopen.c
author koda
Tue, 04 Dec 2012 03:27:12 +0100
changeset 8217 e3f47a1d6f2b
parent 5172 88f2e05288ba
permissions -rw-r--r--
readd this debug line, commented out, could be useful
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
/*  ftzopen.c                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    FreeType support for .Z compressed files.                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  This optional component relies on NetBSD's zopen().  It should mainly  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  be used to parse compressed PCF fonts, as found with many X11 server   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*  distributions.                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  Copyright 2005, 2006, 2007, 2009 by David Turner.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include "ftzopen.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_INTERNAL_MEMORY_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
  static int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
  ft_lzwstate_refill( FT_LzwState  state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
    FT_ULong  count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
    if ( state->in_eof )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
      return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
    count = FT_Stream_TryRead( state->source,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
                               state->buf_tab,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
                               state->num_bits );  /* WHY? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
    state->buf_size   = (FT_UInt)count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
    state->buf_total += count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
    state->in_eof     = FT_BOOL( count < state->num_bits );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
    state->buf_offset = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
    state->buf_size   = ( state->buf_size << 3 ) - ( state->num_bits - 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    if ( count == 0 )  /* end of file */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
      return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  static FT_Int32
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
  ft_lzwstate_get_code( FT_LzwState  state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    FT_UInt   num_bits = state->num_bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    FT_Int    offset   = state->buf_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    FT_Byte*  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    FT_Int    result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    if ( state->buf_clear                    ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
         offset >= state->buf_size           ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
         state->free_ent >= state->free_bits )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
      if ( state->free_ent >= state->free_bits )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
        state->num_bits  = ++num_bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
        state->free_bits = state->num_bits < state->max_bits
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
                           ? (FT_UInt)( ( 1UL << num_bits ) - 256 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
                           : state->max_free + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
      if ( state->buf_clear )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
        state->num_bits  = num_bits = LZW_INIT_BITS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
        state->free_bits = (FT_UInt)( ( 1UL << num_bits ) - 256 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
        state->buf_clear = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
      if ( ft_lzwstate_refill( state ) < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
        return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
      offset = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    state->buf_offset = offset + num_bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
    p         = &state->buf_tab[offset >> 3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    offset   &= 7;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    result    = *p++ >> offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    offset    = 8 - offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    num_bits -= offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    if ( num_bits >= 8 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
      result   |= *p++ << offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
      offset   += 8;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
      num_bits -= 8;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    if ( num_bits > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
      result |= ( *p & LZW_MASK( num_bits ) ) << offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
  /* grow the character stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
  static int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  ft_lzwstate_stack_grow( FT_LzwState  state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    if ( state->stack_top >= state->stack_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
      FT_Memory  memory = state->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
      FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
      FT_Offset  old_size = state->stack_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
      FT_Offset  new_size = old_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
      new_size = new_size + ( new_size >> 1 ) + 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
      if ( state->stack == state->stack_0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
        state->stack = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
        old_size     = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
      if ( FT_RENEW_ARRAY( state->stack, old_size, new_size ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
        return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
      state->stack_size = new_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
  /* grow the prefix/suffix arrays */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
  static int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
  ft_lzwstate_prefix_grow( FT_LzwState  state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    FT_UInt    old_size = state->prefix_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    FT_UInt    new_size = old_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
    FT_Memory  memory   = state->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
    if ( new_size == 0 )  /* first allocation -> 9 bits */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
      new_size = 512;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
      new_size += new_size >> 2;  /* don't grow too fast */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
     *  Note that the `suffix' array is located in the same memory block
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
     *  pointed to by `prefix'.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
     *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
     *  I know that sizeof(FT_Byte) == 1 by definition, but it is clearer
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
     *  to write it literally.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
     *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
    if ( FT_REALLOC_MULT( state->prefix, old_size, new_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
                          sizeof ( FT_UShort ) + sizeof ( FT_Byte ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    /* now adjust `suffix' and move the data accordingly */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
    state->suffix = (FT_Byte*)( state->prefix + new_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    FT_MEM_MOVE( state->suffix,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
                 state->prefix + old_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
                 old_size * sizeof ( FT_Byte ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
    state->prefix_size = new_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
  ft_lzwstate_reset( FT_LzwState  state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    state->in_eof     = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    state->buf_offset = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
    state->buf_size   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    state->buf_clear  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
    state->buf_total  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    state->stack_top  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    state->num_bits   = LZW_INIT_BITS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
    state->phase      = FT_LZW_PHASE_START;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
  ft_lzwstate_init( FT_LzwState  state,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
                    FT_Stream    source )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
    FT_ZERO( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
    state->source = source;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
    state->memory = source->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    state->prefix      = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
    state->suffix      = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    state->prefix_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    state->stack      = state->stack_0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    state->stack_size = sizeof ( state->stack_0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    ft_lzwstate_reset( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
  ft_lzwstate_done( FT_LzwState  state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
    FT_Memory  memory = state->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
    ft_lzwstate_reset( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
    if ( state->stack != state->stack_0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
      FT_FREE( state->stack );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    FT_FREE( state->prefix );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
    state->suffix = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
    FT_ZERO( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
#define FTLZW_STACK_PUSH( c )                        \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
  FT_BEGIN_STMNT                                     \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    if ( state->stack_top >= state->stack_size &&    \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
         ft_lzwstate_stack_grow( state ) < 0   )     \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
      goto Eof;                                      \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
                                                     \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    state->stack[state->stack_top++] = (FT_Byte)(c); \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
  FT_END_STMNT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
  FT_LOCAL_DEF( FT_ULong )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
  ft_lzwstate_io( FT_LzwState  state,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
                  FT_Byte*     buffer,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
                  FT_ULong     out_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    FT_ULong  result = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
    FT_UInt  old_char = state->old_char;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
    FT_UInt  old_code = state->old_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    FT_UInt  in_code  = state->in_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
    if ( out_size == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    switch ( state->phase )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    case FT_LZW_PHASE_START:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
        FT_Byte   max_bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
        FT_Int32  c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
        /* skip magic bytes, and read max_bits + block_flag */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
        if ( FT_Stream_Seek( state->source, 2 ) != 0               ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
             FT_Stream_TryRead( state->source, &max_bits, 1 ) != 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
          goto Eof;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
        state->max_bits   = max_bits & LZW_BIT_MASK;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
        state->block_mode = max_bits & LZW_BLOCK_MASK;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
        state->max_free   = (FT_UInt)( ( 1UL << state->max_bits ) - 256 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
        if ( state->max_bits > LZW_MAX_BITS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
          goto Eof;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
        state->num_bits = LZW_INIT_BITS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
        state->free_ent = ( state->block_mode ? LZW_FIRST
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
                                              : LZW_CLEAR ) - 256;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
        in_code  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
        state->free_bits = state->num_bits < state->max_bits
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
                           ? (FT_UInt)( ( 1UL << state->num_bits ) - 256 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
                           : state->max_free + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
        c = ft_lzwstate_get_code( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
        if ( c < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
          goto Eof;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
        old_code = old_char = (FT_UInt)c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
        if ( buffer )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
          buffer[result] = (FT_Byte)old_char;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
        if ( ++result >= out_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
        state->phase = FT_LZW_PHASE_CODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
      /* fall-through */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
    case FT_LZW_PHASE_CODE:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
        FT_Int32  c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
        FT_UInt   code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
      NextCode:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
        c = ft_lzwstate_get_code( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
        if ( c < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
          goto Eof;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
        code = (FT_UInt)c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
        if ( code == LZW_CLEAR && state->block_mode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
          /* why not LZW_FIRST-256 ? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
          state->free_ent  = ( LZW_FIRST - 1 ) - 256;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
          state->buf_clear = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
          c = ft_lzwstate_get_code( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
          if ( c < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
            goto Eof;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
          code = (FT_UInt)c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
        in_code = code; /* save code for later */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
        if ( code >= 256U )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
          /* special case for KwKwKwK */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
          if ( code - 256U >= state->free_ent )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
            FTLZW_STACK_PUSH( old_char );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
            code = old_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
          while ( code >= 256U )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
            if ( !state->prefix )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
              goto Eof;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
            FTLZW_STACK_PUSH( state->suffix[code - 256] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
            code = state->prefix[code - 256];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
        old_char = code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
        FTLZW_STACK_PUSH( old_char );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
        state->phase = FT_LZW_PHASE_STACK;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
      /* fall-through */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
    case FT_LZW_PHASE_STACK:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
        while ( state->stack_top > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
          --state->stack_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
          if ( buffer )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
            buffer[result] = state->stack[state->stack_top];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
          if ( ++result == out_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
        /* now create new entry */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
        if ( state->free_ent < state->max_free )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
          if ( state->free_ent >= state->prefix_size &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
               ft_lzwstate_prefix_grow( state ) < 0  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
            goto Eof;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
          FT_ASSERT( state->free_ent < state->prefix_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
          state->prefix[state->free_ent] = (FT_UShort)old_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
          state->suffix[state->free_ent] = (FT_Byte)  old_char;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
          state->free_ent += 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
        old_code = in_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
        state->phase = FT_LZW_PHASE_CODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
        goto NextCode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
    default:  /* state == EOF */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
      ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
    state->old_code = old_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
    state->old_char = old_char;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
    state->in_code  = in_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
  Eof:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
    state->phase = FT_LZW_PHASE_EOF;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
    goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
/* END */