/* added */ int GetArray(char*& p, int e[], int add, int dc) { aint val; int t = 0; while ('o') { SkipBlanks(p); if (!*p) { Error("Expression expected", 0, SUPPRESS); break; } if (t == 128) { Error("Too many arguments", p, SUPPRESS); break; } if (*p == '"') { p++; do { if (!*p || *p == '"') { Error("Syntax error", p, SUPPRESS); e[t] = -1; return t; } if (t == 128) { Error("Too many arguments", p, SUPPRESS); e[t] = -1; return t; } GetCharConstChar(p, val); check8(val); e[t++] = (val + add) & 255; } while (*p != '"'); ++p; if (dc && t) { e[t - 1] |= 128; } /* (begin add) */ } else if ((*p == 0x27) && (!*(p+2) || *(p+2) != 0x27)) { p++; do { if (!*p || *p == 0x27) { Error("Syntax error", p, SUPPRESS); e[t] = -1; return t; } if (t == 128) { Error("Too many arguments", p, SUPPRESS); e[t] = -1; return t; } GetCharConstCharSingle(p, val); check8(val); e[t++] = (val + add) & 255; } while (*p != 0x27); ++p; if (dc && t) { e[t - 1] |= 128; } /* (end add) */ } else { if (ParseExpression(p, val)) { check8(val); e[t++] = (val + add) & 255; } else { Error("Syntax error", p, SUPPRESS); break; } } SkipBlanks(p); if (*p != ',') { break; } ++p; } e[t] = -1; return t; }
static bool GetValue( opt_entry *optn, char *ptr, char **val ) { //================================================================== // Get pointer to option value. *val = SkipBlanks( ptr ); if( ( **val != '=' ) && ( **val != '#' ) ) { Warning( CO_NEED_EQUALS, optn->option ); return( false ); } else { *val = SkipBlanks( *val + sizeof( char ) ); return( true ); } }
static char * SkipTwoPatterns(char *s, int flags) { char *base; int done; s = SkipPattern(s, &done, 0); s = SkipPattern(done ? s - 1 : s, &done, 1); if (flags) { base = s; while (*s != 0 && !isspace(CharOf(*s))) { if (isdigit(CharOf(*s)) || *s == 'g' || *s == 'p') s++; else if (*s == 'w') { s += strlen(s); } else { break; } } flt_puts(base, (int) (s - base), Ident2_attr); s = SkipBlanks(s); s = SkipError(s); } return s; }
int cparen(char*& p) { SkipBlanks(p); if (*p != cpc) { return 0; } ++p; return 1; }
static char * SkipLabel(char *s) { if (*s == ':') { char *base; char *tail; flt_puts(s++, 1, Ident_attr); s = SkipBlanks(s); base = s; while (!isspace(CharOf(*s))) /* FIXME: can a label have punctuation? */ s++; tail = s; while (isspace(CharOf(*s))) s++; if (*s || tail == base) { s = SkipRemaining(base, Error_attr); } else { flt_puts(base, (int) (tail - base), Ident2_attr); flt_puts(tail, (int) (s - tail), ""); } } return s; }
int needbparen(char*& p) { SkipBlanks(p); if (*p != ']') { Error("']' expected", 0); } return (*(p++) == ']'); }
int needcomma(char*& p) { SkipBlanks(p); if (*p != ',') { Error("Comma expected", 0); } return (*(p++) == ','); }
static char * parse_arglist(char *name, char *s, char ***args, int *parens) { char *r; char *v; int quoted; size_t count; size_t used; char *t; int processing; t = SkipBlanks(s); if (*parens == 0) { quoted = 0; count = 0; used = 0; if (*t == L_PAREN) { processing = 1; *args = type_alloc(char *, (char *) 0, sizeof(*args) * (count + 4), &used); if (*args == 0) return 0; (*args)[count++] = strmalloc(name); (*args)[count] = 0; t++; } else {
int need(char*& p, char c) { SkipBlanks(p); if (*p != c) { return 0; } ++p; return 1; }
int comma(char*& p) { SkipBlanks(p); if (*p != ',') { return 0; } ++p; return 1; }
char* getparen(char* p) { int teller = 0; SkipBlanks(p); while (*p) { if (*p == '(') { ++teller; } else if (*p == ')') { if (teller == 1) { SkipBlanks(++p); return p; } else { --teller; } } ++p; } return 0; }
/* added */ void SkipParam(char*& p) { SkipBlanks(p); if (!(*p)) { return; } while (((*p) != '\0') && ((*p) != ',')) { p++; } }
static char * SkipRCurly(char *s) { if (*s == R_CURLY) { flt_puts(s++, 1, Action_attr); s = SkipBlanks(s); s = SkipError(s); } return s; }
bool MainCmdLine( char **fn, char **rest, char **opts, char *ptr ) { //===================================================================== uint opt_num; bool scanning_file_name; bool quoted; *fn = NULL; *rest = NULL; opt_num = 0; for(;;) { scanning_file_name = FALSE; quoted = FALSE; ptr = SkipBlanks( ptr ); if( *ptr == NULLCHAR ) break; if( _IsSwitchChar( *ptr ) ) { *ptr = NULLCHAR; // terminate previous option or filename ++ptr; if( opt_num < MAX_OPTIONS ) { *opts = ptr; ++opts; } ++opt_num; } else if( *fn == NULL ) { *fn = ptr; scanning_file_name = TRUE; } else { *rest = ptr; break; } for(;;) { if( *ptr == NULLCHAR ) break; if( quoted ) { if( *ptr == '\"' ) { quoted = FALSE; } } else if( *ptr == '\"' ) { quoted = TRUE; } else if( ( *ptr == ' ' ) || ( *ptr == '\t' ) ) { *ptr = NULLCHAR; ++ptr; break; } if( !scanning_file_name && !quoted ) { if( _IsSwitchChar( *ptr ) ) { break; } } ++ptr; } } *opts = NULL; return( (*fn != NULL) && (opt_num <= MAX_OPTIONS) && (*rest == NULL) ); }
/* remaining nonblanks on the line are unexpected */ static char * SkipError(char *s) { char *base = s; size_t len = strlen(s); while (len > 0 && isspace(CharOf(s[len - 1]))) len--; flt_puts(base, (int) len, Error_attr); return SkipBlanks(base + len); }
uint SceneImporter<real>::ReadUnsignedInt( std::istream& stream ) { uint result; SkipBlanks( stream ); stream >> result; if ( !stream ) throw "Cannot read uint"; return result; }
real SceneImporter<real>::ReadReal( std::istream& stream ) { real result; SkipBlanks( stream ); stream >> result; if ( !stream ) throw "Cannot read real"; return result; }
bool SceneImporter<real>::TryReadClosingParenthesis( std::istream& stream ) { SkipBlanks( stream ); if ( stream.peek() == ')' ) { stream.get(); return true; } return false; }
void ProcInclude( void ) { int old_srcrecnum; ComPrint(); if( strlen( SrcBuff ) > LastColumn ) { SrcBuff[ LastColumn ] = NULLCHAR; } old_srcrecnum = SrcRecNum; SrcRecNum = CurrFile->rec; // in case we get an error processing INCLUDE Include( SkipBlanks( &SrcBuff[ 10 ] ) ); SrcRecNum = old_srcrecnum; }
void SrcOption( void ) { //=================== // Process an option that can appear only in the source input stream. int directive; char *buff; buff = &SrcBuff[ 2 ]; directive = GetDirective( buff ); if( directive == CD_INCLUDE ) { if( ProgSw & PS_SKIP_SOURCE ) return; CurrFile->flags |= INC_PENDING; } else if( directive == CD_EJECT ) { if( ProgSw & PS_SKIP_SOURCE ) return; LFNewPage(); } else if( directive == CD_PRAGMA ) { if( ProgSw & PS_SKIP_SOURCE ) return; ComPrint(); ProcPragma( SkipOpt( buff ) ); } else if( directive == CD_DEFINE ) { if( ProgSw & PS_SKIP_SOURCE ) return; ComPrint(); buff = SkipBlanks( SkipOpt( buff ) ); MacroDEFINE( buff, SkipToken( buff ) - buff ); } else if( directive == CD_UNDEFINE ) { if( ProgSw & PS_SKIP_SOURCE ) return; ComPrint(); buff = SkipBlanks( SkipOpt( buff ) ); MacroUNDEFINE( buff, SkipToken( buff ) - buff ); } else if( directive == CD_IFDEF ) { buff = SkipBlanks( SkipOpt( buff ) ); MacroIFDEF( buff, SkipToken( buff ) - buff ); } else if( directive == CD_ELIFDEF ) { buff = SkipBlanks( SkipOpt( buff ) ); MacroELIFDEF( buff, SkipToken( buff ) - buff ); } else if( directive == CD_IFNDEF ) { buff = SkipBlanks( SkipOpt( buff ) ); MacroIFNDEF( buff, SkipToken( buff ) - buff ); } else if( directive == CD_ELIFNDEF ) { buff = SkipBlanks( SkipOpt( buff ) ); MacroELIFNDEF( buff, SkipToken( buff ) - buff ); } else if( directive == CD_ELSE ) { MacroELSE(); } else if( directive == CD_ENDIF ) { MacroENDIF(); } else { if( ProgSw & PS_SKIP_SOURCE ) return; ComPrint(); ScanOpts( buff ); // consider: // c$warn // c$notime=5 // CO-04 will not be issued unless /warn or c$warn is done. But // in the above case isn't updated unless we do this. Options = NewOptions; } }
/* modified */ int NeedEQU() { char* olp = lp; SkipBlanks(); /*if (*lp=='=') { ++lp; return 1; }*/ /* cut: if (*lp=='=') { ++lp; return 1; } */ if (*lp == '.') { ++lp; } if (cmphstr(lp, "equ")) { return 1; } lp = olp; return 0; }
/* modified */ char* GetFileName(char*& p, bool convertslashes) { int o = 0; int o2 = 0; char* fn, * np; fn = np = new char[LINEMAX]; if (np == NULL) { Error("No enough memory!", 0, FATAL); } *fn = 0; SkipBlanks(p); if (!(*p)) { return fn; } if (*p == '"') { o = 1; ++p; } else if (*p == '<') { o = 2; ++p; } if (*p && strstr(p, ":")) { o2 = 1; } /* added */ /* while (!White() && *p!='"' && *p!='>') { *np=*p; ++np; ++p; } */ while (*p && *p != '"' && *p != '>' && !(o == 0 && o2 == 1 && *p == ':')) { *np = *p; ++np; ++p; } if (*p && o == 1) { if (*p == '"') { ++p; } else { Error("No closing '\"'", 0); } } else if (*p && o == 2 && *p != '>') { Error("No closing '>'", 0); } else if (*p) { ++p; } *np = 0; for (np = fn; *np; ++np) { #if defined(WIN32) || defined(UNDER_CE) if (*np == '/' && convertslashes) { *np = '\\'; } #else if (*np == '\\' && convertslashes) { *np = '/'; } #endif } return fn; }
int NeedField() { char* olp = lp; SkipBlanks(); if (*lp == '#') { ++lp; return 1; } if (*lp == '.') { ++lp; } if (cmphstr(lp, "field")) { return 1; } lp = olp; return 0; }
/* added */ int NeedDEFL() { char* olp = lp; SkipBlanks(); if (*lp == '=') { ++lp; return 1; } if (*lp == '.') { ++lp; } if (cmphstr(lp, "defl")) { return 1; } lp = olp; return 0; }
/* not modified */ int oparen(char*& p, char c) { SkipBlanks(p); if (*p != c) { return 0; } if (c == '[') { cpc = ']'; } if (c == '(') { cpc = ')'; } if (c == '{') { cpc = '}'; } ++p; return 1; }
//*********************************************************************** BOOL CParser::GetNextNum(LPINT Val) // get value of next number - must be 0..9 //*********************************************************************** { if (!m_lpScript) return 0; BOOL bResult = FALSE; SkipBlanks(); // go to anything LPSTR lpNum = m_lpScript; // start of the number char c; while ((c = *(m_lpScript++)) && ((c >= '0' && c <= '9') || c == '-')) bResult = TRUE; m_lpScript--; // next char after the number if (bResult) *Val = latoi(lpNum); return bResult; }
/* modified */ char* GetID(char*& p) { /*char nid[LINEMAX],*/ char* np; np = nidtemp; SkipBlanks(p); //if (!isalpha(*p) && *p!='_') return 0; if (*p && !isalpha((unsigned char) * p) && *p != '_') { return 0; } while (*p) { if (!isalnum((unsigned char) * p) && *p != '_' && *p != '.' && *p != '?' && *p != '!' && *p != '#' && *p != '@') { break; } *np = *p; ++p; ++np; } *np = 0; /*return STRDUP(nid);*/ return nidtemp; }
static void ScanOpts( char *buff ) { //====================================== opt_entry *optn; bool negated; char *value; bool first_opt; if( strlen( SrcBuff ) > LastColumn ) { SrcBuff[ LastColumn ] = NULLCHAR; } first_opt = true; for(;;) { buff = SkipBlanks( buff ); if( *buff == NULLCHAR ) break; optn = GetOptn( buff, &negated ); if( optn == NULL ) { if( !first_opt ) { OptWarning( CO_NOT_RECOG, buff ); } break; } first_opt = false; if( ( optn->flags & SRC ) == 0 ) { Warning( CO_NOT_IN_SOURCE, optn->option ); buff = SkipOpt( buff ); } else { buff = SkipOpt( buff ); if( optn->flags & VAL ) { if( negated ) { Warning( CO_BAD_NO, optn->option ); } if( !GetValue( optn, buff, &value ) ) continue; buff = SkipToken( value ); optn->proc_rtnstr( optn, value ); } else { optn->proc_rtnbool( optn, negated ); } } } }
/* modified */ char* getinstr(char*& p) { /*char nid[LINEMAX],*/ char* np; np = instrtemp; SkipBlanks(p); if (!isalpha((unsigned char) * p) && *p != '.') { return 0; } else { *np = *p; ++p; ++np; } while (*p) { if (!isalnum((unsigned char) * p) && *p != '_') { break; } ///////////////////////////////////// *np = *p; ++p; ++np; } *np = 0; /*return STRDUP(nid);*/ return instrtemp; }
int need(char*& p, char* c) { SkipBlanks(p); while (*c) { if (*p != *c) { c += 2; continue; } ++c; if (*c == ' ') { ++p; return *(c - 1); } if (*c == '_' && *(p + 1) != *(c - 1)) { ++p; return *(c - 1); } if (*(p + 1) == *c) { p += 2; return *(c - 1) + *c; } ++c; } return 0; }