示例#1
0
pubyte copymacros( pubyte dest, pubyte src )
{
    while ( *src )
    {
        if ( !mem_cmpign( src, "%GNAME%", 7 ))
        {
            dest += mem_copyuntilzero( dest, gname ) - 1;
            src += 7;
        }
        else if ( !mem_cmpign( src, "%GPATH%", 7 ))
        {
            dest += mem_copyuntilzero( dest, gpath ) - 1;
            src += 7;
        }
        else if ( !mem_cmpign( src, "%EXEPATH%", 9 ))
        {
            dest += mem_copyuntilzero( dest, exepath ) - 1;
            src += 9;
        }
        else
            *dest++ = *src++;
    }
    *dest++ = 0;
    return dest;
}
示例#2
0
文件: hash.c 项目: Refandler/gentee
phashitem  STDCALL _hash_find( phash ph, pubyte name, uint create )
{
   pubyte  ptr = name;
   ushort  val = 0;
   uint    len = 0;   
   ubyte   shift = 0;
   ushort  nameoff;
   phashitem  phi = 0, prev = 0;

   // Вычисляем хэш-значение строки
   while ( *ptr )
   {
      if ( ph->ignore )
         val += (( ushort )_lower[ *ptr++ ] ) << shift;
      else
         val += (( ushort )*ptr++ ) << shift;
      if ( ++shift > 7 )
         shift = 0;
      len++;
   }
// получаем номер в хэш-таблице
   val &= HASH_SIZE - 1;
   phi = prev = ( phashitem )arr_getuint( &ph->values, val );
   nameoff = sizeof( hashitem ) + ph->isize;
   while ( phi )
   {
//         printf("CMp <%s><%s> %i %i\n", name, ( pubyte )phi + nameoff, len, phi->len );
      if ( len == phi->len && !( ph->ignore ? 
                  mem_cmpign( name, ( pubyte )phi + nameoff, len ) : 
                  mem_cmp( name, ( pubyte )phi + nameoff, len )))
         // нашли совпадение
         return phi;
      phi = ( phashitem )phi->next;
   }
   if ( create )
   {
      // Будем добавлять элемент в таблицу имен
      phi = ( phashitem )mem_alloc( nameoff + len + 1 );
      phi->len = ( ushort )len;
      phi->next = ( pvoid )prev;
      phi->id = arr_count( &ph->names );
      mem_zero( ( pubyte )phi + sizeof( hashitem ), ph->isize );
      mem_copy( ( pubyte )phi + nameoff, name, len + 1 );
//      printf("Append %x %s\n", phi, name );
      arr_appendnum( &ph->names, ( uint )phi );
      arr_setuint( &ph->values, val, ( uint )phi );
   }
   return phi;
}
示例#3
0
文件: str.c 项目: Refandler/gentee
uint   STDCALL str_isequalign( pstr left, pstr right )
{
   return left->use == right->use && 
           !mem_cmpign( str_ptr( left ), str_ptr( right ), left->use );
}