Example #1
0
File: otlgdef.c Project: 8l/inferno
  static void
  otl_caret_value_validate( OTL_Bytes      table,
                            OTL_Validator  valid )
  {
    OTL_Bytes  p = table;

    if ( p + 4 > valid->limit )
      OTL_INVALID_TOO_SHORT;

    format = OTL_NEXT_USHORT( p );
    switch ( format )
    {
      case 1:
      case 2:
        break;

      case 3:
        {
          OTL_Bytes  device;

          p += 2;
          if ( p + 2 > valid->limit )
            OTL_INVALID_TOO_SHORT;

          otl_device_table_validate( table + OTL_PEEK_USHORT( p ) );
        }
        break;

      default:
        OTL_INVALID_DATA;
    }
  }
Example #2
0
  static OTL_Bool
  otl_gsub_lookup1_apply( OTL_Bytes   table,
                          OTL_Parser  parser )
  {
    OTL_Bytes  p = table;
    OTL_Bytes  coverage;
    OTL_UInt   format, gindex, property;
    OTL_Int    index;
    OTL_Bool   subst = 0;

    if ( parser->context_len != 0xFFFF && parser->context_len < 1 )
      goto Exit;

    gindex = otl_parser_get_gindex( parser );

    if ( !otl_parser_check_property( parser, gindex, &property ) )
      goto Exit;

    format   = OTL_NEXT_USHORT(p);
    coverage = table + OTL_NEXT_USHORT(p);
    index    = otl_coverage_lookup( coverage, gindex );

    if ( index >= 0 )
    {
      switch ( format )
      {
        case 1:
          {
            OTL_Int  delta = OTL_NEXT_SHORT(p);

            gindex = ( gindex + delta ) & 0xFFFF;
            otl_parser_replace_1( parser, gindex );
            subst = 1;
          }
          break;

        case 2:
          {
            OTL_UInt  count = OTL_NEXT_USHORT(p);

            if ( (OTL_UInt) index < count )
            {
              p += index*2;
              otl_parser_replace_1( parser, OTL_PEEK_USHORT(p) );
              subst = 1;
            }
          }
          break;

        default:
          ;
      }
    }
  Exit:
    return subst;
  }
Example #3
0
  static OTL_Bool
  otl_gsub_lookup3_apply( OTL_Bytes    table,
                          OTL_Parser   parser )
  {
    OTL_Bytes  p = table;
    OTL_Bytes  coverage, alternates;
    OTL_UInt   format, gindex, index, property;
    OTL_Int    index;
    OTL_Bool   subst = 0;

    OTL_GSUB_Alternate  alternate = parser->alternate;

    if ( context_len != 0xFFFF && context_len < 1 )
      goto Exit;

    if ( alternate == NULL )
      goto Exit;

    gindex = otl_parser_get_gindex( parser );

    if ( !otl_parser_check_property( parser, gindex, &property ) )
      goto Exit;

    p        += 2;  /* skip format */
    coverage  = table + OTL_NEXT_USHORT(p);
    seq_count = OTL_NEXT_USHORT(p);
    index     = otl_coverage_lookup( coverage, gindex );

    if ( (OTL_UInt) index >= seq_count )
      goto Exit;

    p         += index*2;
    alternates = table + OTL_PEEK_USHORT(p);
    p          = alternates;
    count      = OTL_NEXT_USHORT(p);

    gindex = alternate->handler_func(
                 gindex, count, p, alternate->handler_data );

    otl_parser_replace_1( parser, gindex );
    subst = 1;

   Exit:
    return subst;
  }
Example #4
0
  static OTL_Bool
  otl_gsub_lookup2_apply( OTL_Bytes    table,
                          OTL_Parser   parser )
  {
    OTL_Bytes  p = table;
    OTL_Bytes  coverage, sequence;
    OTL_UInt   format, gindex, index, property;
    OTL_Int    index;
    OTL_Bool   subst = 0;

    if ( context_len != 0xFFFF && context_len < 1 )
      goto Exit;

    gindex = otl_parser_get_gindex( parser );

    if ( !otl_parser_check_property( parser, gindex, &property ) )
      goto Exit;

    p        += 2;  /* skip format */
    coverage  = table + OTL_NEXT_USHORT(p);
    seq_count = OTL_NEXT_USHORT(p);
    index     = otl_coverage_lookup( coverage, gindex );

    if ( (OTL_UInt) index >= seq_count )
      goto Exit;

    p       += index*2;
    sequence = table + OTL_PEEK_USHORT(p);
    p        = sequence;
    count    = OTL_NEXT_USHORT(p);

    otl_parser_replace_n( parser, count, p );
    subst = 1;

   Exit:
    return subst;
  }