コード例 #1
0
ファイル: Lang.cpp プロジェクト: ultimatepp/mirror
Array<IdentPos> GetLineIdent(const char *line)
{
	Array<IdentPos> out;
	const char *p = line;
	while(*p && *p != '\n')
		if(*p == '\"' || *p == '\'')
		{
			char term = *p++;
			while(*p && *p != term)
				if(*p++ == '\\' && *p)
					p++;
			if(*p == term)
				p++;
		}
		else if(*p == 's' && p[1] == '_' && p[2] == '(' && (IsAlpha(p[3]) || p[3] == '_'))
		{
			IdentPos& pos = out.Add();
			pos.begin = int(p - line);
			const char *b = (p += 3);
			while(IsAlNum(*++p) || *p == '_')
				;
			pos.ident = String(b, p);
			if(*p == ')')
				p++;
			pos.end = int(p - line);
		}
		else if(IsAlpha(*p) || *p == '_')
		{
			while(IsAlNum(*++p) || *p == '_')
				;
		}
		else
			p++;
	return out;
}
コード例 #2
0
ファイル: id.c プロジェクト: ircd-hybrid/ircd-hybrid
bool
valid_sid(const char *sid)
{
  if (strlen(sid) == IRC_MAXSID)
    if (IsDigit(*sid))
      if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2)))
        return true;

  return false;
}
コード例 #3
0
void InfixPrinter::WriteToken(std::ostream& aOutput, const std::string& aString)
{
    if (IsAlNum(iPrevLastChar) && (IsAlNum(aString[0]) || aString[0] == '_'))
        aOutput.put(' ');
    else if (IsSymbolic(iPrevLastChar) && IsSymbolic(aString[0]))
        aOutput.put(' ');

    aOutput.write(aString.c_str(), aString.size());
    RememberLastChar(aString.back());
}
コード例 #4
0
ファイル: lx.cpp プロジェクト: tadejs/qminer-1
bool TLxChDef::IsNmStr(const TStr& Str) const {
  if (Str.Len()==0){return false;}
  if (!IsAlpha(Str.GetCh(0))){return false;}
  for (int ChN=1; ChN<Str.Len(); ChN++){
    if (!IsAlNum(Str.GetCh(ChN))){return false;}}
  return true;
}
コード例 #5
0
ファイル: scanner.c プロジェクト: pfusik/cc65
int IsIdChar (int C)
/* Return true if the character is a valid character for an identifier */
{
    return IsAlNum (C)                  ||
           (C == '_')                   ||
           (C == '@' && AtInIdents)     ||
           (C == '$' && DollarInIdents);
}
コード例 #6
0
ファイル: help.cpp プロジェクト: AbdelghaniDr/mirror
static void AdjustCat(String& out, const char *in, int maxlen)
{
	for(; *in && out.GetLength() < maxlen; in++)
		if(IsAlNum(*in) || *in == '_' || *in == '-' || *in == '$')
			out.Cat(*in);
		else
			CatUnder(out);
}
コード例 #7
0
void ASNLexer::LookupIdentifier(void)
{
    while ( true ) {
        char c = Char();
        if ( IsAlNum(c) )
            AddChar();
        else if ( c == '-' ) {
            if ( IsAlNum(Char(1)) )
                AddChars(2);
            else {
                if ( AllowIDsEndingWithMinus() )
                    AddChar();
                return;
            }
        }
        else
            return;
    }
}
コード例 #8
0
char* GetName()
{
    char *token = token_buf;

    if( !IsAlNum(Look)) {
        Expected("Name");
    }
    while (IsAlNum(Look)) {
        *token = Look;
        token++;

        GetChar();
    }

    SkipWhite();

    *token = '\0';
    return token_buf;
}
コード例 #9
0
ファイル: LogSyntax.cpp プロジェクト: guowei8412/upp-mirror
void LogSyntax::Highlight(const wchar *s, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int pos)
{
	const HlStyle& ink = hl_style[INK_NORMAL];
	HlStyle err = hl_style[INK_ERROR];
	err.bold = true;
	bool hl_line = false;
	bool sep_line = false;
	while(s < end) {
		int c = *s;
		const wchar *s0 = s;
		if(s + 3 <= end && (Is3(s, '-') || Is3(s, '*') || Is3(s, '=') || Is3(s, '+') ||
		                    Is3(s, '#') || Is3(s, ':') || Is3(s, '%') || Is3(s, '$')))
			sep_line = true;
		if(IsDigit(c))
			s = HighlightNumber(hls, s, thousands_separator, false, false);
		else
		if(c == '\'' || c == '\"') {
			s++;
			for(;;) {
				if(s >= end) {
					hls.Put(1, ink);
					s = s0 + 1;
					break;
				}
				if(*s == c) {
					s++;
					hls.Put((int)(s - s0), hl_style[INK_CONST_STRING]);
					break;
				}
				s += 1 + (s[0] == '\\' && s[1] == c);
			}
		}
		else
		if(IsAlpha(c) || c == '_') {
			static Index<String> rws;
			ONCELOCK {
				rws << "error" << "errors" << "warning" << "warnings" << "failed" << "exit" << "fatal"
				    << "failure" << "rejected";
			}
			String w;
			while(s < end && IsAlNum(*s) || *s == '_')
				w.Cat(ToLower(*s++));
			bool hl = rws.Find(w) >= 0;
			hls.Put(w.GetCount(), hl ? err : ink);
			hl_line = hl_line || hl;
		}
		else {
			bool hl = findarg(c, '[', ']', '(', ')', ':', '-', '=', '{', '}', '/', '<', '>', '*',
			                     '#', '@', '\\', '.') >= 0;
			hls.Put(1, hl ? hl_style[INK_OPERATOR] : ink);
			s++;
		}
		
	}
コード例 #10
0
ファイル: MenuItem.cpp プロジェクト: guowei8412/upp-mirror
bool MenuItem::HotKey(dword key)
{
	if(isenabled && (key == accel || CompareAccessKey(accesskey, key)
	|| key < 256 && IsAlNum((char)key) && CompareAccessKey(accesskey, ToUpper((char)key) + K_DELTA + K_ALT))) {
		LLOG("MenuItem::HotKey(" << key << ") -> SetFocus");
		SetFocus();
		Sync();
		Sleep(50);
		WhenAction();
		return true;
	}
	return false;
}
コード例 #11
0
ファイル: id.c プロジェクト: ircd-hybrid/ircd-hybrid
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;
}
コード例 #12
0
char *  GetName() {
  if(!IsAlpha(Look)) {
      Expected("Name");
  }
  char* Token = malloc(100 * sizeof *Token);
  Token[0] = '\0';
  int i = 0;
  while(IsAlNum(Look)) {
    Token[i] = UPCASE(Look);
    GetChar();
    i++;
  }
  Token[i] = '\0';
  SkipWhite();
  return Token;
}
コード例 #13
0
ファイル: main.c プロジェクト: AntiheroSoftware/cc65
static void CheckLabelName (const char* Label)
/* Check if the given label is a valid label name */
{
    const char* L = Label;

    if (strlen (L) < 256 && (IsAlpha (*L) || *L== '_')) {
        while (*++L) {
            if (!IsAlNum (*L) && *L != '_') {
                break;
            }
        }
    }

    if (*L) {
        Error ("Label name `%s' is invalid", Label);
    }
}
コード例 #14
0
ファイル: xml.c プロジェクト: BuckRogers1965/Examples
// Get an Identifier
char * GetName()
{
    int count=0;

    if (!IsAlpha(Look))
        Expected("Name");

    while ((IsAlNum(Look) || (Look == '-')) && (count < MAX_BUF))  {
        Token[count]=Look;
        GetChar();
        count++;
        Token[count]='\0';
    }

    SkipWhite();
//	printf("[%s]\n", Token);
    return (Token);
}
コード例 #15
0
void GetName()
{
    SkipWhite();   
    while(Look == '\n') {
        Fin();
    }

    char *p = Value;
    if (!IsAlpha(Look)) {
        Expected("Name");
    }

    while(IsAlNum(Look)) {
        *p++ = uppercase(Look);
        GetChar();
    }
    *p = '\0';
}
コード例 #16
0
ファイル: CppBuilder.cpp プロジェクト: ultimatepp/mirror
String CppBuilder::GetSharedLibPath(const String& package) const
{
	String outfn;
	if(HasFlag("POSIX"))
	   outfn << "lib";
	for(const char *p = package; *p; p++)
		outfn.Cat(IsAlNum(*p) || *p == '-' ? *p : '_');
	if(!IsNull(version) && !HasFlag("POSIX"))
		outfn << version;
	outfn << (HasFlag("WIN32") || HasFlag("WINCE") ? ".dll" : ".so");
	if(HasFlag("POSIX"))
	{
		Point p = ExtractVersion();
		int ver = IsNull(p.x) ? 1 : p.x;
		int minver = IsNull(p.y) ? 0 : p.y;
		outfn << '.' << ver << '.' << minver;
	}
	return CatAnyPath(GetFileFolder(target), outfn);
}
コード例 #17
0
ファイル: FileList.cpp プロジェクト: AbdelghaniDr/mirror
bool FileList::Key(dword key, int count) {
	if(key == K_ESCAPE && IsEdit()) {
		EndEdit();
		return true;
	}
	if(key == K_ENTER && IsEdit()) {
		OkEdit();
		return true;
	}
	if(accelkey) {
		int c = ToUpper((int)key);
		if(key < 256 && IsAlNum(c)) {
			if(!FindChar(GetCursor() + 1, c))
				FindChar(0, c);
			return true;
		}
	}
	return ColumnList::Key(key, count);
}
コード例 #18
0
ファイル: Template.cpp プロジェクト: kolyden/mirror
String ToUpper_Caps(const String& name)
{
	String output("");
	int str_len = name.GetLength();
	for (int i = 0; i < str_len; ++i)
	{
		int ch = name[i];
		if (IsAlNum(ch))
		{
			output += ToUpper(ch);
			if (i < str_len - 1)
				if (IsLower(ch) && IsUpper(name[i + 1]))
					output += '_';
		}
		else
			output += '_';
	}
	return output;
}
コード例 #19
0
char* GetNum()
{
    char *value = token_buf;

    if( !IsAlNum(Look)) {
        Expected("Integer");
    }
    while (IsDigit(Look)) {
        *value = Look;
        value++;

        GetChar();
    }

    SkipWhite();

    *value = '\0';
    return token_buf;
}
コード例 #20
0
ファイル: c.c プロジェクト: Aliandrana/cc65
static int ValidIdentifier (const char* L)
/* Check a C identifier for validity */
{
    /* Must begin with underscore or alphabetic character */
    if (*L != '_' && !IsAlpha (*L)) {
        return 0;
    }
    ++L;

    /* Remainder must be as above plus digits */
    while (*L) {
        if (*L != '_' && !IsAlNum (*L)) {
            return 0;
        }
        ++L;
    }

    /* Ok */
    return 1;
}
コード例 #21
0
ファイル: main.c プロジェクト: Aliandrana/cc65
static void DefineSymbol (const char* Def)
/* Define a symbol from the command line */
{
    const char* P;
    long Val;
    StrBuf SymName = AUTO_STRBUF_INITIALIZER;


    /* The symbol must start with a character or underline */
    if (Def [0] != '_' && !IsAlpha (Def [0])) {
        InvDef (Def);
    }
    P = Def;

    /* Copy the symbol, checking the remainder */
    while (IsAlNum (*P) || *P == '_') {
        SB_AppendChar (&SymName, *P++);
    }
    SB_Terminate (&SymName);

    /* Do we have a value given? */
    if (*P != '=') {
        InvDef (Def);
    } else {
        /* We have a value */
        ++P;
        if (*P == '$') {
            ++P;
            if (sscanf (P, "%lx", &Val) != 1) {
                InvDef (Def);
            }
        } else {
            if (sscanf (P, "%li", &Val) != 1) {
                InvDef (Def);
            }
        }
    }

    /* Define the new symbol */
    CreateConstExport (GetStringId (SB_GetConstBuf (&SymName)), Val);
}
コード例 #22
0
ファイル: main.c プロジェクト: PanchoManera/cc65
static void DefineSym (const char* Def)
/* Define a symbol on the command line */
{
    const char* P = Def;

    /* The symbol must start with a character or underline */
    if (Def [0] != '_' && !IsAlpha (Def [0])) {
        InvDef (Def);
    }

    /* Check the symbol name */
    while (IsAlNum (*P) || *P == '_') {
        ++P;
    }

    /* Do we have a value given? */
    if (*P != '=') {
        if (*P != '\0') {
            InvDef (Def);
        }
        /* No value given. Define the macro with the value 1 */
        DefineNumericMacro (Def, 1);
    } else {
        /* We have a value, P points to the '=' character. Since the argument
         * is const, create a copy and replace the '=' in the copy by a zero
         * terminator.
         */
        char* Q;
        unsigned Len = strlen (Def)+1;
        char* S = (char*) xmalloc (Len);
        memcpy (S, Def, Len);
        Q = S + (P - Def);
        *Q++ = '\0';

        /* Define this as a macro */
        DefineTextMacro (S, Q);

        /* Release the allocated memory */
        xfree (S);
    }
}
コード例 #23
0
ファイル: match.c プロジェクト: ratbox-mirrors/ircd-ratbox
/* 
 * valid_username - check username for validity
 *
 * Inputs	- pointer to user
 * Output	- YES if valid, NO if not
 * Side effects - NONE
 * 
 * Absolutely always reject any '*' '!' '?' '@' in an user name
 * reject any odd control characters names.
 * Allow '.' in username to allow for "first.last"
 * style of username
 */
bool
valid_username(const char *username)
{
	int dots = 0;
	const char *p = username;

	s_assert(NULL != p);

	if(username == NULL)
		return false;

	if('~' == *p)
		++p;

	/* reject usernames that don't start with an alphanum
	 * i.e. reject jokers who have '-@somehost' or '.@somehost'
	 * or "-hi-@somehost", "h-----@somehost" would still be accepted.
	 */
	if(!IsAlNum(*p))
		return false;

	while(*++p)
	{
		if((*p == '.') && ConfigFileEntry.dots_in_ident)
		{
			dots++;
			if(dots > ConfigFileEntry.dots_in_ident)
				return false;
			if(!IsUserChar(p[1]))
				return false;
		}
		else if(!IsUserChar(*p))
			return false;
	}
	return true;
}
コード例 #24
0
ファイル: macro.cpp プロジェクト: guowei8412/upp-mirror
String CppMacro::Expand(const Vector<String>& p, const Vector<String>& ep) const
{
	String r;
	const char *s = body;
	String pp = param;
	bool variadic = false;
	if(*pp.Last() == '.') {
		variadic = true;
		pp.Trim(pp.GetCount() - 1);
	}
	Index<String> param(Split(pp, ','));
	static String VA_ARGS("__VA_ARGS__"); // static - Speed optimization
	while(*s) {
		if(IsAlpha(*s) || *s == '_') {
			const char *b = s;
			s++;
			while(IsAlNum(*s) || *s == '_')
				s++;
			String id(b, s);
			const char *ss = b;
			bool cat = false;
			while(ss > ~body && ss[-1] == ' ')
				ss--;
			if(ss >= ~body + 2 && ss[-1] == '#' && ss[-2] == '#')
				cat = true;
			ss = s;
			while(*ss && *ss == ' ')
				ss++;
			if(ss[0] == '#' && ss[1] == '#')
				cat = true;
			if(id == VA_ARGS) {
				bool next = false;
				for(int i = param.GetCount(); i < ep.GetCount(); i++) {
					if(next)
						r.Cat(", ");
					r.Cat((cat ? p : ep)[i]);
					next = true;
				}
			}
			else {
				int q = param.Find(id);
				if(q >= 0) {
					if(q < ep.GetCount())
						r.Cat((cat ? p : ep)[q]);
				}
				else
					r.Cat(id);
			}
			continue;
		}
		if(s[0] == '#' && s[1] == '#') {
			int q = r.GetLength();
			while(q > 0 && IsSpc(r[q - 1]))
				q--;
			r.Trim(q);
			s += 2;
			while((byte)*s <= ' ')
				s++;
			continue;
		}
		if(*s == '#') {
			const char *ss = s + 1;
			while(IsSpc(*ss))
				ss++;
			if(IsAlpha(*ss) || *ss == '_') {
				const char *b = ss;
				ss++;
				while(IsAlNum(*ss) || *ss == '_')
					ss++;
				String id(b, ss);
				int q = param.Find(id);
				if(q >= 0) {
					if(q <= p.GetCount()) {
						if(q < p.GetCount())
							r.Cat(AsCString(p[q]));
						s = ss;
						continue;
					}
				}
				r.Cat(String(s, ss));
				s = ss;
				continue;
			}
		}
		r.Cat(*s++);
	}
	return r;
}
コード例 #25
0
ファイル: scanner.c プロジェクト: eakmeister/cc65
void CfgNextTok (void)
/* Read the next token from the input stream */
{
    unsigned I;


Again:
    /* Skip whitespace */
    while (isspace (C)) {
     	NextChar ();
    }

    /* Remember the current position */
    CfgErrorLine = InputLine;
    CfgErrorCol  = InputCol;

    /* Identifier? */
    if (C == '_' || IsAlpha (C)) {

	/* Read the identifier */
	I = 0;
	while (C == '_' || IsAlNum (C)) {
	    if (I < CFG_MAX_IDENT_LEN) {
	        CfgSVal [I++] = C;
	    }
	    NextChar ();
     	}
	CfgSVal [I] = '\0';
     	CfgTok = CFGTOK_IDENT;
	return;
    }

    /* Hex number? */
    if (C == '$') {
	NextChar ();
	if (!isxdigit (C)) {
	    Error ("%s(%u): Hex digit expected", CfgName, InputLine);
	}
	CfgIVal = 0;
	while (isxdigit (C)) {
       	    CfgIVal = CfgIVal * 16 + DigitVal (C);
	    NextChar ();
	}
	CfgTok = CFGTOK_INTCON;
	return;
    }

    /* Decimal number? */
    if (isdigit (C)) {
	CfgIVal = 0;
	while (isdigit (C)) {
       	    CfgIVal = CfgIVal * 10 + DigitVal (C);
	    NextChar ();
	}
	CfgTok = CFGTOK_INTCON;
	return;
    }

    /* Other characters */
    switch (C) {

	case '{':
	    NextChar ();
	    CfgTok = CFGTOK_LCURLY;
	    break;

	case '}':
	    NextChar ();
	    CfgTok = CFGTOK_RCURLY;
	    break;

	case ';':
	    NextChar ();
     	    CfgTok = CFGTOK_SEMI;
	    break;

	case '.':
	    NextChar ();
            if (C == '.') {
                NextChar ();
                CfgTok = CFGTOK_DOTDOT;
            } else {
	        CfgTok = CFGTOK_DOT;
            }
	    break;

	case ',':
	    NextChar ();
	    CfgTok = CFGTOK_COMMA;
	    break;

	case '=':
	    NextChar ();
	    CfgTok = CFGTOK_EQ;
	    break;

        case ':':
	    NextChar ();
	    CfgTok = CFGTOK_COLON;
     	    break;

        case '\"':
	    NextChar ();
	    I = 0;
	    while (C != '\"') {
		if (C == EOF || C == '\n') {
	 	    Error ("%s(%u): Unterminated string", CfgName, InputLine);
		}
	       	if (I < CFG_MAX_IDENT_LEN) {
		    CfgSVal [I++] = C;
		}
		NextChar ();
	    }
       	    NextChar ();
	    CfgSVal [I] = '\0';
	    CfgTok = CFGTOK_STRCON;
	    break;

        case '#':
	    /* Comment */
	    while (C != '\n' && C != EOF) {
   		NextChar ();
	    }
     	    if (C != EOF) {
	     	goto Again;
	    }
	    CfgTok = CFGTOK_EOF;
	    break;

        case EOF:
	    CfgTok = CFGTOK_EOF;
	    break;

	default:
	    Error ("%s(%u): Invalid character `%c'", CfgName, InputLine, C);

    }
}
コード例 #26
0
ファイル: asminc.c プロジェクト: Aliandrana/snesdev
void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown)
/* Read an assembler include file */
{
    char        Buf[1024];
    char*       L;
    const char* Comment;
    unsigned    Line;
    unsigned	Len;
    long        Val;
    unsigned    DVal;
    int         Sign;
    unsigned    Base;
    unsigned    Digits;
    StrBuf      Ident = STATIC_STRBUF_INITIALIZER;

    /* Try to open the file for reading */
    FILE* F = fopen (Filename, "r");
    if (F == 0) {
        Error ("Cannot open asm include file \"%s\": %s",
               Filename, strerror (errno));
    }

    /* Read line by line, check for NAME = VALUE lines */
    Line = 0;
    while ((L = fgets (Buf, sizeof (Buf), F)) != 0) {

        /* One more line read */
        ++Line;

        /* Ignore leading white space */
        while (IsBlank (*L)) {
            ++L;
        }

	/* Remove trailing whitespace */
	Len = strlen (L);
	while (Len > 0 && IsSpace (L[Len-1])) {
	    --Len;
	}
	L[Len] = '\0';

        /* If the line is empty or starts with a comment char, ignore it */
        if (*L == '\0' || *L == CommentStart) {
            continue;
        }

        /* Read an identifier */
        SB_Clear (&Ident);
        if (IsAlpha (*L) || *L == '_') {
            SB_AppendChar (&Ident, *L++);
            while (IsAlNum (*L) || *L == '_') {
                SB_AppendChar (&Ident, *L++);
            }
            SB_Terminate (&Ident);
        } else {
            if (!IgnoreUnknown) {
                Error ("%s(%u): Syntax error", Filename, Line);
            }
            continue;
        }

        /* Ignore white space */
        L = SkipWhitespace (L);

        /* Check for := or = */
        if (*L == '=') {
            ++L;
        } else if (*L == ':' && *++L == '=') {
            ++L;
        } else {
	    if (!IgnoreUnknown) {
	       	Error ("%s(%u): Missing `='", Filename, Line);
	    }
	    continue;
	}

        /* Allow white space once again */
        L = SkipWhitespace (L);

        /* A number follows. Read the sign. */
        if (*L == '-') {
            Sign = -1;
            ++L;
        } else {
            Sign = 1;
            if (*L == '+') {
                ++L;
            }
        }

        /* Determine the base of the number. Allow $ and % as prefixes for
         * hex and binary numbers respectively.
         */
        if (*L == '$') {
            Base = 16;
            ++L;
        } else if (*L == '%') {
            Base = 2;
            ++L;
        } else {
            Base = 10;
        }

        /* Decode the number */
        Digits = 0;
        Val = 0;
        while (IsXDigit (*L) && (DVal = DigitVal (*L)) < Base) {
            Val = (Val * Base) + DVal;
            ++Digits;
            ++L;
        }

        /* Must have at least one digit */
        if (Digits == 0) {
            if (!IgnoreUnknown) {
                Error ("%s(%u): Error in number format", Filename, Line);
            }
            continue;
        }

        /* Skip whitespace again */
        L = SkipWhitespace (L);

        /* Check for a comment */
        if (*L == CommentStart) {
            Comment = SkipWhitespace (L+1);
            if (*Comment == '\0') {
                Comment = 0;
            }
        } else {
            Comment = 0;
        }

        /* Check for a comment character or end of line */
        if (*L != CommentStart && *L != '\0') {
            if (!IgnoreUnknown) {
                Error ("%s(%u): Trailing garbage", Filename, Line);
            }
            continue;
        }

        /* Apply the sign */
        Val *= Sign;

        /* Define the symbol and the comment */
        AddExtLabel (Val, SB_GetConstBuf (&Ident));
        SetComment (Val, Comment);

    }

    /* Delete the string buffer contents */
    SB_Done (&Ident);

    /* Close the include file ignoring errors (we were just reading). */
    (void) fclose (F);
}
コード例 #27
0
ファイル: ParseQtf.cpp プロジェクト: koz4k/soccer
void RichQtfParser::ReadObject()
{
	Flush();
	RichObject obj;
	if(*term == '#') {
		term++;
	#ifdef CPU_64
		obj = *(RichObject *)stou64(term, &term);
	#else
		obj = *(RichObject *)stou(term, &term);
	#endif
		term++;
	}
	else {
		String type;
		while(IsAlNum(*term) || *term == '_')
			type.Cat(*term++);
		Size sz;
		Key(':');
		sz.cx = ReadNumber();
		bool keepratio = false;
		if(Key('&'))
			keepratio = true;
		else
			Key('*');
		sz.cy = ReadNumber();
		int yd = 0;
		if(Key('/'))
			yd = GetNumber();
		while(*term && (byte)*term < 32)
			term++;
		String odata;
		if(Key('`'))
			while(*term) {
				if(*term == '`') {
					term++;
					if(*term == '`')
						odata.Cat('`');
					else
						break;
				}
				else
				if((byte)*term >= 32)
					odata.Cat(*term);
				term++;
			}
		else
		if(Key('(')) {
			const char *b = term;
			while(*term && *term != ')')
				term++;
			odata = Base64Decode(b, term);
			if(*term == ')')
				term++;
		}
		else {
			StringBuffer data;
			for(;;) {
				while(*term < 32 && *term > 0) term++;
				if((byte)*term >= ' ' && (byte)*term <= 127 || *term == '\0') break;
				byte seven = *term++;
				for(int i = 0; i < 7; i++) {
					while((byte)*term < 32 && (byte)*term > 0) term++;
					if((byte)*term >= ' ' && (byte)*term <= 127 || *term == '\0') break;
					data.Cat((*term++ & 0x7f) | ((seven << 7) & 0x80));
					seven >>= 1;
				}
			}
			odata = data;
		}
		obj.Read(type, odata, sz, context);
		obj.KeepRatio(keepratio);
		obj.SetYDelta(yd);
	}
	paragraph.Cat(obj, format);
}
コード例 #28
0
ファイル: GatherTpp.cpp プロジェクト: dreamsxin/ultimatepp
int CharFilterLbl(int c)
{
	return IsAlNum(c) ? c : '.';
}
コード例 #29
0
ファイル: Navigator.cpp プロジェクト: AbdelghaniDr/mirror
int CharFilterNavigator(int c)
{
	return c == ':' ? '.' : IsAlNum(c) || c == '_' || c == '.' ? c : 0;
}
コード例 #30
0
ファイル: Pre.cpp プロジェクト: AbdelghaniDr/mirror
SrcFile PreProcess(Stream& in, Parser& parser) // This is not really C preprocess, only removes (or processes) comment and directives
{
	SrcFile res;
	bool include = true;
	int lineno = 0;
	while(!in.IsEof()) {
		String ln = in.GetLine();
		lineno++;
		SLPos(res);
		while(*ln.Last() == '\\') {
			ln.Trim(ln.GetLength() - 1);
			ln.Cat(in.GetLine());
			SLPos(res);
		}
		const char *rm = ln;
		if(IsAlNum(*rm)) {
			const char *s = ln;
			bool islbl = false;
			bool wassemi = false;
			while(*s && iscid(*s) || findarg(*s, '\t', ' ', ':') >= 0) { // check for label, labeled lines are not grounded
				if(*s == ':' && !wassemi) {
					islbl = true;
					wassemi = true; // second ':' cancels label
				}
				else
				if(*s != '\t' && *s != ' ')
					islbl = false; // something was after the label, e.g. void Foo::Bar()
				s++;
			}
			if(!islbl)
				res.text << '\2';
		}
		else
		if(*rm == '\x1f') // line started with macro
			res.text << '\2';
		while(*rm == ' ' || *rm == '\t') rm++;
		if(*rm == '\0')
			res.blankLinesRemoved++;
		else
		if(*rm == '#')
		{
			const char *s = rm + 1;
			while(*s == ' ' || *s == '\t')
				s++;
			if(s[0] == 'd' && s[1] == 'e' && s[2] == 'f' &&
			   s[3] == 'i' && s[4] == 'n' && s[5] == 'e' && !iscid(s[6])) {
				s += 6;
				while(*s == ' ' || *s == '\t') s++;
				String macro;
				while(iscid(*s))
					macro.Cat(*s++);
				if(*s == '(') {
					while(*s != ')' && *s)
						macro.Cat(*s++);
					macro << ')';
				}
				if(include)
					parser.AddMacro(lineno, macro);
			}
			res.preprocessorLinesRemoved++;
		}
		else {
			bool lineContainsComment = false;
			bool lineContainsNonComment = false;
			String cmd;
			while(*rm) {
				if(*rm == '\"') {
					lineContainsNonComment = true;
					res.text << '\"';
					rm++;
					while((byte)*rm && *rm != '\r' && *rm != '\n') {
						if(*rm == '\"') {
							res.text << '\"';
							rm++;
							break;
						}
						if(*rm == '\\' && rm[1]) {
							if(include)
								res.text.Cat(*rm);
							rm++;
						}
						if(include)
							res.text.Cat(*rm);
						rm++;
					}
				}
				else
				if(*rm == '\\' && rm[1]) {
					lineContainsNonComment = true;
					if(include) {
						res.text.Cat(*rm++);
						res.text.Cat(*rm++);
					}
					else
						rm += 2;
				}
				else
				if(rm[0] == '/' && rm[1] == '/') {
					cmd = rm + 2;
					if(!lineContainsNonComment)
						res.commentLinesRemoved++;
					break;
				}
				else
				if(rm[0] == '/' && rm[1] == '*') {
					lineContainsComment = true;
					rm += 2;
					for(;;) {
						if(*rm == '\0') {
							if(!lineContainsNonComment)
								res.commentLinesRemoved++;
							if(in.IsEof()) break;
							SLPos(res);
							ln = in.GetLine();
							rm = ~ln;
							lineContainsNonComment = false;
						}
						if(rm[0] == '*' && rm[1] == '/') {
							rm += 2;
							break;
						}
						rm++;
					}
					if(include)
						res.text.Cat(' ');
				}
				else {
					lineContainsNonComment = true;
					if(include)
						res.text.Cat(*rm);
					rm++;
				}
			}
			if(include)
				res.text << ' ';
			if(cmd[0] == '$') {
				if(cmd[1] == '-') include = false;
				if(cmd[1] == '+') include = true;
				if(cmd[1]) {
					res.text.Cat(~cmd + 2);
					res.text.Cat(' ');
				}
			}
			if(lineContainsComment && !lineContainsNonComment)
				res.commentLinesRemoved++;
		}
	}
	return pick(res);
}