summaryrefslogtreecommitdiff
path: root/l10ntools/source/gsicheck.cxx
blob: 3a4c0af5d7ec95156729c6571a3507529f8c5f41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#include "sal/config.h"

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <fstream>
#include <string>

#include <stdio.h>

#include <rtl/strbuf.hxx>
#include "sal/main.h"
#include "helper.hxx"
#include "tagtest.hxx"
#include "gsicheck.hxx"

/*****************************************************************************/
void PrintMessage( rtl::OString const & aType, rtl::OString const & aMsg, rtl::OString const & aPrefix,
                   rtl::OString const & aContext, sal_Bool bPrintContext, std::size_t nLine, rtl::OString aUniqueId )
/*****************************************************************************/
{
    fprintf( stdout, "%s %s, Line %u", aType.getStr(), aPrefix.getStr(), static_cast<unsigned>( nLine ) );
    if ( !aUniqueId.isEmpty() )
        fprintf( stdout, ", UniqueID %s", aUniqueId.getStr() );
    fprintf( stdout, ": %s", aMsg.getStr() );

    if ( bPrintContext )
        fprintf( stdout, "  \"%s\"", aContext.getStr() );
    fprintf( stdout, "\n" );
}

/*****************************************************************************/
void PrintError( rtl::OString const & aMsg, rtl::OString const & aPrefix,
                 rtl::OString const & aContext, sal_Bool bPrintContext, std::size_t nLine, rtl::OString const & aUniqueId )
/*****************************************************************************/
{
    PrintMessage( "Error:", aMsg, aPrefix, aContext, bPrintContext, nLine, aUniqueId );
}

bool LanguageOK( rtl::OString const & aLang )
{
    sal_Int32 n = 0;
    rtl::OString t0(aLang.getToken(0, '-', n));
    if (n == -1) {
        return !t0.isEmpty()
            && (helper::isAllAsciiDigits(t0)
                || helper::isAllAsciiLowerCase(t0));
    }
    rtl::OString t1(aLang.getToken(0, '-', n));
    return n == -1
        && !t0.isEmpty() && helper::isAllAsciiLowerCase(t0)
        && !t1.isEmpty() && helper::isAllAsciiUpperCase(t1)
        && !t0.equalsIgnoreAsciiCase(t1);
}

void LazyStream::LazyOpen()
{
    if ( !bOpened )
    {
        open(aFileName.getStr(), std::ios_base::out | std::ios_base::trunc);
        if (!is_open())
        {
            fprintf( stderr, "\nERROR: Could not open Output-File %s!\n\n",
                     aFileName.getStr() );
            exit ( 4 );
        }
        bOpened = true;
    }
}


//
// class GSILine
//

/*****************************************************************************/
GSILine::GSILine( const rtl::OString &rLine, std::size_t nLine )
/*****************************************************************************/
                : nLineNumber( nLine )
                , bOK( sal_True )
                , bFixed ( sal_False )
                , data_( rLine )
{
    if (rLine.isEmpty()) {
        NotOK();
        return;
    }

    aFormat = FORMAT_SDF;
    sal_Int32 n = 0;
    aUniqId = rLine.getToken(0, '\t', n); // token 0
    aUniqId += "/";
    aUniqId += rLine.getToken(0, '\t', n); // token 1
    aUniqId += "/";
    aUniqId += rLine.getToken(1, '\t', n); // token 3
    aUniqId += "/";
    rtl::OString gid(rLine.getToken(0, '\t', n)); // token 4
    aUniqId += gid;
    aUniqId += "/";
    rtl::OString lid(rLine.getToken(0, '\t', n)); // token 5
    aUniqId += lid;
    aUniqId += "/";
    aUniqId += rLine.getToken(0, '\t', n); // token 6
    aUniqId += "/";
    aUniqId += rLine.getToken(0, '\t', n); // token 7
    rtl::OString length(rLine.getToken(0, '\t', n)); // token 8
    aLineType = rtl::OString();
    aLangId = rLine.getToken(0, '\t', n); // token 9
    aText = rLine.getToken(0, '\t', n); // token 10
    aQuickHelpText = rLine.getToken(1, '\t', n); // token 12
    aTitle = rLine.getToken(0, '\t', n); // token 13
    if (n == -1) {
        NotOK();
        return;
    }
    rLine.getToken(0, '\t', n); // token 14
    if (n != -1) {
        NotOK();
        return;
    }

    // do some more format checks here
    if (!helper::isAllAsciiDigits(length)) {
        PrintError(
            "The length field does not contain a number!", "Line format",
            length, true, GetLineNumber(), GetUniqId());
        NotOK();
    }
    if (!LanguageOK(aLangId)) {
        PrintError(
            "The Language is invalid!", "Line format", aLangId, true,
            GetLineNumber(), GetUniqId());
        NotOK();
    }
    // Limit GID and LID to MAX_GID_LID_LEN chars each for database conformity,
    // see #137575#:
    if (gid.getLength() > MAX_GID_LID_LEN || lid.getLength() > MAX_GID_LID_LEN)
    {
        PrintError(
            (rtl::OString(
                RTL_CONSTASCII_STRINGPARAM("GID and LID may only be "))
             + rtl::OString::valueOf(MAX_GID_LID_LEN)
             + rtl::OString(RTL_CONSTASCII_STRINGPARAM(" chars long each"))),
            "Line format", aLangId, true, GetLineNumber(), GetUniqId());
        NotOK();
    }
}

/*****************************************************************************/
void GSILine::NotOK()
/*****************************************************************************/
{
    bOK = sal_False;
}

/*****************************************************************************/
void GSILine::ReassembleLine()
/*****************************************************************************/
{
    if (GetLineFormat() != FORMAT_SDF) {
        PrintError(
            "Cannot reassemble line of unknown type (internal Error).",
            "Line format", rtl::OString(), false, GetLineNumber(),
            GetUniqId());
        return;
    }
    rtl::OStringBuffer b;
    sal_Int32 n = 0;
    for (sal_Int32 i = 0; i != 10; ++i) {
        b.append(data_.getToken(0, '\t', n)); // token 0--9
        b.append('\t');
    }
    b.append(aText);
    b.append('\t');
    b.append(data_.getToken(1, '\t', n));
        // token 11; should be empty but there are some places in sc not
        // reflected to sources
    b.append('\t');
    b.append(aQuickHelpText);
    b.append('\t');
    b.append(aTitle);
    b.append('\t');
    b.append(data_.getToken(2, '\t', n)); // token 14
    data_ = b.makeStringAndClear();
}

//
// class GSIBlock
//
/*****************************************************************************/
GSIBlock::GSIBlock( sal_Bool PbPrintContext, sal_Bool bSource, sal_Bool bTrans, sal_Bool bRef, sal_Bool bAllowSusp )
/*****************************************************************************/
            : pSourceLine( NULL )
            , pReferenceLine( NULL )
            , bPrintContext( PbPrintContext )
            , bCheckSourceLang( bSource )
            , bCheckTranslationLang( bTrans )
            , bReference( bRef )
            , bAllowSuspicious( bAllowSusp )
            , bHasBlockError( sal_False )
{
}

/*****************************************************************************/
GSIBlock::~GSIBlock()
/*****************************************************************************/
{
    delete pSourceLine;
    delete pReferenceLine;

    for ( size_t i = 0, n = maList.size(); i < n; ++i )
        delete maList[ i ];
    maList.clear();
}

void GSIBlock::InsertLine( GSILine* pLine, const rtl::OString &rSourceLang)
{
    if ( pLine->GetLanguageId() == rSourceLang )
    {
        if ( pSourceLine )
        {
            PrintError( "Source Language entry double. Treating as Translation.", "File format", "", pLine->GetLineNumber(), pLine->GetUniqId() );
            bHasBlockError = sal_True;
            pSourceLine->NotOK();
            pLine->NotOK();
        }
        else
        {
            pSourceLine = pLine;
            return;
        }
    }

    if (!rSourceLang.isEmpty()) // only check blockstructure if source lang is given
    {
        for ( size_t nPos = 0, n = maList.size(); nPos < n; ++nPos )
        {
            if ( maList[ nPos ]->GetLanguageId() == pLine->GetLanguageId() )
            {
                PrintError( "Translation Language entry double. Checking both.", "File format", "", pLine->GetLineNumber(), pLine->GetUniqId() );
                bHasBlockError = sal_True;
                maList[ nPos ]->NotOK();
                pLine->NotOK();
            }
            nPos++;
        }
    }
    maList.push_back( pLine );
}

/*****************************************************************************/
void GSIBlock::SetReferenceLine( GSILine* pLine )
/*****************************************************************************/
{
    pReferenceLine = pLine;
}

/*****************************************************************************/
void GSIBlock::PrintMessage( rtl::OString const & aType, rtl::OString const & aMsg, rtl::OString const & aPrefix,
                             rtl::OString const & aContext, std::size_t nLine, rtl::OString const & aUniqueId )
/*****************************************************************************/
{
    ::PrintMessage( aType, aMsg, aPrefix, aContext, bPrintContext, nLine, aUniqueId );
}

/*****************************************************************************/
void GSIBlock::PrintError( rtl::OString const & aMsg, rtl::OString const & aPrefix,
                           rtl::OString const & aContext, std::size_t nLine, rtl::OString const & aUniqueId )
/*****************************************************************************/
{
    PrintMessage( "Error:", aMsg, aPrefix, aContext, nLine, aUniqueId );
}

/*****************************************************************************/
void GSIBlock::PrintList( ParserMessageList *pList, rtl::OString const & aPrefix,
    GSILine *pLine )
/*****************************************************************************/
{
    for ( size_t i = 0 ; i < pList->size() ; i++ )
    {
        ParserMessage *pMsg = (*pList)[ i ];
        rtl::OString aContext;
        if ( bPrintContext )
        {
            if ( pMsg->GetTagBegin() == -1 )
                aContext = pLine->GetText().copy( 0, 300 );
            else
                aContext = helper::abbreviate( pLine->data_, pMsg->GetTagBegin()-150, 300 );
            aContext = aContext.trim();
        }

        PrintMessage( pMsg->Prefix(), pMsg->GetErrorText(), aPrefix, aContext, pLine->GetLineNumber(), pLine->GetUniqId() );
    }
}

/*****************************************************************************/
sal_Bool GSIBlock::IsUTF8( const rtl::OString &aTestee, sal_Bool bFixTags, sal_Int32 &nErrorPos, rtl::OString &aErrorMsg, sal_Bool &bHasBeenFixed, rtl::OString &aFixed ) const
/*****************************************************************************/
{
    rtl::OUString aUTF8Tester(
        rtl::OStringToOUString(aTestee, RTL_TEXTENCODING_UTF8));
    rtl::OString aTestee2(
        rtl::OUStringToOString(aUTF8Tester, RTL_TEXTENCODING_UTF8));
    sal_Int32 i = 0;
    while (i != std::min(aTestee.getLength(), aTestee2.getLength())
           && aTestee[i] == aTestee2[i])
    {
        ++i;
    }
    if (i != aTestee.getLength() || i != aTestee2.getLength())
    {
        aUTF8Tester = rtl::OUString(aTestee.getStr(), i, RTL_TEXTENCODING_UTF8);
        nErrorPos = aUTF8Tester.getLength();
        aErrorMsg = "UTF8 Encoding seems to be broken";
        return sal_False;
    }

    nErrorPos = helper::indexOfAnyAsciiL(
        aUTF8Tester,
        RTL_CONSTASCII_STRINGPARAM(
            "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0b\x0c\x0e\x0f\x10\x11\x12"
            "\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f"));
    if (nErrorPos != -1)
    {
        aErrorMsg = "String contains illegal character";
        return sal_False;
    }

    if ( bFixTags )
    {
        bHasBeenFixed = sal_False;
        aFixed = rtl::OString();
    }

    return sal_True;
}

/*****************************************************************************/
sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags )
/*****************************************************************************/
{
    sal_Int32 nErrorPos = 0;
    rtl::OString aErrorMsg;
    sal_Bool bError = sal_False;
    rtl::OString aFixed;
    sal_Bool bHasBeenFixed = sal_False;
    if ( !IsUTF8( pTestee->GetText(), bFixTags, nErrorPos, aErrorMsg, bHasBeenFixed, aFixed ) )
    {
        rtl::OString aContext(copyUpTo(pTestee->GetText(), nErrorPos, 20));
        PrintError(rtl::OStringBuffer(aErrorMsg).append(RTL_CONSTASCII_STRINGPARAM(" in Text at Position "))
             .append(nErrorPos).getStr(),
            "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
        bError = sal_True;
        if ( bHasBeenFixed )
        {
            pTestee->SetText( aFixed );
            pTestee->SetFixed();
        }
    }
    if ( !IsUTF8( pTestee->GetQuickHelpText(), bFixTags, nErrorPos, aErrorMsg, bHasBeenFixed, aFixed ) )
    {
        rtl::OString aContext(
            copyUpTo(pTestee->GetQuickHelpText(), nErrorPos, 20));
        PrintError(rtl::OStringBuffer(aErrorMsg).append(RTL_CONSTASCII_STRINGPARAM(" in QuickHelpText at Position "))
             .append(nErrorPos).getStr(),
            "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
        bError = sal_True;
        if ( bHasBeenFixed )
        {
            pTestee->SetQuickHelpText( aFixed );
            pTestee->SetFixed();
        }
    }
    if ( !IsUTF8( pTestee->GetTitle(), bFixTags, nErrorPos, aErrorMsg, bHasBeenFixed, aFixed ) )
    {
        rtl::OString aContext( pTestee->GetTitle().copy( nErrorPos, 20 ) );
        PrintError(rtl::OStringBuffer(aErrorMsg).append(RTL_CONSTASCII_STRINGPARAM(" in Title at Position "))
             .append(nErrorPos).getStr(),
            "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
        bError = sal_True;
        if ( bHasBeenFixed )
        {
            pTestee->SetTitle( aFixed );
            pTestee->SetFixed();
        }
    }
    if ( bError )
        pTestee->NotOK();
    return !bError;
}


/*****************************************************************************/
sal_Bool GSIBlock::HasSuspiciousChars( GSILine* pTestee, GSILine* pSource )
/*****************************************************************************/
{
    sal_Int32 nPos = 0;
    if ( !bAllowSuspicious && ( nPos = pTestee->GetText().indexOf("??")) != -1 )
        if ( pSource->GetText().indexOf("??") == -1 )
        {
            rtl::OUString aUTF8Tester(
                rtl::OStringToOUString(
                    pTestee->GetText().copy(0, nPos), RTL_TEXTENCODING_UTF8));
            sal_Int32 nErrorPos = aUTF8Tester.getLength();
            rtl::OString aContext( helper::abbreviate( pTestee->GetText(), nPos, 20 ) );
            PrintError(rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM("Found double questionmark in translation only. Looks like an encoding problem at Position "))
                 .append(nErrorPos).getStr(),
                "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
            pTestee->NotOK();
            return sal_True;
        }

    return sal_False;
}


/*****************************************************************************/
sal_Bool GSIBlock::CheckSyntax( std::size_t nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags )
/*****************************************************************************/
{
    static LingTest aTester;
    sal_Bool bHasError = sal_False;

    if ( !pSourceLine )
    {
        if ( bRequireSourceLine )
        {
            PrintError( "No source language entry defined!", "File format", "", nLine );
            bHasBlockError = sal_True;
        }
    }
    else
    {
        aTester.CheckReference( pSourceLine );
        if ( pSourceLine->HasMessages() )
        {
            PrintList( pSourceLine->GetMessageList(), "ReferenceString", pSourceLine );
            pSourceLine->NotOK();
            bHasError = sal_True;
        }
    }
    if ( bReference )
    {
        if ( !pReferenceLine )
        {
            GSILine *pSource;
            if ( pSourceLine )
                pSource = pSourceLine;
            else
                pSource = maList.empty() ? NULL : maList[ 0 ];   // get some other line
            if ( pSource )
                PrintError( "No reference line found. Entry is new in source file", "File format", "", pSource->GetLineNumber(), pSource->GetUniqId() );
            else
                PrintError( "No reference line found. Entry is new in source file", "File format", "", nLine );
            bHasBlockError = sal_True;
        }
        else
        {
            if ( pSourceLine && pSourceLine->data_ != pReferenceLine->data_ )
            {
                sal_Int32 nPos = pSourceLine->data_.indexOf( pReferenceLine->data_ );
                rtl::OStringBuffer aContext( pReferenceLine->data_.copy( nPos - 5, 15) );
                aContext.append( "\" --> \"" ).append( pSourceLine->data_.copy( nPos - 5, 15) );
                PrintError( "Source Language Entry has changed.", "File format", aContext.makeStringAndClear(), pSourceLine->GetLineNumber(), pSourceLine->GetUniqId() );
                pSourceLine->NotOK();
                bHasError = sal_True;
            }
        }
    }

    if ( pSourceLine )
        bHasError |= !TestUTF8( pSourceLine, bFixTags );

    for ( size_t i = 0, n = maList.size(); i < n; ++i )
    {
        GSILine* pItem = maList[ i ];
        aTester.CheckTestee( pItem, pSourceLine != NULL, bFixTags );
        if ( pItem->HasMessages() || aTester.HasCompareWarnings() )
        {
            if ( pItem->HasMessages() || aTester.GetCompareWarnings().HasErrors() )
                pItem->NotOK();
            bHasError = sal_True;
            PrintList( pItem->GetMessageList(), "Translation", pItem );
            PrintList( &(aTester.GetCompareWarnings()), "Translation Tag Mismatch", pItem );
        }
        bHasError |= !TestUTF8( pItem, bFixTags );
        if ( pSourceLine )
            bHasError |= HasSuspiciousChars( pItem, pSourceLine );
    }

    return bHasError || bHasBlockError;
}

void GSIBlock::WriteError( LazyStream &aErrOut, sal_Bool bRequireSourceLine  )
{
    if ( pSourceLine && pSourceLine->IsOK() && bCheckSourceLang && !bHasBlockError )
        return;

    sal_Bool bHasError = sal_False;
    sal_Bool bCopyAll = ( !pSourceLine && bRequireSourceLine ) || ( pSourceLine && !pSourceLine->IsOK() && !bCheckTranslationLang ) || bHasBlockError;
    for ( size_t i = 0, n = maList.size(); i < n; ++i )
    {
        GSILine* pItem = maList[ i ];
        if ( !pItem->IsOK() || bCopyAll )
        {
            bHasError = sal_True;
            aErrOut.LazyOpen();
            aErrOut << pItem->data_.getStr() << '\n';
        }
    }

    if ( pSourceLine && ( bHasError || !pSourceLine->IsOK() ) && !( !bHasError && bCheckTranslationLang ) )
    {
        aErrOut.LazyOpen();
        aErrOut << pSourceLine->data_.getStr() << '\n';
    }
}

void GSIBlock::WriteCorrect( LazyStream &aOkOut, sal_Bool bRequireSourceLine )
{
    if ( ( !pSourceLine && bRequireSourceLine ) || ( pSourceLine && !pSourceLine->IsOK() && !bCheckTranslationLang ) )
        return;

    sal_Bool bHasOK = sal_False;
    for ( size_t i = 0, n = maList.size(); i < n; ++i )
    {
        GSILine* pItem = maList[ i ];
        if ( ( pItem->IsOK() || bCheckSourceLang ) && !bHasBlockError )
        {
            bHasOK = sal_True;
            aOkOut.LazyOpen();
            aOkOut << pItem->data_.getStr() << '\n';
        }
    }

    if ( ( pSourceLine && pSourceLine->IsOK() && ( !maList.empty() || !bCheckTranslationLang ) ) || ( bHasOK && bCheckTranslationLang ) )
    {
        aOkOut.LazyOpen();
        aOkOut << pSourceLine->data_.getStr() << '\n';
    }
}

void GSIBlock::WriteFixed( LazyStream &aFixOut )
{
    if ( pSourceLine && !pSourceLine->IsFixed() && bCheckSourceLang )
        return;

    sal_Bool bHasFixes = sal_False;
    for ( size_t i = 0, n = maList.size(); i < n; ++i )
    {
        GSILine* pItem = maList[ i ];
        if ( pItem->IsFixed() )
        {
            bHasFixes = sal_True;
            aFixOut.LazyOpen();
            aFixOut << pItem->data_.getStr() << '\n';
        }
    }

    if ( pSourceLine && ( bHasFixes || pSourceLine->IsFixed() ) )
    {
        aFixOut.LazyOpen();
        aFixOut << pSourceLine->data_.getStr() << '\n';
    }
}

sal_Bool check(rtl::OString s, std::size_t nLine)
{
    sal_Bool bFileHasError = sal_False;
    GSILine* pGSILine = NULL;
    GSIBlock *pBlock = NULL;
    pGSILine = new GSILine(s, nLine );

    if ( !pGSILine->data_.isEmpty() )
    {
        if ( FORMAT_UNKNOWN == pGSILine->GetLineFormat() )
        {
            PrintError( "Format of line is unknown. Ignoring!", "Line format", pGSILine->data_.copy( 0,40 ), sal_True, pGSILine->GetLineNumber() );
            bFileHasError = sal_True;
            pGSILine->NotOK();
        }
        else if ( !(pGSILine->GetLineType().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("res-comment"))) )
        {
            pBlock = new GSIBlock( sal_True, sal_False, sal_False, sal_False, sal_False );
            pBlock->InsertLine( pGSILine, rtl::OString() );
            bFileHasError |= pBlock->CheckSyntax( nLine, sal_False, sal_False );
            if (pBlock!=NULL)
            {
                delete pBlock;
                pBlock=NULL;
                pGSILine=NULL;
            }
        }
    }
    delete pGSILine;
    if ( bFileHasError )
        return false;
    else
        return true;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */