Exemple #1
0
// while((nstr = yylook()) >= 0)
void subtest5(void)
{
	int nstr;

	bogus();
	while((nstr = yylook()) >= 0)
	{
		printf("nstr: %04x\n",nstr);
		bogus();
	}
}
Exemple #2
0
int main(int argc, char * argv[])
{
    if (argc < 3)
    {
        std::cerr << "Usage: " << argv[0] << " <font name> <font image>...\n";
        return 1;
    }

    // Average symbol information
    std::map<char, OCR::Font::Symbol> average;

    // Image
    BMP img;

    // Load a non-existent font
    OCR::Font bogus("BOGUS");

    // Open file for output
    std::string outFileName = argv[1];
    outFileName = "font/" + outFileName + ".font";
    std::ofstream outFile(outFileName.c_str());

    // Load each line and read its statistics
    for (int fileNum = 2; fileNum < argc; ++fileNum)
    {
        // Create line
        img.ReadFromFile(argv[fileNum]);
        OCR::Line line(img, bogus);

        // Create vector for symbol info
        std::vector<OCR::Font::Symbol> symbols;
        symbols.reserve(ALPHABET.size());

        // Do the reading
        line.Read(&symbols);

        // Loop through and add to the "average"
        std::vector<OCR::Font::Symbol>::iterator itr = symbols.begin();
        for (unsigned charIndex = 0; itr != symbols.end() && charIndex
                < ALPHABET .size(); ++itr, ++charIndex)
        {
            average[ALPHABET[charIndex]] += *itr;
        }
    }

    for (std::map<char, OCR::Font::Symbol>::iterator itr = average.begin(); itr
            != average.end(); ++itr)
    {
        // Divide all statistics by number of lines read
        itr->second /= (argc - 2);
        // Print the character and its statistics to the file
        outFile << itr->first << ' ' << itr->second << std::endl;
    }

    outFile.close();
    return 0;
}
Exemple #3
0
void user_q( void ) {

	write( FD_CONSOLE, "User Q running\n", 0 );
	write( FD_SIO, "Q", 1 );
	bogus();
	write( FD_SIO, "q", 1 );
	write( FD_CONSOLE, "User Q returned from bogus syscall!?!?!\n", 0 );
	exit();

}
void MessageFormatRegressionTest::Test4094906()
{
    UErrorCode status = U_ZERO_ERROR;
    UnicodeString pattern("-");
    pattern += (UChar) 0x221E;
    pattern += "<are negative|0<are no or fraction|1#is one|1<is 1+|";
    pattern += (UChar) 0x221E;
    pattern += "<are many.";

    ChoiceFormat *fmt = new ChoiceFormat(pattern, status);
    failure(status, "new ChoiceFormat");
    UnicodeString pat;
    if (fmt->toPattern(pat) != pattern) {
        errln( (UnicodeString) "Formatter Pattern : " + pat);
        errln( (UnicodeString) "Expected Pattern  : " + pattern);
    }
    FieldPosition bogus(FieldPosition::DONT_CARE);
    UnicodeString str;

    // Will this work for -inf?
    logln("Format with -INF : " + fmt->format(Formattable(-uprv_getInfinity()), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with -1.0 : " + fmt->format(Formattable(-1.0), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with -1.0 : " + fmt->format(Formattable(-1.0), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 0 : " + fmt->format(Formattable((int32_t)0), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 0.9 : " + fmt->format(Formattable(0.9), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 1.0 : " + fmt->format(Formattable(1.0), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 1.5 : " + fmt->format(Formattable(1.5), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 2 : " + fmt->format(Formattable((int32_t)2), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 2.1 : " + fmt->format(Formattable(2.1), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with NaN : " + fmt->format(Formattable(uprv_getNaN()), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with +INF : " + fmt->format(Formattable(uprv_getInfinity()), str, bogus, status));
    failure(status, "fmt->format");

    delete fmt;
}
Exemple #5
0
// yyt = yyt + yych;
void subtest2(void)
{
	register struct yywork *yyt;
	int yych;

	yyt=yycrank;
	yych=10;

	bogus();
	yyt = yyt + yych;

	printf("yyt: %d %d\n",yyt->verify,yyt->advance);
}
void MessageFormatRegressionTest::Test4106661()
{
    UErrorCode status = U_ZERO_ERROR;
    ChoiceFormat *fmt = new ChoiceFormat(
      "-1#are negative| 0#are no or fraction | 1#is one |1.0<is 1+ |2#are two |2<are more than 2.", status);
    failure(status, "new ChoiceFormat");
    UnicodeString pat;
    logln("Formatter Pattern : " + fmt->toPattern(pat));

    FieldPosition bogus(FieldPosition::DONT_CARE);
    UnicodeString str;

    // Will this work for -inf?
    logln("Format with -INF : " + fmt->format(Formattable(-uprv_getInfinity()), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with -1.0 : " + fmt->format(Formattable(-1.0), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with -1.0 : " + fmt->format(Formattable(-1.0), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 0 : " + fmt->format(Formattable((int32_t)0), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 0.9 : " + fmt->format(Formattable(0.9), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 1.0 : " + fmt->format(Formattable(1.0), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 1.5 : " + fmt->format(Formattable(1.5), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 2 : " + fmt->format(Formattable((int32_t)2), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with 2.1 : " + fmt->format(Formattable(2.1), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with NaN : " + fmt->format(Formattable(uprv_getNaN()), str, bogus, status));
    failure(status, "fmt->format");
    str.remove();
    logln("Format with +INF : " + fmt->format(Formattable(uprv_getInfinity()), str, bogus, status));
    failure(status, "fmt->format");

    delete fmt;
}
Exemple #7
0
// yyps -= yyr2[yyn];
void subtest4(void)
{
	register short *yyps, yyn;

	yyps=0x8004;
	yyn=0;

	while(yyn<14)
	{
		bogus();
		yyps -= yyr2[yyn];

		yyn++;
	}
	printf("yyps: %04x\n",yyps);
}
Exemple #8
0
// if(yyt <= yytop && yyt->verify+yysvec == yystate)
void subtest3(void)
{
	register struct yywork *yyt;
	register struct yysvf *yystate;

	yyt=yycrank;
	yystate=yysvec;
	
	bogus();
	if(yyt <= yytop && yyt->verify+yysvec == yystate)
	{
		printf("if ok %d %d\n",yyt->verify,yyt->advance);
	}
	else
	{
		printf("if not ok %d %d\n",yyt->verify,yyt->advance);
	}
}
void tst_QSocketNotifier::bogusFds()
{
#ifndef Q_OS_SYMBIAN
    //behaviour of QSocketNotifier with an invalid fd is totally different across OS
    //main point of this test was to check symbian backend doesn't crash
    QSKIP("test only for symbian", SkipAll);
#else
    QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error");
    QSocketNotifier max(std::numeric_limits<int>::max(), QSocketNotifier::Read);
    QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Invalid socket specified");
    QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error");
    QSocketNotifier min(std::numeric_limits<int>::min(), QSocketNotifier::Write);
    QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error");
    //bogus magic number is the first pseudo socket descriptor from symbian socket engine.
    QSocketNotifier bogus(0x40000000, QSocketNotifier::Exception);
    QSocketNotifier largestlegal(FD_SETSIZE - 1, QSocketNotifier::Read);

    QSignalSpy maxspy(&max, SIGNAL(activated(int)));
    QSignalSpy minspy(&min, SIGNAL(activated(int)));
    QSignalSpy bogspy(&bogus, SIGNAL(activated(int)));
    QSignalSpy llspy(&largestlegal, SIGNAL(activated(int)));

    //generate some unrelated socket activity
    QTcpServer server;
    QVERIFY(server.listen(QHostAddress::LocalHost));
    connect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
    QTcpSocket client;
    client.connectToHost(QHostAddress::LocalHost, server.serverPort());
    QTestEventLoop::instance().enterLoop(5);
    QVERIFY(server.hasPendingConnections());

    //check no activity on bogus notifiers
    QCOMPARE(maxspy.count(), 0);
    QCOMPARE(minspy.count(), 0);
    QCOMPARE(bogspy.count(), 0);
    QCOMPARE(llspy.count(), 0);
#endif
}
void MessageFormatRegressionTest::Test4105380()
{
    UnicodeString patternText1("The disk \"{1}\" contains {0}.");
    UnicodeString patternText2("There are {0} on the disk \"{1}\"");
    UErrorCode status = U_ZERO_ERROR;
    const UBool possibleDataError = TRUE;
    MessageFormat *form1 = new MessageFormat(patternText1, status);
    failure(status, "new MessageFormat");
    MessageFormat *form2 = new MessageFormat(patternText2, status);
    failure(status, "new MessageFormat");
    double filelimits [] = {0,1,2};
    UnicodeString filepart [] = {
        (UnicodeString)"no files",
            (UnicodeString)"one file",
            (UnicodeString)"{0,number} files"
    };
    ChoiceFormat *fileform = new ChoiceFormat(filelimits, filepart, 3);
    form1->setFormat(1, *fileform);
    form2->setFormat(0, *fileform);
    //Object[] testArgs = {new Long(12373), "MyDisk"};
    Formattable testArgs [] = {
        Formattable((int32_t)12373), 
            Formattable((UnicodeString)"MyDisk")
    };
    
    FieldPosition bogus(FieldPosition::DONT_CARE);

    UnicodeString result;
    logln(form1->format(testArgs, 2, result, bogus, status));
    failure(status, "form1->format", possibleDataError);
    result.remove();
    logln(form2->format(testArgs, 2, result, bogus, status));
    failure(status, "form1->format", possibleDataError);

    delete form1;
    delete form2;
    delete fileform;
}
Exemple #11
0
// PR c++/54020
// { dg-do compile { target c++11 } }

// Preliminaries.
extern int nonconst_func(int);
constexpr int identity(int x) { return x; }
constexpr int zero() { return identity(0); }
constexpr int one() { return identity(1); }

// Correctly accepted.
constexpr int three = one() ? 3 : nonconst_func(0);

// Incorrectly accepted.  See [dcl.constexpr] #5:
//   For a constexpr function, if no function argument values exist
//   such that the function invocation sub-stitution would produce a
//   constant expression (5.19), the program is ill-formed; no diagnostic
//   required.
constexpr int bogus() { return zero () ? 3 : nonconst_func(0); } // { dg-error "nonconst_func" }

// Correctly rejected (not sure why).
constexpr int correct_error() { return nonconst_func(0); } // { dg-error "nonconst_func" }

// Correctly rejected.
constexpr int z = bogus();	// { dg-error "" }

// This is also correctly rejected.
constexpr int correct_failure() { return 0 ? 3 : nonconst_func(0); } // { dg-error "nonconst_func" }
Exemple #12
0
void QGIPiece::propertySet( char const *pname, QVariant const & var )
{
    // FIXME: treat QVariant::Invalid appropriately for each property
    typedef QMap<QString,int> PMAP;
    static PMAP pmap;
    if( pmap.isEmpty() )
    {
#define MAP(S,V) pmap[S] = Impl::V;
	MAP("color",PropColor);
	MAP("alpha",PropAlpha);
	MAP("colorAlpha",PropAlpha); // older name
	MAP("borderColor",PropBorderColor);
	MAP("borderSize",PropBorderSize);
	MAP("borderAlpha",PropBorderAlpha);
	MAP("borderStyle",PropBorderStyle);
	MAP("zLevel",PropZLevel);
	MAP("pos",PropPos);
	MAP("scale",PropScale);
	MAP("size",PropSize);
	MAP("angle",PropAngle);
	MAP("dragDisabled",PropDragDisabled);
	MAP("pixmap",PropPixmap);
#undef MAP
    }

    const QString key(pname?pname:"");
    int kid = pmap.value( key, Impl::PropUnknown );
    if( Impl::PropUnknown == kid ) return;
    if(0) qDebug() << "QGIPiece::propertySet("<<key<<")] val ="<<var;
    if( Impl::PropZLevel == kid )
    {
	this->setZValue(var.toDouble());
	this->update();
    }
    else if( Impl::PropPos == kid )
    {
	this->setPos( var.value<QPointF>() );
	this->update();
    }
    else if( Impl::PropColor == kid )
    {
 	QColor col = var.value<QColor>();
	qreal alpha = impl->pen.color().alphaF();
 	if( 255 == col.alpha() ) // keep original alpha level
 	{
	    if( alpha > 1 )
	    {
		col.setAlpha( int(alpha) );
	    }
	    else
	    {
		col.setAlphaF( alpha );
	    }
 	}
	impl->pen.setColor( col );
	if(0) qDebug() << "QGIPiece::propertySet(color):"<<impl->pen.color()<<" alpha ="<<impl->alpha;
	impl->clearCache();
	this->update();
    }
    else if( Impl::PropAlpha == kid )
    {
	qreal a = var.toDouble();
	QColor col = impl->pen.color();
	if( a > 1.0 )
	{ // assume it's int-encoded
	    col.setAlpha( int(a) );
	}
	else
	{
	    col.setAlphaF( a );
	}
	impl->pen.setColor( col );
	impl->clearCache();
    	this->update();
    }
    else if( Impl::PropBorderColor == kid )
    {
	QColor col = var.value<QColor>();
 	if( 255 == col.alpha() )
 	{
	    col.setAlphaF( impl->penB.color().alphaF() );
 	}
	impl->penB.setColor( col );
	impl->clearCache();
	this->update();
    }
    else if( Impl::PropBorderAlpha == kid )
    {
	qreal a = var.toDouble();
	QColor col( impl->penB.color() );
	if( a > 1.0 )
	{ // assume it's int-encoded
	    col.setAlpha( int(a) );
	}
	else
	{
	    col.setAlphaF( a );
	}
	impl->penB.setColor( col );
	impl->clearCache();
	this->update();
    }
    else if( Impl::PropBorderSize == kid )
    {
	double bs = var.toDouble();
	impl->penB.setWidth( (bs >= 0) ? bs : 0 );
	impl->clearCache();
	this->update();
    }
    else if( Impl::PropBorderStyle == kid )
    {
	impl->clearCache();
	impl->penB.setStyle( s11n::qt::stringToPenStyle(var.toString()) );
	this->update();
    }
    else if( (Impl::PropScale == kid) || (Impl::PropAngle == kid) )
    {
	this->refreshTransformation();
    }
    else if( Impl::PropDragDisabled == kid )
    {
	if( var.isValid() )
	{
	    this->setFlag( QGraphicsItem::ItemIsMovable, var.toInt() ? false : true );
	}
	else
	{
	    this->setFlag( QGraphicsItem::ItemIsMovable, true );
	}
    }
    else if( Impl::PropPixmap == kid )
    {
	this->prepareGeometryChange();
	impl->clearCache();
	QPixmap pix;
	if( var.canConvert<QPixmap>() )
	{
	    pix = var.value<QPixmap>();
	}
	else if( var.canConvert<QString>() )
	{
	    QString fname( qboard::homeRelative(var.toString()) );
	    if( pix.load( fname ) )
	    {
		this->setProperty("size",pix.size());
	    }
	    else
	    {
		pix = QPixmap(300,40);
		QPainter pain(&pix);
		pain.fillRect( pix.rect(), Qt::yellow );
		QFont font( "courier", 8 );
		pain.setFont( font ); 
		pain.setPen( QPen(Qt::red) );
		pain.drawText(5,font.pointSize()+6,"Error loading pixmap:");
		pain.drawText(5,pix.height()-6,fname);
	    }
	} // var.canConvert<QString>()
	this->impl->pixmap = pix;
	if(1)
	{
	    // Kludge to ensure that this type's shape is properly set. We don't want
	    // the parent class to have the real pixmap, so that we can control all
	    // painting ourselves.
	    QPixmap bogus( pix.size() );
	    bogus.fill( QColor(Qt::transparent) );
	    this->setPixmap(bogus);
	}
	this->update();
    } // pixmap property
    if( Impl::PropSize == kid )
    {
	impl->clearCache();
	if( impl->pixmap.isNull() )
	{
	    QPixmap bogus( var.toSize() );
	    bogus.fill( QColor(Qt::transparent) );
	    impl->pixmap = bogus;
	    // Kludge to ensure bounding rect is kept intact
	    this->setPixmap(bogus);
	}
    }
}