示例#1
0
void *_table_remove(void)
{
  ATerm table, key;
  int i;
  if(MatchPair(Ttop(), &table, &key))
    {
      lookup_table(i, table);
      ATtableRemove(ST_tables[i], key);
      return NULL;
    }
  return fail_address;
}
示例#2
0
ATbool _table_remove(void)
{
  ATerm table, key;
  int i;
  if(MatchPair(Ttop, &table, &key))
    {
      lookup_table(i, table);
      ATtableRemove(ST_tables[i], key);
      return ATtrue;
    }
  return ATfalse;
}
示例#3
0
void *_table_get(void)
{
  ATerm table, key, value;
  int i;
  if(MatchPair(Ttop(), &table, &key))
    {
      /* ATfprintf(stderr, "<table-get>(%t,%t)\n", table, key); */
      lookup_table(i, table);
      value = ATtableGet(ST_tables[i], key);
      if(value == NULL)
	return fail_address;
      else
	Tset(value);
      return NULL;
    }
  return fail_address;
}
示例#4
0
ATbool _table_get(void)
{
  ATerm table, key, value;
  int i;
  if(MatchPair(Ttop, &table, &key))
    {
      /* ATfprintf(stderr, "<table-get>(%t,%t)\n", table, key); */
      lookup_table(i, table);
      value = ATtableGet(ST_tables[i], key);
      if(value == NULL)
	return ATfalse;
      else
	Tset(value);
      return ATtrue;
    }
  return ATfalse;
}
示例#5
0
static int MatchOne( DaoRegex *self, DaoRgxItem *patt, daoint pos )
{
	DCharState st = { 0, 1, 0 };
	DCharState st2 = { 0, 1, 0 };
	uint_t ch, ch2, b1, b2;
	int i;

	patt->offset = 0;
	patt->count += 1;
	switch( patt->type ){
	case PAT_WBORDER : 
		if( pos == self->start || pos >= self->end ) return 1;
		for(i=1; i <= 4 && (pos-i) >= self->start; ++i){
			st = DString_DecodeChar( self->source + pos - i, self->source + self->end );
			if( i == 1 ) st2 = st;
			if( st.type == i ) break;
		}
		if( st.type == 0 ) st = st2;
		st2 = DString_DecodeChar( self->source + pos, self->source + self->end );
		if( dao_character( st.value ) != dao_character( st2.value ) ) return 1;
		return 0;
	case PAT_ANY :
		if( pos >= self->end ) return 0;
		st = DString_DecodeChar( self->source + pos, self->source + self->end );
		if( pos + st.width > self->end ) st.width = 1;
		patt->offset = st.width;
		return 1;
	case PAT_SPLIT:
	case PAT_BEGIN: case PAT_JOIN: return 1;
	case PAT_START: return (pos == self->start);
	case PAT_END : return (pos >= self->end);
	case PAT_SET  : return MatchSet(  self, patt, pos );
	case PAT_WORD : return MatchWord( self, patt, pos );
	case PAT_PAIR : return MatchPair( self, patt, pos );
	case PAT_PATPAIR : return MatchPatPair( self, patt, pos );
	case PAT_BACKREF: return MatchBackRef( self, patt, pos );
	default : break;
	}
	if( pos >= self->end ) return 0;

	st = DString_DecodeChar( self->source + pos, self->source + self->end );
	if( st.type == 0 ) return 0;

	patt->offset = st.width;
	ch = ch2 = st.value;
	if( sizeof(wchar_t) == 2 && ch > 0xFFFF ) ch = 0; /* for isw*(); */

	switch( patt->type ){
	case 'a' : return iswalpha( ch );
	case 's' : return iswspace( ch );
	case 'k' : return iswcntrl( ch );
	case 'p' : return iswpunct( ch );
	case 'd' : return iswdigit( ch );
	case 'x' : return iswxdigit( ch );
	case 'e' : return dao_cjk( ch2 );
	case 'w' : return dao_character( ch2 );
	case 'c' : return iswlower( ch );
	case 'A' : return ! iswalpha( ch );
	case 'S' : return ! iswspace( ch );
	case 'K' : return ! iswcntrl( ch );
	case 'P' : return ! iswpunct( ch );
	case 'D' : return ! iswdigit( ch );
	case 'X' : return ! iswxdigit( ch );
	case 'E' : return ! dao_cjk( ch2 );
	case 'W' : return ! dao_character( ch2 );
	case 'C' : return iswupper( ch );
	default : return 0;
	}
	return 0;
}