示例#1
0
 vector<string> findMissingRanges(vector<int>& nums, int lower, int upper) {
     vector<string> res;
     int start = lower, end = lower;
     for (int n : nums) {
         end = n - 1;
         addRange(res, start, end);
         start = n + 1;
     }
     addRange(res, start, upper);
     return res;
 }
示例#2
0
/**
 * Report there's no matching nonblocking call for request var used by wait.
 *
 * @param callExpr
 * @param requestVar
 * @param node
 */
void MPIBugReporter::reportUnmatchedWait(
    const CallEvent &callEvent, const clang::ento::MemRegion *requestRegion,
    const ExplodedNode *const node) const {
    std::string errorText{"Request '" + util::variableName(requestRegion) +
                          "' has no matching nonblocking call. "};

    auto bugReport =
        llvm::make_unique<BugReport>(*unmatchedWaitBugType_, errorText, node);
    bugReport->addRange(callEvent.getSourceRange());
    SourceRange r = util::sourceRange(requestRegion);
    if (r.isValid()) bugReport->addRange(r);
    bugReporter_.emitReport(std::move(bugReport));
}
示例#3
0
void IpPool::addRanges(const std::string str)
{	
	std::size_t begin = 0;
	for (std::size_t position = position = str.find(' ', 0); 
		position != str.npos; position = str.find(' ', begin))
	{
		std::string range = str.substr(begin, position - begin);
		addRange(range);
		begin = position + 1;
	}
	std::string range = str.substr(begin, str.npos);
	addRange(range);
}
示例#4
0
int acqMakeChannelRange(int channels[], int cmax, const char* definition)
/** 
 *  @definition "-N  N-M  N,M,P  N-"
 *  returns number of selected channels
 */
{
	char* dbuf = new char[strlen(definition)+1];
	char* tbuf = new char[strlen(definition)+1];

	char* rbuf = tbuf;
	char* ptok;

	memset(tbuf, 0, strlen(definition)+1);
	strcpy(dbuf, definition);

	for(ptok = dbuf; (ptok = strtok_r(ptok, " ,",  &rbuf)) != 0; ptok = 0){
		addRange(channels, cmax, ptok);
	}
	
	int ichan;
	int selected = 0;

	for (ichan = 1; ichan <= cmax; ++ichan){
		if (channels[ichan] != 0){
			selected++;
		}
	}

	delete [] tbuf;
	delete [] dbuf;

	return selected;
}
示例#5
0
/**
 * Report a missing wait for a nonblocking call.
 *
 * @param requestVar
 * @param node
 */
void MPIBugReporter::reportMissingWait(const RequestVar &requestVar,
                                       const ExplodedNode *const node) const {
    std::string lineNo{lineNumber(requestVar.lastUser_)};
    std::string lastUser =
        requestVar.lastUser_->getCalleeIdentifier()->getName();

    std::string errorText{
        "'" + lastUser + "' in line " + lineNo + ", using request '" +
        requestVar.variableName() +
        "', has no matching wait in the scope of this function. "};

    auto bugReport =
        llvm::make_unique<BugReport>(*missingWaitBugType_, errorText, node);
    bugReport->addRange(requestVar.lastUser_->getSourceRange());
    SourceRange r = util::sourceRange(requestVar.memRegion_);
    if (r.isValid()) bugReport->addRange(r);
    bugReporter_.emitReport(std::move(bugReport));
}
示例#6
0
/**
 * Report duplicate request use by waits.
 *
 * @param observedCall
 * @param requestVar
 * @param node
 */
void MPIBugReporter::reportDoubleWait(const CallEvent &observedCall,
                                      const RequestVar &requestVar,
                                      const ExplodedNode *const node) const {
    std::string lineNo{lineNumber(requestVar.lastUser_)};
    std::string lastUser =
        requestVar.lastUser_->getCalleeIdentifier()->getName();
    std::string errorText{"Request '" + requestVar.variableName() +
                          "' is already waited upon by '" + lastUser +
                          "' in line " + lineNo + ". "};

    auto bugReport =
        llvm::make_unique<BugReport>(*doubleWaitBugType_, errorText, node);
    bugReport->addRange(observedCall.getSourceRange());
    bugReport->addRange(requestVar.lastUser_->getSourceRange());
    SourceRange r = util::sourceRange(requestVar.memRegion_);
    if (r.isValid()) bugReport->addRange(r);
    bugReporter_.emitReport(std::move(bugReport));
}
示例#7
0
文件: Program.cpp 项目: 8l/snowman
BasicBlock *Program::createBasicBlock(ByteAddr address) {
    if (BasicBlock *result = getBasicBlockStartingAt(address)) {
        return result;
    } else if (BasicBlock *basicBlock = getBasicBlockCovering(address)) {
        removeRange(basicBlock);

        auto iterator = std::find_if(basicBlock->statements().begin(), basicBlock->statements().end(), [address](const Statement *statement) {
            return statement->instruction()->addr() >= address;
        });

        BasicBlock *result = takeOwnership(basicBlock->split(iterator, address));

        addRange(basicBlock);
        addRange(result);

        return result;
    } else {
        BasicBlock *result = takeOwnership(std::make_unique<BasicBlock>(address));
        addRange(result);
        return result;
    }
}
示例#8
0
int CharacterEdits::exec( TextRangeRegExp* regexp )
{
    _regexp = regexp;
    negate->setChecked( regexp->negate() );
    digit->setChecked( regexp->digit() );
    _nonDigit->setChecked( regexp->nonDigit() );
    space->setChecked( regexp->space() );
    _nonSpace->setChecked( regexp->nonSpace() );
    wordChar->setChecked( regexp->wordChar() );
    _nonWordChar->setChecked( regexp->nonWordChar() );

    bool enabled = (RegExpConverter::current()->features() & RegExpConverter::CharacterRangeNonItems);
    _nonWordChar->setEnabled( enabled );
    _nonDigit->setEnabled( enabled );
    _nonSpace->setEnabled( enabled );

    // Characters

    KMultiFormListBoxEntryList list1 = _single->elements();
    for ( TQPtrListIterator<KMultiFormListBoxEntry> it(list1); *it; ++it ) {
        SingleEntry* entry = dynamic_cast<SingleEntry*>( *it );
        if (entry)
            entry->setText( TQString::fromLocal8Bit("") );
    }
    TQStringList list2 = regexp->chars();
    for ( TQStringList::Iterator it2( list2.begin() ); ! (*it2).isNull(); ++it2 ) {
        addCharacter( *it2 );
    }

    // Ranges
    KMultiFormListBoxEntryList list3 = _range->elements();
    for ( TQPtrListIterator<KMultiFormListBoxEntry> it3(list3); *it3; ++it3 ) {
        RangeEntry* entry = dynamic_cast<RangeEntry*>( *it3 );
        if (entry) {
            entry->setFrom( TQString::fromLocal8Bit("") );
            entry->setTo( TQString::fromLocal8Bit("") );
        }
    }

    TQPtrList<StringPair> ranges = regexp->range();
    for ( TQPtrListIterator<StringPair> it4(ranges); *it4; ++it4 ) {
        TQString from = (*it4)->first();
        TQString to = (*it4)->second();
        addRange(from,to);
    }

    int res = KDialogBase::exec();
    _regexp = 0;
    return res;
}
	void ResourceManualFont::initialise()
	{
		if (mVectorPairCodeCoord.empty()) return;

		std::sort(mVectorPairCodeCoord.begin(), mVectorPairCodeCoord.end());

		const IntSize& size = texture_utility::getTextureSize(mSource);
		float aspect = (float)size.width / (float)size.height;

		Char code = mVectorPairCodeCoord.front().code;
		size_t count = mVectorPairCodeCoord.size();
		size_t first = 0;

		for (size_t pos = 1; pos < count; ++pos)
		{
			// диапазон оборвался
			if (code + 1 != mVectorPairCodeCoord[pos].code)
			{
				addRange(mVectorPairCodeCoord, first, pos - 1, size.width, size.height, aspect);
				code = mVectorPairCodeCoord[pos].code;
				first = pos;
			}
			else
			{
				code ++;
			}
		}

		addRange(mVectorPairCodeCoord, first, count - 1, size.width, size.height, aspect);

		// уничтожаем буфер
		VectorPairCodeCoord tmp;
		std::swap(tmp, mVectorPairCodeCoord);

		checkTexture();
	}
/**
 * Search for \c #include directives
 *
 * \invariant Document supposed to have \c KTextEditor::MovingInterface implemented!
 */
void DocumentInfo::scanForHeadersIncluded(const KTextEditor::Range& source_range)
{
    auto* mv_iface = qobject_cast<KTextEditor::MovingInterface*>(m_doc);
    assert("No moving iface for document!" && mv_iface);

    auto range = (source_range == KTextEditor::Range::invalid())
      ? m_doc->documentRange()
      : source_range
      ;

    /**
     * \todo It would be \b cool to have a view class over a document
     * so the following code would be possible:
     * \code
     *  for (const auto& l : DocumentLinesView(range, doc))
     *  {
     *      QString line_str = l;    // auto converstion to strings
     *      int line_no = l.index(); // tracking of the current line number
     *  }
     *  // Or even smth like this
     *  DocumentLinesView dv = { view->document() };
     *  // Get line text by number
     *  QString line_str = dv[line_no];
     * \endcode
     */
    // Search lines and filenames #include'd in a selected range
    for (auto i = range.start().line(); i < range.end().line(); i++)
    {
        auto r = parseIncludeDirective(m_doc->line(i), false);
        if (r.range.isValid())
        {
            r.range.setBothLines(i);
            kDebug(DEBUG_AREA) << "found #include at" << r.range;
            if (!isRangeWithSameLineExists(r.range))
                addRange(
                    mv_iface->newMovingRange(
                        r.range
                      , KTextEditor::MovingRange::ExpandLeft | KTextEditor::MovingRange::ExpandRight
                      )
                  , r.type
                  );
            else kDebug(DEBUG_AREA) << "range already registered";
        }
    }
}
示例#11
0
void *malloc537(size_t size) {
    void *address = NULL;
    if ((int) size < 0) {
        printf("Can't have a negative size.\n");
        exit(-1);
    } else if (size == 0) {
        printf("Allocating a range of size of 0.\n");
    }
    // Is this a case?
    if ((address = malloc(size)) == NULL && size > 0) {
        printf("Unable to allocate memory.\n");
        exit(-1);
    }
    if (size > 0) {
        addRange(address, size);
    }
    return address;
}
示例#12
0
vector<uint32_t> getListOfPoints(std::string p)
{
    vector<uint32_t> output;

    //Remove whitespace from string with awful remove/erase idiom.
    p.erase(remove_if(p.begin(), p.end(), ::isspace), p.end());

    vector<string> ranges = tokenize(p, ',');
    for (string s : ranges)
    {
        vector<string> limits = tokenize(s, '-');
        if (limits.size() == 1)
            addSingle(limits[0], output);
        else if (limits.size() == 2)
            addRange(limits[0], limits[1], output);
        else
            throw pdal_error(string("Invalid point range: ") + s);
    }
    return output;
}
示例#13
0
BasicBlock *Program::getBasicBlockForInstruction(const arch::Instruction *instruction) {
    /* If there is a basic block that starts here, just take it. */
    BasicBlock *result = getBasicBlockStartingAt(instruction->addr());

    if (!result) {
        /* Maybe this instruction stands next to an existing basic block? */
        result = getBasicBlockCovering(instruction->addr() - 1);

        /* No way? Create new block. */
        if (!result) {
            result = createBasicBlock(instruction->addr());
        }
    }

    removeRange(result);
    result->setSuccessorAddress(instruction->endAddr());
    addRange(result);

    return result;
}
示例#14
0
int main(int argc, char **argv)
{
	uintptr_t i;
	uintptr_t x;
	i=0;
	while(i<atoi(argv[1]))
	{
		x=i*500;
		addRange((void*)x, 400);
		i++;
	}
	
	printf("Free result: %d\n", freeRange((void*)(i/2*500)));
	/*printRangeTree();*/
	printf("About to add %X,%X\n", i*500/2-25, i*500/2-25+100-1);
	addRange((void*)(i*500/2-25), 100); 
	/*Before to between
	printRangeTree();*/
	printf("About to add %X,%X\n", i*500/2+125, i*500/2+125+1);
	addRange((void*)(i*500/2+125), 2); 
	/*After to Between
	printRangeTree();*/
	printf("About to add %X,%X\n", i*500/2+128, i*500/2+128 + 500-1);
	fflush(stdout);
	addRange((void*)(i*500/2+128), 500); 
	/*after to after
	printRangeTree();*/
	printf("About to add %X,%X\n", i*500/2, i*500/2 +4);
	fflush(stdout);
	addRange((void*)(i*500/2), 5); 
	/*should already exist
	printRangeTree();*/
	printf("About to add %X,%X\n", 0x627, 0x627 +(0x658-0x627));
	fflush(stdout);
	addRange((void*)0x627, (0x658-0x627+1)); 
	/*should remove freed node*/
	printRangeTree();
	
	deleteTree();
	return 0;
}
示例#15
0
tnode* RangeQuery::addRange(tnode* curr, int min, int max)
{
    if(curr == NULL)
    {
        curr = allocNode(min,max,NULL,NULL);
        return curr;
    }

    bool isMinInRange = contains(curr,min);
    bool isMaxInRange = contains(curr,max);
    if(isMinInRange && isMaxInRange)
    {
        return curr;
    }
    else if(isMinInRange && !isMaxInRange)
    {
        curr->right = addRange(curr->right,curr->max + 1,max);
    }
    else if(!isMinInRange && isMaxInRange)
    {
        curr->left = addRange(curr->left,min,curr->min - 1);
    }
    else
    {
        if(max < curr->min)
        {
            curr->left = addRange(curr->left,min,max);
        }
        else if(min > curr->max)
        {
            curr->right = addRange(curr->right,min,max);
        }
        else//max > curr->max && min < curr->min
        {
            curr->left = addRange(curr->left,min,curr->min - 1);
            curr->right = addRange(curr->right,curr->max + 1, max);
        }
    }
    return curr;
}
示例#16
0
void RangeQuery::addRange(int min, int max)
{
    root = addRange(root,min,max);
}
示例#17
0
 void range(T l, T r) {
     resetDistribution();
     addRange(weighted_range<T>(l, r));
 }
示例#18
0
 void addRange(T l, T r) {
     addRange(weighted_range<T>(l, r));
 }
示例#19
0
 void addWeightedRange(T l, T r, unsigned long long w) {
     addRange(weighted_range<T>(l, r, w));
 }
示例#20
0
void MessagesList::addSlice(
		std::vector<MessagePosition> &&messageIds,
		MessagesRange noSkipRange,
		std::optional<int> count) {
	addRange(messageIds, noSkipRange, count);
}
示例#21
0
void MessagesList::addNew(MessagePosition messageId) {
	auto range = { messageId };
	addRange(range, { messageId, MaxMessagePosition }, std::nullopt, true);
}
示例#22
0
void PortList::addPort(int port) { addRange(port, port); }
示例#23
0
MojErr MojDbQueryPlan::rangesFromKeys(MojDbKey lowerKey, MojDbKey upperKey, MojDbKey prefix, MojUInt32 index,
		const MojDbQuery::WhereClause* clause)
{
	MojErr err = MojErrNone;
	MojUInt32 group = 0;
	MojDbQuery::CompOp lowerOp = MojDbQuery::OpEq;
	MojDbQuery::CompOp upperOp = MojDbQuery::OpNone;
	if (clause) {
		lowerOp = clause->lowerOp();
		upperOp = clause->upperOp();
	}

	// set up upper bound
	switch (upperOp) {
	case MojDbQuery::OpNone:
		MojAssert(lowerOp != MojDbQuery::OpNone);
		upperKey = prefix;
		// no break. fall through to OpLessThanEq case

	case MojDbQuery::OpLessThanEq:
		// match while less-than ++upperKey
		err = upperKey.increment();
		MojErrCheck(err);
		break;

	default:
		MojAssert(upperOp == MojDbQuery::OpLessThan);
		break;
	}

	// set up lower bound
	switch (lowerOp) {
	case MojDbQuery::OpNone:
		// seek to prefix and match while less than upperKey
		MojAssert(upperOp != MojDbQuery::OpNone);
		err = addRange(lowerKey, upperKey);
		MojErrCheck(err);
		break;

	case MojDbQuery::OpSearch:
		group = index % m_groupCount;
		// no break. fall through to OpPrefix case

	case MojDbQuery::OpPrefix:
		// remove null terminator
		MojAssert(!prefix.empty());
		if (prefix.byteVec().back() == 0) {
			err = prefix.byteVec().pop();
			MojErrCheck(err);
		}
		// no break. fall through to OpEq case

	case MojDbQuery::OpEq:
		// seek to lowerKey and match while less than ++prefix
		err = prefix.increment();
		MojErrCheck(err);
		err = addRange(lowerKey, prefix, group);
		MojErrCheck(err);
		break;

	case MojDbQuery::OpNotEq:
		// seek to prefix and match while less than lowerKey
		err = addRange(prefix, lowerKey);
		MojErrCheck(err);
		// seek to ++lowerKey, and match while less than ++prefix
		err = lowerKey.increment();
		MojErrCheck(err);
		err = prefix.increment();
		MojErrCheck(err);
		err = addRange(lowerKey, prefix);
		MojErrCheck(err);
		break;

	case MojDbQuery::OpGreaterThan:
		// seek to ++lowerKey and match while less than upperKey
		err = lowerKey.increment();
		MojErrCheck(err);
		// no break. fall through to OpGreaterThanEq case

	case MojDbQuery::OpGreaterThanEq:
		// seek to lowerKey and match while less than upperKey
		err = addRange(lowerKey, upperKey);
		MojErrCheck(err);
		break;

	default:
		MojAssertNotReached();
		break;
	}
	return MojErrNone;
}
IOReturn IOAudioLevelControl::addNegativeInfinity(SInt32 negativeInfinityValue)
{
    return addRange(negativeInfinityValue, negativeInfinityValue, kIOAudioLevelControlNegativeInfinity, kIOAudioLevelControlNegativeInfinity);
}
示例#25
0
void twinOrfStats(char *axtFile, char *raFile, char *outFile)
/* twinOrfStats - Collect stats on refSeq cDNAs aligned to another species via axtForEst. */
{
struct hash *rsiHash = readRefRa(raFile);
struct lineFile *lf = lineFileOpen(axtFile, TRUE);
FILE *f = mustOpen(outFile, "w");
struct axt *axt;
static struct c1Counts c1Kozak[10], c1all, c1utr5, c1utr3, c1cds;
static struct c2Counts c2Kozak[10], c2All, c2Utr5, c2Utr3, c2Cds;
static struct c3Counts c3All, c3Utr5, c3Utr3, c3Cds;
char label[64];
char *predictFile = optionVal("predict", NULL);
int i;
static struct c3Counts cod1, cod2, cod3, stop, earlyCod1, earlyCod2, earlyCod3;
int earlySize;

initC3Counts(&cod1, 0);
initC3Counts(&cod2, 0);
initC3Counts(&cod3, 0);
initC3Counts(&earlyCod1, 0);
initC3Counts(&earlyCod2, 0);
initC3Counts(&earlyCod3, 0);
initC3Counts(&c3Utr3, 0);
initC3Counts(&c3Utr5, 0);
initC3Counts(&stop, 0);

threshold = optionFloat("threshold", threshold);
earlyAaSize = optionInt("earlyAaSize", earlyAaSize);
earlySize = 3*earlyAaSize;
while ((axt = axtRead(lf)) != NULL)
    {
    struct refSeqInfo *rsi = hashFindVal(rsiHash, axt->tName);
    if (rsi != NULL && rsi->cdsStart >= 6)
        {
	if (checkAtg(axt, rsi->cdsStart))
	    {
	    for (i=0; i<10; ++i)
		addPos(&c1Kozak[i], &c2Kozak[i], axt, rsi->cdsStart - 5 + i);
	    addRange(&c1all, &c2All, &c3All, axt, 0, rsi->size);
	    addRange(&c1utr5, &c2Utr5, &c3Utr5, axt, 0, rsi->cdsStart);
	    addRange(&c1cds, &c2Cds, &c3Cds, axt, rsi->cdsStart, rsi->cdsEnd);
	    addRange(&c1utr3, &c2Utr3, &c3Utr3, axt, rsi->cdsEnd, rsi->size);

	    /* The +3+1 in the expression below breaks down as so:  the
	     * +3 is to move past the first 'ATG' codon, which is part of
	     * the Kozak consensus model, not the coding model.  The +1
	     * is so that we look at the 2nd and 3rd bases of the previous
	     * codon, and the first base of the current codon.   */
	    addCodons(&earlyCod1, axt, rsi->cdsStart+3+1, rsi->cdsStart+1+earlySize);
	    addCodons(&earlyCod2, axt, rsi->cdsStart+3+2, rsi->cdsStart+2+earlySize);
	    addCodons(&earlyCod3, axt, rsi->cdsStart+3+3, rsi->cdsStart+3+earlySize);
	    addCodons(&cod1, axt, rsi->cdsStart+3+1+earlySize, rsi->cdsEnd-5);
	    addCodons(&cod2, axt, rsi->cdsStart+3+2+earlySize, rsi->cdsEnd-4);
	    addCodons(&cod3, axt, rsi->cdsStart+3+3+earlySize, rsi->cdsEnd-3);
	    addCodons(&stop, axt, rsi->cdsEnd-3, rsi->cdsEnd);
	    }
	}
    axtFree(&axt);
    }
lineFileClose(&lf);

dumpC1(f, &c1all, "c1_all");
dumpC2(f, &c2All, "c2_all");
dumpC3(f, &c3All, "c3_all");

dumpC1(f, &c1utr5, "c1_utr5");
dumpC2(f, &c2Utr5, "c2_utr5");
dumpC3(f, &c3Utr5, "c3_utr5");

dumpC1(f, &c1cds, "c1_cds");
dumpC2(f, &c2Cds, "c2_cds");
dumpC3(f, &c3Cds, "c3_cds");

dumpC1(f, &c1utr3, "c1_utr3");
dumpC2(f, &c2Utr3, "c2_utr3");
dumpC3(f, &c3Utr3, "c3_utr3");

for (i=0; i<10; ++i)
    {
    sprintf(label, "c1_kozak[%d]", i-5);
    dumpC1(f, &c1Kozak[i], label);
    sprintf(label, "c2_kozak[%d]", i-5);
    dumpC2(f, &c2Kozak[i], label);
    }
dumpC3(f, &earlyCod1, "earlyCod1");
dumpC3(f, &earlyCod2, "earlyCod2");
dumpC3(f, &earlyCod3, "earlyCod3");
dumpC3(f, &cod1, "cod1");
dumpC3(f, &cod2, "cod2");
dumpC3(f, &cod3, "cod3");
dumpC3(f, &stop, "stop");

if (predictFile)
    {
    predict(c1Kozak, &c1all, axtFile, predictFile, rsiHash);
    }
}
示例#26
0
VerseUrl::VerseUrl(const VerseUrlRange &range) : m_params(), m_ranges(), m_isValid(true)
{
    addRange(range);
}