Ignore:
Timestamp:
Mar 8, 2010, 12:52:58 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.2 sources.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    17331733                    }
    17341734                }
    1735                 if (!pendingContext.isEmpty()) {
     1735                if (!pendingContext.isEmpty()) {
    17361736                    QStringList unresolved;
    17371737                    if (!fullyQualify(namespaces, pendingContext, true, &functionContext, &unresolved)) {
  • trunk/tools/linguist/lupdate/java.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/tools/linguist/lupdate/lupdate.h

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/tools/linguist/lupdate/main.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    4444#include <translator.h>
    4545#include <profileevaluator.h>
    46 #include <proreader.h>
    4746
    4847#include <QtCore/QCoreApplication>
     
    119118        "           Disable the named merge heuristic. Can be specified multiple times.\n"
    120119        "    -pro <filename>\n"
    121         "           Name of a .pro file. Useful for files with .pro\n"
    122         "           file syntax but different file suffix\n"
     120        "           Name of a .pro file. Useful for files with .pro\n"
     121        "           \n"
    123122        "    -source-language <language>[_<region>]\n"
    124123        "           Specify the language of the source strings for new files.\n"
     
    127126        "           Specify the language of the translations for new files.\n"
    128127        "           Guessed from the file name if not specified.\n"
     128
     129
     130
     131
     132
    129133        "    -version\n"
    130134        "           Display the version of lupdate and exit.\n"
     
    215219}
    216220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
     349
     350
     351
     352
     353
     354
     355
     356
     357
     358
     359
     360
     361
     362
     363
     364
     365
     366
     367
     368
     369
     370
     371
     372
     373
     374
     375
     376
     377
     378
     379
     380
     381
     382
     383
     384
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
    217405int main(int argc, char **argv)
    218406{
     
    221409
    222410    QStringList args = app.arguments();
    223     QString defaultContext; // This was QLatin1String("@default") before.
    224     Translator fetchedTor;
    225     QByteArray codecForTr;
    226     QByteArray codecForSource;
    227411    QStringList tsFileNames;
    228412    QStringList proFiles;
     
    233417    QString targetLanguage;
    234418    QString sourceLanguage;
     419
    235420
    236421    UpdateOptions options =
     
    238423        HeuristicSameText | HeuristicSimilarText | HeuristicNumber;
    239424    int numFiles = 0;
    240     bool standardSyntax = true;
    241425    bool metTsFlag = false;
    242426    bool recursiveScan = true;
     
    244428    QString extensions = m_defaultExtensions;
    245429    QSet<QString> extensionsNameFilters;
    246 
    247     for (int  i = 1; i < argc; ++i) {
    248         if (args.at(i) == QLatin1String("-ts"))
    249             standardSyntax = false;
    250     }
    251430
    252431    for (int i = 1; i < argc; ++i) {
     
    337516            printOut(QObject::tr("lupdate version %1\n").arg(QLatin1String(QT_VERSION_STR)));
    338517            return 0;
     518
     519
     520
     521
     522
     523
     524
     525
    339526        } else if (arg == QLatin1String("-ts")) {
    340527            metTsFlag = true;
     
    373560            return 1;
    374561        }
    375 
    376         numFiles++;
    377 
    378         QString fullText;
    379 
    380         codecForTr.clear();
    381         codecForSource.clear();
    382562
    383563        if (metTsFlag) {
     
    404584                || arg.endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) {
    405585            proFiles << arg;
     586
    406587        } else {
    407588            QFileInfo fi(arg);
     
    448629                sourceFiles << QDir::cleanPath(fi.absoluteFilePath());;
    449630            }
     631
    450632        }
    451633    } // for args
    452634
    453     foreach (const QString &proFile, proFiles)
    454         projectRoots.insert(QDir::cleanPath(QFileInfo(proFile).absolutePath()) + QLatin1Char('/'));
    455 
    456     bool firstPass = true;
     635    if (numFiles == 0) {
     636        printUsage();
     637        return 1;
     638    }
     639
     640    if (!targetLanguage.isEmpty() && tsFileNames.count() != 1)
     641        std::cerr << "lupdate warning: -target-language usually only "
     642                     "makes sense with exactly one TS file.\n";
     643    if (!codecForTr.isEmpty() && tsFileNames.isEmpty())
     644        std::cerr << "lupdate warning: -codecfortr has no effect without -ts.\n";
     645
    457646    bool fail = false;
    458     while (firstPass || !proFiles.isEmpty()) {
     647    if (proFiles.isEmpty()) {
     648        if (tsFileNames.isEmpty())
     649            std::cerr << "lupdate warning: no TS files specified. "
     650                         "Only diagnostics will be produced.\n";
     651
     652        Translator fetchedTor;
    459653        ConversionData cd;
    460         cd.m_defaultContext = defaultContext;
    461654        cd.m_noUiLines = options & NoUiLines;
    462655        cd.m_projectRoots = projectRoots;
    463656        cd.m_includePath = includePath;
    464657        cd.m_allCSources = allCSources;
    465 
    466         QStringList tsFiles = tsFileNames;
    467         if (proFiles.count() > 0) {
    468             QFileInfo pfi(proFiles.takeFirst());
    469             QHash<QByteArray, QStringList> variables;
    470 
    471             ProFileEvaluator visitor;
    472             visitor.setVerbose(options & Verbose);
    473 
    474             ProFile pro(pfi.absoluteFilePath());
    475             if (!visitor.queryProFile(&pro))
    476                 return 2;
    477             if (!visitor.accept(&pro))
    478                 return 2;
    479 
    480             if (visitor.templateType() == ProFileEvaluator::TT_Subdirs) {
    481                 QDir proDir(pfi.absoluteDir());
    482                 foreach (const QString &subdir, visitor.values(QLatin1String("SUBDIRS"))) {
    483                     QString subPro = QDir::cleanPath(proDir.absoluteFilePath(subdir));
    484                     QFileInfo subInfo(subPro);
    485                     if (subInfo.isDir())
    486                         proFiles << (subPro + QLatin1Char('/')
    487                                      + subInfo.fileName() + QLatin1String(".pro"));
    488                     else
    489                         proFiles << subPro;
    490                 }
    491                 continue;
    492             }
    493 
    494             cd.m_includePath += visitor.values(QLatin1String("INCLUDEPATH"));
    495 
    496             evaluateProFile(visitor, &variables, pfi.absolutePath());
    497 
    498             sourceFiles = variables.value("SOURCES");
    499 
    500             QStringList tmp = variables.value("CODECFORTR");
    501             if (!tmp.isEmpty() && !tmp.first().isEmpty()) {
    502                 codecForTr = tmp.first().toLatin1();
    503                 fetchedTor.setCodecName(codecForTr);
    504                 cd.m_outputCodec = codecForTr;
    505             }
    506             tmp = variables.value("CODECFORSRC");
    507             if (!tmp.isEmpty() && !tmp.first().isEmpty()) {
    508                 codecForSource = tmp.first().toLatin1();
    509                 if (!QTextCodec::codecForName(codecForSource))
    510                     qWarning("lupdate warning: Codec for source '%s' is invalid. Falling back to codec for tr().",
    511                              codecForSource.constData());
    512                 else
    513                     cd.m_codecForSource = codecForSource;
    514             }
    515 
    516             tsFiles += variables.value("TRANSLATIONS");
    517         }
    518 
    519         QStringList sourceFilesCpp;
    520         for (QStringList::iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) {
    521             if (it->endsWith(QLatin1String(".java"), Qt::CaseInsensitive))
    522                 loadJava(fetchedTor, *it, cd);
    523             else if (it->endsWith(QLatin1String(".ui"), Qt::CaseInsensitive)
    524                      || it->endsWith(QLatin1String(".jui"), Qt::CaseInsensitive))
    525                 loadUI(fetchedTor, *it, cd);
    526             else if (it->endsWith(QLatin1String(".js"), Qt::CaseInsensitive)
    527                      || it->endsWith(QLatin1String(".qs"), Qt::CaseInsensitive))
    528                 loadQScript(fetchedTor, *it, cd);
    529             else
    530                 sourceFilesCpp << *it;
    531         }
    532         loadCPP(fetchedTor, sourceFilesCpp, cd);
    533         if (!cd.error().isEmpty())
    534             printOut(cd.error());
    535 
    536         tsFiles.sort();
    537         tsFiles.removeDuplicates();
    538 
    539         if (!tsFiles.isEmpty())
    540             updateTsFiles(fetchedTor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, &fail);
    541 
    542         firstPass = false;
     658        fetchedTor.setCodecName(codecForTr);
     659        processSources(fetchedTor, sourceFiles, cd);
     660        updateTsFiles(fetchedTor, tsFileNames, codecForTr,
     661                      sourceLanguage, targetLanguage, options, &fail);
     662    } else {
     663        if (!sourceFiles.isEmpty() || !includePath.isEmpty()) {
     664            qWarning("lupdate error: Both project and source files / include paths specified.\n");
     665            return 1;
     666        }
     667        if (!tsFileNames.isEmpty()) {
     668            Translator fetchedTor;
     669            fetchedTor.setCodecName(codecForTr);
     670            processProjects(true, true, proFiles, options, QByteArray(),
     671                            targetLanguage, sourceLanguage, &fetchedTor, &fail);
     672            updateTsFiles(fetchedTor, tsFileNames, codecForTr,
     673                          sourceLanguage, targetLanguage, options, &fail);
     674        } else {
     675            processProjects(true, false, proFiles, options, QByteArray(),
     676                            targetLanguage, sourceLanguage, 0, &fail);
     677        }
    543678    }
    544 
    545     if (numFiles == 0) {
    546         printUsage();
    547         return 1;
    548     }
    549 
    550679    return fail ? 1 : 0;
    551680}
  • trunk/tools/linguist/lupdate/merge.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    6161static int numberLength(const QString &s, int i)
    6262{
    63     if (i < s.size() || !s.at(i).isDigit())
     63    if (i s.size() || !s.at(i).isDigit())
    6464        return 0;
    6565
     
    8888    bool metSomething = false;
    8989
    90     for (int i = 0; i != key.size(); ++i) {
     90    for (int i = 0; i key.size(); ++i) {
    9191        int len = numberLength(key, i);
    9292        if (len > 0) {
  • trunk/tools/linguist/lupdate/qscript.cpp

    r561 r651  
    22/****************************************************************************
    33**
    4 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     4** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies).
    55** All rights reserved.
    66** Contact: Nokia Corporation ([email protected])
  • trunk/tools/linguist/lupdate/qscript.g

    r561 r651  
    11----------------------------------------------------------------------------
    22--
    3 -- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3-- Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies).
    44-- All rights reserved.
    55-- Contact: Nokia Corporation ([email protected])
  • trunk/tools/linguist/lupdate/ui.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
Note: See TracChangeset for help on using the changeset viewer.