예제 #1
0
파일: parse.c 프로젝트: kamilion/charybdis
/* remove_unknown()
 *
 * inputs	- client who gave us message, supposed sender, buffer
 * output	-
 * side effects	- kills issued for clients, squits for servers
 */
static void
remove_unknown(struct Client *client_p, const char *lsender, char *lbuffer)
{
	int slen = strlen(lsender);
	char sid[4];
	struct Client *server;

	/* meepfoo	is a nickname (ignore)
	 * #XXXXXXXX	is a UID (KILL)
	 * #XX		is a SID (SQUIT)
	 * meep.foo	is a server (SQUIT)
	 */
	if((IsDigit(lsender[0]) && slen == 3) ||
	   (strchr(lsender, '.') != NULL))
	{
		sendto_realops_snomask(SNO_DEBUG, L_ALL,
				     "Unknown prefix (%s) from %s, Squitting %s",
				     lbuffer, client_p->name, lsender);

		sendto_one(client_p,
			   ":%s SQUIT %s :(Unknown prefix (%s) from %s)",
			   get_id(&me, client_p), lsender,
			   lbuffer, client_p->name);
	}
	else if(!IsDigit(lsender[0]))
		;
	else if(slen != 9)
		sendto_realops_snomask(SNO_DEBUG, L_ALL,
				     "Invalid prefix (%s) from %s",
				     lbuffer, client_p->name);
	else
	{
		memcpy(sid, lsender, 3);
		sid[3] = '\0';
		server = find_server(NULL, sid);
		if (server != NULL && server->from == client_p)
			sendto_one(client_p, ":%s KILL %s :%s (Unknown Client)",
					get_id(&me, client_p), lsender, me.name);
	}
}
예제 #2
0
// Get the name of first volume. Return the leftmost digit of volume number.
wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,size_t MaxSize,bool NewNumbering)
{
  if (FirstName!=VolName)
    wcsncpyz(FirstName,VolName,MaxSize);
  wchar *VolNumStart=FirstName;
  if (NewNumbering)
  {
    wchar N='1';

    // From the rightmost digit of volume number to the left.
    for (wchar *ChPtr=GetVolNumPart(FirstName);ChPtr>FirstName;ChPtr--)
      if (IsDigit(*ChPtr))
      {
        *ChPtr=N; // Set the rightmost digit to '1' and others to '0'.
        N='0';
      }
      else
        if (N=='0')
        {
          VolNumStart=ChPtr+1; // Store the position of leftmost digit in volume number.
          break;
        }
  }
  else
  {
    // Old volume numbering scheme. Just set the extension to ".rar".
    SetExt(FirstName,L"rar",MaxSize);
    VolNumStart=GetExt(FirstName);
  }
  if (!FileExist(FirstName))
  {
    // If the first volume, which name we just generated, is not exist,
    // check if volume with same name and any other extension is available.
    // It can help in case of *.exe or *.sfx first volume.
    wchar Mask[NM];
    wcsncpyz(Mask,FirstName,ASIZE(Mask));
    SetExt(Mask,L"*",ASIZE(Mask));
    FindFile Find;
    Find.SetMask(Mask);
    FindData FD;
    while (Find.Next(&FD))
    {
      Archive Arc;
      if (Arc.Open(FD.Name,0) && Arc.IsArchive(true) && Arc.FirstVolume)
      {
        wcsncpyz(FirstName,FD.Name,MaxSize);
        break;
      }
    }
  }
  return VolNumStart;
}
예제 #3
0
Stack<Error>* Corrector::CheckExpression(Lexema *input) {
	int i = 0;
	int count_bracket = 0;
	while (input[i].GetType() != Type_Lexems::terminal) {
		if (IsDigit(input[i])) {
			if(IsDigitRight(input[i]) == false){
				AddError(input[i].GetPosition(), "Ошибка в числе. Позиция ошибки: ");
			}
		}
		if (IsBinaryOperaion(input[i]))
		{
			if (input[i+1].GetType() == Type_Lexems::terminal)
			{
				AddError(input[i].GetPosition(), "Ошибка в бинарной операции. Позиция ошибки: ");
			}
			if (input[i + 1].GetType() != Type_Lexems::terminal && IsBinaryOperaion(input[i+1])) {
				AddError(input[i].GetPosition(), "Ошибка в повторе бинарной операций. Позиция ошибки: ");
			}
			if (input[i + 1].GetType() != Type_Lexems::terminal && input[i + 1].GetType() == Type_Lexems::close_bracket) {
				AddError(input[i].GetPosition(), "Ошибка в бинарной операции, пропущен аргумент. Позиция ошибки: ");
			}
		}
		if (IsOperationUnary(input[i]))
		{
			if (input[i + 1].GetType() == Type_Lexems::terminal) {
				AddError(input[i].GetPosition(), "Ошибка в унарной операции. Позиция ошибки: ");
			}
			if (input[i + 1].GetType() != Type_Lexems::terminal && input[i + 1].GetType() == Type_Lexems::close_bracket)
			{
				AddError(input[i].GetPosition(), "Ошибка в унарной операции, пропущен аргумент. Позиция ошибки: ");
			}
		}
		if (IsOpenBracket(input[i]))
		{
			count_bracket++;
		}
		if (IsCloseBracket(input[i]))
		{
			count_bracket--;
			if (count_bracket<0)
			{
				AddError(input[i].GetPosition(), "Ошибка в закрывающей скобке. Позиция ошибки: ");
			}
		}
		i++;
	}
	if (count_bracket != 0)
	{
		AddError("Ошибка в скобках.");
	}
	return &errors;
}
예제 #4
0
파일: xlate.c 프로젝트: berkus/flick
static int xl_eval(definition *def_ptr, char *val)
{
	if (!val)
		panic("Null value found in evaluation!");
	if (IsDigit(val[0])) {
		if (val[0] == '~')
			return ~xl_eval(def_ptr, &val[1]);
		if (val[1] == '-')
			return -xl_eval(def_ptr, &val[1]);
		if ((val[0] == '0') && (val[1] == 'x')) {
			/* Hexadecimal. */
			int num = 0;
			int pos = 2;
			
			while (val[pos]) {
				num = num << 4;
				if (isdigit(((int) val[pos])))
					num += (val[pos] - '0');
				else {
					num += (((val[pos] - 'A') & 0x1f)
						+ 10);
					if ((val[pos] < 'A')
					    || (val[pos] > 'f'))
						panic(("Invalid hex value "
						       "`%s'."),
						      val);
					if ((val[pos] & 0x1f) > 5)
						panic(("Invalid hex value "
						       "`%s'."),
						      val);
				}
				pos++;
			}
			return num;
		} else
			return atoi(val);
		
	} else {
		int ref = aoi_name(def_ptr, val, NO_CREATE);
		aoi_type bind = outaoi.defs.defs_val[ref].binding;
		
		if (ref < 0)
			panic("Undefined const `%s'.", val);
		if (bind->kind != AOI_CONST)
			panic("Invalid type found in evaluation.");
		if (bind->aoi_type_u_u.const_def.value->kind != AOI_CONST_INT)
			panic("Invalid const type found in evaluation.");
		
		return (bind->aoi_type_u_u.const_def.value->aoi_const_u_u.
			const_int);
	}
}
예제 #5
0
TToken ASNLexer::LookupNumber(void)
{
    while ( IsDigit(Char()) ) {
        AddChar();
    }
    char c = Char();
    if (c == '.' || c == 'e' || c == 'E' || c == '-' || c == '+') {
        AddChar();
        LookupNumber();
        return T_DOUBLE;
    }
    return T_NUMBER;
}
예제 #6
0
	void MeasureTokenLength()
	{
		if(IsNameChar(*m_pNext))
		{
			for(m_len = 1; IsNameChar(m_pNext[m_len]) || IsDigit(m_pNext[m_len]); m_len++)
			{
			}
			m_type = name;
		}
		else if(IsDigit(*m_pNext) || *m_pNext == '.')
		{
			int exps = 0;
			int decimals = 0;
			if(*m_pNext == '.')
				decimals++;
			for(m_len = 1; m_pNext[m_len] != '\0'; m_len++)
			{
				if(IsDigit(m_pNext[m_len]))
					continue;
				if(m_pNext[m_len] == '.' && decimals == 0 && exps == 0)
				{
					decimals++;
					continue;
				}
				if(m_pNext[m_len] == 'e' && IsDigit(m_pNext[m_len + 1]) && exps == 0)
				{
					exps++;
					continue;
				}
				break;
			}
			m_type = number;
		}
		else
		{
			m_len = 1;
			m_type = symbol;
		}
	}
예제 #7
0
char GetNum()
{
    char c = Look;

    if( !IsDigit(Look)) {
        sprintf(tmp, "Integer");
        Expected(tmp);
    }

    GetChar();

    return c;
}
예제 #8
0
bool CSocketAddressIP::SetHostStr( LPCTSTR pszHostName )
{
	// try to resolve the host name with DNS for the true ip address.
	if ( pszHostName[0] == '\0' )
		return( false );
	if ( IsDigit( pszHostName[0] ))
	{
		SetAddrStr( pszHostName ); // 0.1.2.3
		return( true );
	}
	// NOTE: This is a blocking call !!!!
	return SetHostStruct( gethostbyname( pszHostName ));
}
예제 #9
0
// The <seq-id> is a sequence number in base 36,
// using digits and upper case letters
static bool ParseSeqId(State *state) {
  const char *p = state->mangled_cur;
  for (;*p != '\0'; ++p) {
    if (!IsDigit(*p) && !(*p >= 'A' && *p <= 'Z')) {
      break;
    }
  }
  if (p != state->mangled_cur) {  // Conversion succeeded.
    state->mangled_cur = p;
    return true;
  }
  return false;
}
예제 #10
0
파일: Util.cpp 프로젝트: koz4k/soccer
Date Asn1ToDate(ASN1_STRING *time)
{
	if(!time) return Null;
	int digit = 0;
	while(digit < time->length && IsDigit(time->data[digit]))
		digit++;
	if(digit < 6)
		return Null;
	int year2 = time->data[0] * 10 + time->data[1] - 11 * '0';
	int month = time->data[2] * 10 + time->data[3] - 11 * '0';
	int day   = time->data[4] * 10 + time->data[5] - 11 * '0';
	return Date(year2 + (year2 < 90 ? 2000 : 1900), month, day);
}
예제 #11
0
	virtual bool operator()(int pos, const RichPara& para)// A++ bug here....
	{
		if(!IsNull(para.format.label)) {
			AddLinkRef(link, para.format.label);
			ref.FindAdd(para.format.label);
		}
		for(int i = 0; i < para.part.GetCount(); i++)
			if(para.part[i].IsText()) {
				const wchar *s = para.part[i].text;
				for(;;) {
					while(!IsLetter(*s) && !IsDigit(*s) && *s)
						s++;
					if(*s == '\0')
						break;
					StringBuffer sb;
					while(IsLetter(*s) || IsDigit(*s))
						sb.Cat(ToAscii(ToLower(*s++)));
					words.FindAdd(TopicWordIndex(sb));
				}
			}
		return false;
	}
예제 #12
0
static int ParseDigits(char **ppText)
{
	char *p=*ppText;
	int Value=0;

	SkipSpaces(&p);
	while (IsDigit(*p)) {
		Value=Value*10+(*p-'0');
		p++;
	}
	*ppText=p;
	return Value;
}
예제 #13
0
bool IsStrNumericDec( lpctstr pszTest )
{
	if ( !pszTest || !*pszTest )
		return false;

	do
	{
		if ( !IsDigit(*pszTest) )
			return false;
	}
	while ( *(++pszTest) );

	return true;
}
예제 #14
0
	JsonValue * JsonParser::ReadValue(JsonValue * parent)
	{
		if (*cur_ == '"')
		{
			return ReadString(parent);
		}
		else if (IsDigit(*cur_) || *cur_ == '-')
		{
			return ReadNumber(parent);
		}
		else if (IsAlpha(*cur_))
		{
			std::string keyword;
			ParseIdentifier(keyword);

			if (keyword == "null")
			{
				return 0;
			}
			if (keyword == "true")
			{
				return new JsonBooleanValue(parent, true);
			}
			else if (keyword == "false")
			{
				return new JsonBooleanValue(parent, false);
			}
			else
			{
				throw Error(
					row_,
					column_ - keyword.length(),
					FormatString("Invalid bareword \"%s\", while value expected", keyword.c_str())
				);
			}
		}
		else if (*cur_ == '[')
		{
			return ReadArray(parent);
		}
		else if (*cur_ == '{')
		{
			return ReadObject(parent);
		}
		else
		{
			RaiseError("Invalid symbol, while value expected");
			return 0;
		}
	}
예제 #15
0
// <factor>          ::= <number_literal> | <identifier> | ( <bool_expression> )
void Factor(CPU *cpu, Files file){
    if(Peek('(', file)){
        Match('(', file);
        Boolean::Expression(cpu, file);
        Match(')', file);
    }
    else if(IsDigit(Peek())){
        cpu->LoadNumber(GetNumber(file));
    }
    else if(IsAlpha(Peek()))
        Identifier(cpu, file);
    else
        Abort("Internal Error. FIXME!", file);
}
예제 #16
0
파일: lex.c 프로젝트: gyc2015/GYC
void SetupLexer()
{
	int i;

	for (i = 0; i < END_OF_FILE + 1; i++)
	{
		if (IsLetter(i))
		{
			Scanners[i] = ScanIdentifier;
		}
		else if (IsDigit(i))
		{
			Scanners[i] = ScanNumericLiteral;
		}
		else
		{
			Scanners[i] = ScanBadChar;
		}
	}

	Scanners[END_OF_FILE] = ScanEOF;
	Scanners['\''] = ScanCharLiteral;
	Scanners['"']  = ScanStringLiteral;
	Scanners['+']  = ScanPlus;
	Scanners['-']  = ScanMinus;
	Scanners['*']  = ScanStar;
	Scanners['/']  = ScanSlash;
    Scanners['%']  = ScanPercent;
	Scanners['<']  = ScanLess;
	Scanners['>']  = ScanGreat;
	Scanners['!']  = ScanExclamation;
	Scanners['=']  = ScanEqual;
	Scanners['|']  = ScanBar;
	Scanners['&']  = ScanAmpersand;
	Scanners['^']  = ScanCaret;
	Scanners['.']  = ScanDot;
	Scanners['{']  = ScanLBRACE;
	Scanners['}']  = ScanRBRACE;
	Scanners['[']  = ScanLBRACKET;
	Scanners[']']  = ScanRBRACKET;
	Scanners['(']  = ScanLPAREN;
	Scanners[')']  = ScanRPAREN;
	Scanners[',']  = ScanCOMMA;
	Scanners[';']  = ScanSEMICOLON;
	Scanners['~']  = ScanCOMP;
	Scanners['?']  = ScanQUESTION;
	Scanners[':']  = ScanCOLON;
	Scanners['#']  = ScanHASH;
    Scanners['\n'] = ScanNewLine;
}
예제 #17
0
/* remove_unknown()
 *
 * inputs	- client who gave us message, supposed sender, buffer
 * output	- 
 * side effects	- kills issued for clients, squits for servers
 */
static void
remove_unknown(struct Client *client_p, char *lsender, char *lbuffer)
{
	int slen = strlen(lsender);

	/* meepfoo      is a nickname (ignore)
	 * #XXXXXXXX    is a UID (KILL)
	 * #XX          is a SID (SQUIT)
	 * meep.foo     is a server (SQUIT)
	 */
	if((IsDigit(lsender[0]) && slen == 3) || (strchr(lsender, '.') != NULL))
	{
		sendto_realops_flags(UMODE_DEBUG, L_ALL,
				     "Unknown prefix (%s) from %s, Squitting %s",
				     lbuffer, client_p->name, lsender);

		sendto_one(client_p, ":%s SQUIT %s :(Unknown prefix (%s) from %s)",
			   get_id(&me, client_p), lsender, lbuffer, client_p->name);
	}
	else if(IsDigit(lsender[0]))
		sendto_one(client_p, ":%s KILL %s :%s (Unknown Client)",
			   get_id(&me, client_p), lsender, me.name);
}
예제 #18
0
파일: hexval.c 프로젝트: PanchoManera/cc65
unsigned HexVal (int C)
/* Convert a hex digit into a value. The function will emit an error for
 * invalid hex digits.
 */
{
    if (!IsXDigit (C)) {
        Error ("Invalid hexadecimal digit: `%c'", C);
    }
    if (IsDigit (C)) {
        return C - '0';
    } else {
        return toupper (C) - 'A' + 10;
    }
}
예제 #19
0
파일: m_nick.c 프로젝트: Apsu/bahamut
static int do_nick_name(char *nick) {
  char   *ch;
  
  if (*nick == '-' || IsDigit(*nick))	/* first character is [0..9-] */
      return 0;
  
  for (ch = nick; *ch && (ch - nick) < NICKLEN; ch++)
      if (!isvalid(*ch) || IsSpace(*ch))
	  break;
  
  *ch = '\0';
  
  return (ch - nick);
}
예제 #20
0
파일: coptsub.c 프로젝트: Aliandrana/cc65
unsigned OptSub3 (CodeSeg* S)
/* Search for a call to decaxn and replace it by an 8 bit sub if the X register
** is not used later.
*/
{
    unsigned Changes = 0;

    /* Walk over the entries */
    unsigned I = 0;
    while (I < CS_GetEntryCount (S)) {

        CodeEntry* E;

        /* Get next entry */
        E = CS_GetEntry (S, I);

        /* Check for the sequence */
        if (E->OPC == OP65_JSR                          &&
            strncmp (E->Arg, "decax", 5) == 0           &&
            IsDigit (E->Arg[5])                         &&
            E->Arg[6] == '\0'                           &&
            !RegXUsed (S, I+1)) {

            CodeEntry* X;
            const char* Arg;

            /* Insert new code behind the sequence */
            X = NewCodeEntry (OP65_SEC, AM65_IMP, 0, 0, E->LI);
            CS_InsertEntry (S, X, I+1);

            Arg = MakeHexArg (E->Arg[5] - '0');
            X = NewCodeEntry (OP65_SBC, AM65_IMM, Arg, 0, E->LI);
            CS_InsertEntry (S, X, I+2);

            /* Delete the old code */
            CS_DelEntry (S, I);

            /* Remember, we had changes */
            ++Changes;

        }

        /* Next entry */
        ++I;

    }

    /* Return the number of changes made */
    return Changes;
}
예제 #21
0
파일: lex.c 프로젝트: gyc2015/GYC
static int ScanNumericLiteral()
{
    int base = 10;
    if('.' == *CURSOR)
    {
        return ScanFloatLiteral();
    }

    if('0' == *CURSOR && (CURSOR[1] == 'x'|| CURSOR[1] == 'X'))
    {
        base = 16;
        CURSOR += 2;
        while(IsHexDigit(*CURSOR))
        {
            CURSOR++;
        }
    }
    else if('0' == *CURSOR)
    {
        base = 8;
        CURSOR++;
        while(IsOctDigit(*CURSOR))
        {
            CURSOR++;
        }
    }
    else
    {
        CURSOR++;
        while(IsDigit(*CURSOR))
        {
            CURSOR++;
        }
    }

    if(base == 16 || (*CURSOR == '.' && *CURSOR == 'e' && *CURSOR == 'E'))
    {
        while('u' == *CURSOR || 'U' == *CURSOR ||
              'l' == *CURSOR || 'L' == *CURSOR)
        {
            CURSOR++;
        }
        return TK_INTCONST;
    }
    else
    {
        return ScanFloatLiteral();
    }
}
예제 #22
0
bool
valid_uid(const char *uid)
{
  if (strlen(uid) != TOTALSIDUID)
    return false;

  if (!IsDigit(*uid))
    return false;

  for (unsigned int i = 1; i < TOTALSIDUID; ++i)
    if (!IsAlNum(*(uid + i)))
      return false;

  return true;
}
예제 #23
0
파일: CRect.cpp 프로젝트: DarkLotus/Source
size_t CPointBase::Read( TCHAR * pszVal )
{
	ADDTOCALLSTACK("CPointBase::Read");
	// parse reading the point
	// NOTE: do not use = as a separator here !
	m_z = 0;
	m_map = 0;
	TCHAR * ppVal[4];
	size_t iArgs = Str_ParseCmds( pszVal, ppVal, COUNTOF( ppVal ), " ,\t" );
	switch ( iArgs )
	{
		default:
		case 4:	// m_map
			if ( IsDigit(ppVal[3][0]))
			{
				m_map = static_cast<unsigned char>(ATOI(ppVal[3]));
				if ( !g_MapList.m_maps[m_map] )
				{
					g_Log.EventError("Unsupported map #%d specified. Auto-fixing that to 0.\n", m_map);
					m_map = 0;
				}
			}
		case 3: // m_z
			if ( IsDigit(ppVal[2][0]) || ppVal[2][0] == '-' )
			{
				m_z = static_cast<signed char>(ATOI(ppVal[2]));
			}
		case 2:
			m_y = static_cast<signed short>(ATOI(ppVal[1]));
		case 1:
			m_x = static_cast<signed short>(ATOI(ppVal[0]));
		case 0:
			break;
	}
	return( iArgs );
}
예제 #24
0
파일: string_utils.cpp 프로젝트: whrool/Net
bool IsDigit(const std::string& str, bool bHex /*= false*/)
{
    if (str.empty())
        return false;
    if (!bHex && str.length() == 1 && '-' == str[0])
        return false;
    for (size_t i = 0; i < str.length(); ++i)
    {
        if (!bHex && 0 == i && '-' == str[i])
            continue;
        if (!IsDigit(str[i], bHex))
            return false;
    }
    return true;
}
예제 #25
0
static bool IsCommentUnsafe(const wchar *Data,size_t Size)
{
  for (size_t I=0;I<Size;I++)
    if (Data[I]==27 && Data[I+1]=='[')
      for (size_t J=I+2;J<Size;J++)
      {
        // Return true for <ESC>[{key};"{string}"p used to redefine
        // a keyboard key on some terminals.
        if (Data[J]=='\"')
          return true;
        if (!IsDigit(Data[J]) && Data[J]!=';')
          break;
      }
  return false;
}
bool nsMediaFragmentURIParser::ParseNPTSS(nsDependentSubstring& aString, uint32_t& aSecond)
{
  if (aString.Length() < 2) {
    return false;
  }

  if (IsDigit(aString[0]) && IsDigit(aString[1])) {
    nsDependentSubstring n(aString, 0, 2);
    nsresult ec;
    int32_t u = PromiseFlatString(n).ToInteger(&ec);
    if (NS_FAILED(ec)) {
      return false;
    }

    aString.Rebind(aString, 2);
    if (u >= 60)
      return false;

    aSecond = u;
    return true;
  }

  return false;
}
예제 #27
0
파일: system.c 프로젝트: embray/gap
static Int storePosInteger( Char **argv, void *Where )
{
  UInt *where = (UInt *)Where;
  UInt n;
  Char *p = argv[0];
  n = 0;
  while (IsDigit(*p)) {
    n = n * 10 + (*p-'0');
    p++;
  }
  if (p == argv[0] || *p || n == 0)
    FPUTS_TO_STDERR("Argument not a positive integer");
  *where = n;
  return 1;
}
예제 #28
0
파일: lex.c 프로젝트: vmezhang/sometest
/* 处理浮点常量和.../. 操作 */
static int ScanDot(void)
{
	if (IsDigit(CURRENT[1])) {

		return ScanFloatLiteral(CURRENT);
	} else if (CURRENT[1] == '.' && CURRENT[2] == '.') {

		CURRENT += 3;
		return TK_ELLIPSE;
	} else {

		CURRENT++;
		return TK_DOT;
	}
}
예제 #29
0
파일: scanner.cpp 프로젝트: it3ration/opcpp
// parses a number (an integer)
bool opScanner::Number(const inputtype& Input, int& current) {
    char c = Input[current];
    int size = Input.Size();

    if (IsDigit(c)) {
        opToken newToken(T_NUMBER, c, CurrentLine);
        ++current;

        while (current + 1 < size) {
            c = Input[current];

            if (!IsDigit(c)) break;

            newToken.Value += c;
            ++current;
        }

        Tokens.PushBack(newToken);

        return true;
    }

    return false;
}
예제 #30
0
const char* wxURI::ParsePort(const char* uri)
{
    // port          = *DIGIT
    if( *uri == ':' )
    {
        ++uri;
        while ( IsDigit(*uri) )
        {
            m_port += *uri++;
        }

        m_fields |= wxURI_PORT;
    }

    return uri;
}