static void DumpMotorwayEnterDescription(size_t& lineCount, const osmscout::RouteDescription::MotorwayEnterDescriptionRef& motorwayEnterDescription, const osmscout::RouteDescription::CrossingWaysDescriptionRef& crossingWaysDescription) { std::string crossingWaysString; if (crossingWaysDescription.Valid()) { crossingWaysString=CrossingWaysDescriptionToString(crossingWaysDescription); } if (!crossingWaysString.empty()) { NextLine(lineCount); std::cout << "At crossing " << crossingWaysString << std::endl; } NextLine(lineCount); std::cout << "Enter motorway"; if (motorwayEnterDescription->GetToDescription().Valid() && motorwayEnterDescription->GetToDescription()->HasName()) { std::cout << " '" << motorwayEnterDescription->GetToDescription()->GetDescription() << "'"; } std::cout << std::endl; }
void BeginParse(struct out *firstOUT, struct info *in) { const char *gfwStart, *gfwEnd; gfwEnd = gfwStart = in->decodeGFWlist; char *buf = (char*)malloc(sizeof(in->proxy) + 48 * sizeof(char)); sprintf(buf, "{+forward-override{%s .}}\n", in->proxy); appendtoOUT(firstOUT, buf); free(buf); gfwEnd = NextLine(gfwStart);//skip the first line :[AutoProxy 0.2.9] do { gfwStart = SkipBlank(gfwEnd); gfwEnd = NextLine(gfwStart); // apple appple apppple\n apppple...... // ^ ^ // | | // start end if (*gfwStart == '\0' || *gfwEnd == '\0') {//meet the end of in->decodeGFWlist break; } else { appendtoOUT(firstOUT, parseALine(gfwStart, gfwEnd)); } } while (1); }
static void RenderNextLineIfNeeded() { Area2D rect = {0, 0, WIDTH, SIZE}; WORD s = frameCount / 16; if (s > last_line) { APTR ptr = scroll->planes[0]; WORD line_num = (s % (LINES + 2)) * SIZE; char *line_end; WORD size; line_end = line_start; NextLine(&line_end); size = (line_end - line_start) - 1; ptr += line_num * scroll->bytesPerRow; rect.y = line_num; BitmapClearArea(scroll, &rect); WaitBlitter(); RenderLine(ptr, line_start, min(size, COLUMNS)); last_line = s; NextLine(&line_start); } }
void SimpleConsole::OutputChar( int ch ) { outbyte(0xE9,ch); //for bochs if(ch=='\t') { do{ OutputChar(' '); }while( (cursorX-1)%4 ); return; } if(ch=='\n') { NextLine(); } else if( ch == 8 ) { OutputChar( charStyle, cursorY, --cursorX ); } else if ( isprint((unsigned char)ch) ) { OutputChar( charStyle | ch, cursorY, cursorX++ ); } if(cursorX >= width ) { NextLine(); } MoveCursor(); }
static void DumpTurnDescription(size_t& lineCount, const osmscout::RouteDescription::TurnDescriptionRef& turnDescription, const osmscout::RouteDescription::CrossingWaysDescriptionRef& crossingWaysDescription, const osmscout::RouteDescription::DirectionDescriptionRef& directionDescription, const osmscout::RouteDescription::NameDescriptionRef& nameDescription) { std::string crossingWaysString; if (crossingWaysDescription.Valid()) { crossingWaysString=CrossingWaysDescriptionToString(crossingWaysDescription); } if (!crossingWaysString.empty()) { NextLine(lineCount); std::cout << "At crossing " << crossingWaysString << std::endl; } NextLine(lineCount); if (directionDescription.Valid()) { std::cout << MoveToTurnCommand(directionDescription->GetCurve()); } else { std::cout << "Turn"; } if (nameDescription.Valid() && nameDescription->HasName()) { std::cout << " into '" << nameDescription->GetDescription() << "'"; } std::cout << std::endl; }
/////////////////////////////////////////////////////////////////////////////// // // SkipBeginning // /////////////////////////////////////////////////////////////////////////////// int TFile::SkipBeginning() { mStateManager->ResetErrorCode(); typestr line; typestr aSpec; // Au debut de chaque fichier, il faut sauter deux lignes de commentaires if (NextLine(&line, false, &aSpec)) mStateManager->SetErrorD(9506, ERROR, aSpec.str()); if(NextLine(&line, false, &aSpec)) mStateManager->SetErrorD(9506, ERROR, aSpec.str()); return mStateManager->GetErrorCode(); }
static void DumpStartDescription(size_t& lineCount, const osmscout::RouteDescription::StartDescriptionRef& startDescription, const osmscout::RouteDescription::NameDescriptionRef& nameDescription) { NextLine(lineCount); std::cout << "Start at '" << startDescription->GetDescription() << "'" << std::endl; if (nameDescription.Valid() && nameDescription->HasName()) { NextLine(lineCount); std::cout << "Drive along '" << nameDescription->GetDescription() << "'" << std::endl; } }
/***************************************************************************** * Write a string to the current document *****************************************************************************/ void WriteString(char* sz, int len) { int tabn = (int)CURRENT_FILE->tabsout_num; int i=0; char *p=NULL; char ch=0; DWORD dwNumWritten=0; if ( pd.hDC == NULL ) return; if ( !documentON ) StartDocument( ); for (i = 0,p = sz; i < len; p++, i++) { ch = *p; switch ( ch ) { case '\n': // Line-feed NextLine(); break; case '\f' : // Form-feed NextPage(); break; case '\r' : // Carriage-return column = 0; break; case '\t' : // Tab column += tabn - (column % tabn); if ( bLineWrapping && column >= LOWORD(dwCharExtent) ) NextLine(); break; default : if ( isprint(ch) ) { if (defaultprinter) TextOut(pd.hDC, column++, row, &ch, 1); else WritePrinter( hPrinter, p, 1, &dwNumWritten ); // Wrap line if ( bLineWrapping && column >= LOWORD(dwCharExtent) ) NextLine(); } break; } // End switch } }
bool SDFfile::ReadHeader() { if (!IsOpen()) return true; // Read title title_ = GetLine(); RemoveTrailingWhitespace( title_ ); // Read past info and comment if (NextLine() == 0) return true; if (NextLine() == 0) return true; // Read Connection table const char* ptr = NextLine(); if (ptr == 0) return true; if (sscanf(ptr, "%i %i", &Natoms_, &Nbonds_) != 2) return true; return false; }
BOOL CReg::LoadRegFromMem(LPBYTE buf, DWORD size, BOOL bMerge) {_STTEX(); DWORD i = 0; // Lose old record if ( !bMerge ) Destroy(); // Sanity check if ( buf == NULL || size == 0 ) return FALSE; // No key currently m_pCurKey = NULL; i = SkipWhiteSpace( buf, size, i ); // Read in first line tag if ( i < size && buf[ i ] > ' ' && buf[ i ] <= '~' && buf[ i ] != '[' ) { // I really don't know what to do with this tag i = NextLine( buf, size, i ); } // end if // Process file while ( i < size && buf[ i ] != 0 ) { // Skip white space i = SkipWhiteSpace( buf, size, i ); if ( i < size && buf[ i ] == ';' ) i = NextLine( buf, size, i ); // Process this line if not a comment else if ( i < size && buf[ i ] != 0 ) { DWORD skip = ProcessLine( &buf[ i ], size - i ); // Did we read a valid line if ( skip != 0 ) i += skip; // Just skip invalid line else i = NextLine( buf, size, i ); } // end if } // end while return TRUE; }
bool Scanner::Next() { char currentChar; do { if(lastString) { currentToken = new Token(currentLine, currentPos, END_OF_FILE, DEFAULT, ""); return false; } currentChar = GetChar(); } while(IsSpace(currentChar) || IsTabulationSymbol(currentChar) || IsEndOfLine(currentChar)); if(IsCommentBegin(currentChar)) { char secondChar; if( IsCommentBegin(secondChar = GetChar()) ) { NextLine(); return Next(); } if(secondChar == '*') { while( GetChar() != '*' || !IsCommentBegin(GetChar()) ) {} return Next(); } else BackToPreviousChar(); } if(IsLetter(currentChar)) currentToken = GetIdentificator(currentChar); else if(IsNumber(currentChar)) currentToken = GetNumber(currentChar); else if(IsCharSeparator(currentChar)) currentToken = GetSymbol(currentChar); else if(IsStringSeparator(currentChar)) currentToken = GetString(currentChar); else if(IsSeparator(currentChar)) currentToken = GetSeparator(currentChar); else if(IsSpecialSymbol(currentChar)) currentToken = GetOperation(currentChar); else throw ScannerException(currentLine, currentPos, "Indefinite character: \"" + string(1, currentChar) + "\""); return true; }
static BOOL ParseVertexUVs(char **data, Mesh3D *mesh) { FLOAT scale_u = SPFlt(16); FLOAT scale_v = SPFlt(16); UVCoord *uv; WORD n; if (!(ReadShort(data, &n) && EndOfLine(data))) return FALSE; Log("[3D] Mesh has %ld uv coordinates\n", (LONG)n); mesh->uv = MemAlloc(sizeof(Point2D) * n, MEMF_PUBLIC); uv = mesh->uv ; while (NextLine(data) && !MatchString(data, "@end")) { FLOAT u, v; if (!(ReadFloat(data, &u) && ReadFloat(data, &v) && EndOfLine(data))) return FALSE; uv->u = SPFix(SPMul(u, scale_u)); uv->v = SPFix(SPMul(v, scale_v)); uv++; n--; } return n == 0; }
static BOOL ParseVertices(char **data, Mesh3D *mesh) { FLOAT scale = SPMul(mesh->scale, SPFlt(16)); Point3D *vertex; WORD n; if (!(ReadShort(data, &n) && EndOfLine(data))) return FALSE; Log("[3D] Mesh has %ld points\n", (LONG)n); mesh->vertices = n; mesh->vertex = MemAlloc(sizeof(Point3D) * n, MEMF_PUBLIC); vertex = mesh->vertex; while (NextLine(data) && !MatchString(data, "@end") && n > 0) { FLOAT x, y, z; if (!(ReadFloat(data, &x) && ReadFloat(data, &y) && ReadFloat(data, &z) && EndOfLine(data))) return FALSE; vertex->x = SPFix(SPMul(x, scale)); vertex->y = SPFix(SPMul(y, scale)); vertex->z = SPFix(SPMul(z, scale)); vertex++; n--; } return n == 0; }
__regargs Mesh3D *LoadMesh3D(char *filename, FLOAT scale) { char *file = LoadFile(filename, MEMF_PUBLIC); char *data = file; Mesh3D *mesh = MemAlloc(sizeof(Mesh3D), MEMF_PUBLIC|MEMF_CLEAR); Log("[3D] Parsing '%s' file\n", filename); mesh->scale = scale; while (NextLine(&data)) { ParserT *parser = TopLevelParser; for (; parser->name; parser++) { if (!MatchString(&data, parser->name)) continue; if (parser->func(&data, mesh)) break; Log("[3D] Syntax error at %ld position!\n", (LONG)(data - file)); DeleteMesh3D(mesh); return NULL; } } return mesh; }
static BOOL ParseSurface(char **data, Mesh3D *mesh) { MeshSurfaceT *surface; WORD n; if (!(ReadShort(data, &n) && EndOfLine(data))) return FALSE; surface = &mesh->surface[n]; while (NextLine(data) && !MatchString(data, "@end")) { if (MatchString(data, "color")) { if (!(ReadByte(data, &surface->r) && ReadByte(data, &surface->g) && ReadByte(data, &surface->b) && EndOfLine(data))) return FALSE; } else if (MatchString(data, "side")) { if (!(ReadByte(data, &surface->sideness) && EndOfLine(data))) return FALSE; } else if (MatchString(data, "texture")) { if (!(ReadShort(data, &surface->texture) && EndOfLine(data))) return FALSE; } else { SkipLine(data); } } return TRUE; }
void ASNLexer::SkipComment(void) { CComment& comment = AddComment(); while ( true ) { // wait for end of comments char c = Char(); switch ( c ) { case '\n': SkipChar(); NextLine(); return; case 0: if ( Eof() ) return; break; case '-': if ( Char(1) == '-' ) { SkipChars(2); return; } break; case '*': if ( Char(1) == '/' ) { SkipChars(2); return; } break; } comment.AddChar(c); SkipChar(); } }
static void DumpTargetDescription(size_t& lineCount, const osmscout::RouteDescription::TargetDescriptionRef& targetDescription) { NextLine(lineCount); std::cout << "Target reached '" << targetDescription->GetDescription() << "'" << std::endl; }
static void OldStyleComment (void) /* Remove an old style C comment from line. */ { /* Remember the current line number, so we can output better error * messages if the comment is not terminated in the current file. */ unsigned StartingLine = GetCurrentLine(); /* Skip the start of comment chars */ NextChar (); NextChar (); /* Skip the comment */ while (CurC != '*' || NextC != '/') { if (CurC == '\0') { if (NextLine () == 0) { PPError ("End-of-file reached in comment starting at line %u", StartingLine); return; } } else { if (CurC == '/' && NextC == '*') { PPWarning ("`/*' found inside a comment"); } NextChar (); } } /* Skip the end of comment chars */ NextChar (); NextChar (); }
bool ScrollBar::VertKey(dword key, bool homeend) { if(!IsVisible() || !IsEnabled() || GetRect().IsEmpty()) return false; switch(key) { case K_PAGEUP: PrevPage(); break; case K_PAGEDOWN: NextPage(); break; case K_UP: PrevLine(); break; case K_DOWN: NextLine(); break; case K_HOME: if(!homeend) break; case K_CTRL_HOME: case K_CTRL_PAGEUP: Begin(); break; case K_END: if(!homeend) break; case K_CTRL_END: case K_CTRL_PAGEDOWN: End(); break; default: return false; } return true; }
bool ScrollBar::HorzKey(dword key) { if(!IsVisible() || !IsEnabled() || GetRect().IsEmpty()) return false; switch(key) { case K_CTRL_LEFT: PrevPage(); break; case K_CTRL_RIGHT: NextPage(); break; case K_LEFT: PrevLine(); break; case K_RIGHT: NextLine(); break; case K_HOME: Begin(); break; case K_END: End(); break; default: return false; } return true; }
/* ************************************************************************************** * ReadNames: * Read all the position names in the position definiton file and store * them in the POSITIONS table. Also, allocate and initialize the HP Line * share logical vectors for every name read. ************************************************************************************** */ void ReadNames() { int p = 0; char *ptr; char *nameptr; infof("Reading position definition names..."); while (NextLine()) { if (strncmp(IOBuff,"DEFINE POSITION ",16)) continue; ptr = IOBuff + 16; nameptr = NextToken(&ptr,DYNAMIC_STRING); if (nameptr == NULL) { errorfp("Missing name at line %d",CurrentLine); continue; } if (!CopyValidName(nameptr,Positions[p].name.name)) errorfp("Invalid name %s at line %d",nameptr,CurrentLine); if (LookupName(Positions[p].name.name) != p) errorfp("Multiply defined name %s at line %d", Positions[p].name.name,CurrentLine); p++; free(nameptr); } if (p != TotalPositions) { errorfp("Expected %d names, found %d",TotalPositions,p); TotalPositions = p; } }
char Scanner::GetChar() { if(currentPos < currentString.length()) return currentString[currentPos++]; NextLine(); return '\0'; }
int FormatText::CountLines ( FTTextureFont* font, const char* text, float maxwidth, float* outMaxLineWidth ) { assert(outMaxLineWidth); int lineCount = 0; int lineEnd = 0; (*outMaxLineWidth) = -1; do { int outStart = 0; float outPixelWidth = 0; NextLine(font, text, lineEnd, maxwidth, &outStart, &lineEnd, &outPixelWidth); (*outMaxLineWidth) = std::max((*outMaxLineWidth), outPixelWidth); lineCount++; } while (text[lineEnd] != '\0'); return lineCount; }
void OOPLyric::OnTimerNotify(wxTimerEvent &) { wxASSERT(IsOk()); if (m_Window->IsExiting()) { return; } if (m_stopWatch->Time() >= m_parser->GetTimeSum()) { m_timer.Stop(); return; } //----------------------------------------------------- VdkDC dc(m_Window, GetAbsoluteRect(), NULL); LineIter next(m_currLine); ++next; if (next != m_parser->end()) { if ((*next)->GetStartTime() <= m_stopWatch->Time()) { NextLine(&dc, false); return; } } CorrectViewStart(&dc); }
static BOOL ParseFaceUVs(char **data, Mesh3D *mesh) { IndexListT **faceUVs; WORD *index; WORD n, m; if (!(ReadShort(data, &n) && ReadShort(data, &m) && EndOfLine(data))) return FALSE; mesh->faceUV = MemAlloc(sizeof(IndexListT *) * (n + 1) + sizeof(WORD) * (m + n), MEMF_PUBLIC|MEMF_CLEAR); faceUVs = mesh->faceUV; index = (WORD *)&mesh->faceUV[n + 1]; while (NextLine(data) && !MatchString(data, "@end")) { IndexListT *faceUV = (IndexListT *)index++; while (!EndOfLine(data)) { if (!ReadShort(data, index++)) return FALSE; faceUV->count++, m--; } *faceUVs++ = faceUV, n--; } return (n == 0) && (m == 0); }
bool Loader::ReadToken(char *token, bool trim, bool lcase) { int i = 0; do { strcpy(token, ""); EatWhitespace(); if (!ReadString(token)) return false; if ((strncmp(token, "//", 2) == 0) || (strncmp(token, "#", 1) == 0)) { NextLine(); // Ignore the comment line strcpy(token, ""); } } while (!strcmp(token, "")); if (trim) Trim(token); if (lcase) LCase(token); return true; }
void ASNLexer::LookupComments(void) { while ( true ) { char c = Char(); switch ( c ) { case ' ': case '\t': case '\r': SkipChar(); break; case '\n': SkipChar(); NextLine(); break; case '-': if ( Char(1) == '-' ) { // comments SkipChars(2); SkipComment(); break; } return; case '/': if ( Char(1) == '*' ) { // comments SkipChars(2); SkipComment(); break; } return; default: return; } } }
static void DumpMotorwayLeaveDescription(size_t& lineCount, const osmscout::RouteDescription::MotorwayLeaveDescriptionRef& motorwayLeaveDescription, const osmscout::RouteDescription::DirectionDescriptionRef& directionDescription, const osmscout::RouteDescription::NameDescriptionRef& nameDescription) { NextLine(lineCount); std::cout << "Leave motorway"; if (motorwayLeaveDescription->GetFromDescription().Valid() && motorwayLeaveDescription->GetFromDescription()->HasName()) { std::cout << " '" << motorwayLeaveDescription->GetFromDescription()->GetDescription() << "'"; } if (directionDescription.Valid() && directionDescription->GetCurve()!=osmscout::RouteDescription::DirectionDescription::slightlyLeft && directionDescription->GetCurve()!=osmscout::RouteDescription::DirectionDescription::straightOn && directionDescription->GetCurve()!=osmscout::RouteDescription::DirectionDescription::slightlyRight) { std::cout << " " << MoveToTurnCommand(directionDescription->GetCurve()); } if (nameDescription.Valid() && nameDescription->HasName()) { std::cout << " into '" << nameDescription->GetDescription() << "'"; } std::cout << std::endl; }
static int SkipWhitespace (int SkipLines) /* Skip white space in the input stream. Do also skip newlines if SkipLines * is true. Return zero if nothing was skipped, otherwise return a * value != zero. */ { int Skipped = 0; while (1) { if (IsSpace (CurC)) { NextChar (); Skipped = 1; } else if (CurC == '\0' && SkipLines) { /* End of line, read next */ if (NextLine () != 0) { Skipped = 1; } else { /* End of input */ break; } } else { /* No more white space */ break; } } return Skipped; }
static void DumpRoundaboutEnterDescription(size_t& lineCount, const osmscout::RouteDescription::RoundaboutEnterDescriptionRef& roundaboutEnterDescription, const osmscout::RouteDescription::CrossingWaysDescriptionRef& crossingWaysDescription) { std::string crossingWaysString; if (crossingWaysDescription.Valid()) { crossingWaysString=CrossingWaysDescriptionToString(crossingWaysDescription); } if (!crossingWaysString.empty()) { NextLine(lineCount); std::cout << "At crossing " << crossingWaysString << std::endl; } NextLine(lineCount); std::cout << "Enter roundabout" << std::endl; }