void TopLevel::answerReceived( int id, const QList<QByteArray> &answerList ) { // we have received an answer from the daemon. QByteArray answer; if(!answerList.isEmpty()) answer = answerList[0]; QString s; static QString unit; static qlonglong mFree = 0; static qlonglong mUsedApplication = 0; static qlonglong mUsedTotal = 0; static qlonglong sUsed = 0; static qlonglong sFree = 0; switch ( id ) { case 1: s = i18n( "CPU: %1%\xc2\x9c%1%", (int) (100 - answer.toFloat()) ); sbCpuStat->setText( s ); break; case 2: mFree = answer.toLongLong(); break; case 3: mUsedTotal = answer.toLongLong(); break; case 4: mUsedApplication = answer.toLongLong(); //Use a multi-length string s = i18nc( "Arguments are formatted byte sizes (used/total)", "Memory: %1 / %2" "\xc2\x9c" "Mem: %1 / %2" "\xc2\x9c" "Mem: %1" "\xc2\x9c" "%1", KFormat().formatByteSize( mUsedApplication*1024), KFormat().formatByteSize( (mFree+mUsedTotal)*1024 ) ); sbMemTotal->setText( s ); break; case 5: sFree = answer.toLongLong(); break; case 6: sUsed = answer.toLongLong(); setSwapInfo( sUsed, sFree, unit ); break; case 7: { KSGRD::SensorIntegerInfo info( answer ); unit = KSGRD::SensorMgr->translateUnit( info.unit() ); break; } } }
void Bdecoder::read(qulonglong *value, bool &bSigned) { if (m_pos >= m_len || m_buf[m_pos] != 'i') { setError("expected integer, got %c", char(m_buf[m_pos])); return; } m_pos++; int end = m_buf.indexOf('e', m_pos); if (end <= m_pos || end >= m_len) { setError("buffer overrun"); return; } if (value) { QByteArray s = m_buf.mid(m_pos, end - m_pos); if (!validateInt(s)) return; bool ok; if(bSigned = (s.left(1) == "-")) *value = s.toLongLong(&ok, 10); else *value = s.toULongLong(&ok, 10); if (!ok) { setError("Invalid integer (%s)", s.constData()); return; } } m_pos = end + 1; }
Collection HandlerHelper::collectionFromIdOrName(const QByteArray &id) { // id is a number bool ok = false; qint64 collectionId = id.toLongLong(&ok); if (ok) { return Collection::retrieveById(collectionId); } // id is a path QString path = QString::fromUtf8(id); // ### should be UTF-7 for real IMAP compatibility const QStringList pathParts = path.split(QLatin1Char('/'), QString::SkipEmptyParts); Collection col; for (const QString &part : pathParts) { SelectQueryBuilder<Collection> qb; qb.addValueCondition(Collection::nameColumn(), Query::Equals, part); if (col.isValid()) { qb.addValueCondition(Collection::parentIdColumn(), Query::Equals, col.id()); } else { qb.addValueCondition(Collection::parentIdColumn(), Query::Is, QVariant()); } if (!qb.exec()) { return Collection(); } Collection::List list = qb.result(); if (list.count() != 1) { return Collection(); } col = list.first(); } return col; }
qint64 ValgrindRunner::runCallgrind(const QString &qbsCommand, const QString &buildDir, bool dryRun, const QString &outFile) { runProcess(valgrindCommandLine(qbsCommand, buildDir, dryRun, "callgrind", outFile)); QFile f(outFile); if (!f.open(QIODevice::ReadOnly)) { throw Exception(QString::fromLatin1("Failed to open file '%1': %2") .arg(outFile, f.errorString())); } while (!f.atEnd()) { const QByteArray line = f.readLine().trimmed(); static const QByteArray magicString = "summary: "; if (!line.startsWith(magicString)) continue; const QByteArray icString = line.mid(magicString.size()); bool ok; const qint64 iCount = icString.toLongLong(&ok); if (!ok) { throw Exception(QString::fromLatin1("Unexpected line in callgrind output file " "'%1': '%2'.") .arg(outFile, QString::fromLocal8Bit(line))); } return iCount; } throw Exception(QString::fromLatin1("Failed to find summary line in callgrind " "output file '%1'.").arg(outFile)); }
int WLongInteger::parse(const QByteArray &data, uint start) { unsigned char len = data[start]; QByteArray numdata = data.mid(start + 1, len); m_value = numdata.toLongLong(); return len + 1; // bytes processed }
qint64 ValgrindRunner::runMassif(const QString &qbsCommand, const QString &buildDir, bool dryRun, const QString &outFile) { runProcess(valgrindCommandLine(qbsCommand, buildDir, dryRun, "massif", outFile)); QByteArray ms_printOutput; runProcess(QStringList() << "ms_print" << outFile, QString(), &ms_printOutput); QBuffer buffer(&ms_printOutput); buffer.open(QIODevice::ReadOnly); QByteArray peakSnapshot; const QString exceptionStringPattern = QString::fromLatin1("Failed to extract peak memory " "usage from file '%1': %2").arg(outFile); while (!buffer.atEnd()) { const QByteArray line = buffer.readLine(); static const QByteArray magicString = " (peak)"; const int magicStringOffset = line.indexOf(magicString); if (magicStringOffset == -1) continue; int delimiterOffset = line.lastIndexOf(',', magicStringOffset); if (delimiterOffset == -1) delimiterOffset = line.lastIndexOf('[', magicStringOffset); if (delimiterOffset == -1) { const QString details = QString::fromLatin1("Failed to extract peak snapshot from " "line '%1'.").arg(QString::fromLocal8Bit(line)); throw Exception(exceptionStringPattern.arg(details)); } peakSnapshot = line.mid(delimiterOffset + 1, magicStringOffset - delimiterOffset).trimmed(); break; } if (peakSnapshot.isEmpty()) throw Exception(exceptionStringPattern.arg("No peak marker found")); while (!buffer.atEnd()) { const QByteArray line = buffer.readLine().simplified(); if (!line.startsWith(peakSnapshot + ' ')) continue; const QList<QByteArray> entries = line.split(' '); if (entries.size() != 6) { const QString details = QString::fromLatin1("Expected 6 entries in line '%1', but " "there are %2.").arg(QString::fromLocal8Bit(line)).arg(entries.size()); throw Exception(exceptionStringPattern.arg(details)); } QByteArray peakMemoryString = entries.at(2); peakMemoryString.replace(',', QByteArray()); bool ok; qint64 peakMemoryUsage = peakMemoryString.toLongLong(&ok); if (!ok) { const QString details = QString::fromLatin1("Failed to parse peak memory value '%1' " "as a number.").arg(QString::fromLocal8Bit(peakMemoryString)); throw Exception(exceptionStringPattern.arg(details)); } return peakMemoryUsage; } const QString details = QString::fromLatin1("Failed to find snapshot '%1'.") .arg(QString::fromLocal8Bit(peakSnapshot)); throw Exception(exceptionStringPattern.arg(details)); }
void SetMetaDataJob::handleResponse(const Message &response) { Q_D(SetMetaDataJob); //TODO: Test if a server can really return more then one untagged NO response. If not, no need to OR the error codes if (!response.content.isEmpty() && d->tags.contains(response.content.first().toString())) { if (response.content[1].toString() == "NO") { setError(UserDefinedError); setErrorText(i18n("%1 failed, server replied: %2", d->m_name, QLatin1String(response.toString().constData()))); if (response.content[2].toString() == "[ANNOTATEMORE TOOMANY]" || response.content[2].toString() == "[METADATA TOOMANY]") { d->metaDataErrors |= TooMany; } else if (response.content[2].toString() == "[ANNOTATEMORE TOOBIG]" || response.content[2].toString().startsWith("[METADATA MAXSIZE")) { //krazy:exclude=strings d->metaDataErrors |= TooBig; d->maxAcceptedSize = -1; if (response.content[2].toString().startsWith("[METADATA MAXSIZE")) { //krazy:exclude=strings QByteArray max = response.content[2].toString(); max.replace("[METADATA MAXSIZE", ""); //krazy:exclude=doublequote_chars max.replace("]", ""); //krazy:exclude=doublequote_chars d->maxAcceptedSize = max.toLongLong(); } } else if (response.content[2].toString() == "[METADATA NOPRIVATE]") { d->metaDataErrors |= NoPrivate; } } else if (response.content.size() < 2) { setErrorText(i18n("%1 failed, malformed reply from the server.", d->m_name)); } else if (response.content[1].toString() != "OK") { setError(UserDefinedError); setErrorText(i18n("%1 failed, server replied: %2", d->m_name, QLatin1String(response.toString().constData()))); } emitResult(); } else if (d->serverCapability == Metadata && response.content[0].toString() == "+") { QByteArray content = ""; if (d->entriesIt.value().isEmpty()) { content += "NIL"; } else { content += d->entriesIt.value(); } ++d->entriesIt; if (d->entriesIt == d->entries.constEnd()) { content += ')'; } else { content += " \"" + d->entriesIt.key() + '\"'; int size = d->entriesIt.value().size(); content += " {" + QByteArray::number( size==0 ? 3 : size ) + '}'; } // qCDebug(KIMAP_LOG) << "SENT: " << content; d->sessionInternal()->sendData(content); } }
void ThreadsHandler::notifyStopped(const QByteArray &data) { if (data.isEmpty() || data == "all") { notifyAllStopped(); } else { bool ok; qlonglong id = data.toLongLong(&ok); if (ok) notifyRunning(ThreadId(id)); else // FIXME notifyAllStopped(); } }
void HttpThread::OnHeadersReceived() { // We don't notify our callback here, because OnDownloadFinished() will always be called // Note: after calling reply->abort() all other reply's members calls crash the app if (m_reply->error()) return; int const httpStatusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); // When we didn't ask for chunks, code should be 200 // When we asked for a chunk, code should be 206 bool const isChunk = !(m_begRange == 0 && m_endRange < 0); if ((isChunk && httpStatusCode != 206) || (!isChunk && httpStatusCode != 200)) { LOG(LWARNING, ("Http request to", m_reply->url().toEncoded().constData(), "aborted with HTTP code", httpStatusCode)); m_reply->abort(); } else if (m_expectedSize > 0) { // try to get content length from Content-Range header first if (m_reply->hasRawHeader("Content-Range")) { QList<QByteArray> const contentRange = m_reply->rawHeader("Content-Range").split('/'); int const numElements = contentRange.size(); if (numElements && contentRange.at(numElements - 1).toLongLong() != m_expectedSize) { LOG(LWARNING, ("Http request to", m_reply->url().toEncoded().constData(), "aborted - invalid Content-Range:", contentRange.at(numElements - 1).toLongLong())); m_reply->abort(); } } else if (m_reply->hasRawHeader("Content-Length")) { QByteArray const header = m_reply->rawHeader("Content-Length"); int64_t const expSize = header.toLongLong(); if (expSize != m_expectedSize) { LOG(LWARNING, ("Http request to", m_reply->url().toEncoded().constData(), "aborted - invalid Content-Length:", m_reply->rawHeader("Content-Length").toLongLong())); m_reply->abort(); } } else { LOG(LWARNING, ("Http request to", m_reply->url().toEncoded().constData(), "aborted, server didn't send any valid file size")); m_reply->abort(); } } }
float CSupervision::getFloatFromQByteArrayHex(const QByteArray& argByteArrayHex) { bool ok; int sign = 1; //QByteArray array("425AE78F"); QByteArray byteArrayHex = QByteArray::number(argByteArrayHex.toLongLong(&ok,16),2); //convert hex to binary -you don't need this since your incoming data is binary if(byteArrayHex.length()==32) { if(byteArrayHex.at(0)=='1') sign =-1; // if bit 0 is 1 number is negative byteArrayHex.remove(0,1); // remove sign bit } QByteArray fraction =byteArrayHex.right(23); //get the fractional part double mantissa = 0; for(int i=0;i<fraction.length();i++) // iterate through the array to claculate the fraction as a decimal. if(fraction.at(i)=='1') mantissa += 1.0/(pow(2,i+1)); int exponent = byteArrayHex.left(byteArrayHex.length()-23).toLongLong(&ok,2)-127; //claculate the exponent float fResult = sign*pow(2,exponent)*(mantissa+1.0); return fResult; }
bool QSerialPortInfo::isBusy() const { QString lockFilePath = serialPortLockFilePath(portName()); if (lockFilePath.isEmpty()) return false; QFile reader(lockFilePath); if (!reader.open(QIODevice::ReadOnly)) return false; QByteArray pidLine = reader.readLine(); pidLine.chop(1); if (pidLine.isEmpty()) return false; qint64 pid = pidLine.toLongLong(); if (pid && (::kill(pid, 0) == -1) && (errno == ESRCH)) return false; // PID doesn't exist anymore return true; }
bool QLockFilePrivate::getLockInfo(qint64 *pid, QString *hostname, QString *appname) const { QFile reader(fileName); if (!reader.open(QIODevice::ReadOnly)) return false; QByteArray pidLine = reader.readLine(); pidLine.chop(1); QByteArray appNameLine = reader.readLine(); appNameLine.chop(1); QByteArray hostNameLine = reader.readLine(); hostNameLine.chop(1); if (pidLine.isEmpty() || appNameLine.isEmpty()) return false; qint64 thePid = pidLine.toLongLong(); if (pid) *pid = thePid; if (appname) *appname = QString::fromUtf8(appNameLine); if (hostname) *hostname = QString::fromUtf8(hostNameLine); return thePid > 0; }
static int getToken() { const char tab[] = "bfnrt\"\'\\"; const char backTab[] = "\b\f\n\r\t\"\'\\"; yyIdent.clear(); yyComment.clear(); yyString.clear(); while ( yyCh != EOF ) { yyLineNo = yyCurLineNo; if ( yyCh.isLetter() || yyCh.toLatin1() == '_' ) { do { yyIdent.append(yyCh); yyCh = getChar(); } while ( yyCh.isLetterOrNumber() || yyCh.toLatin1() == '_' ); if (yyTok != Tok_Dot) { switch ( yyIdent.at(0).toLatin1() ) { case 'r': if ( yyIdent == QLatin1String("return") ) return Tok_return; break; case 'c': if ( yyIdent == QLatin1String("class") ) return Tok_class; break; case 'n': if ( yyIdent == QLatin1String("null") ) return Tok_null; break; } } switch ( yyIdent.at(0).toLatin1() ) { case 'T': // TR() for when all else fails if ( yyIdent == QLatin1String("TR") ) return Tok_tr; break; case 'p': if( yyIdent == QLatin1String("package") ) return Tok_Package; break; case 't': if ( yyIdent == QLatin1String("tr") ) return Tok_tr; if ( yyIdent == QLatin1String("translate") ) return Tok_translate; } return Tok_Ident; } else { switch ( yyCh.toLatin1() ) { case '/': yyCh = getChar(); if ( yyCh == QLatin1Char('/') ) { do { yyCh = getChar(); if (yyCh == EOF) break; yyComment.append(yyCh); } while (yyCh != QLatin1Char('\n')); return Tok_Comment; } else if ( yyCh == QLatin1Char('*') ) { bool metAster = false; bool metAsterSlash = false; while ( !metAsterSlash ) { yyCh = getChar(); if ( yyCh == EOF ) { yyMsg() << qPrintable(LU::tr("Unterminated Java comment.\n")); return Tok_Comment; } yyComment.append( yyCh ); if ( yyCh == QLatin1Char('*') ) metAster = true; else if ( metAster && yyCh == QLatin1Char('/') ) metAsterSlash = true; else metAster = false; } yyComment.chop(2); yyCh = getChar(); return Tok_Comment; } break; case '"': yyCh = getChar(); while ( yyCh != EOF && yyCh != QLatin1Char('\n') && yyCh != QLatin1Char('"') ) { if ( yyCh == QLatin1Char('\\') ) { yyCh = getChar(); if ( yyCh == QLatin1Char('u') ) { yyCh = getChar(); uint unicode(0); for (int i = 4; i > 0; --i) { unicode = unicode << 4; if( yyCh.isDigit() ) { unicode += yyCh.digitValue(); } else { int sub(yyCh.toLower().toLatin1() - 87); if( sub > 15 || sub < 10) { yyMsg() << qPrintable(LU::tr("Invalid Unicode value.\n")); break; } unicode += sub; } yyCh = getChar(); } yyString.append(QChar(unicode)); } else if ( yyCh == QLatin1Char('\n') ) { yyCh = getChar(); } else { yyString.append( QLatin1Char(backTab[strchr( tab, yyCh.toLatin1() ) - tab]) ); yyCh = getChar(); } } else { yyString.append(yyCh); yyCh = getChar(); } } if ( yyCh != QLatin1Char('"') ) yyMsg() << qPrintable(LU::tr("Unterminated string.\n")); yyCh = getChar(); return Tok_String; case ':': yyCh = getChar(); return Tok_Colon; case '\'': yyCh = getChar(); if ( yyCh == QLatin1Char('\\') ) yyCh = getChar(); do { yyCh = getChar(); } while ( yyCh != EOF && yyCh != QLatin1Char('\'') ); yyCh = getChar(); break; case '{': yyCh = getChar(); return Tok_LeftBrace; case '}': yyCh = getChar(); return Tok_RightBrace; case '(': if (yyParenDepth == 0) yyParenLineNo = yyCurLineNo; yyParenDepth++; yyCh = getChar(); return Tok_LeftParen; case ')': if (yyParenDepth == 0) yyParenLineNo = yyCurLineNo; yyParenDepth--; yyCh = getChar(); return Tok_RightParen; case ',': yyCh = getChar(); return Tok_Comma; case '.': yyCh = getChar(); return Tok_Dot; case ';': yyCh = getChar(); return Tok_Semicolon; case '+': yyCh = getChar(); if (yyCh == QLatin1Char('+')) { yyCh = getChar(); return Tok_PlusPlus; } if( yyCh == QLatin1Char('=') ) { yyCh = getChar(); return Tok_PlusEq; } return Tok_Plus; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { QByteArray ba; ba += yyCh.toLatin1(); yyCh = getChar(); bool hex = yyCh == QLatin1Char('x'); if ( hex ) { ba += yyCh.toLatin1(); yyCh = getChar(); } while ( hex ? isxdigit(yyCh.toLatin1()) : yyCh.isDigit() ) { ba += yyCh.toLatin1(); yyCh = getChar(); } bool ok; yyInteger = ba.toLongLong(&ok); if (ok) return Tok_Integer; break; } default: yyCh = getChar(); } } } return Tok_Eof; }
static int getToken() { const char tab[] = "abfnrtv"; const char backTab[] = "\a\b\f\n\r\t\v"; uint n; bool quiet; yyIdentLen = 0; yyCommentLen = 0; yyStringLen = 0; while ( yyCh != EOF ) { yyLineNo = yyCurLineNo; if ( isalpha(yyCh) || yyCh == '_' ) { do { if ( yyIdentLen < sizeof(yyIdent) - 1 ) yyIdent[yyIdentLen++] = (char) yyCh; yyCh = getChar(); } while ( isalnum(yyCh) || yyCh == '_' ); yyIdent[yyIdentLen] = '\0'; bool might_be_str = false; switch ( yyIdent[0] ) { case 'N': if ( strcmp(yyIdent + 1, "one") == 0 ) return Tok_None; break; case 'Q': if (strcmp(yyIdent + 1, "T_TR_NOOP") == 0) { yyParsingUtf8 = false; return Tok_tr; } else if (strcmp(yyIdent + 1, "T_TR_NOOP_UTF8") == 0) { yyParsingUtf8 = true; return Tok_trUtf8; } else if (strcmp(yyIdent + 1, "T_TRANSLATE_NOOP") == 0) { yyParsingUtf8 = false; return Tok_translate; } break; case 'c': if ( strcmp(yyIdent + 1, "lass") == 0 ) return Tok_class; break; case 'f': /* * QTranslator::findMessage() has the same parameters as * QApplication::translate(). */ if ( strcmp(yyIdent + 1, "indMessage") == 0 ) return Tok_translate; break; case 'r': if ( strcmp(yyIdent + 1, "eturn") == 0 ) return Tok_return; /* Drop through. */ case 'R': if (yyIdent[1] == '\0') might_be_str = true; break; case 'b': case 'B': case 'u': case 'U': if (yyIdent[1] == '\0') might_be_str = true; else if ((yyIdent[1] == 'r' || yyIdent[1] == 'R') && yyIdent[2] == '\0') might_be_str = true; break; case 't': if ( strcmp(yyIdent + 1, "r") == 0 ) { yyParsingUtf8 = false; return Tok_tr; } else if ( qstrcmp(yyIdent + 1, "rUtf8") == 0 ) { yyParsingUtf8 = true; return Tok_trUtf8; } else if ( qstrcmp(yyIdent + 1, "ranslate") == 0 ) { yyParsingUtf8 = false; return Tok_translate; } break; case '_': if ( strcmp(yyIdent + 1, "_tr") == 0 ) { yyParsingUtf8 = false; return Tok_tr; } else if ( strcmp(yyIdent + 1, "_trUtf8") == 0 ) { yyParsingUtf8 = true; return Tok_trUtf8; } else if ( qstrcmp(yyIdent + 1, "translate") == 0 ) { yyParsingUtf8 = false; return Tok_translate; } break; } /* * Handle the standard Python v2 and v3 string prefixes by simply * ignoring them. */ if (!might_be_str) return Tok_Ident; if (yyCh != '"' && yyCh != '\'') return Tok_Ident; } { switch ( yyCh ) { case '#': do { yyCh = getChar(); } while ( yyCh != EOF && yyCh != '\n' ); break; case '"': case '\'': int quoteChar; int trippelQuote, singleQuote; int in; quoteChar = yyCh; trippelQuote = 0; singleQuote = 1; in = 0; yyCh = getChar(); quiet = false; while ( yyCh != EOF ) { if ( singleQuote && (yyCh == '\n' || (in && yyCh == quoteChar)) ) break; if ( yyCh == quoteChar ) { if (peekChar() == quoteChar) { yyCh = getChar(); if (!trippelQuote) { trippelQuote = 1; singleQuote = 0; in = 1; yyCh = getChar(); } else { yyCh = getChar(); if (yyCh == quoteChar) { trippelQuote = 0; break; } } } else if (trippelQuote) { if ( yyStringLen < sizeof(yyString) - 1 ) yyString[yyStringLen++] = (char) yyCh; yyCh = getChar(); continue; } else break; } else in = 1; if ( yyCh == '\\' ) { yyCh = getChar(); if ( yyCh == 'x' ) { QByteArray hex = "0"; yyCh = getChar(); while ( isxdigit(yyCh) ) { hex += (char) yyCh; yyCh = getChar(); } #if defined(_MSC_VER) && _MSC_VER >= 1400 sscanf_s( hex, "%x", &n ); #else sscanf( hex, "%x", &n ); #endif if ( yyStringLen < sizeof(yyString) - 1 ) yyString[yyStringLen++] = (char) n; } else if ( yyCh >= '0' && yyCh < '8' ) { QByteArray oct = ""; int n = 0; do { oct += (char) yyCh; ++n; yyCh = getChar(); } while ( yyCh >= '0' && yyCh < '8' && n < 3 ); #if defined(_MSC_VER) && _MSC_VER >= 1400 sscanf_s( oct, "%o", &n ); #else sscanf( oct, "%o", &n ); #endif if ( yyStringLen < sizeof(yyString) - 1 ) yyString[yyStringLen++] = (char) n; } else if ( yyCh == '\n' ) { yyCh = getChar(); } else { const char *p = strchr( tab, yyCh ); if ( yyStringLen < sizeof(yyString) - 1 ) yyString[yyStringLen++] = ( p == 0 ) ? (char) yyCh : backTab[p - tab]; yyCh = getChar(); } } else { if (!yyCodecForSource) { if ( yyParsingUtf8 && yyCh >= 0x80 && !quiet) { qWarning( "%s:%d: Non-ASCII character detected in trUtf8 string", (const char *) yyFileName, yyLineNo ); quiet = true; } // common case: optimized if ( yyStringLen < sizeof(yyString) - 1 ) yyString[yyStringLen++] = (char) yyCh; yyCh = getChar(); } else { QByteArray originalBytes; while ( yyCh != EOF && (trippelQuote || yyCh != '\n') && yyCh != quoteChar && yyCh != '\\' ) { if ( yyParsingUtf8 && yyCh >= 0x80 && !quiet) { qWarning( "%s:%d: Non-ASCII character detected in trUtf8 string", (const char *) yyFileName, yyLineNo ); quiet = true; } originalBytes += (char)yyCh; yyCh = getChar(); } QString unicodeStr = yyCodecForSource->toUnicode(originalBytes); QByteArray convertedBytes; if (!yyCodecForTr->canEncode(unicodeStr) && !quiet) { qWarning( "%s:%d: Cannot convert Python string from %s to %s", (const char *) yyFileName, yyLineNo, yyCodecForSource->name().constData(), yyCodecForTr->name().constData() ); quiet = true; } convertedBytes = yyCodecForTr->fromUnicode(unicodeStr); size_t len = qMin((size_t)convertedBytes.size(), sizeof(yyString) - yyStringLen - 1); memcpy(yyString + yyStringLen, convertedBytes.constData(), len); yyStringLen += len; } } } yyString[yyStringLen] = '\0'; if ( yyCh != quoteChar ) { if (trippelQuote) qWarning("%s:%d: Empty or unterminated triple quoted string", (const char *)yyFileName, yyLineNo); else qWarning("%s:%d: Unterminated string", (const char *)yyFileName, yyLineNo); } if ( yyCh == EOF ) { return Tok_Eof; } else { yyCh = getChar(); return Tok_String; } break; case '(': if (yyParenDepth == 0) yyParenLineNo = yyCurLineNo; yyParenDepth++; yyCh = getChar(); return Tok_LeftParen; case ')': if (yyParenDepth == 0) yyParenLineNo = yyCurLineNo; yyParenDepth--; yyCh = getChar(); return Tok_RightParen; case ',': yyCh = getChar(); return Tok_Comma; case '.': yyCh = getChar(); return Tok_Dot; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { QByteArray ba; ba+=yyCh; yyCh = getChar(); bool hex = yyCh == 'x'; if ( hex ) { ba+=yyCh; yyCh = getChar(); } while ( (hex ? isxdigit(yyCh) : isdigit(yyCh)) ) { ba+=yyCh; yyCh = getChar(); } bool ok; yyInteger = ba.toLongLong(&ok); if (ok) return Tok_Integer; break; } default: yyCh = getChar(); } } } return Tok_Eof; }