void QDeclarativeBorderImage::sciRequestFinished() { Q_D(QDeclarativeBorderImage); d->redirectCount++; if (d->redirectCount < BORDERIMAGE_MAX_REDIRECT) { QVariant redirect = d->sciReply->attribute(QNetworkRequest::RedirectionTargetAttribute); if (redirect.isValid()) { QUrl url = d->sciReply->url().resolved(redirect.toUrl()); setSource(url); return; } } d->redirectCount=0; if (d->sciReply->error() != QNetworkReply::NoError) { d->status = Error; d->sciReply->deleteLater(); d->sciReply = 0; emit statusChanged(d->status); } else { QDeclarativeGridScaledImage sci(d->sciReply); d->sciReply->deleteLater(); d->sciReply = 0; setGridScaledImage(sci); } }
static void printreal(double x, bool ex) { bool neg = false; if(x < zero) { neg = true; x = -x; } if(x == zero|| (!neg && x < 0.0001e-99) || (neg && x < 0.001e-99)) { draw_dp(0b10000, 8); draw(0, 7); return;//Zero rounding } if((!neg && x > 9.9999e+99) || (neg && x > 9.999e+99) || x != x) {//NaN test too error = true; draw(15, 7); return;//Overflow } double mask = ((ex)?100000.0:100000000.0);//use exponent mask = ((!neg)?mask:(mask * tenth));//leave space for negative sign if(x >= mask || x <= one/mask) {//sci notation as too big sci(neg, x); return; } dp = (ex?5:8);//set zero placed deciaml //either defered as sci exponent, zero or error printed so far!! bool zeros = (x < one); int check = 0; while((zeros)?(dp > (neg?2:1)):(x < mask)) { check = (int)x; if((double)check == x) break;//exact --dp; x *= 10; } draw_dp(0b10000, dp); printint(neg?-check:check, ex?4:7, zeros);//integer part drawn }
void CharIterTest::TestUCharIterator() { // test string of length 8 UnicodeString s=UnicodeString("a \\U00010001b\\U0010fffdz", "").unescape(); const char *const moves= "0+++++++++" // 10 moves per line "----0-----" ">>|>>>>>>>" "<<|<<<<<<<" "22+>8>-8+2"; StringCharacterIterator sci(s), compareCI(s); UCharIterator sIter, cIter, rIter; uiter_setString(&sIter, s.getBuffer(), s.length()); uiter_setCharacterIterator(&cIter, &sci); uiter_setReplaceable(&rIter, &s); TestUCharIterator(&sIter, compareCI, moves, "uiter_setString"); compareCI.setIndex(0); TestUCharIterator(&cIter, compareCI, moves, "uiter_setCharacterIterator"); compareCI.setIndex(0); TestUCharIterator(&rIter, compareCI, moves, "uiter_setReplaceable"); // test move & getIndex some more sIter.start=2; sIter.index=3; sIter.limit=5; if( sIter.getIndex(&sIter, UITER_ZERO)!=0 || sIter.getIndex(&sIter, UITER_START)!=2 || sIter.getIndex(&sIter, UITER_CURRENT)!=3 || sIter.getIndex(&sIter, UITER_LIMIT)!=5 || sIter.getIndex(&sIter, UITER_LENGTH)!=s.length() ) { errln("error: UCharIterator(string).getIndex returns wrong index"); } if( sIter.move(&sIter, 4, UITER_ZERO)!=4 || sIter.move(&sIter, 1, UITER_START)!=3 || sIter.move(&sIter, 3, UITER_CURRENT)!=5 || sIter.move(&sIter, -1, UITER_LIMIT)!=4 || sIter.move(&sIter, -5, UITER_LENGTH)!=3 || sIter.move(&sIter, 0, UITER_CURRENT)!=sIter.getIndex(&sIter, UITER_CURRENT) || sIter.getIndex(&sIter, UITER_CURRENT)!=3 ) { errln("error: UCharIterator(string).move sets/returns wrong index"); } sci=StringCharacterIterator(s, 2, 5, 3); uiter_setCharacterIterator(&cIter, &sci); if( cIter.getIndex(&cIter, UITER_ZERO)!=0 || cIter.getIndex(&cIter, UITER_START)!=2 || cIter.getIndex(&cIter, UITER_CURRENT)!=3 || cIter.getIndex(&cIter, UITER_LIMIT)!=5 || cIter.getIndex(&cIter, UITER_LENGTH)!=s.length() ) { errln("error: UCharIterator(character iterator).getIndex returns wrong index"); } if( cIter.move(&cIter, 4, UITER_ZERO)!=4 || cIter.move(&cIter, 1, UITER_START)!=3 || cIter.move(&cIter, 3, UITER_CURRENT)!=5 || cIter.move(&cIter, -1, UITER_LIMIT)!=4 || cIter.move(&cIter, -5, UITER_LENGTH)!=3 || cIter.move(&cIter, 0, UITER_CURRENT)!=cIter.getIndex(&cIter, UITER_CURRENT) || cIter.getIndex(&cIter, UITER_CURRENT)!=3 ) { errln("error: UCharIterator(character iterator).move sets/returns wrong index"); } if(cIter.getIndex(&cIter, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(char iter).getIndex did not return error value"); } if(cIter.move(&cIter, 0, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(char iter).move did not return error value"); } if(rIter.getIndex(&rIter, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(repl iter).getIndex did not return error value"); } if(rIter.move(&rIter, 0, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(repl iter).move did not return error value"); } if(sIter.getIndex(&sIter, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(string iter).getIndex did not return error value"); } if(sIter.move(&sIter, 0, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(string iter).move did not return error value"); } /* Testing function coverage on bad input */ UErrorCode status = U_ZERO_ERROR; uiter_setString(&sIter, NULL, 1); uiter_setState(&sIter, 1, &status); if (status != U_UNSUPPORTED_ERROR) { errln("error: uiter_setState returned %s instead of U_UNSUPPORTED_ERROR", u_errorName(status)); } status = U_ZERO_ERROR; uiter_setState(NULL, 1, &status); if (status != U_ILLEGAL_ARGUMENT_ERROR) { errln("error: uiter_setState returned %s instead of U_ILLEGAL_ARGUMENT_ERROR", u_errorName(status)); } if (uiter_getState(&sIter) != UITER_NO_STATE) { errln("error: uiter_getState did not return UITER_NO_STATE on bad input"); } }
void CharIterTest::TestUCharIterator() { // test string of length 8 UnicodeString s=UnicodeString("a \\U00010001b\\U0010fffdz", "").unescape(); const char *const moves= "0+++++++++" // 10 moves per line "----0-----" ">>|>>>>>>>" "<<|<<<<<<<" "22+>8>-8+2"; StringCharacterIterator sci(s), compareCI(s); UCharIterator sIter, cIter, rIter; uiter_setString(&sIter, s.getBuffer(), s.length()); uiter_setCharacterIterator(&cIter, &sci); uiter_setReplaceable(&rIter, &s); TestUCharIterator(&sIter, compareCI, moves, "uiter_setString"); compareCI.setIndex(0); TestUCharIterator(&cIter, compareCI, moves, "uiter_setCharacterIterator"); compareCI.setIndex(0); TestUCharIterator(&rIter, compareCI, moves, "uiter_setReplaceable"); // test move & getIndex some more sIter.start=2; sIter.index=3; sIter.limit=5; if( sIter.getIndex(&sIter, UITER_ZERO)!=0 || sIter.getIndex(&sIter, UITER_START)!=2 || sIter.getIndex(&sIter, UITER_CURRENT)!=3 || sIter.getIndex(&sIter, UITER_LIMIT)!=5 || sIter.getIndex(&sIter, UITER_LENGTH)!=s.length() ) { errln("error: UCharIterator(string).getIndex returns wrong index"); } if( sIter.move(&sIter, 4, UITER_ZERO)!=4 || sIter.move(&sIter, 1, UITER_START)!=3 || sIter.move(&sIter, 3, UITER_CURRENT)!=5 || sIter.move(&sIter, -1, UITER_LIMIT)!=4 || sIter.move(&sIter, -5, UITER_LENGTH)!=3 || sIter.move(&sIter, 0, UITER_CURRENT)!=sIter.getIndex(&sIter, UITER_CURRENT) || sIter.getIndex(&sIter, UITER_CURRENT)!=3 ) { errln("error: UCharIterator(string).move sets/returns wrong index"); } sci=StringCharacterIterator(s, 2, 5, 3); uiter_setCharacterIterator(&cIter, &sci); if( cIter.getIndex(&cIter, UITER_ZERO)!=0 || cIter.getIndex(&cIter, UITER_START)!=2 || cIter.getIndex(&cIter, UITER_CURRENT)!=3 || cIter.getIndex(&cIter, UITER_LIMIT)!=5 || cIter.getIndex(&cIter, UITER_LENGTH)!=s.length() ) { errln("error: UCharIterator(character iterator).getIndex returns wrong index"); } if( cIter.move(&cIter, 4, UITER_ZERO)!=4 || cIter.move(&cIter, 1, UITER_START)!=3 || cIter.move(&cIter, 3, UITER_CURRENT)!=5 || cIter.move(&cIter, -1, UITER_LIMIT)!=4 || cIter.move(&cIter, -5, UITER_LENGTH)!=3 || cIter.move(&cIter, 0, UITER_CURRENT)!=cIter.getIndex(&cIter, UITER_CURRENT) || cIter.getIndex(&cIter, UITER_CURRENT)!=3 ) { errln("error: UCharIterator(character iterator).move sets/returns wrong index"); } if(cIter.getIndex(&cIter, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(char iter).getIndex did not return error value"); } if(cIter.move(&cIter, 0, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(char iter).move did not return error value"); } if(rIter.getIndex(&rIter, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(repl iter).getIndex did not return error value"); } if(rIter.move(&rIter, 0, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(repl iter).move did not return error value"); } if(sIter.getIndex(&sIter, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(string iter).getIndex did not return error value"); } if(sIter.move(&sIter, 0, (enum UCharIteratorOrigin)-1) != -1) { errln("error: UCharIterator(string iter).move did not return error value"); } }
int DLL_FUNC parse_elements( const char *line1, const char *line2, tle_t *sat) { int year, rval, checksum_problem = 0; if( *line1 != '1' || *line2 != '2') rval = -4; else { rval = tle_checksum( line1); if( rval > 0) { checksum_problem = 1; /* there's a checksum problem, but it's */ rval = 0; /* not fatal; continue processing the TLE */ } } if( rval) rval -= 100; else { rval = tle_checksum( line2); if( rval > 0) { checksum_problem |= 2; /* there's a checksum problem, but it's */ rval = 0; /* not fatal; continue processing the TLE */ } } if( !rval) { char tbuff[13]; sat->xmo = (double)get_angle( line2 + 43) * (PI / 180e+4); sat->xnodeo = (double)get_angle( line2 + 17) * (PI / 180e+4); sat->omegao = (double)get_angle( line2 + 34) * (PI / 180e+4); sat->xincl = (double)get_angle( line2 + 8) * (PI / 180e+4); sat->eo = atoi( line2 + 26) * 1.e-7; /* Make sure mean motion is null-terminated, since rev. no. may immediately follow. */ memcpy( tbuff, line2 + 51, 12); tbuff[12] = '\0'; /* Input mean motion, derivative of mean motion and second */ /* deriv of mean motion, are all in revolutions and days. */ /* Convert them here to radians and minutes: */ sat->xno = get_eight_places( tbuff) * TWOPI / MINUTES_PER_DAY; sat->xndt2o = (double)atoi( line1 + 35) * 1.e-8 * TWOPI / MINUTES_PER_DAY_SQUARED; if( line1[33] == '-') sat->xndt2o *= -1.; sat->xndd6o = sci( line1 + 44) * TWOPI / MINUTES_PER_DAY_CUBED; sat->bstar = sci(line1 + 53) * AE; year = line1[19] - '0'; if( line1[18] >= '0') year += (line1[18] - '0') * 10; if( year < 57) /* cycle around Y2K */ year += 100; sat->epoch = get_eight_places( line1 + 20) + J1900 + (double)( year * 365 + (year - 1) / 4); sat->norad_number = atoi( line1 + 2); memcpy( tbuff, line1 + 64, 4); tbuff[4] = '\0'; sat->bulletin_number = atoi( tbuff); sat->classification = line1[7]; memcpy( sat->intl_desig, line1 + 9, 8); sat->intl_desig[8] = '\0'; memcpy( tbuff, line2 + 63, 5); tbuff[5] = '\0'; sat->revolution_number = atoi( tbuff); sat->ephemeris_type = line1[62]; } return( rval ? rval : checksum_problem); }
DWORD CRichtextLayout::CalcSize(CCalcInfo* pci, SIZE* psize, SIZE* psizeDefault) { Assert(ElementOwner()); Assert(pci); Assert(psize); CScopeFlag csfCalcing(this); CRichtext* pTextarea = DYNCAST(CRichtext, ElementOwner()); Listen(); CSaveCalcInfo sci(pci, this); CSize sizeOriginal; DWORD grfReturn; GetSize(&sizeOriginal); if(_fForceLayout) { pci->_grfLayout |= LAYOUT_FORCE; _fForceLayout = FALSE; } grfReturn = (pci->_grfLayout & LAYOUT_FORCE); if(pci->_grfLayout & LAYOUT_FORCE) { _fSizeThis = TRUE; _fAutoBelow = FALSE; _fPositionSet = FALSE; _fContainsRelative = FALSE; } BOOL fRecalcText = FALSE; BOOL fNormalMode = pci->_smMode==SIZEMODE_NATURAL || pci->_smMode==SIZEMODE_SET || pci->_smMode==SIZEMODE_FULLSIZE; BOOL fWidthChanged = (fNormalMode ? psize->cx!=sizeOriginal.cx : FALSE); BOOL fHeightChanged = (fNormalMode ? psize->cy!=sizeOriginal.cy : FALSE); fRecalcText = (fNormalMode && (IsDirty() || _fSizeThis || fWidthChanged || fHeightChanged)) || (pci->_grfLayout&LAYOUT_FORCE) || (pci->_smMode==SIZEMODE_MMWIDTH && !_fMinMaxValid) || (pci->_smMode==SIZEMODE_MINWIDTH && (!_fMinMaxValid || _xMin<0)); // If this site is in need of sizing, then size it if(fRecalcText) { //BUGBUG (gideons) should modify Cols and Rows if user resizes CUnitValue uvWidth = pTextarea->GetFirstBranch()->GetCascadedwidth(); CUnitValue uvHeight = pTextarea->GetFirstBranch()->GetCascadedheight(); int charX = 1; int charY = 1; // If dirty, ensure display tree nodes exist if(_fSizeThis && (EnsureDispNode(pci, (grfReturn&LAYOUT_FORCE))==S_FALSE)) { grfReturn |= LAYOUT_HRESIZE | LAYOUT_VRESIZE; } SetWrap(); _fContentsAffectSize = FALSE; if(uvWidth.IsNullOrEnum() || uvHeight.IsNullOrEnum()) { charX = pTextarea->GetAAcols(); Assert(charX > 0); charY = pTextarea->GetAArows(); Assert(charY > 0); } grfReturn |= CalcSizeHelper(pci, charX, charY, psize); if(fNormalMode) { grfReturn |= super::CalcSize(pci, psize); } if(psizeDefault) { *psizeDefault = *psize; } // If size changes occurred, size the display nodes if(fNormalMode && grfReturn&(LAYOUT_FORCE|LAYOUT_HRESIZE|LAYOUT_VRESIZE)) { SizeDispNode(pci, *psize); SizeContentDispNode(CSize(_dp.GetMaxWidth(), _dp.GetHeight())); } if(pci->_smMode == SIZEMODE_MMWIDTH) { // for minmax mode min width is returned in cy. _xMin = psize->cy = psize->cx; } } else { grfReturn = super::CalcSize(pci, psize); } return grfReturn; }
void CollectionShardingState::checkShardVersionOrThrow(OperationContext* opCtx) { const auto optReceivedShardVersion = getOperationReceivedVersion(opCtx, _nss); if (!optReceivedShardVersion) return; const auto& receivedShardVersion = *optReceivedShardVersion; if (ChunkVersion::isIgnoredVersion(receivedShardVersion)) { return; } // An operation with read concern 'available' should never have shardVersion set. invariant(repl::ReadConcernArgs::get(opCtx).getLevel() != repl::ReadConcernLevel::kAvailableReadConcern); const auto metadata = getCurrentMetadata(); const auto wantedShardVersion = metadata->isSharded() ? metadata->getShardVersion() : ChunkVersion::UNSHARDED(); auto criticalSectionSignal = [&] { auto csrLock = CSRLock::lock(opCtx, this); return _critSec.getSignal(opCtx->lockState()->isWriteLocked() ? ShardingMigrationCriticalSection::kWrite : ShardingMigrationCriticalSection::kRead); }(); if (criticalSectionSignal) { // Set migration critical section on operation sharding state: operation will wait for the // migration to finish before returning failure and retrying. auto& oss = OperationShardingState::get(opCtx); oss.setMigrationCriticalSectionSignal(criticalSectionSignal); uasserted(StaleConfigInfo(_nss, receivedShardVersion, wantedShardVersion), str::stream() << "migration commit in progress for " << _nss.ns()); } if (receivedShardVersion.isWriteCompatibleWith(wantedShardVersion)) { return; } // // Figure out exactly why not compatible, send appropriate error message // The versions themselves are returned in the error, so not needed in messages here // StaleConfigInfo sci(_nss, receivedShardVersion, wantedShardVersion); uassert(std::move(sci), str::stream() << "epoch mismatch detected for " << _nss.ns() << ", " << "the collection may have been dropped and recreated", wantedShardVersion.epoch() == receivedShardVersion.epoch()); if (!wantedShardVersion.isSet() && receivedShardVersion.isSet()) { uasserted(std::move(sci), str::stream() << "this shard no longer contains chunks for " << _nss.ns() << ", " << "the collection may have been dropped"); } if (wantedShardVersion.isSet() && !receivedShardVersion.isSet()) { uasserted(std::move(sci), str::stream() << "this shard contains chunks for " << _nss.ns() << ", " << "but the client expects unsharded collection"); } if (wantedShardVersion.majorVersion() != receivedShardVersion.majorVersion()) { // Could be > or < - wanted is > if this is the source of a migration, wanted < if this is // the target of a migration uasserted(std::move(sci), str::stream() << "version mismatch detected for " << _nss.ns()); } // Those are all the reasons the versions can mismatch MONGO_UNREACHABLE; }