/////////////////////////////////////////////////
// Translation-Evaluation-Scores
void TEvalScore::Tokenize(const TStr& Str, TStrV& TokenV) {
    TStr LcStr = GetLc(Str);
    TokenV.Clr(); TChA WordChA; 
    const int Chs = LcStr.Len();
    for (int ChN = 0; ChN < Chs; ChN++) {
        const char Ch = LcStr[ChN];
        if (IsChar(Ch)) { 
            WordChA += Ch; 
        } else if (!WordChA.Empty()) {
            TokenV.Add(WordChA);
            WordChA.Clr();
        }
    }        
}
	virtual void FireGameEvent_Internal( IGameEvent *event )
	{
		CBasePlayer *pLocalPlayer = CBasePlayer::GetLocalPlayer();
		if ( !pLocalPlayer ) return;
		int localid = pLocalPlayer->entindex();

		if ( Q_strcmp( event->GetName(), "round_end" ) == 0 && event->GetBool("showreport") )
		{
			// We must also win the round, so filter out round loss events
			if ( !(event->GetInt("winnerid") == localid) )
			{
				// Make sure we can achieve this next round
				if ( IsChar() ) SetCharForRound( true );
				return;
			}
		}
		CGEAchBaseAwardType::FireGameEvent_Internal( event );
	}
Esempio n. 3
0
Wtroka CWordBase::GetOriginalText() const
{
    //затычка для дурацких символов, порождаемых для <BR> после конца предложения
    if (m_typ == Punct && IsChar(m_txt, 'W'))
        return Wtroka();

    size_t quoteCount = (m_bHasOpenQuote ? 1 : 0) + (m_bHasCloseQuote ? 1 : 0);

    // optimize most frequent case
    if (quoteCount == 0)
        return m_txt;

    Wtroka res;
    res.reserve(m_txt.size() + quoteCount);
    if (m_bHasOpenQuote)
        res += m_bSingleOpenQuote ? SINGLE_QUOTE_CHAR : DOUBLE_QUOTE_CHAR;
    res += m_txt;
    if (m_bHasCloseQuote)
        res += m_bSingleCloseQuote ? SINGLE_QUOTE_CHAR : DOUBLE_QUOTE_CHAR;
    return res;
}
Esempio n. 4
0
// !quotedValue means Translation String
BString* Scanner::ScanLiteral(bool quotedValue, int separator)
{
	BString* literal = new BString();
	
	while (true) {
		int ch = GetCurrentChar();
		if (ch == '<') {
			if (!ScanHexadecimalSubstring(literal)) {
				delete literal;
				return NULL;
			}
		} else if (quotedValue && (ch == kLf || ch == kCr)) {
			// nothing to do
		} else if (!quotedValue && ch == '"') {
			// translation string allows '"'
		} else if (!IsChar(ch) || ch == separator) {
			return literal;
		}
		literal->Append(ch, 1);
		NextChar();
	}
}
Esempio n. 5
0
static int prSerialPort_Put(struct VMGlobals *g, int numArgsPushed)
{
	PyrSlot *args = g->sp - 1;

	PyrSlot* self = args+0;
	SerialPort* port = (SerialPort*)getSerialPort(self);
	if (port == 0) return errFailed;

	PyrSlot* src = args+1;

	int val;
	if (IsChar(src)) {
		val = slotRawChar(src);
	} else {
		int err = slotIntVal(src, &val);
		if (err) return err;
	}

	bool res = port->put(val & 0xFF);
	SetBool(self, res);

	return errNone;
}
Esempio n. 6
0
int main()
{
	int s[40],i;
	char ch[40];
	printf("\n\t\t输入含x的表达式:4x^3+6#,一定要用'#'结尾,然后按Enter键!\n");
	scanf("%s",ch);
	for(i=0;i<strlen(ch);i++)
	{
	if(!IsChar(ch[i]))
	{
		printf("\n Input Error!");
		exit(0);
	}
	}
	for(i=0;i<strlen(ch);i++)
	{
		Process(s,ch[i]);
	}
	printf("求导结果为:");
	for(i=0;i<n;i++)
	{
		if(s[i]==-2)
		{
			i=n;
		}
		else if(s[i]==-1)
		{
			printf("%c",s[++i]);
		}
		else 
			printf("%d",s[i]);
	}
	printf("\n");
	getchar();
	getchar();
 	return 0;
}
Esempio n. 7
0
NS_IMETHODIMP
UIEvent::GetIsChar(bool* aIsChar)
{
  *aIsChar = IsChar();
  return NS_OK;
}
Esempio n. 8
0
bool CWordBase::IsCloseBracket() const
{
    return m_typ == Punct && IsChar(m_txt, ')');
}
Esempio n. 9
0
bool CWordBase::IsColon() const
{
    return m_typ == Punct && IsChar(m_txt, ':');
}
Esempio n. 10
0
bool CWordBase::IsOpenBracket() const
{
    return m_typ == Punct && IsChar(m_txt, '(');
}
Esempio n. 11
0
bool CWordBase::IsPoint() const
{
    return m_bIsPunct && IsChar(m_txt, '.');
}
Esempio n. 12
0
bool CWordBase::IsComma() const
{
    return m_bIsPunct && IsChar(m_txt, ',');
}
Esempio n. 13
0
bool CWordBase::IsInterrogationMark() const
{
    return m_bIsPunct && IsChar(m_txt, '?');
}
Esempio n. 14
0
bool CWordBase::IsExclamationMark() const
{
    return m_bIsPunct && IsChar(m_txt, '!');
}
Esempio n. 15
0
void do_set(COMMAND_ARGS)
{
	/*
	 *  on_msg checks:
	 */
	Chan	*chan;
	UniVar	*univar,*varval;
	char	tmp[MSGLEN];
	char	*pp,*channel,*name;
	int	n,which,i,sz,limit,uaccess;

	/*
	 *
	 */
	channel = get_channel2(to,&rest);
	chan = find_channel_ny(channel);
	name = chop(&rest);

	/*
	 *  empty args, its "set" or "set #channel"
	 */
	if (!name)
	{
		if (!chan)
		{
			to_user(from,ERR_CHAN,channel);
			return;
		}

		if (!CurrentDCC)
			return;

		i = CHANSET_SIZE;
		limit = SIZE_VARS - 1;
		univar = current->setting;
		*tmp = 0;
		if ((uaccess = get_useraccess(from,GLOBAL_CHANNEL)))
			to_user(from,str_underline("Global settings"));
second_pass:
		for(;i<limit;i++)
		{
			if (uaccess < VarName[i].uaccess)
				continue;

			varval = (IsProc(i)) ? current->setting[i].proc_var : &univar[i];

			sz = Strlen2(tmp,VarName[i].name);

			if (IsStr(i))
			{
				sz += (varval->str_var) ? strlen(varval->str_var) : 7;
			}

			if (sz > 58)
			{
				to_user(from,FMT_PLAIN,tmp);
				*tmp = 0;
			}

			if (IsInt(i))
			{
				pp = tolowercat(tmp,VarName[i].name);
				sprintf(pp,(IsChar(i)) ? "=`%c' " : "=%i ",varval->int_var);
			}
			else
			if (IsStr(i))
			{
				pp = tolowercat(tmp,VarName[i].name);
				sprintf(pp,(varval->str_var) ? "=\"%s\" " : "=(unset) ",varval->str_var);
			}
			else
			if (IsTog(i))
			{
				pp = Strcat(tmp,(varval->int_var) ? "+" : "-");
				pp = tolowercat(pp,VarName[i].name);
				pp[0] = ' ';
				pp[1] = 0;
			}
		}
		if (*tmp && tmp[1])
			to_user(from,FMT_PLAIN,tmp);

		if (limit != CHANSET_SIZE)
		{
			to_user(from,"\037Channel settings: %s\037",(chan) ? chan->name : rest);
			i = 0;
			limit = CHANSET_SIZE;
			univar = chan->setting;
			*tmp = 0;
			uaccess = get_useraccess(from,(chan) ? chan->name : rest);
			goto second_pass;
		}
		return;
	}

	/*
	 *  alter a setting
	 */
	if ((which = find_setting(name)) == -1)
	{
set_usage:
		usage(from);	/* usage for CurrentCmd->name */
		return;
	}

	if ((which < CHANSET_SIZE) && *channel != '*')
	{
		if (!chan)
		{
			to_user(from,ERR_CHAN,channel);
			return;
		}
		/*
		 *  its a channel setting
		 */
		channel = chan->name;
		varval = &chan->setting[which];
	}
	else
	{
		/*
		 *  its a global setting
		 */
		channel = MATCH_ALL;
		varval = &current->setting[which];
	}

	if (VarName[which].uaccess > get_authaccess(from,channel))
		return;

	/*
	 *  Check each type and process `rest' if needed.
	 */
	n = 0;
	if (IsChar(which))
	{
		if (rest[1])
			goto set_usage;
	}
	else
	if (IsNum(which))
	{
		if (IsTog(which))
		{
			if (!Strcasecmp(rest,"ON"))
			{
				n = 1;
				goto num_data_ok;
			}
			else
			if (!Strcasecmp(rest,"OFF"))
			{
				/* n is 0 by default */
				goto num_data_ok;
			}
		}
		n = a2i((rest = chop(&rest)));
		if (errno || n < VarName[which].min || n > VarName[which].max)
		{
			to_user(from,"Possible values are %i through %i",VarName[which].min,VarName[which].max);
			return;
		}
	}
num_data_ok:
	/*
	 *
	 */
	if ((which < CHANSET_SIZE) && *channel == '*')
	{
		for(chan=current->chanlist;chan;chan=chan->next)
		{
			if (IsNum(which))
			{
				chan->setting[which].int_var = n;
			}
			else
			if (IsStr(which))
			{
				Free((char**)&chan->setting[which].str_var);
				if (*rest)
				{
					set_mallocdoer(do_set);
					chan->setting[which].str_var = Strdup(rest);
				}
			}
		}
		channel = "(all channels)";
	}
	else
	{
		if (IsProc(which))
			varval = varval->proc_var;

		if (IsChar(which))
			varval->char_var = *rest;
		else
		if (IsNum(which))
			varval->int_var = n;
		else
		{
			if (varval->str_var)
				Free((char**)&varval->str_var);
			if (*rest)
			{
				set_mallocdoer(do_set);
				varval->str_var = Strdup(rest);
			}
		}
	}
	to_user(from,"Var: %s   On: %s   Set to: %s",VarName[which].name,
		(which >= CHANSET_SIZE) ? "(global)" : channel,(*rest) ? rest : NULLSTR);
	if (VarName[which].func)
		VarName[which].func(&VarName[which]);
}
Esempio n. 16
0
void ec_set(char *from, char *to)
{
	Chan	*chan;
	UniVar	*varval;
	char	num[20];
	char	*src;
	int	which,uaccess;

	src = ec_src;
	while(*src && *src != ')')
		src++;
	if (*src != ')')
		return;
	*(src++) = 0;

	if ((which = find_setting(ec_src)) >= 0)
	{
		if (which >= CHANSET_SIZE)
		{
			uaccess = get_useraccess(from,ANY_CHANNEL);
			varval = &current->setting[which];
		}
		else
		if ((chan = find_channel_ny(to)))
		{
			uaccess = get_useraccess(from,to);
			varval = &chan->setting[which];
		}
		else
		{
			nobo_strcpy("(unknown channel)");
			return;
		}
		if (uaccess < VarName[which].uaccess)
			return;

		if (IsProc(which))
			varval = varval->proc_var;

		if (IsChar(which))
		{
			num[0] = varval->char_var;
			num[1] = 0;
			nobo_strcpy(num);
		}
		else
		if (IsInt(which))
		{
			sprintf(num,"%i",varval->int_var);
			nobo_strcpy(num);
		}
		else
		if (IsTog(which))
		{
			nobo_strcpy((varval->int_var) ? "on" : "off");
		}
		else
		if (IsStr(which))
		{
			nobo_strcpy(nullstr(varval->str_var));
		}
	}
	else
	{
		nobo_strcpy("(unknown setting)");
	}
	ec_src = src;
}