Ejemplo n.º 1
0
Archivo: jo.c Proyecto: imjerrybao/jo
int member_to_object(JsonNode *object, int flags, char *kv)
{
	/* we expect key=value or key:value (boolean on last) */
	char *p = strchr(kv, '=');
	char *q = strchr(kv, '@');

	if (!p && !q) {
		return (-1);
	}


	if (p) {
		*p = 0;

		if (nested(flags, kv, p+1) == TRUE)
			 return (0);
		json_append_member(object, kv, vnode(p+1, flags));
	} else {
		*q = 0;

		if (nested(flags | FLAG_BOOLEAN, kv, q+1) == TRUE)
			 return (0);
		json_append_member(object, kv, boolnode(q+1));
	}
	return (0);
}
Ejemplo n.º 2
0
void nested(const int nest)
{
	if (nest == 0)
		test("testtest");
	else
		nested(nest - 1);
}
Ejemplo n.º 3
0
void loops_10_times()
{
	if (dummy & 1)
	{
		nested();
	}

	dummy++;
}
Ejemplo n.º 4
0
void
sql::write_subquery_exprn(const query_base &query) {
    assert(!_implicit_table);
    write("(");
    {
        nested_select_scope nested(*this);
        query.write_maximal_select(*this);
    }
    write(")");
}
Ejemplo n.º 5
0
int
zero (int n)
{
  int
  nested (int m)
  {
    return m - n;
  }

  return nested (n);
}
Ejemplo n.º 6
0
int main()
{
	try
	{
		nested(10000);
	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
	}

	return 0;
}
Ejemplo n.º 7
0
int main(int argc, char** argv)
{
	// Parse cmd line args.
	int	pointCount	= 0;

	if(argc == 2) {
		pointCount	= atoi(argv[1]);
	}
	else {
		printf("usage: quickhull <points>\n");
		exit(1);
	}

	long* uvec		= malloc(pointCount * sizeof(long));

	long* out1		= malloc(pointCount * sizeof(long));
	long* out2		= malloc(pointCount * sizeof(long));

	for (int i = 0; i < pointCount; i++) {
		uvec[i] = i;
	}

	// Timing setup
        struct timeval start, finish;
        struct rusage start_ru, finish_ru;

        gettimeofday( &start, NULL );
        getrusage( RUSAGE_SELF, &start_ru );

	// Do the deed.
	long out1_len, out2_len;
	nested(pointCount, uvec, out1, out2, &out1_len, &out2_len);

	// Print how long it took.
        gettimeofday( &finish, NULL );
        getrusage( RUSAGE_SELF, &finish_ru );

//	printf("depth          = %d\n", depth);
//	printf("points on hull = %d\n", hull->length);

        sub_timeval( &finish, &start );
        sub_timeval( &finish_ru.ru_utime, &start_ru.ru_utime );
        sub_timeval( &finish_ru.ru_stime, &start_ru.ru_stime );
        add_timeval( &finish_ru.ru_utime, &finish_ru.ru_stime );

	printf("elapsedTimeMS   = ");
        print_timeval( &finish ); putchar( '\n' );

 	printf("cpuTimeMS       = ");
        print_timeval( &finish_ru.ru_utime); putchar( '\n' );
}
Ejemplo n.º 8
0
void arraysInBlocks() {
  typedef int INTS[4];
  void (^simple)(int [_Nonnull 2]) = ^(int x[_Nonnull 2]) {};
  simple(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
  void (^nested)(void *_Nullable x[_Nonnull 2]) = ^(void *_Nullable x[_Nonnull 2]) {};
  nested(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
  void (^nestedBad)(int x[2][_Nonnull 2]) = // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'int [2]'}}
    ^(int x[2][_Nonnull 2]) {}; // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'int [2]'}}

  void (^withTypedef)(INTS _Nonnull) = ^(INTS _Nonnull x) {};
  withTypedef(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
  void (^withTypedefBad)(INTS _Nonnull [2]) = // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'INTS' (aka 'int [4]')}}
      ^(INTS _Nonnull x[2]) {}; // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'INTS' (aka 'int [4]')}}
}
Ejemplo n.º 9
0
void expr_context_simplifier::reduce_rec(quantifier* q, expr_ref & result) {
    result = q;

#if 0
    //
    // The context assumes that asserted expressions are in NNF with
    // respect to the quantifier occurrences.
    // This can be disabled if the strong context simplifier
    // is called from the API over the Z3_simplify method.
    //
    expr_context_simplifier nested(m_manager);
    expr_ref body_r(m_manager);
    nested.reduce(q->get_expr(), body_r);
    if (body_r.get() != q->get_expr()) {
        result = m_manager.update_quantifier(q, body_r.get());
    }
    else {
        result = q;
    }
#endif
}
Ejemplo n.º 10
0
static void test_bytes_used(skiatest::Reporter* reporter) {
    SkPictureRecorder recorder;

    recorder.beginRecording(0, 0);
    SkAutoTUnref<SkPicture> empty(recorder.endRecording());

    // Sanity check to make sure we aren't under-measuring.
    REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get()) >=
                              sizeof(SkPicture) + sizeof(SkRecord));

    // Protect against any unintentional bloat.
    size_t approxUsed = SkPictureUtils::ApproximateBytesUsed(empty.get());
    REPORTER_ASSERT(reporter, approxUsed <= 432);

    // Sanity check of nested SkPictures.
    SkPictureRecorder r2;
    r2.beginRecording(0, 0);
    r2.getRecordingCanvas()->drawPicture(empty.get());
    SkAutoTUnref<SkPicture> nested(r2.endRecording());

    REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(nested.get()) >
                              SkPictureUtils::ApproximateBytesUsed(empty.get()));
}
Ejemplo n.º 11
0
void tst_QVersitOrganizerExporter::testExport_data()
{
    QTest::addColumn<QList<QOrganizerItem> >("items");
    QTest::addColumn<QVersitDocument>("expectedDocument");

    {
        QVersitDocument document(QVersitDocument::ICalendar20Type);
        document.setComponentType(QLatin1String("VCALENDAR"));
        QVersitDocument nested(QVersitDocument::ICalendar20Type);
        nested.setComponentType(QLatin1String("VEVENT"));
        QVersitProperty property;
        property.setName(QLatin1String("SUMMARY"));
        property.setValue(QLatin1String("Bastille Day Party"));
        nested.addProperty(property);
        property.setName(QLatin1String("DTSTART"));
        property.setValue(QLatin1String("19970714T170000Z"));
        nested.addProperty(property);
        property.setName(QLatin1String("DTEND"));
        property.setValue(QLatin1String("19970715T035959Z"));
        nested.addProperty(property);
        document.addSubDocument(nested);

        nested.clear();
        nested.setType(QVersitDocument::ICalendar20Type);
        nested.setComponentType(QLatin1String("VTODO"));
        property.setName(QLatin1String("SUMMARY"));
        property.setValue(QLatin1String("Take out the garbage"));
        nested.addProperty(property);
        property.setName(QLatin1String("DTSTART"));
        property.setValue(QLatin1String("20100609T080000"));
        nested.addProperty(property);
        property.setName(QLatin1String("DUE"));
        property.setValue(QLatin1String("20100610T080000"));
        nested.addProperty(property);
        document.addSubDocument(nested);

        nested.clear();
        nested.setType(QVersitDocument::ICalendar20Type);
        nested.setComponentType(QLatin1String("VJOURNAL"));
        property.setName(QLatin1String("SUMMARY"));
        property.setValue(QLatin1String("Trip to Thailand"));
        nested.addProperty(property);
        property.setName(QLatin1String("DTSTART"));
        property.setValue(QLatin1String("20100615T112300"));
        nested.addProperty(property);
        document.addSubDocument(nested);

        QOrganizerEvent event;
        event.setDisplayLabel(QLatin1String("Bastille Day Party"));
        event.setStartDateTime(QDateTime(QDate(1997, 7, 14), QTime(17, 0, 0), Qt::UTC));
        event.setEndDateTime(QDateTime(QDate(1997, 7, 15), QTime(3, 59, 59), Qt::UTC));

        QOrganizerTodo todo;
        todo.setDisplayLabel(QLatin1String("Take out the garbage"));
        todo.setStartDateTime(QDateTime(QDate(2010, 6, 9), QTime(8, 0, 0)));
        todo.setDueDateTime(QDateTime(QDate(2010, 6, 10), QTime(8, 0, 0)));

        QOrganizerJournal journal;
        journal.setDisplayLabel(QLatin1String("Trip to Thailand"));
        journal.setDateTime(QDateTime(QDate(2010, 6, 15), QTime(11, 23, 0)));

        QList<QOrganizerItem> items;
        items << static_cast<QOrganizerItem>(event);
        items << static_cast<QOrganizerItem>(todo);
        items << static_cast<QOrganizerItem>(journal);

        QTest::newRow("sample event, todo and journal") << items << document;
    }

    {
        QVersitDocument document(QVersitDocument::ICalendar20Type);
        document.setComponentType(QLatin1String("VCALENDAR"));
        QVersitDocument nested(QVersitDocument::ICalendar20Type);
        nested.setComponentType(QLatin1String("VEVENT"));
        QVersitProperty property;
        property.setName(QLatin1String("UID"));
        property.setValue(QLatin1String("1234"));
        nested.addProperty(property);
        property.setName(QLatin1String("RECURRENCE-ID"));
        property.setValue(QLatin1String("20100608"));
        nested.addProperty(property);
        document.addSubDocument(nested);

        // An event occurrence with OriginalDate and Guid set
        QOrganizerEventOccurrence event;
        event.setGuid(QLatin1String("1234"));
        event.setOriginalDate(QDate(2010, 6, 8));

        QList<QOrganizerItem> items;
        items << static_cast<QOrganizerItem>(event);

        QTest::newRow("event occurrence exception") << items << document;
    }
}
Ejemplo n.º 12
0
int main()
{
    Enclosing enclosing;
    Enclosing::Nested nested(enclosing);
    return 0;
}
Ejemplo n.º 13
0
SAWYER_EXPORT bool
PodFormatter::beginTag(std::ostream &out, const Tag::Ptr &tag, const TagArgs &args) {
    tagStack_.push_back(tag);
    if (tag->type() == DIVIDING) {
        out <<(atBeginningOfLine_?"":"\n") <<"\n";
        atBeginningOfLine_ = true;
    }

    if (tag->name() == "prose") {
        checkArgs(tag, 1, args);
        out <<"=over\n\n";
        textModePush(PROSE);

    } else if (tag->name() == "nonprose") {
        checkArgs(tag, 1, args);
        out <<"=over\n\n";
        textModePush(NONPROSE);

    } else if (tag->name() == "section") {
        // Nested sections, but only if the body is not empty.
        checkArgs(tag, 2, args);
        size_t level = nested() + 1;
        if (level > 4)
            throw std::runtime_error("POD formatter can handle at most four levels of section nesting");
        std::ostringstream arg0, arg1;
        arg0 <<"=head" <<level <<" ";
        atBeginningOfLine_ = false;
        args[0]->emit(arg0, self());
        arg0 <<"\n\n";
        atBeginningOfLine_ = true;
        args[1]->emit(arg1, self());
        if (hasNonSpace(arg1.str()))
            out <<arg0.str() <<arg1.str();
        return false;                                   // no recursion

    } else if (tag->name() == "list") {
        out <<"=over\n\n";
        atBeginningOfLine_ = true;

    } else if (tag->name() == "bullet") {
        checkArgs(tag, 1, args);
        out <<"=item * ";
        atBeginningOfLine_ = false;

    } else if (tag->name() == "numbered") {
        checkArgs(tag, 1, args);
        out <<"=item 1 ";
        atBeginningOfLine_ = false;

    } else if (tag->name() == "named") {
        checkArgs(tag, 2, args);
        out <<"=item ";
        args[0]->emit(out, self());
        out <<"\n\n";
        atBeginningOfLine_ = true;
        args[1]->emit(out, self());
        return false;

    } else if (tag->name() == "comment") {
        return false;

    } else if (tag->name() == "emphasis") {
        checkArgs(tag, 1, args);
        out <<(nested() % 2 ? 'B' : 'I') <<'<';
        atBeginningOfLine_ = false;
        args[0]->emit(out, self());
        out <<">";
        atBeginningOfLine_ = false;
        return false;
            
    } else if (tag->name() == "variable") {
        checkArgs(tag, 1, args);
        out <<"I<";
        atBeginningOfLine_ = false;
        args[0]->emit(out, self());
        out <<">";
        atBeginningOfLine_ = false;
        return false;

    } else if (tag->name() == "link") {                 // second arg (text) is ignored; only link is shown
        checkArgs(tag, 2, args);
        out <<"L<";
        atBeginningOfLine_ = false;
        args[0]->emit(out, self());
        out <<">";
        atBeginningOfLine_ = false;
        return false;

    } else if (tag->name() == "verbatim") {

    } else {
        throw std::runtime_error("unrecognized markup tag \"" + tag->name() + "\" for Perl POD formatter");
    }
    return true;
}
Ejemplo n.º 14
0
void tst_QVersitWriter::testWritingDocument_data()
{
    QTest::addColumn<QVersitDocument>("document");
    QTest::addColumn<QByteArray>("expected");

    QVersitDocument document(QVersitDocument::VCard21Type);
    document.setComponentType(QStringLiteral("VCARD"));
    QVersitProperty property;
    property.setName(QStringLiteral("FN"));
    property.setValue(QStringLiteral("Bob"));
    document.addProperty(property);
    QTest::newRow("basic vCard 2.1") << document << QByteArray(
            "BEGIN:VCARD\r\n"
            "VERSION:2.1\r\n"
            "FN:Bob\r\n"
            "END:VCARD\r\n"
            );

    document.setComponentType(QStringLiteral("VCARD"));
    document.setType(QVersitDocument::VCard30Type);
    QTest::newRow("basic vCard 3.0") << document << QByteArray(
            "BEGIN:VCARD\r\n"
            "VERSION:3.0\r\n"
            "FN:Bob\r\n"
            "END:VCARD\r\n"
            );

    document.setComponentType(QStringLiteral("VCARD"));
    document.setType(QVersitDocument::VCard40Type);
    QTest::newRow("basic vCard 4.0") << document << QByteArray(
            "BEGIN:VCARD\r\n"
            "VERSION:4.0\r\n"
            "FN:Bob\r\n"
            "END:VCARD\r\n"
            );
    
    {
        QVersitDocument document(QVersitDocument::ICalendar20Type);
        document.setComponentType(QStringLiteral("VCALENDAR"));
        QVersitDocument subdocument(QVersitDocument::ICalendar20Type);
        subdocument.setComponentType(QStringLiteral("VEVENT"));
        property.setValueType(QVersitProperty::PreformattedType);
        property.setName(QStringLiteral("RRULE"));
        property.setValue(QStringLiteral("FREQ=MONTHLY;BYMONTHDAY=1,3"));
        subdocument.addProperty(property);
        document.addSubDocument(subdocument);
        QTest::newRow("basic iCalendar 2.0") << document << QByteArray(
                "BEGIN:VCALENDAR\r\n"
                "VERSION:2.0\r\n"
                "BEGIN:VEVENT\r\n"
                "RRULE:FREQ=MONTHLY;BYMONTHDAY=1,3\r\n"
                "END:VEVENT\r\n"
                "END:VCALENDAR\r\n");
    }

    {
        QVersitDocument document(QVersitDocument::ICalendar20Type);
        document.setComponentType(QStringLiteral("VCALENDAR"));
        QVersitProperty property;
        property.setName(QStringLiteral("PRODID"));
        property.setValue(QStringLiteral("-//hacksw/handcal//NONSGML v1.0//EN"));
        document.addProperty(property);
        QVersitDocument nested(QVersitDocument::ICalendar20Type);
        nested.setComponentType(QStringLiteral("VEVENT"));
        property.setName(QStringLiteral("DTSTART"));
        property.setValue(QStringLiteral("19970714T170000Z"));
        nested.addProperty(property);
        property.setName(QStringLiteral("DTEND"));
        property.setValue(QStringLiteral("19970715T035959Z"));
        nested.addProperty(property);
        property.setName(QStringLiteral("SUMMARY"));
        property.setValue(QStringLiteral("Bastille Day Party"));
        nested.addProperty(property);
        document.addSubDocument(nested);
        QTest::newRow("iCalendar 2.0 from spec") << document << QByteArray(
                        "BEGIN:VCALENDAR\r\n"
                        "VERSION:2.0\r\n"
                        "PRODID:-//hacksw/handcal//NONSGML v1.0//EN\r\n"
                        "BEGIN:VEVENT\r\n"
                        "DTSTART:19970714T170000Z\r\n"
                        "DTEND:19970715T035959Z\r\n"
                        "SUMMARY:Bastille Day Party\r\n"
                        "END:VEVENT\r\n"
                        "END:VCALENDAR\r\n");
    }

    {
        QString longString(QLatin1String(
            "4567890123456789012345678901234567890123456789012345678901234567890123456"
            "234567890123456789012345678901234567890123456789012345678901234567890123456"
            "234567890123456789012"));
        QVersitDocument document(QVersitDocument::VCard21Type);
        document.setComponentType(QStringLiteral("VCARD"));
        QVersitProperty property;
        property.setName(QStringLiteral("FN"));
        property.setValue(longString);
        document.addProperty(property);
        QByteArray expected21(
                "BEGIN:VCARD\r\n"
                "VERSION:2.1\r\n"
                "FN:4567890123456789012345678901234567890123456789012345678901234567890123456\r\n"
                " 234567890123456789012345678901234567890123456789012345678901234567890123456\r\n"
                " 234567890123456789012\r\n"
                "END:VCARD\r\n");
        QTest::newRow("folding 2.1") << document << expected21;

        document.setType(QVersitDocument::VCard30Type);
        QByteArray expected30(
                "BEGIN:VCARD\r\n"
                "VERSION:3.0\r\n"
                "FN:4567890123456789012345678901234567890123456789012345678901234567890123456\r\n"
                " 234567890123456789012345678901234567890123456789012345678901234567890123456\r\n"
                " 234567890123456789012\r\n"
                "END:VCARD\r\n");
        QTest::newRow("folding 3.0") << document << expected30;

        document.setType(QVersitDocument::VCard21Type);
        property.setValue(longString.toLatin1());
        property.setValueType(QVersitProperty::BinaryType);
        document.removeProperties("FN");
        document.addProperty(property);
        QByteArray expected21b(
                "BEGIN:VCARD\r\n"
                "VERSION:2.1\r\n"
                "FN;ENCODING=BASE64:\r\n"
                " NDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODk\r\n"
                " wMTIzNDU2Nzg5MDEyMzQ1NjIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MD\r\n"
                " EyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1NjIzNDU2Nzg5MDEyMzQ1Njc4OTAxM\r\n"
                " g==\r\n"
                "\r\n"
                "END:VCARD\r\n");
        QTest::newRow("folding 2.1") << document << expected21b;

        document.setType(QVersitDocument::VCard30Type);
        QByteArray expected30b(
                "BEGIN:VCARD\r\n"
                "VERSION:3.0\r\n"
                "FN;ENCODING=b:NDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OT\r\n"
                " AxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1NjIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwM\r\n"
                " TIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1NjIzNDU2Nzg5MDEy\r\n"
                " MzQ1Njc4OTAxMg==\r\n"
                "END:VCARD\r\n");
        QTest::newRow("folding 3.0") << document << expected30b;
    }
}
Ejemplo n.º 15
0
void init_in_nested_func(int **x) {
  *x = 0; // expected-note{{Null pointer value stored to 'y'}}
  nested();
} // no-note
Ejemplo n.º 16
0
int main(void) {
    float *a = createvect(NUM),
           *b = createvect(NUM);

    // incrementing up to 20
    setvect(NUM, a, 1);
    basicIncrement(NUM, a);
    printf("0: a = ");
    printvect(NUM, a);
    printf("\n");

    // nested while loop
    setvect(NUM, a, 1);
    setvect(NUM, b, 2);
    nested(NUM, a, b);
    printf("1: a = ");
    printvect(NUM, a);
    printf("\n");
    printf("   b = ");
    printvect(NUM, b);
    printf("\n");

    // nested while loop
    setvect(NUM, a, 1);
    setvect(NUM, b, 2);
    nested2(NUM, a, b);
    printf("2: a = ");
    printvect(NUM, a);
    printf("\n");
    printf("   b = ");
    printvect(NUM, b);
    printf("\n");

    // a and b changing relative to each other
    setvect(NUM, a, 1);
    setvect(NUM, b, 2);
    relativeChange(NUM, a, b);
    printf("3: a = ");
    printvect(NUM, a);
    printf("\n");
    printf("   b = ");
    printvect(NUM, b);
    printf("\n");

    // while with an if loop inside it
    setvect(NUM, a, 1);
    setvect(NUM, b, 3);
    whileIf(NUM, a, b);
    printf("4: a = ");
    printvect(NUM, a);
    printf("\n");
    printf("   b = ");
    printvect(NUM, b);
    printf("\n");

    // if with a while loop inside it
    setvect(NUM, a, 1);
    setvect(NUM, b, 0);
    ifWhile(NUM, a, b);
    printf("5: a = ");
    printvect(NUM, a);
    printf("\n");
    printf("   b = ");
    printvect(NUM, b);
    printf("\n");

    // else in big if else statement
    setvect(NUM, a, 1);
    setvect(NUM, b, 4);
    ifWhile(NUM, a, b);
    printf("6: a = ");
    printvect(NUM, a);
    printf("\n");
    printf("   b = ");
    printvect(NUM, b);
    printf("\n");

    return 0;
}