char * CFile::GetS (char * buf, size_t n) { char * t = buf; size_t i; int c; for (i = 0; i < n - 1; i++) { do { if (m_cf.rawPosition >= m_cf.size) { *buf = 0; return (buf == t) ? NULL : t; } c = GetC (); if (c == 0 || c == 10) // Unix line ending break; if (c == 13) { // Mac or DOS line ending int c1 = GetC (); Seek ( -1, SEEK_CUR); if (c1 == 10) // DOS line ending continue; else // Mac line ending break; } } while (c == 13); if (c == 0 || c == 10 || c == 13) // because cr-lf is a bad thing on the mac break; // and anyway -- 0xod is CR on mac, not 0x0a *buf++ = c; if (c == '\n') break; } *buf++ = 0; return t; }
String FileZip::GetS() { // Check parameters if (m_cZipFile.IsFileOpen()) { // Read string char szString[2048]; char *pszPos = szString; int nChar = GetC(); while (nChar >= 0 && nChar != 10) { // Concatenate char to string *pszPos = static_cast<char>(nChar); pszPos++; // Read next character nChar = GetC(); } // Terminate string if (nChar == 10) { *pszPos = '\n'; pszPos++; } *pszPos = 0; // Return string if (pszPos > szString || nChar != -1) return szString; } // Error! return ""; }
wxSVGMatrix wxSVGMatrix::Multiply(const wxSVGMatrix& secondMatrix) const { wxSVGMatrix res; res.SetA(GetA() * secondMatrix.GetA() + GetC() * secondMatrix.GetB()); res.SetB(GetB() * secondMatrix.GetA() + GetD() * secondMatrix.GetB()); res.SetC(GetA() * secondMatrix.GetC() + GetC() * secondMatrix.GetD()); res.SetD(GetB() * secondMatrix.GetC() + GetD() * secondMatrix.GetD()); res.SetE(GetA() * secondMatrix.GetE() + GetC() * secondMatrix.GetF() + GetE()); res.SetF(GetB() * secondMatrix.GetE() + GetD() * secondMatrix.GetF() + GetF()); return res; }
void CttView::LineCai(const CPoint &x, const CPoint &y){ int c[2][4]; int cnum[2]; CDC* pDC = GetWindowDC(); CPen pen1(0, 0, RGB(255, 0, 0)); CPen pen2(0, 3, RGB(0, 0, 0)); CPen pen3(0, 2, RGB(0, 0, 0)); GetC(c[0],cnum[0],x); GetC(c[1],cnum[1],y); if (cnum[0] & cnum[1]){ pDC->SelectObject(&pen1); pDC->MoveTo(x); pDC->LineTo(y); return; } if ((cnum[0] | cnum[1])==0){ pDC->SelectObject(&pen2); pDC->MoveTo(x); pDC->LineTo(y); return; } pDC->SelectObject(&pen1); pDC->MoveTo(x); pDC->LineTo(y); CPoint a[2]; int an = 0; if (c[0][0] != c[1][0])//与下边有交 { int jx = x.x + (1.0*m_d - x.y) / (y.y - x.y) *(y.x - x.x); if (jx > m_l && jx < m_r) a[an++] = CPoint(jx, m_d); } if (c[0][1] != c[1][1])//与上边有交 { int jx = x.x + (1.0*m_u - x.y) / (y.y - x.y) *(y.x - x.x); if (jx > m_l && jx < m_r) a[an++] = CPoint(jx, m_u); } if (c[0][2] != c[1][2])//与右边有交 { int jy = x.y + (1.0*m_r - x.x) / (y.x - x.x) *(y.y - x.y); if (jy < m_d && jy > m_u) a[an++] = CPoint(m_r, jy); } if (c[0][3] != c[1][3])//与左边有交 { int jy = x.y + (1.0*m_l - x.x) / (y.x - x.x) *(y.y - x.y); if (jy < m_d && jy > m_u) a[an++] = CPoint(m_l, jy); } if (an == 1){ if (cnum[0] == 0)a[an++] = x; else a[an++] = y; } pDC->SelectObject(&pen2); pDC->MoveTo(a[0]); pDC->LineTo(a[1]); }
wxSVGMatrix wxSVGMatrix::Inverse() const { wxSVGMatrix res; double d = 1.0 / (GetA() * GetD() - GetB() * GetC()); res.SetA(GetD() * d); res.SetB(-GetB() * d); res.SetC(-GetC() * d); res.SetD(GetA() * d); res.SetE(-GetE() * res.GetA() - GetF() * res.GetC()); res.SetF(-GetE() * res.GetB() - GetF() * res.GetD()); return res; }
//----------------------------------------------------------------------------- // // CloudP series // //----------------------------------------------------------------------------- void mglGraph::AVertex(mreal x,mreal y,mreal z, mreal a,mreal alpha) { mglColor c; if(!ScalePoint(x,y,z) || isnan(a)) return; a = GetA(a); if(OnCoord) c = GetC(x,y,z); else c = GetC(a,false); a = alpha>0 ? (a+1)*(a+1)/4 : -(a-1)*(a-1)/4; // a = alpha>0 ? (a+1)/2 : (a-1)/2; if(a) Ball(x,y,z,c,-alpha*a); }
void SimplexLP::ShiftLowerBoundsToZero( void ) { //-------------------------------------------------------------------------- // Shift lower bounds to zero (where possible, i.e. where the lower bounds // are finite. Adjust the finite upper bound on variable as well as the // value of the objective function fixed adjustment accordingly. // Int_T i, nn = GetN(), len; Ptr<Real_T> a; Ptr<Int_T> row; for( i = 0; i < nn; i++ ) { Real_T ll = GetL( i ); Bool_T up = ( GetVarType( i ) & VT_HAS_LO_BND ) ? True : False; if( up && IsNonZero( ll ) ) { for( MPS_LP::GetColumn( i, a, row, len ); len; --len, ++a, ++row ) b[ *row ] -= *a * ll; if( up ) u[i] -= ll; f += GetC( i ) * ll; } } }
void SimplexLP::GetPenaltyEstimates( Real_T &MinM, Real_T &MaxM ) { //-------------------------------------------------------------------------- // Estimate the minimum penalty. // MaxM = -INFINITY; // "Guarantees" that the problem will not be unbounded. MinM = +INFINITY; // Guarantees that the problem will be unbounded. Ptr<Real_T> a; Ptr<Int_T> row; Int_T j, len, nn = GetStructN(); for( j = 0; j < nn; j++ ) { Real_T x = 0.0; for( GetColumn( j, a, row, len ); len; --len, ++a, ++row ) if( ! ( LambdaVT[ *row ] & VT_FX ) ) x += Lambda[ *row ] * *a; if( IsNonZero( x ) ) { x = GetC( j ) / x; if( MaxM < x ) MaxM = x; if( MinM > x ) MinM = x; } } }
bool Grid::isConsistent() { bool result = true; if(Col1().isConsistent()){result=false;} if(Col2().isConsistent()){result=false;} if(Col3().isConsistent()){result=false;} if(Col4().isConsistent()){result=false;} if(Col5().isConsistent()){result=false;} if(Col6().isConsistent()){result=false;} if(Col7().isConsistent()){result=false;} if(Col8().isConsistent()){result=false;} if(Col9().isConsistent()){result=false;} if(Row1().isConsistent()){result=false;} if(Row2().isConsistent()){result=false;} if(Row3().isConsistent()){result=false;} if(Row4().isConsistent()){result=false;} if(Row5().isConsistent()){result=false;} if(Row6().isConsistent()){result=false;} if(Row7().isConsistent()){result=false;} if(Row8().isConsistent()){result=false;} if(Row9().isConsistent()){result=false;} if(GetNO().isConsistent()){result=false;} if(GetN().isConsistent()){result=false;} if(GetNE().isConsistent()){result=false;} if(GetO().isConsistent()){result=false;} if(GetC().isConsistent()){result=false;} if(GetE().isConsistent()){result=false;} if(GetSO().isConsistent()){result=false;} if(GetS().isConsistent()){result=false;} if(GetSE().isConsistent()){result=false;} return result; }
//----------------------------------------------------------------------------- // // Surf3 series // //----------------------------------------------------------------------------- long mglGraph::add_spoint(long &pc,mreal **p,mreal **k,mreal **b,mreal **n, mreal x,mreal y,mreal z,mreal nx,mreal ny,mreal nz, mreal k1,mreal k2,mreal k3,mreal a) { static long pMax=0; if(!ScalePoint(x,y,z) || a==0) return -1; mglColor c; if(OnCoord) c = GetC(x,y,z); else c = Pal[100]; if(!(*p)) { pMax = 100; pc = 0; *p = (mreal *)malloc(3*pMax*sizeof(mreal)); *n = (mreal *)malloc(3*pMax*sizeof(mreal)); *k = (mreal *)malloc(3*pMax*sizeof(mreal)); *b = (mreal *)malloc(4*pMax*sizeof(mreal)); } b[0][4*pc] = c.r; b[0][4*pc+1] = c.g; b[0][4*pc+2] = c.b; b[0][4*pc+3] = Transparent ? a : 1; p[0][3*pc] = x; p[0][3*pc+1] = y; p[0][3*pc+2] = z; n[0][3*pc] = nx; n[0][3*pc+1] = ny; n[0][3*pc+2] = nz; k[0][3*pc] = k1; k[0][3*pc+1] = k2; k[0][3*pc+2] = k3; pc++; if(pc>=pMax) { pMax += 100; *p = (mreal *)realloc(*p,3*pMax*sizeof(mreal)); *n = (mreal *)realloc(*n,3*pMax*sizeof(mreal)); *k = (mreal *)realloc(*k,3*pMax*sizeof(mreal)); *b = (mreal *)realloc(*b,4*pMax*sizeof(mreal)); } return pc-1; }
void O3QuadraticEquation<TYPE>::GetXIntercepts(double* r1, double* r2, const double x) const { double a=GetA(), b=GetB(), c=GetC()-x; double sqrt_b2_minus_4ac = sqrt((b*b)-(4*a*c)); double recip_2a = O3recip(2*a); if (r1) *r1 = (-b + sqrt_b2_minus_4ac) * recip_2a; if (r2) *r2 = (-b - sqrt_b2_minus_4ac) * recip_2a; }
LLBC_MD5::MD5GroupDigest &LLBC_MD5::MD5GroupDigest::operator +=(const LLBC_MD5::MD5GroupDigest &right) { SetA(GetA() + right.GetA()); SetB(GetB() + right.GetB()); SetC(GetC() + right.GetC()); SetD(GetD() + right.GetD()); return *this; }
/* skip over line continuations to start of next property */ static uint NextProperty( TidyConfigImpl* config ) { do { /* skip to end of line */ while ( config->c != '\n' && config->c != '\r' && config->c != EndOfStream ) config->c = GetC( config ); /* treat \r\n \r or \n as line ends */ if ( config->c == '\r' ) config->c = GetC( config ); if ( config->c == '\n' ) config->c = GetC( config ); } while ( IsWhite(config->c) ); /* line continuation? */ return config->c; }
char * CxMemFile::GetS(char *string, int32_t n) { n--; int32_t c,i=0; while (i<n){ c = GetC(); if (c == EOF) return 0; string[i++] = (char)c; if (c == '\n') break; } string[i] = 0; return string; }
OBUnitCell::LatticeType OBUnitCell::GetLatticeType() const { if (_lattice != Undefined) return _lattice; else if (_spaceGroup != NULL) return GetLatticeType(_spaceGroup->GetId()); double a = GetA(); double b = GetB(); double c = GetC(); double alpha = GetAlpha(); double beta = GetBeta(); double gamma = GetGamma(); unsigned int rightAngles = 0; if (IsApprox(alpha, 90.0, 1.0e-3)) rightAngles++; if (IsApprox(beta, 90.0, 1.0e-3)) rightAngles++; if (IsApprox(gamma, 90.0, 1.0e-3)) rightAngles++; // recast cache member "_lattice" as mutable OBUnitCell::LatticeType *lattice = const_cast<OBUnitCell::LatticeType*>(&_lattice); switch (rightAngles) { case 3: if (IsApprox(a, b, 1.0e-4) && IsApprox(b, c, 1.0e-4)) *lattice = Cubic; else if (IsApprox(a, b, 1.0e-4) || IsApprox(b, c, 1.0e-4)) *lattice = Tetragonal; else *lattice = Orthorhombic; break; case 2: if ( (IsApprox(alpha, 120.0, 1.0e-3) || IsApprox(beta, 120.0, 1.0e-3) || IsApprox(gamma, 120.0f, 1.0e-3)) && (IsApprox(a, b, 1.0e-4) || IsApprox(b, c, 1.0e-4)) ) *lattice = Hexagonal; else *lattice = Monoclinic; break; default: if (IsApprox(a, b, 1.0e-4) && IsApprox(b, c, 1.0e-4)) *lattice = Rhombohedral; else *lattice = Triclinic; } return *lattice; }
void P (int64 t) { int cc; /* { dg-excess-errors "note: 'cc' was declared here" } */ if (GetC (&cc) <= 0 ) /* return flag checked wrongly */ return; if (t && cc <= 0 ) /* { dg-warning "uninitialized" "uninitialized variable warning" } */ { this->do_sth(); return; } do_sth2(); }
/* * Read the file's contents for the given page and set up the display in case * we decide to use it. */ static int StartPage(int *infile, /* in/out: current-line # */ int skip, /* in: # of lines to skip */ int *eoff) /* out: set iff we got eof */ { int c; int blank = (*infile == 0) || (*infile + 1 == LineAt[*infile].blank); int y = mark_W + 1; showMARK(Shift); move(y, 0); typeinit(); HadPattern = FALSE; *eoff = FALSE; for (;;) { if ((c = GetC()) == EOF) { *eoff = TRUE; if (Tlen == 0) break; } if (*eoff || typeconv(c)) { if (Tlen == 0) { LineAt[(*infile)].blank = *infile > 0 ? LineAt[(*infile) - 1].blank + 1 : 1; } else { LineAt[(*infile)].blank = 0; } MarkLine(infile); if ((Tlen == 0) && blank) { typeinit(); continue; } blank = (Tlen == 0); y = typeline(y, skip); if (*eoff || (y >= LINES - 1)) break; } } if (!feof(InFile) && ferror(InFile)) clearerr(InFile); return y; /* result is the current line of display */ }
void mux_process::process_input(bool end_of_process) { if (!m_dialog) return; std::string input; auto in = GetInputStream(); if (in) while (in->CanRead()) input += in->GetC(); if (end_of_process) input += "\n"; if (!input.empty()) m_dialog->add_input(input); }
int main() { float a, b, x, y, c, e, Cn = 0, m; printf("Vvedite a: "); scanf("%f", &a); printf("Vvedite b: "); scanf("%f", &b); printf("Vvedite e: "); scanf("%f", &e); m = 1; while (m >= e) { c = GetC(a, b); m = absf(c - Cn); Cn = c; if (f(a)*f(c) < 0) b = c; if (f(c)*f(b) < 0) a = c; } printf("Otvet: %10.4f", c); getch(); return (0); }
/* returns false if unknown option, missing parameter, ** or option doesn't use parameter */ Bool ParseConfigValue( TidyDocImpl* doc, TidyOptionId optId, ctmbstr optval ) { const TidyOptionImpl* option = option_defs + optId; Bool status = ( optId < N_TIDY_OPTIONS && optval != NULL ); if ( !status ) ReportBadArgument( doc, option->name ); else { TidyBuffer inbuf = {0}; /* Set up input source */ tidyBufAttach( &inbuf, (byte*)optval, tmbstrlen(optval)+1 ); doc->config.cfgIn = BufferInput( doc, &inbuf, ASCII ); doc->config.c = GetC( &doc->config ); status = option->parser( doc, option ); freeStreamIn(doc->config.cfgIn); /* Release input source */ doc->config.cfgIn = NULL; tidyBufDetach( &inbuf ); } return status; }
//--------------------------------------------------------------------------------------------- void TEditorMapLogic::CheckTerrainGroupUpdateForSave() { Ogre::TerrainGroup* pTG = GetC()->pGraphicEngine->GetGE()->GetTerrainGroup(); // проверка: идёт ли создание данных для теней и света для земли if( pTG->isDerivedDataUpdateInProgress() ) { if( flgIsTerrainGroupUpdate == false ) { // начался процесс создания, TODO: вывести сообщение в GUI? flgIsTerrainGroupUpdate = true; } } else { if( flgIsTerrainGroupUpdate ) { // закончился процесс создания, TODO: вывести сообщение в GUI? pTG->saveAllTerrains( false ); flgIsTerrainGroupUpdate = false; } } // README: флаг flgIsTerrainGroupUpdate надо учитывать при попытке загрузки карты. }
Row Grid::Row4() { RowHolder rH = GetO().TopRow(), rC = GetC().TopRow(), rB = GetE().TopRow(); return Row(rH, rC, rB); }
Row Grid::Row5() { RowHolder rH = GetO().MiddleRow(), rC = GetC().MiddleRow(), rB = GetE().MiddleRow(); return Row(rH, rC, rB); }
Row Grid::Row6() { RowHolder rH = GetO().BottomRow(), rC = GetC().BottomRow(), rB = GetE().BottomRow(); return Row(rH, rC, rB); }
//----------------------------------------------------------------------------- // // Surf3C series // //----------------------------------------------------------------------------- void mglGraph::Surf3C(mreal val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &b, const char *sch) { long i,j,k,i0,i1,n=a.nx,m=a.ny,l=a.nz; long *kx1,*kx2,*ky1,*ky2,*kz,pc; bool both, wire = sch && strchr(sch,'#'); mreal *pp=0,*cc=0,*kk=0,*nn=0; mreal d,xx,yy,zz,nx,ny,nz,dx,dy,dz,tx,ty,tz,alpha; if(n<2 || m<2 || l<2) { SetWarn(mglWarnLow,"Surf3C"); return; } both = x.nx*x.ny*x.nz==n*m*l && y.nx*y.ny*y.nz==n*m*l && z.nx*z.ny*z.nz==n*m*l; if(!(both || (x.nx==n && y.nx==m && z.nx==l))) { SetWarn(mglWarnDim,"Surf3C"); return; } if(b.nx*b.ny*b.nz!=n*m*l) { SetWarn(mglWarnDim,"Surf3C"); return; } static int cgid=1; StartGroup("Surf3C",cgid++); bool inv = (sch && strchr(sch,'-')); SetScheme(sch); kx1 = new long[n*m]; kx2 = new long[n*m]; ky1 = new long[n*m]; ky2 = new long[n*m]; kz = new long[n*m]; Pal[100]=GetC(val); // DefColor(c,AlphaDef); for(k=0;k<l;k++) { memcpy(kx1,kx2,n*m*sizeof(long)); memset(kx2,-1,n*m*sizeof(long)); memcpy(ky1,ky2,n*m*sizeof(long)); memset(ky2,-1,n*m*sizeof(long)); memset(kz ,-1,n*m*sizeof(long)); for(i=0;i<n;i++) for(j=0;j<m;j++) { i1 = i+n*j; i0 = i1+n*m*k; if(i<n-1) { d = _d(val,a.a[i0],a.a[i0+1]); if(d>=0 && d<1) { xx = both ? x.a[i0]*(1.-d)+x.a[i0+1]*d : x.a[i]*(1.-d)+x.a[i+1]*d; yy = both ? y.a[i0]*(1.-d)+y.a[i0+1]*d : y.a[j]; zz = both ? z.a[i0]*(1.-d)+z.a[i0+1]*d : z.a[k]; alpha = b.a[i0]*(1.-d)+b.a[i0+1]*d; normal_3d(a,i+d,j,k,&dx,&dy,&dz,inv); if(both) { normal_3d(x,i+d,j,k,&tx,&ty,&tz,true); nx = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(y,i+d,j,k,&tx,&ty,&tz,true); ny = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(z,i+d,j,k,&tx,&ty,&tz,true); nz = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); } else { normal_1d(x,i+d,&tx,true); nx = dx/tx; normal_1d(y,j,&ty,true); ny = dy/ty; normal_1d(z,k,&tz,true); nz = dz/tz; } Pal[100]=GetC(alpha); kx2[i1] = add_spoint(pc,&pp,&kk,&cc,&nn,xx,yy,zz,nx,ny,nz, i+d,j,k,Transparent ? AlphaDef : 1); } } if(j<m-1) { d = _d(val,a.a[i0],a.a[i0+n]); if(d>=0 && d<1) { xx = both ? x.a[i0]*(1.-d)+x.a[i0+n]*d : x.a[i]; yy = both ? y.a[i0]*(1.-d)+y.a[i0+n]*d : y.a[j]*(1.-d)+y.a[j+1]*d; zz = both ? z.a[i0]*(1.-d)+z.a[i0+n]*d : z.a[k]; alpha = b.a[i0]*(1.-d)+b.a[i0+n]*d; normal_3d(a,i,j+d,k,&dx,&dy,&dz,inv); if(both) { normal_3d(x,i,j+d,k,&tx,&ty,&tz,true); nx = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(y,i,j+d,k,&tx,&ty,&tz,true); ny = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(z,i,j+d,k,&tx,&ty,&tz,true); nz = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); } else { normal_1d(x,i,&tx,true); nx = dx/tx; normal_1d(y,j+d,&ty,true); ny = dy/ty; normal_1d(z,k,&tz,true); nz = dz/tz; } Pal[100]=GetC(alpha); ky2[i1] = add_spoint(pc,&pp,&kk,&cc,&nn,xx,yy,zz,nx,ny,nz, i,j+d,k,Transparent ? AlphaDef : 1); } } if(k>0) { d = _d(val,a.a[i0-n*m],a.a[i0]); if(d>=0 && d<1) { xx = both ? x.a[i0-n*m]*(1.-d)+x.a[i0]*d : x.a[i]; yy = both ? y.a[i0-n*m]*(1.-d)+y.a[i0]*d : y.a[j]; zz = both ? z.a[i0-n*m]*(1.-d)+z.a[i0]*d : z.a[k-1]*(1.-d)+z.a[k]*d; alpha = b.a[i0-n*m]*(1.-d)+b.a[i0]*d; normal_3d(a,i,j,k+d-1,&dx,&dy,&dz,inv); if(both) { normal_3d(x,i,j,k+d-1,&tx,&ty,&tz,true); nx = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(y,i,j,k+d-1,&tx,&ty,&tz,true); ny = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(z,i,j,k+d-1,&tx,&ty,&tz,true); nz = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); } else { normal_1d(x,i,&tx,true); nx = dx/tx; normal_1d(y,j,&ty,true); ny = dy/ty; normal_1d(z,k+d-1,&tz,true); nz = dz/tz; } Pal[100]=GetC(alpha); kz[i1] = add_spoint(pc,&pp,&kk,&cc,&nn,xx,yy,zz,nx,ny,nz, i,j,k+d-1,Transparent ? AlphaDef : 1); } } } if(k>0) surf3_plot(n,m,kx1,kx2,ky1,ky2,kz,pp,cc,kk,nn,wire); } EndGroup(); delete []kx1; delete []kx2; delete []ky1; delete []ky2; delete []kz; if(pp) { free(pp); free(kk); free(cc); free(nn); } }
static lexicon Get() { lexicon c; register lexicon *pC = &c; register int character; if (!Empty) { *pC = lifo[rp]; rp++; if (rp == sizeof lifo/sizeof (lexicon)) { rp = 0; } if (rp == wp) { Empty = 1; } Full = 0; } else { character = GetC(); switch (character) { case EOF: pC->type = LEX_END_OF_FILE; break; case '^': character = GetC(); if (!IsPrint(character)) { pC->type = LEX_ILLEGAL; } else { pC->type = LEX_CARETED; if (character == '?') { character |= 0x40; /* rubout */ } else { character &= 0x1f; } } break; case '\\': character = GetC(); if (!IsPrint(character)) { pC->type = LEX_ILLEGAL; } else { pC->type = LEX_ESCAPED; switch (character) { case 'E': case 'e': character = ESCAPE; break; case 't': character = TAB; break; case 'n': character = NEWLINE; break; case 'r': character = CARRIAGE_RETURN; break; default: pC->type = LEX_ILLEGAL; break; } } break; default: if ((IsPrint(character)) || isspace(character)) { pC->type = LEX_CHAR; } else { pC->type = LEX_ILLEGAL; } break; } pC->value = character; } return(*pC); }
int Lex::SubGetToken(void) { int c, n; for(;;) { f_stoken = f_input; c = GetC(); switch(c) { case 0: return 0; case '0': c = GetC(); if(c == 'x' && c == 'X') { do { c = GetC(); } while((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); return NUMBER; } // here we could test for octal, but it doesn't // matter too much here, we're not a compiler! UngetC(); case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': do { c = GetC(); } while(c >= '0' && c <= '9'); if(c == 'U' || c == 'u') { c = GetC(); if(c == 'L' || c == 'l') { c = GetC(); if(c != 'L' && c != 'l') { UngetC(); } return NUMBER; } // a U by itself is ignored UngetC(); return NUMBER; } if(c == 'L' || c == 'l') { c = GetC(); if(c != 'L' && c != 'l') { UngetC(); } return NUMBER; } if(c == '.') { do { c = GetC(); } while(c >= '0' && c <= '9'); } if(c == 'e' || c == 'E') { c = GetC(); if(c == '-' || c == '+') { c = GetC(); } while(c >= '0' && c <= '9') { c = GetC(); } } if(c == 'f' || c == 'F') { return NUMBER; } UngetC(); return NUMBER; case '\'': character: c = GetC(); if(c == '\\') { c = GetC(); } c = GetC(); if(c != '\'') { fprintf(stderr, "%s:%ld: error: invalid character\n", f_filename, f_line); g_errcnt++; } return CHARACTER; case '"': string: do { c = GetC(); if(c == '\n' || c == '\0') { fprintf(stderr, "%s:%ld: error: unterminated string\n", f_filename, f_line); g_errcnt++; break; } if(c == '\\') { c = GetC(); if(c == '\n' || c == '\0') { fprintf(stderr, "%s:%ld: error: unterminated string\n", f_filename, f_line); g_errcnt++; break; } c = '\0'; } } while(c != '"'); return STRING; case 'l': case 'L': c = GetC(); if(c == '"') { goto string; } if(c == '\'') { goto character; } // comments are very simply ignored case '/': n = GetC(); if(n == '/') { do { c = GetC(); } while(c != '\n' && c != '\0'); break; } if(n == '*') { n = GetC(); do { c = n; n = GetC(); } while(n != '\0' && (c != '*' || n != '/')); break; } UngetC(); return c; default: if( isalpha(c) || (c=='_') || (c==':') ) { do { c = GetC(); } while((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || c == ':'); UngetC(); return IDENTIFIER; } else { return c; } } } }
Component* Component::AddC ( Component* c) { c->SetParent ( this ); if (GetC (c->GetName() ))assert (0); components[c->GetName()] = c; return c ; }
WZSMDToken ScriptEncode::GetToken() { char ch; TokenString[0] = '\0'; do { if ( (ch =(char) GetC() ) == EOF) return T_END; if (ch == '/') { if ((ch =(char) GetC() )=='/') { while ((ch != '\n') && (ch != EOF)) ch =(char) GetC(); } } } while( isspace(ch) ); char *p, TempString[100]; switch(ch) { case '#': return CurrentToken = T_COMMAND; case ';': return CurrentToken = T_SEMICOLON; case ',': return CurrentToken = T_COMMA; case '{': return CurrentToken = T_LP; case '}': return CurrentToken = T_RP; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': case '-': UnGetC(ch); p = TempString; while ( ( (ch = GetC() ) !=EOF) && (ch=='.' || isdigit(ch) || ch=='-') ) *p++ = ch; *p = 0; TokenNumber = (float)atof(TempString); return CurrentToken = T_NUMBER; case '"': p = TokenString; while ( ( (ch = GetC() ) !=EOF) && (ch!='"')) *p++ = ch; if (ch!='"') UnGetC(ch); *p = 0; return CurrentToken = T_NAME; default: if (isalpha(ch)) { p = TokenString; *p++ = ch; while ( ( (ch = GetC() ) !=EOF) && (ch=='.' || ch=='_' || isalnum(ch)) ) *p++ = ch; UnGetC(ch); *p = 0; return CurrentToken = T_NAME; } return CurrentToken = T_SMD_ERROR; } }
Column Grid::Col6() { ColumnHolder sH = GetN().RightColumn(), sC = GetC().RightColumn(), sB = GetS().RightColumn(); return Column(sH, sC, sB); }