Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/linguist/lupdate/java.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5151#include <QtCore/QString>
    5252#include <QtCore/QTextCodec>
     53#include <QtCore/QCoreApplication>
     54
     55#include <iostream>
    5356
    5457#include <ctype.h>
    5558
    5659QT_BEGIN_NAMESPACE
     60
     61class LU {
     62    Q_DECLARE_TR_FUNCTIONS(LUpdate)
     63};
    5764
    5865enum { Tok_Eof, Tok_class, Tok_return, Tok_tr,
     
    107114static QStack<Scope*> yyScope;
    108115static QString yyDefaultContext;
     116
     117std::ostream &yyMsg(int line = 0)
     118{
     119    return std::cerr << qPrintable(yyFileName) << ':' << (line ? line : yyLineNo) << ": ";
     120}
    109121
    110122static QChar getChar()
     
    190202                        yyCh = getChar();
    191203                        if ( yyCh == EOF ) {
    192                             qFatal( "%s: Unterminated Java comment starting at"
    193                                     " line %d\n",
    194                                     qPrintable(yyFileName), yyLineNo );
    195 
     204                            yyMsg() << qPrintable(LU::tr("Unterminated Java comment.\n"));
    196205                            return Tok_Comment;
    197206                        }
     
    229238                                    int sub(yyCh.toLower().toAscii() - 87);
    230239                                    if( sub > 15 || sub < 10) {
    231                                         qFatal( "%s:%d: Invalid Unicode",
    232                                             qPrintable(yyFileName), yyLineNo );
     240                                        yyMsg() << qPrintable(LU::tr("Invalid Unicode value.\n"));
     241                                        break;
    233242                                    }
    234243                                    unicode += sub;
     
    252261
    253262                if ( yyCh != QLatin1Char('"') )
    254                     qFatal( "%s:%d: Unterminated string",
    255                         qPrintable(yyFileName), yyLineNo );
     263                    yyMsg() << qPrintable(LU::tr("Unterminated string.\n"));
    256264
    257265                yyCh = getChar();
     
    366374            s += yyString;
    367375        else {
    368             qWarning( "%s:%d: String used in translation can only contain strings"
    369                 " concatenated with other strings, not expressions or numbers.",
    370                 qPrintable(yyFileName), yyLineNo );
     376            yyMsg() << qPrintable(LU::tr(
     377                "String used in translation can contain only literals"
     378                " concatenated with other literals, not expressions or numbers.\n"));
    371379            return false;
    372380        }
     
    476484            }
    477485            else {
    478                 qFatal( "%s:%d: Class must be followed by a classname",
    479                                           qPrintable(yyFileName), yyLineNo );
     486                yyMsg() << qPrintable(LU::tr("'class' must be followed by a class name.\n"));
     487                break;
    480488            }
    481489            while (!match(Tok_LeftBrace)) {
     
    548556        case Tok_RightBrace:
    549557            if ( yyScope.isEmpty() ) {
    550                 qFatal( "%s:%d: Unbalanced right brace in Java code\n",
    551                         qPrintable(yyFileName), yyLineNo );
     558                yyMsg() << qPrintable(LU::tr("Excess closing brace.\n"));
    552559            }
    553560            else
     
    578585                        break;
    579586                    default:
    580                          qFatal( "%s:%d: Package keyword should be followed by com.package.name;",
    581                                           qPrintable(yyFileName), yyLineNo );
     587                         yyMsg() << qPrintable(LU::tr("'package' must be followed by package name.\n"));
    582588                         break;
    583589                }
     
    592598
    593599    if ( !yyScope.isEmpty() )
    594         qFatal( "%s:%d: Unbalanced braces in Java code\n",
    595                  qPrintable(yyFileName), yyScope.top()->line );
     600        yyMsg(yyScope.top()->line) << qPrintable(LU::tr("Unbalanced opening brace.\n"));
    596601    else if ( yyParenDepth != 0 )
    597         qFatal( "%s:%d: Unbalanced parentheses in Java code\n",
    598                  qPrintable(yyFileName), yyParenLineNo );
     602        yyMsg(yyParenLineNo) << qPrintable(LU::tr("Unbalanced opening parenthesis.\n"));
    599603}
    600604
     
    604608    QFile file(filename);
    605609    if (!file.open(QIODevice::ReadOnly)) {
    606         cd.appendError(QString::fromLatin1("Cannot open %1: %2")
    607             .arg(filename, file.errorString()));
     610        cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
    608611        return false;
    609612    }
Note: See TracChangeset for help on using the changeset viewer.