EnglishРусский  

   ..

   arr.c

   arr.h

   arrdata.c

   arrdata.h

   buf.c

   buf.h

   crc.c

   crc.h

   file.c

   file.h

   hash.c

   hash.h

   memory.c

   memory.h

   mix.c

   mix.h

   msg.c

   msg.h

   msglist.c

   msglist.g

   msglist.h

   number.c

   number.h

   str.c

   str.h

   types.h

Данный проект закрыт! Создан новый скриптовый язык с тем же именем. Всё доступно на GitHub.
Также попробуйте нашу open source кроссплатформенную программу для создания и управления скриптами.

Реклама

Инсталлятор CreateInstall
Бесплатные и коммерческие инсталляторы

source\src\common\number.c
  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2006, The Gentee Group. All rights reserved. 
  4 * This file is part of the Gentee open source project - http://www.gentee.com. 
  5 * 
  6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  8 * ACCEPTANCE OF THE AGREEMENT.
  9 *
 10 * ID: number 18.10.06 0.0.A.
 11 *
 12 * Author: Alexey Krivonogov
 13 *
 14 * Summary: This file provides functionality for numbers.
 15 *
 16 ******************************************************************************/
 17 
 18 #include "number.h"
 19 #include "../bytecode/cmdlist.h"
 20 #include "../os/user/defines.h"
 21 
 22 /*-----------------------------------------------------------------------------
 23 *
 24 * ID: num_gethex 19.10.06 0.0.A.
 25 * 
 26 * Summary: Convert hex input string to value
 27 *  
 28 -----------------------------------------------------------------------------*/
 29 
 30 pubyte STDCALL num_gethex( pubyte in, pnumber pnum, uint mode )
 31 {
 32    pubyte  cur = in;
 33    int     len = mode << 1;
 34 
 35    pnum->vlong = 0L;
 36    pnum->type = mode == 8 ? TUlong : TUint;
 37 
 38    while ( _hex[ *cur ] != 0xFF && ( cur - in ) < len )
 39    {
 40       pnum->vlong = ( pnum->vlong << 4 ) + _hex[ *cur ];
 41       cur++;
 42    }
 43    return cur;
 44 }
 45 
 46 /*-----------------------------------------------------------------------------
 47 *
 48 * ID: num_getval 19.10.06 0.0.A.
 49 * 
 50 * Summary: Convert input string to value
 51 *  
 52 -----------------------------------------------------------------------------*/
 53 
 54 pubyte STDCALL num_getval( pubyte in, pnumber pnum )
 55 {
 56    uint    sign = 0;
 57    uint    base = 10;
 58    pubyte  val = _dec;
 59    ubyte   stop;
 60    pubyte  eval;
 61    pubyte  cur = in;
 62 
 63    while ( *cur == '+' || *cur == '-' || *cur == ' ' )
 64    {
 65       if ( *cur == '-' )
 66          sign = !sign;
 67       cur++;
 68    }
 69    if ( _lower[ *( cur + 1 ) ] == 'x' )
 70    {
 71       cur += 2;
 72       base = 16;
 73       val = _hex;
 74    }
 75    else
 76       if ( _lower[ *( cur + 1 ) ] == 'b' )
 77       {
 78          cur += 2;
 79          base = 2;
 80          val = _bin;
 81       }
 82    pnum->vlong = 0L;
 83    pnum->type = sign ? TInt : TUint;
 84    while ( val[ *cur ] != 0xFF )
 85    {
 86       pnum->vlong = pnum->vlong * base + val[ *cur ];
 87       cur++;
 88    }
 89 //   printf("val=%i %c %i\n", pnum->vint, *cur,  val[ *cur ] );
 90    stop = _lower[ *cur ];
 91    if ( stop == 'l' )
 92    {
 93       cur++;
 94       if ( sign )
 95       {
 96          pnum->type = TLong;
 97          pnum->vlong = -(long64)pnum->vlong;
 98       }
 99       else
100          pnum->type = TUlong;
101    }
102    else
103       if ( stop == '.' || stop == 'e' || stop == 'd' || stop == 'f' )
104       {
105          pnum->type = TDouble;
106          pnum->vdouble = strtod( in, &eval );
107          stop = _lower[ *eval ];
108          if ( stop == 'f' )
109          {
110             pnum->type = TFloat;
111             pnum->vfloat = (float)pnum->vdouble;
112          }
113          if ( stop == 'd' || stop == 'f' )
114             eval++;
115          return eval;
116       }
117       else
118       {
119          if ( sign )
120             pnum->vint = -(int)pnum->vint;
121       }
122 
123    return cur;
124 }
125 
126 //--------------------------------------------------------------------------
127 
Редактировать