bool ProcBegin( void ) /***************************/ /* process a new overlay area */ { section *oldsect; file_list **oldflist; section *sect; LinkState |= FMT_SPECIFIED; // she must want DOS mode. if( ( OvlLevel > 0 ) && FmtData.u.dos.dynamic ) { oldsect = NULL; oldflist = NULL; CmdFlags &= ~CF_AUTOSECTION; // merge old area with this. } else { oldsect = CurrSect; oldflist = CurrFList; sect = NewSection(); if( LinkFlags & ANY_DBI_FLAG ) { DBISectInit( sect ); } NewArea( sect ); sect->relocs = SECT_ALREADY_MADE; CurrSect = sect; CurrFList = §->files; } OvlLevel++; while( ProcOne( Sections, SEP_NO, FALSE ) != FALSE ) {} // NULL LOOP if( ( OvlLevel == 0 ) || !FmtData.u.dos.dynamic ) { CurrFList = oldflist; CurrSect = oldsect; } return( TRUE ); }
static void ResetSubSystems( void ) /*********************************/ { ResetPermData(); ResetMsg(); VirtMemInit(); ResetMisc(); Root = NewSection(); ResetDBI(); ResetMapIO(); ResetCmdAll(); ResetOvlSupp(); ResetComdef(); ResetDistrib(); ResetLoadNov(); ResetLoadPE(); ResetObj2Supp(); ResetObjIO(); ResetObjOMF(); ResetObjPass1(); // ResetDistrib(); // duplicate call ResetObjStrip(); ResetOMFReloc(); ResetReloc(); ResetSymTrace(); ResetLoadFile(); ResetAddr(); ResetToc(); }
TSharedRef<ISequencerSection> FAnimationTrackEditor::MakeSectionInterface( UMovieSceneSection& SectionObject, UMovieSceneTrack* Track ) { check( SupportsType( SectionObject.GetOuter()->GetClass() ) ); TSharedRef<ISequencerSection> NewSection( new FAnimationSection(SectionObject) ); return NewSection; }
// Create a field on the vertices with given degrees of freedom Vec NewField(MPI_Comm comm, DM mesh, uint32_t dof) { Vec field; VecCreate(comm, &field); // Create a new section PetscSection section = NewSection(comm, mesh, dof); // Set the vector size int size; PetscSectionGetStorageSize(section, &size); VecSetSizes(field, size, PETSC_DETERMINE); // Finalise setup VecSetFromOptions(field); return field; }
char *DFsScript::ProcessFindChar(char *datap, char find) { while(*datap) { if(*datap==find) return datap; if(*datap=='\"') // found a quote: ignore stuff in it { datap++; while(*datap && *datap != '\"') { // escape sequence ? if(*datap=='\\') datap++; datap++; } // error: end of script in a constant if(!*datap) return NULL; } // comments: blank out if(*datap=='/' && *(datap+1)=='*') // /* -- */ comment { while(*datap && (*datap != '*' || *(datap+1) != '/') ) { *datap=' '; datap++; } if(*datap) *datap = *(datap+1) = ' '; // blank the last bit else { // script terminated in comment script_error("script terminated inside comment\n"); } } if(*datap=='/' && *(datap+1)=='/') // // -- comment { while(*datap != '\n') { *datap=' '; datap++; // blank out } } /********** labels ****************/ // labels are also found during the // preprocessing. these are of the form // // label_name: // // and are used for the goto function. // goto labels are stored as variables. if(*datap==':' && scriptnum != -1) // not in global scripts { char *labelptr = datap-1; while(!isop(*labelptr)) labelptr--; FString labelname(labelptr+1, strcspn(labelptr+1, ":")); if (labelname.Len() == 0) { Printf(PRINT_BOLD,"Script %d: ':' encountrered in incorrect position!\n",scriptnum); } DFsVariable *newlabel = NewVariable(labelname, svt_label); newlabel->value.i = MakeIndex(labelptr); } if(*datap=='{') // { -- } sections: add 'em { DFsSection *newsec = NewSection(datap); newsec->type = st_empty; // find the ending } and save char * theend = ProcessFindChar(datap+1, '}'); if(!theend) { // brace not found // This is fatal because it will cause a crash later // if the game isn't terminated. I_Error("Script %d: section error: no ending brace\n", scriptnum); } newsec->end_index = MakeIndex(theend); // continue from the end of the section datap = theend; } datap++; } return NULL; }
Section* ReadSection (FILE* F, ObjData* O) /* Read a section from a file */ { unsigned Name; unsigned Size; unsigned long Alignment; unsigned char Type; unsigned FragCount; Segment* S; Section* Sec; /* Read the segment data */ (void) Read32 (F); /* File size of data */ Name = MakeGlobalStringId (O, ReadVar (F)); /* Segment name */ ReadVar (F); /* Segment flags (currently unused) */ Size = ReadVar (F); /* Size of data */ Alignment = ReadVar (F); /* Alignment */ Type = Read8 (F); /* Segment type */ FragCount = ReadVar (F); /* Number of fragments */ /* Print some data */ Print (stdout, 2, "Module '%s': Found segment '%s', size = %u, alignment = %lu, type = %u\n", GetObjFileName (O), GetString (Name), Size, Alignment, Type); /* Get the segment for this section */ S = GetSegment (Name, Type, GetObjFileName (O)); /* Allocate the section we will return later */ Sec = NewSection (S, Alignment, Type); /* Remember the object file this section was from */ Sec->Obj = O; /* Set up the combined segment alignment */ if (Sec->Alignment > 1) { Alignment = LeastCommonMultiple (S->Alignment, Sec->Alignment); if (Alignment > MAX_ALIGNMENT) { Error ("Combined alignment for segment '%s' is %lu which exceeds " "%lu. Last module requiring alignment was '%s'.", GetString (Name), Alignment, MAX_ALIGNMENT, GetObjFileName (O)); } else if (Alignment >= LARGE_ALIGNMENT) { Warning ("Combined alignment for segment '%s' is suspiciously " "large (%lu). Last module requiring alignment was '%s'.", GetString (Name), Alignment, GetObjFileName (O)); } S->Alignment = Alignment; } /* Start reading fragments from the file and insert them into the section . */ while (FragCount--) { Fragment* Frag; /* Read the fragment type */ unsigned char Type = Read8 (F); /* Extract the check mask from the type */ unsigned char Bytes = Type & FRAG_BYTEMASK; Type &= FRAG_TYPEMASK; /* Handle the different fragment types */ switch (Type) { case FRAG_LITERAL: Frag = NewFragment (Type, ReadVar (F), Sec); ReadData (F, Frag->LitBuf, Frag->Size); break; case FRAG_EXPR: case FRAG_SEXPR: Frag = NewFragment (Type, Bytes, Sec); Frag->Expr = ReadExpr (F, O); break; case FRAG_FILL: /* Will allocate memory, but we don't care... */ Frag = NewFragment (Type, ReadVar (F), Sec); break; default: Error ("Unknown fragment type in module '%s', segment '%s': %02X", GetObjFileName (O), GetString (S->Name), Type); /* NOTREACHED */ return 0; } /* Read the line infos into the list of the fragment */ ReadLineInfoList (F, O, &Frag->LineInfos); /* Remember the module we had this fragment from */ Frag->Obj = O; } /* Return the section */ return Sec; }
bool IniReader::Parse() { FILE* f = OpenGameFile(m_filename, "r"); if(f == NULL) return false; bool res = true; enum ParseState { S_DEFAULT, S_IGNORERESTLINE, S_PROPNAME, S_PROPVALUE, S_SECTION }; ParseState state = S_DEFAULT; std::string propname; std::string section; std::string value; while(!feof(f) && !ferror(f)) { unsigned char c = 0; if(fread(&c, 1, 1, f) == 0) break; if(c == '\r') continue; // ignore this switch(state) { case S_DEFAULT: if(c >= 128) break; // just ignore unicode-stuff when we are in this state (UTF8 bytes at beginning are also handled by this) else if(isspace(c)) break; // ignore spaces and newlines else if(c == '#') { state = S_IGNORERESTLINE; /* this is a comment */ break; } else if(c == '[') { state = S_SECTION; section = ""; break; } else if(c == '=') { warnings << "WARNING: \"=\" is not allowed as the first character in a line of " << m_filename << endl; break; /* ignore */ } else { state = S_PROPNAME; propname = c; break; } case S_SECTION: if(c == ']') { if( ! OnNewSection(section) ) { res = false; goto parseCleanup; } state = S_DEFAULT; NewSection(section); break; } else if(c == '\n') { warnings << "WARNING: section-name \"" << section << "\" of " << m_filename << " is not closed correctly" << endl; state = S_DEFAULT; break; } else if(isspace(c)) { warnings << "WARNING: section-name \"" << section << "\" of " << m_filename << " contains a space" << endl; break; /* ignore */ } else { section += c; break; } case S_PROPNAME: if(c == '\n') { warnings << "WARNING: property \"" << propname << "\" of " << m_filename << " incomplete" << endl; state = S_DEFAULT; break; } else if(isspace(c)) break; // just ignore spaces else if(c == '=') { state = S_PROPVALUE; value = ""; break; } else { propname += c; break; } case S_PROPVALUE: if(c == '\n' || c == '#') { if( ! OnEntry(section, propname, value) ) { res = false; goto parseCleanup; } NewEntryInSection(propname, value); if(c == '#') state = S_IGNORERESTLINE; else state = S_DEFAULT; break; } else if(isspace(c) && value == "") break; // ignore heading spaces else { value += c; break; } case S_IGNORERESTLINE: if(c == '\n') state = S_DEFAULT; break; // ignore everything } } // In case the endline is missing at the end of file, finish the parsing of the last line if (state == S_PROPVALUE) { if( ! OnEntry(section, propname, value) ) { res = false; goto parseCleanup; } NewEntryInSection(propname, value); } // DEBUG: dump the file /*notes << "Dump of " << m_filename << endl; for (SectionMap::iterator it = m_sections.begin(); it != m_sections.end(); ++it) { notes << "[" << it->first << "]" << endl; for (Section::iterator k = it->second.begin(); k != it->second.end(); ++k) notes << k->first << "=" << k->second << endl; notes << endl; } notes << endl;*/ parseCleanup: fclose(f); return res; }
//============================================================================= // // // //============================================================================= bool CreateSections() { int pick = 0; MarkInternalSubsectors(); while (pick < numsubsectors) { if (ISDONE(pick, processed_subsectors)) { pick++; continue; } subsector_t *subsector = &subsectors[pick]; seg_t *workseg = NULL; vertex_t *startpt = NULL; NewSection(subsector->render_sector); while (1) { if (!ISDONE(subsector-subsectors, processed_subsectors)) { SETDONE(subsector-subsectors, processed_subsectors); section->subsectors.Push(subsector); SectionForSubsector[subsector - subsectors] = int(section - &Sections[0]); } bool result = AddSubSector(subsector, startpt, &workseg); if (!result) { return false; // couldn't create Sections } else if (workseg != NULL) { // crossing into another subsector seg_t *partner = workseg->PartnerSeg; if (workseg->v2 != partner->v1) { DPrintf("Inconsistent subsector references in seg %d. Cannot create Sections.\n", workseg-segs); return false; } subsector = partner->Subsector; startpt = workseg->v1; } else { // loop complete. Check adjoining subsectors for other loops to // be added to this section if (!FindNextSeg(&workseg)) { return false; } else if (workseg == NULL) { // No more subsectors found. This section is complete! FinalizeSection(); break; } else { subsector = workseg->Subsector; // If this is a regular seg, start there, otherwise start // at the subsector's first seg startpt = workseg->sidedef == NULL? NULL : workseg->v1; NewLoop(); } } } } if (!CheckSections()) return false; SetReferences(); Sections.ShrinkToFit(); SectionLoops.ShrinkToFit(); SectionLines.ShrinkToFit(); tesselateSections(); return true; }