⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t1parse.c

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 C
📖 第 1 页 / 共 2 页
字号:
      base = cur;    }  }  /* read exponent, if any */  if ( *cur == 'e' || *cur == 'E' )  {    cur++;    base = cur;    error = parse_integer( base, limit, &exponent );    if (error) goto Fail;    /* now check that exponent is within 'correct bounds' */    /* i.e. between -6 and 6                              */    if ( exponent < -6 || exponent > 6 )      goto Fail;  }  /* now adjust integer value and exponent for fractional part */  while ( num_frac > 0 )  {    number_int *= 10;    exponent   --;    num_frac--;  }  number_int += num_frac;  /* skip point if any, read fractional part */  if ( cur+1 < limit )  {    if (*cur  }  /* now compute scaled float value */  /* XXXXX : incomplete !!!         */#endif  Fail:    FT_ERROR(( "T1.parse_float : syntax error !\n" ));    return T1_Err_Syntax_Error;  }  static  T1_Error  parse_integer( T1_Byte*  base,                           T1_Byte*  limit,                           T1_Long*  result )  {    T1_Byte*  cur;    /* the lexical analyser accepts floats as well as integers */    /* now, check that we really have an int in this token     */    cur = base;    while ( cur < limit )    {      T1_Byte  c = *cur++;      if ( c == '.' || c == 'e' || c == 'E' )        goto Float_Number;    }    /* now read the number's value */    return parse_int( base, limit, result );  Float_Number:    /* We really have a float there, simply call parse_float in this */    /* case with a scale of '10' to perform round..                */    {      T1_Error error;      error = parse_float( base, limit, 10, result );      if (!error)      {        if (*result >= 0) *result = (*result+5)/10;      /* round value */                    else  *result = -((5-*result)/10);      }      return error;    }  }  LOCAL_FUNC  T1_Long  CopyInteger( T1_Parser*  parser )  {    T1_Long   sum   = 0;    T1_Token* token = parser->args++;    if ( token->kind == tok_number )    {      T1_Byte*  base  = parser->tokenizer->base + token->start;      T1_Byte*  limit = base + token->len;      /* now read the number's value */      parser->error = parse_integer( base, limit, &sum );      return sum;    }    FT_ERROR(( "T1.CopyInteger : number expected\n" ));    parser->args--;    parser->error = T1_Err_Syntax_Error;    return 0;  }  LOCAL_FUNC  T1_Bool   CopyBoolean( T1_Parser*  parser )  {    T1_Error  error  = T1_Err_Ok;    T1_Bool   result = 0;    T1_Token* token  = parser->args++;    if ( token->kind == tok_keyword )    {      if ( token->kind2 == key_false )        result = 0;      else if ( token->kind2 == key_true )        result = !0;      else        goto Fail;    }    else    {      Fail:        FT_ERROR(( "T1.CopyBoolean : syntax error, 'false' or 'true' expected\n" ));        error = T1_Err_Syntax_Error;    }    parser->error = error;    return result;  }  LOCAL_FUNC  T1_Long   CopyFloat( T1_Parser*  parser,                       T1_Int      scale )  {    T1_Error  error;    T1_Long   sum = 0;    T1_Token* token = parser->args++;    if ( token->kind == tok_number )    {      T1_Byte*  base  = parser->tokenizer->base + token->start;      T1_Byte*  limit = base + token->len;      error = parser->error = parse_float( base, limit, scale, &sum );      if (error) goto Fail;      return sum;    }  Fail:    FT_ERROR(( "T1.CopyFloat : syntax error !\n" ));    parser->error = T1_Err_Syntax_Error;    return 0;  }  LOCAL_FUNC  void  CopyBBox( T1_Parser*  parser,                  T1_BBox*    bbox )  {    T1_Token* token = parser->args++;    T1_Int    n;    T1_Error  error;    if ( token->kind == tok_program ||         token->kind == tok_array   )    {      /* get rid of '['/']', or '{'/'}' */      T1_Byte*  base  = parser->tokenizer->base + token->start + 1;      T1_Byte*  limit = base + token->len - 1;      T1_Byte*  cur;      T1_Byte*  start;      /* read each parameter independently */      cur = base;      for ( n = 0; n < 4; n++ )      {        T1_Long*  result;        /* skip whitespace */        while (cur < limit && *cur == ' ') cur++;        /* skip numbers */        start = cur;        while (cur < limit && *cur != ' ') cur++;        /* compute result address */        switch (n)        {          case 0 : result = &bbox->xMin; break;          case 1 : result = &bbox->yMin; break;          case 2 : result = &bbox->xMax; break;          default: result = &bbox->yMax;        }        error = parse_integer( start, cur, result );        if (error) goto Fail;      }      parser->error = 0;      return;    }  Fail:    FT_ERROR(( "T1.CopyBBox : syntax error !\n" ));    parser->error = T1_Err_Syntax_Error;  }  LOCAL_FUNC  void  CopyMatrix( T1_Parser*  parser,                    T1_Matrix*  matrix )  {    T1_Token* token = parser->args++;    T1_Error  error;    if ( token->kind == tok_array )    {      /* get rid of '[' and ']' */      T1_Byte*  base  = parser->tokenizer->base + token->start + 1;      T1_Byte*  limit = base + token->len - 1;      T1_Byte*  cur;      T1_Byte*  start;      T1_Int    n;      /* read each parameter independently */      cur = base;      for ( n = 0; n < 4; n++ )      {        T1_Long*  result;        /* skip whitespace */        while (cur < limit && *cur == ' ') cur++;        /* skip numbers */        start = cur;        while (cur < limit && *cur != ' ') cur++;        /* compute result address */        switch (n)        {          case 0 : result = &matrix->xx; break;          case 1 : result = &matrix->xy; break;          case 2 : result = &matrix->yx; break;          default: result = &matrix->yy;        }        error = parse_float( start, cur, 65536000, result );        if (error) goto Fail;      }      parser->error = 0;      return;    }  Fail:    FT_ERROR(( "T1.CopyMatrix : syntax error !\n" ));    parser->error = T1_Err_Syntax_Error;  }  LOCAL_FUNC  void  CopyArray( T1_Parser*  parser,                   T1_Byte*    num_elements,                   T1_Short*   elements,                   T1_Int      max_elements )  {    T1_Token* token = parser->args++;    T1_Error  error;    if ( token->kind == tok_array   ||         token->kind == tok_program )   /* in the case of MinFeature */    {      /* get rid of '['/']', or '{'/'}' */      T1_Byte*  base  = parser->tokenizer->base + token->start + 1;      T1_Byte*  limit = base + token->len - 2;      T1_Byte*  cur;      T1_Byte*  start;      T1_Int    n;      /* read each parameter independently */      cur = base;      for ( n = 0; n < max_elements; n++ )      {        T1_Long  result;        /* test end of string */        if (cur >= limit)          break;        /* skip whitespace */        while (cur < limit && *cur == ' ') cur++;        /* end of list ? */        if (cur >= limit)          break;        /* skip numbers */        start = cur;        while (cur < limit && *cur != ' ') cur++;        error = parse_integer( start, cur, &result );        if (error) goto Fail;        *elements ++ = (T1_Short)result;      }      if (num_elements)        *num_elements = (T1_Byte)n;      parser->error = 0;      return;    }  Fail:    FT_ERROR(( "T1.CopyArray : syntax error !\n" ));    parser->error = T1_Err_Syntax_Error;  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -