misc/libfreetype/src/psaux/psconv.c
author koda
Mon, 25 Apr 2011 01:46:54 +0200
changeset 5172 88f2e05288ba
permissions -rw-r--r--
aaand let's add freetype as well while we are at it other smaller changes
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
/*  psconv.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
/*    Some convenience conversions (body).                                 */
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
/*  Copyright 2006, 2008, 2009 by                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  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
    11
/*  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
    12
/*  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
    13
/*  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
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
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
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_INTERNAL_POSTSCRIPT_AUX_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include "psconv.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include "psauxerr.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
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
  /* The following array is used by various functions to quickly convert */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
  /* digits (both decimal and non-decimal) into numbers.                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#if 'A' == 65
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
  /* ASCII */
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
  static const FT_Char  ft_char_table[128] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
    /* 0x00 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
     0,  1,  2,  3,  4,  5,  6,  7,  8,  9, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
    -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
    25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
    -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
    25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  /* no character >= 0x80 can represent a valid number */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
#define OP  >=
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
#endif /* 'A' == 65 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
#if 'A' == 193
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
  /* EBCDIC */
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 const FT_Char  ft_char_table[128] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    /* 0x80 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
    -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
    -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
     0,  1,  2,  3,  4,  5,  6,  7,  8,  9, -1, -1, -1, -1, -1, -1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
  };
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
  /* no character < 0x80 can represent a valid number */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
#define OP  <
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
#endif /* 'A' == 193 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
  FT_LOCAL_DEF( FT_Int )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
  PS_Conv_Strtol( FT_Byte**  cursor,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
                  FT_Byte*   limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
                  FT_Int     base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    FT_Byte*  p = *cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
    FT_Int    num = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    FT_Bool   sign = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    if ( p == limit || base < 2 || base > 36 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    if ( *p == '-' || *p == '+' )
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
      sign = FT_BOOL( *p == '-' );
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++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
      if ( p == limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
        return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
    for ( ; p < limit; p++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
      FT_Char  c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
      if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
      c = ft_char_table[*p & 0x7f];
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
      if ( c < 0 || c >= base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
        break;
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
      num = num * base + c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
    if ( sign )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
      num = -num;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    *cursor = p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    return num;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
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
  FT_LOCAL_DEF( FT_Int )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
  PS_Conv_ToInt( FT_Byte**  cursor,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
                 FT_Byte*   limit )
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
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
    FT_Byte*  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    FT_Int    num;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    num = PS_Conv_Strtol( cursor, limit, 10 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    p   = *cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    if ( p < limit && *p == '#' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
      *cursor = p + 1;
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
      return PS_Conv_Strtol( cursor, limit, num );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
      return num;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
  FT_LOCAL_DEF( FT_Fixed )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
  PS_Conv_ToFixed( FT_Byte**  cursor,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
                   FT_Byte*   limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
                   FT_Int     power_ten )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    FT_Byte*  p = *cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    FT_Fixed  integral;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
    FT_Long   decimal = 0, divider = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    FT_Bool   sign = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    if ( p == limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    if ( *p == '-' || *p == '+' )
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
      sign = FT_BOOL( *p == '-' );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
      p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      if ( p == limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
        return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
    if ( *p != '.' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
      integral = PS_Conv_ToInt( &p, limit ) << 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
      integral = 0;
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
    /* read the decimal part */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
    if ( p < limit && *p == '.' )
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
      p++;
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
      for ( ; p < limit; p++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
        FT_Char  c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
        if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
        c = ft_char_table[*p & 0x7f];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
        if ( c < 0 || c >= 10 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
          break;
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
        if ( !integral && power_ten > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
          power_ten--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
          decimal = decimal * 10 + c;
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
        else
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
          if ( divider < 10000000L )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
            decimal = decimal * 10 + c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
            divider *= 10;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
        }
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
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    /* read exponent, if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    if ( p + 1 < limit && ( *p == 'e' || *p == 'E' ) )
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
      p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
      power_ten += PS_Conv_ToInt( &p, limit );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    while ( power_ten > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
      integral *= 10;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
      decimal  *= 10;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
      power_ten--;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    while ( power_ten < 0 )
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
      integral /= 10;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
      divider  *= 10;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
      power_ten++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
    }
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
    if ( decimal )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
      integral += FT_DivFix( decimal, divider );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
    if ( sign )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
      integral = -integral;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    *cursor = p;
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
    return integral;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
  }
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
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
  FT_LOCAL_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
  PS_Conv_StringDecode( FT_Byte**  cursor,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
                        FT_Byte*   limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
                        FT_Byte*   buffer,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
                        FT_Offset  n )
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_Byte*  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
    FT_UInt   r = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
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
    for ( p = *cursor; r < n && p < limit; p++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
      FT_Byte  b;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
      if ( *p != '\\' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
        buffer[r++] = *p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
        continue;
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
      p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
      switch ( *p )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
      case 'n':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
        b = '\n';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
      case 'r':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
        b = '\r';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
      case 't':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
        b = '\t';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
      case 'b':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
        b = '\b';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
      case 'f':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
        b = '\f';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
      case '\r':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
        p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
        if ( *p != '\n' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
          b = *p;
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
          break;
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
        /* no break */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
      case '\n':
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
        if ( IS_PS_DIGIT( *p ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
          b = *p - '0';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
          p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
          if ( IS_PS_DIGIT( *p ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
            b = b * 8 + *p - '0';
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
            p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
            if ( IS_PS_DIGIT( *p ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
              b = b * 8 + *p - '0';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
            else
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
              buffer[r++] = b;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
              b = *p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
            }
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
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
            buffer[r++] = b;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
            b = *p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
          b = *p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
        break;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
      buffer[r++] = b;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
    }
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
    *cursor = p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
    return r;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
#endif /* 0 */
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
  FT_LOCAL_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
  PS_Conv_ASCIIHexDecode( FT_Byte**  cursor,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
                          FT_Byte*   limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
                          FT_Byte*   buffer,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
                          FT_Offset  n )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
    FT_Byte*  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
    FT_UInt   r   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
    FT_UInt   w   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
    FT_UInt   pad = 0x01;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
    n *= 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
#if 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    p  = *cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
    if ( n > (FT_UInt)( limit - p ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
      n = (FT_UInt)( limit - p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
    /* we try to process two nibbles at a time to be as fast as possible */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
    for ( ; r < n; r++ )
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
      FT_UInt  c = p[r];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
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 ( IS_PS_SPACE( c ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
        continue;
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
      if ( c OP 0x80 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
      c = ft_char_table[c & 0x7F];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
      if ( (unsigned)c >= 16 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
      pad = ( pad << 4 ) | c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
      if ( pad & 0x100 )
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
        buffer[w++] = (FT_Byte)pad;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
        pad         = 0x01;
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
    }
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
    if ( pad != 0x01 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
      buffer[w++] = (FT_Byte)( pad << 4 );
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
    *cursor = p + r;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
    return w;
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
#else /* 0 */
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
    for ( r = 0; r < n; r++ )
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
      FT_Char  c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
      if ( IS_PS_SPACE( *p ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
      if ( *p OP 0x80 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
      c = ft_char_table[*p & 0x7f];
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
      if ( (unsigned)c >= 16 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
      if ( r & 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
        *buffer = (FT_Byte)(*buffer + c);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
        buffer++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
        *buffer = (FT_Byte)(c << 4);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
      r++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
    *cursor = p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
    return ( r + 1 ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
#endif /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
  FT_LOCAL_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
  PS_Conv_EexecDecode( FT_Byte**   cursor,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
                       FT_Byte*    limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
                       FT_Byte*    buffer,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
                       FT_Offset   n,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
                       FT_UShort*  seed )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
    FT_Byte*  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
    FT_UInt   r;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
    FT_UInt   s = *seed;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
#if 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
    p = *cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
    if ( n > (FT_UInt)(limit - p) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
      n = (FT_UInt)(limit - p);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
    for ( r = 0; r < n; r++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
      FT_UInt  val = p[r];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
      FT_UInt  b   = ( val ^ ( s >> 8 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
      s         = ( (val + s)*52845U + 22719 ) & 0xFFFFU;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
      buffer[r] = (FT_Byte) b;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
    *cursor = p + n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
    *seed   = (FT_UShort)s;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
#else /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
    for ( r = 0, p = *cursor; r < n && p < limit; r++, p++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
      FT_Byte  b = (FT_Byte)( *p ^ ( s >> 8 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
      s = (FT_UShort)( ( *p + s ) * 52845U + 22719 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
      *buffer++ = b;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
    *cursor = p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
    *seed   = s;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
#endif /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
    return r;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
/* END */