int main(void) { #pragma STDC FENV_ACCESS ON long long yi; int e, i, err = 0; struct f_i *p; for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; if (p->r < 0) continue; fesetround(p->r); feclearexcept(FE_ALL_EXCEPT); yi = ___(p->x); e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s ___(%a)=%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e)); printf(" got %s\n", estr(e)); err++; } if (yi != p->i) { printf("%s:%d: %s ___(%a) want %lld got %lld\n", p->file, p->line, rstr(p->r), p->x, p->i, yi); err++; } } return !!err; }
int main(void) { #pragma STDC FENV_ACCESS ON float ysin, ycos; float dsin, dcos; int e, i, err = 0; struct f_ff *p; for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; if (p->r < 0) continue; fesetround(p->r); feclearexcept(FE_ALL_EXCEPT); sincosf(p->x, &ysin, &ycos); e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s sincosf(%a)=%a,%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->y2, estr(p->e)); printf(" got %s\n", estr(e)); err++; } dsin = ulperr(ysin, p->y, p->dy); dcos = ulperr(ycos, p->y2, p->dy2); if (!checkulp(dsin, p->r) || !checkulp(dcos, p->r)) { printf("%s:%d: %s sincosf(%a) want %a,%a got %a,%a, ulperr %.3f = %a + %a, %.3f = %a + %a\n", p->file, p->line, rstr(p->r), p->x, p->y, p->y2, ysin, ycos, dsin, dsin-p->dy, p->dy, dcos, dcos-p->dy2, p->dy2); err++; } } return !!err; }
int main(void) { #pragma STDC FENV_ACCESS ON int yi; double y; float d; int e, i, err = 0; struct d_di *p; for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; if (p->r < 0) continue; fesetround(p->r); feclearexcept(FE_ALL_EXCEPT); y = frexp(p->x, &yi); e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); if (!checkexceptall(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s frexp(%a)=%a,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); printf(" got %s\n", estr(e)); err++; } d = ulperr(y, p->y, p->dy); if (!checkcr(y, p->y, p->r) || (isfinite(p->x) && yi != p->i)) { printf("%s:%d: %s frexp(%a) want %a,%lld got %a,%d ulperr %.3f = %a + %a\n", p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy); err++; } } return !!err; }
int main(void) { #pragma STDC FENV_ACCESS ON long double y; float d; int e, i, err = 0; struct l_l *p; for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; if (p->r < 0) continue; fesetround(p->r); feclearexcept(FE_ALL_EXCEPT); y = erfl(p->x); e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s erfl(%La)=%La, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); printf(" got %s\n", estr(e)); err++; } d = ulperrl(y, p->y, p->dy); if (!checkulp(d, p->r)) { printf("%s:%d: %s erfl(%La) want %La got %La ulperr %.3f = %a + %a\n", p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy); err++; } } return !!err; }
int main(void) { #pragma STDC FENV_ACCESS ON int yi; long double y; float d; int e, i, err = 0; struct l_li *p; for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; if (p->r < 0) continue; fesetround(p->r); feclearexcept(FE_ALL_EXCEPT); y = lgammal_r(p->x, &yi); e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s lgammal_r(%La)=%La,%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e)); printf(" got %s\n", estr(e)); err++; } d = ulperrl(y, p->y, p->dy); // TODO: 2 ulp errors allowed if ((p->r==RN && fabs(d)>2) || (!isnan(p->x) && p->x!=-inf && !(p->e&DIVBYZERO) && yi != p->i)) { printf("%s:%d: %s lgammal_r(%La) want %La,%lld got %La,%d ulperr %.3f = %a + %a\n", p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy); err++; } } return !!err; }
int main(void) { #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; struct ff_f *p; for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; if (p->r < 0) continue; fesetround(p->r); feclearexcept(FE_ALL_EXCEPT); y = fmaxf(p->x, p->x2); e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); if (!checkexceptall(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s fmaxf(%a,%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); printf(" got %s\n", estr(e)); err++; } d = ulperrf(y, p->y, p->dy); if (!checkcr(y, p->y, p->r)) { printf("%s:%d: %s fmaxf(%a,%a) want %a got %a ulperr %.3f = %a + %a\n", p->file, p->line, rstr(p->r), p->x, p->x2, p->y, y, d, d-p->dy, p->dy); err++; } } return !!err; }
static const char *mode_str(Iss2::ExecMode mode) { switch(mode) { rstr(MODE_HYPER); rstr(MODE_KERNEL); rstr(MODE_USER); default: return "invalid"; } }
String operator + (const char* p, const String& s) { String rstr(p); rstr += s; return rstr; }
void dcRSys::interprete(const char *input){ char *buff = new char[strlen(input)]; strcpy(buff,input); char *ptr; ptr = strtok(buff, " "); if(!ptr) return; rid *crid = create_rid(ptr); while(ptr != NULL){ ptr = strtok(NULL, " "); if(ptr != NULL) link_child(crid, rstr(ptr)); } last = cmd(crid); }
/*! \reimp */ QCString QTsciiCodec::fromUnicode(const QString& uc, int& lenInOut) const { int l = QMIN((int)uc.length(), lenInOut); int rlen = l+1; QCString rstr(rlen); uchar* cursor = (uchar*)rstr.data(); for (int i = 0; i < l; i++) { QChar ch = uc[i]; uchar j; if ( ch.row() == 0x00 && ch.cell() < 0x80 ) { // ASCII j = ch.cell(); } else if ((j = qt_UnicodeToTSCII(uc[i].unicode(), uc[i + 1].unicode(), uc[i + 2].unicode()))) { // We have to check the combined chars first! i += 2; } else if ((j = qt_UnicodeToTSCII(uc[i].unicode(), uc[i + 1].unicode(), 0))) { i++; } else if ((j = qt_UnicodeToTSCII(uc[i].unicode(), 0, 0))) { } else { // Error j = '?'; // unknown char } *cursor++ = j; } lenInOut = cursor - (uchar*)rstr.data(); *cursor = 0; return rstr; }
String operator + (char c, const String& s) { String rstr(c); rstr += s; return rstr; }
/*! \reimp */ QCString QEucJpCodec::fromUnicode(const QString& uc, int& lenInOut) const { int l = QMIN((int)uc.length(),lenInOut); int rlen = l*3+1; QCString rstr(rlen); uchar* cursor = (uchar*)rstr.data(); for (int i=0; i<l; i++) { QChar ch = uc[i]; uint j; if ( ch.row() == 0x00 && ch.cell() < 0x80 ) { // ASCII *cursor++ = ch.cell(); } else if ((j = conv->unicodeToJisx0201(ch.row(), ch.cell())) != 0) { if (j < 0x80) { // JIS X 0201 Latin ? *cursor++ = j; } else { // JIS X 0201 Kana *cursor++ = Ss2; *cursor++ = j; } } else if ((j = conv->unicodeToJisx0208(ch.row(), ch.cell())) != 0) { // JIS X 0208 *cursor++ = (j >> 8) | 0x80; *cursor++ = (j & 0xff) | 0x80; } else if ((j = conv->unicodeToJisx0212(ch.row(), ch.cell())) != 0) {
String operator + (const String& s, char c) { String rstr(s); rstr += String(c); return rstr; }
String operator + (const String& s1, const String& s2) { String rstr(s1); rstr += s2; return rstr; }
String operator + (const String& s, const char* p) { String rstr(s); rstr += p; return rstr; }
/** @SYMTestCaseID PDS-STORE-CT-4016 @SYMTestCaseDesc Tests for CPBEncryptElement @SYMTestPriority High @SYMTestActions Externalizing and internalizing CPBEncryptionData. Tests for constructors. @SYMTestExpectedResults Externalizing must not fail. After internalization CPBEncryptionData object should be valid. Object created with all constructors should be valid. @SYMDEF DEF135804 */ LOCAL_C void testForgottenAPI_L() { test.Next(_L("@SYMTestCaseID PDS-STORE-CT-4016: Tests for CPBEncryptElement")); CBufFlat* buffer = CBufFlat::NewL(10*1024); CleanupStack::PushL(buffer); RBufWriteStream wstr(*buffer,0); CPBEncryptElement* elementKey = CPBEncryptElement::NewLC(KTestPassword); const CPBEncryptionData& encryptData = elementKey->EncryptionData(); wstr << encryptData; CleanupStack::PopAndDestroy(); wstr.CommitL(); wstr.Close(); RBufReadStream rstr(*buffer,0); CPBEncryptionData* enData = CPBEncryptionData::NewL(rstr); test(enData != NULL); delete enData; enData = NULL; rstr.Close(); rstr.Open(*buffer,0); enData = CPBEncryptionData::NewLC(rstr); test(enData != NULL); CleanupStack::PopAndDestroy(); enData = NULL; rstr.Close(); CleanupStack::PopAndDestroy(); }
QCString QKoi8Codec::fromUnicode(const QString& uc, int& len_in_out) const { int l = QMIN((int)uc.length(),len_in_out); int rlen = l+1; QCString rstr(rlen); uchar* cursor = (uchar*)rstr.data(); for (int i=0; i<l; i++) { const QChar ch = uc[i]; if ( ch.row() ) { if ( ch.row() == 0x25 ) { if ( ch.cell() < n_unicode_to_koi8_25 ) *cursor++ = unicode_to_koi8_25[ch.cell()]; else *cursor++ = unkn; } else if ( ch.row() == 0x04 ) { if ( ch.cell() < n_unicode_to_koi8_04 ) *cursor++ = unicode_to_koi8_04[ch.cell()]; else *cursor++ = unkn; } else if ( ch.row() == 0x22 ) { if ( ch.cell() == 0x1A ) *cursor++ = 0x96; else if ( ch.cell() == 0x48 ) *cursor++ = 0x97; else if ( ch.cell() == 0x64 ) *cursor++ = 0x98; else if ( ch.cell() == 0x65 ) *cursor++ = 0x99; else *cursor++ = unkn; } else if ( ch.row() == 0x23 ) { if ( ch.cell() == 0x20 ) *cursor++ = 0x93; else if ( ch.cell() == 0x21 ) *cursor++ = 0x9B; else *cursor++ = unkn; } else if ( ch.row() == 0x20 ) { if ( ch.cell() == 0x22 ) *cursor++ = 0x95; else *cursor++ = unkn; } else { *cursor++ = unkn; } } else { if ( ch.cell() < 128 ) { *cursor++ = ch.cell(); } else { *cursor++ = unkn; } } } *cursor = '\0'; // len_in_out = cursor - result; return rstr; }
/* static function, throws OperationError, has no traces but optional pstate for returned value */ Value_Ptr op_strings(Sass::Operand operand, Value& lhs, Value& rhs, struct Sass_Inspect_Options opt, const ParserState& pstate, bool delayed) { enum Sass_OP op = operand.operand; String_Quoted_Ptr lqstr = Cast<String_Quoted>(&lhs); String_Quoted_Ptr rqstr = Cast<String_Quoted>(&rhs); std::string lstr(lqstr ? lqstr->value() : lhs.to_string(opt)); std::string rstr(rqstr ? rqstr->value() : rhs.to_string(opt)); if (Cast<Null>(&lhs)) throw Exception::InvalidNullOperation(&lhs, &rhs, op); if (Cast<Null>(&rhs)) throw Exception::InvalidNullOperation(&lhs, &rhs, op); std::string sep; switch (op) { case Sass_OP::ADD: sep = ""; break; case Sass_OP::SUB: sep = "-"; break; case Sass_OP::DIV: sep = "/"; break; case Sass_OP::EQ: sep = "=="; break; case Sass_OP::NEQ: sep = "!="; break; case Sass_OP::LT: sep = "<"; break; case Sass_OP::GT: sep = ">"; break; case Sass_OP::LTE: sep = "<="; break; case Sass_OP::GTE: sep = ">="; break; default: throw Exception::UndefinedOperation(&lhs, &rhs, op); break; } if (op == Sass_OP::ADD) { // create string that might be quoted on output (but do not unquote what we pass) return SASS_MEMORY_NEW(String_Quoted, pstate, lstr + rstr, 0, false, true); } // add whitespace around operator // but only if result is not delayed if (sep != "" && delayed == false) { if (operand.ws_before) sep = " " + sep; if (operand.ws_after) sep = sep + " "; } if (op == Sass_OP::SUB || op == Sass_OP::DIV) { if (lqstr && lqstr->quote_mark()) lstr = quote(lstr); if (rqstr && rqstr->quote_mark()) rstr = quote(rstr); } return SASS_MEMORY_NEW(String_Constant, pstate, lstr + sep + rstr); }
static const char *type_str(Iss2::DataOperationType type) { switch(type) { rstr(DATA_READ); rstr(DATA_WRITE); rstr(DATA_LL); rstr(DATA_SC); rstr(XTN_WRITE); rstr(XTN_READ); default: return "invalid"; } }
void ParserCWHandler::updateRequest( MC2String& urlStr, LangTypes::language_t clientLang ) const { const char* instance = Properties::getProperty( "WF_INSTANCE", "eu" ); for ( repmap::const_iterator it = m_repurls.begin() ; it != m_repurls.end() ; ++it ) { if ( urlStr.find( (*it).first ) != MC2String::npos ) { MC2String rstr( (*it).second.replaceWith ); STLStringUtility::replaceString( rstr, "[INSTANCE]", instance ); STLStringUtility::replaceString( urlStr, (*it).first, rstr.c_str() ); if ( (*it).second.defaultPage != "" ) { // Check if no page then replace with defaultPage URL url( urlStr ); MC2String file( url.getFile() ); if ( file.size() > 0 && file[ file.size() -1 ] == '/' ) { MC2String path( url.getPath() ); MC2String::size_type qPos = path.find( '?' ); if ( qPos == MC2String::npos ) { qPos = path.find( '#' ); } MC2String params; if ( qPos != MC2String::npos ) { params = path.substr( qPos ); } MC2String defaultPage( url.getFile() ); defaultPage.append( (*it).second.defaultPage ); defaultPage.append( params ); // ?u=... // TODO: Convert clientLang to languageCode and back // to get only translated languages (There is a webpage). STLStringUtility::replaceString( defaultPage, "[ISO639-1]", LangTypes::getLanguageAsISO639( clientLang ) ); URL newUrl( url.getProto(), url.getHost(), url.getPort(), defaultPage.c_str() ); urlStr = newUrl.getSpec(); } } } } }
/*! \reimp */ QCString QSjisCodec::fromUnicode(const QString& uc, int& len_in_out) const { int l = QMIN((int)uc.length(),len_in_out); int rlen = l*2+1; QCString rstr(rlen); uchar* cursor = (uchar*)rstr.data(); for (int i=0; i<l; i++) { QChar ch = uc[i]; uint j; if ( ch.row() == 0x00 && ch.cell() < 0x80 ) { // ASCII *cursor++ = ch.cell(); } else if ((j = conv->UnicodeToJisx0201(ch.row(), ch.cell())) != 0) { // JIS X 0201 Latin or JIS X 0201 Kana *cursor++ = j; } else if ((j = conv->UnicodeToSjis(ch.row(), ch.cell())) != 0) { // JIS X 0208 *cursor++ = (j >> 8); *cursor++ = (j & 0xff); } else if ((j = conv->UnicodeToJisx0212(ch.row(), ch.cell())) != 0) {
/*! Converts the first \a len characters in \a uc from Unicode to this encoding, and returns the result in a byte array. The \a state contains some conversion flags, and is used by the codec to maintain state information. */ QByteArray QTsciiCodec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const { char replacement = '?'; if (state) { if (state->flags & ConvertInvalidToNull) replacement = 0; } int invalid = 0; QByteArray rstr(len, Qt::Uninitialized); uchar* cursor = (uchar*)rstr.data(); for (int i = 0; i < len; i++) { QChar ch = uc[i]; uchar j; if (ch.row() == 0x00 && ch.cell() < 0x80) { // ASCII j = ch.cell(); } else if ((j = qt_UnicodeToTSCII(uc[i].unicode(), uc[i + 1].unicode(), uc[i + 2].unicode()))) { // We have to check the combined chars first! i += 2; } else if ((j = qt_UnicodeToTSCII(uc[i].unicode(), uc[i + 1].unicode(), 0))) { i++; } else if ((j = qt_UnicodeToTSCII(uc[i].unicode(), 0, 0))) { } else { // Error j = replacement; ++invalid; } *cursor++ = j; } rstr.resize(cursor - (const uchar*)rstr.constData()); if (state) { state->invalidChars += invalid; } return rstr; }
void Ask(const TRequest& request, TReply& reply) const { CNcbiOstream& job_in = m_Grid_cli->GetOStream(); // job input stream auto_ptr<CObjectOStream> outstr(TConnectTraits::GetOStream(job_in)); *outstr << request; if (job_in.bad()) { NCBI_THROW(CIOException, eWrite, "Error while writing request"); } outstr.reset(); m_Grid_cli->CloseStream(); CNetScheduleJob& job = m_Grid_cli->GetJob(); CDeadline deadline(m_Timeout, 0); CNetScheduleNotificationHandler submit_job_handler; submit_job_handler.SubmitJob(m_NS_api.GetSubmitter(), job, m_Timeout ); LOG_POST(Trace << "job: " << job.job_id); CNetScheduleAPI::EJobStatus status( submit_job_handler.WaitForJobCompletion(job, deadline, m_NS_api) ); // TODO The wait is over; the current job status is in the status // variable. CNetScheduleAPI::StatusToString(status) can convert it // to a human-readable string. if (status == CNetScheduleAPI::eDone) { // TODO The job has completed successfully. CStringOrBlobStorageReader reader(job.output, m_NC_api); CRStream rstr(&reader); auto_ptr<CObjectIStream> instr(TConnectTraits::GetIStream(rstr)); *instr >> reply; }
int main(void) { #pragma STDC FENV_ACCESS ON float y; float d; int e, i, err = 0; struct f_f *p; for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; if (p->r < 0) continue; fesetround(p->r); feclearexcept(FE_ALL_EXCEPT); y = j0f(p->x); e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s j0f(%a)=%a, want %s", p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e)); printf(" got %s\n", estr(e)); err++; } d = ulperrf(y, p->y, p->dy); if (!checkulp(d, p->r)) { // printf("%s:%d: %s j0f(%a) want %a got %a ulperr %.3f = %a + %a\n", // p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy); err++; // TODO: avoid spamming the output printf(__FILE__ ": known to be broken near zeros\n"); break; } } return !!err; }
TEST_F(RoStrTest, gsub1) { gsub(rstr(""), "\\u0000", ""); }
static const char *xtn_str(Iss2::ExternalAccessType type) { switch(type) { rstr(XTN_PTPR); rstr(XTN_TLB_MODE); rstr(XTN_ICACHE_FLUSH); rstr(XTN_DCACHE_FLUSH); rstr(XTN_ITLB_INVAL); rstr(XTN_DTLB_INVAL); rstr(XTN_ICACHE_INVAL); rstr(XTN_DCACHE_INVAL); rstr(XTN_ICACHE_PREFETCH); rstr(XTN_DCACHE_PREFETCH); rstr(XTN_SYNC); rstr(XTN_INS_ERROR_TYPE); rstr(XTN_DATA_ERROR_TYPE); rstr(XTN_INS_BAD_VADDR); rstr(XTN_DATA_BAD_VADDR); default: return "invalid"; } }