void CompStates::copyIndex(int from, int to) { if(states.size()==0)return; if(from==to)return; SCState* fromstate=NULL; if(indexInUse(from))fromstate = getState(from); if(fromstate==NULL) //this means a clean state at 'to' { if(indexInUse(to)) { bool ok = delIndex(to); DASSERT(ok); } else { //nothing } } else { //beacuse getState() creates new if it does not exist: SCState* ts = getState(to); DASSERT(ts!=NULL); *ts = *fromstate; } }
void Translator::replaceSorted(const TranslatorMessage &msg) { int index = find(msg); if (index == -1) { appendSorted(msg); } else { delIndex(index); m_messages[index] = msg; addIndex(index, msg); } }
void IndexPage::shrinkIndex(IndexNode index, const char* key, const char* value) { if (!index.canShrink(key)) { error("Record size unsuitable for shrinking"); } size_t oldSize = index.getSize(); size_t newSize = IndexNode::getSize(key); int pageId = index.getRecordPageId(); size_t cursor = index.getRecordPageCursor(); IndexNode freeRec(*this, index.getCursor() + newSize); freeRec.initDel(oldSize - newSize); delIndex(freeRec.getCursor()); index.init(key, pageId, cursor); }
void Translator::extend(const TranslatorMessage &msg, ConversionData &cd) { int index = find(msg); if (index == -1) { append(msg); } else { TranslatorMessage &emsg = m_messages[index]; if (emsg.sourceText().isEmpty()) { delIndex(index); emsg.setSourceText(msg.sourceText()); addIndex(index, msg); } else if (!msg.sourceText().isEmpty() && emsg.sourceText() != msg.sourceText()) { cd.appendError(QString::fromLatin1("Contradicting source strings for message with id '%1'.") .arg(emsg.id())); return; } if (emsg.extras().isEmpty()) { emsg.setExtras(msg.extras()); } else if (!msg.extras().isEmpty() && emsg.extras() != msg.extras()) { cd.appendError(QString::fromLatin1("Contradicting meta data for for %1.") .arg(!emsg.id().isEmpty() ? QString::fromLatin1("message with id '%1'").arg(emsg.id()) : QString::fromLatin1("message '%1'").arg(makeMsgId(msg)))); return; } emsg.addReferenceUniq(msg.fileName(), msg.lineNumber()); if (!msg.extraComment().isEmpty()) { QString cmt = emsg.extraComment(); if (!cmt.isEmpty()) { QStringList cmts = cmt.split(QLatin1String("\n----------\n")); if (!cmts.contains(msg.extraComment())) { cmts.append(msg.extraComment()); cmt = cmts.join(QLatin1String("\n----------\n")); } } else { cmt = msg.extraComment(); } emsg.setExtraComment(cmt); } } }