LCOV - code coverage report
Current view: top level - i18npool/source/textconversion - genconv_dict.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 252 267 94.4 %
Date: 2015-06-13 12:38:46 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <stdio.h>
      22             : #include <string.h>
      23             : #include <stdlib.h>
      24             : #include <errno.h>
      25             : #include <sal/main.h>
      26             : #include <sal/types.h>
      27             : #include <rtl/strbuf.hxx>
      28             : #include <rtl/ustring.hxx>
      29             : 
      30             : #include <vector>
      31             : 
      32             : void make_hhc_char(FILE *sfp, FILE *cfp);
      33             : void make_stc_char(FILE *sfp, FILE *cfp);
      34             : void make_stc_word(FILE *sfp, FILE *cfp);
      35             : 
      36             : /* Main Procedure */
      37             : 
      38           6 : SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
      39             : {
      40             :     FILE *sfp, *cfp;
      41             : 
      42           3 :     if (argc < 4) exit(-1);
      43             : 
      44             : 
      45           3 :     sfp = fopen(argv[2], "rb"); // open the source file for read;
      46           3 :     if (sfp == NULL)
      47             :     {
      48           0 :         fprintf(stderr, "Opening the dictionary source file %s for reading failed: %s\n", argv[1], strerror(errno));
      49           0 :         exit(1);
      50             :     }
      51             : 
      52             :     // create the C source file to write
      53           3 :     cfp = fopen(argv[3], "wb");
      54           3 :     if (cfp == NULL) {
      55           0 :         fclose(sfp);
      56           0 :         fprintf(stderr, "Opening %s for writing failed: %s\n", argv[3], strerror(errno));
      57           0 :         exit(1);
      58             :     }
      59             : 
      60           3 :     fprintf(cfp, "/*\n");
      61           3 :     fprintf(cfp, " * Copyright(c) 1999 - 2000, Sun Microsystems, Inc.\n");
      62           3 :     fprintf(cfp, " * All Rights Reserved.\n");
      63           3 :     fprintf(cfp, " */\n\n");
      64           3 :     fprintf(cfp, "/* !!!The file is generated automatically. DONOT edit the file manually!!! */\n\n");
      65           3 :     fprintf(cfp, "#include <sal/types.h>\n");
      66           3 :     fprintf(cfp, "#include <textconversion.hxx>\n");
      67           3 :     fprintf(cfp, "\nextern \"C\" {\n");
      68             : 
      69           3 :     if (strcmp(argv[1], "hhc_char") == 0)
      70           1 :         make_hhc_char(sfp, cfp);
      71           2 :     else if (strcmp(argv[1], "stc_char") == 0)
      72           1 :         make_stc_char(sfp, cfp);
      73           1 :     else if (strcmp(argv[1], "stc_word") == 0)
      74           1 :         make_stc_word(sfp, cfp);
      75             : 
      76           3 :     fprintf (cfp, "}\n");
      77             : 
      78           3 :     fclose(sfp);
      79           3 :     fclose(cfp);
      80             : 
      81           3 :     return 0;
      82             : } // end of main
      83             : 
      84             : // Hangul/Hanja character conversion
      85           1 : void make_hhc_char(FILE *sfp, FILE *cfp)
      86             : {
      87             :     sal_Int32 count, address, i, j, k;
      88             :     sal_Unicode Hanja2HangulData[0x10000];
      89       65537 :     for (i = 0; i < 0x10000; i++) {
      90       65536 :         Hanja2HangulData[i] = 0;
      91             :     }
      92             :     sal_uInt16 Hangul2HanjaData[10000][3];
      93             : 
      94             :     // generate main dict. data array
      95           1 :     fprintf(cfp, "\nstatic const sal_Unicode Hangul2HanjaData[] = {");
      96             : 
      97             :     sal_Char Cstr[1024];
      98           1 :     count = 0;
      99           1 :     address = 0;
     100         504 :     while (fgets(Cstr, 1024, sfp)) {
     101             :         // input file is in UTF-8 encoding (Hangul:Hanja)
     102             :         // don't convert last new line character to Ostr.
     103         502 :         OUString Ostr(Cstr, strlen(Cstr) - 1, RTL_TEXTENCODING_UTF8);
     104         502 :         const sal_Unicode *Ustr = Ostr.getStr();
     105         502 :         sal_Int32  len = Ostr.getLength();
     106             : 
     107         502 :         Hangul2HanjaData[count][0] = Ustr[0];
     108         502 :         Hangul2HanjaData[count][1] = sal::static_int_cast<sal_uInt16>( address );
     109         502 :         Hangul2HanjaData[count][2] = sal::static_int_cast<sal_uInt16>( len - 2 );
     110         502 :         count++;
     111             : 
     112        9536 :         for (i = 2; i < len; i++) {
     113        9034 :             Hanja2HangulData[Ustr[i]] = Ustr[0];
     114        9034 :             if (address++ % 16 == 0)
     115         565 :                 fprintf(cfp, "\n\t");
     116        9034 :             fprintf(cfp, "0x%04x, ", Ustr[i]);
     117             :         }
     118         502 :     }
     119           1 :     fprintf(cfp, "\n};\n");
     120             : 
     121           1 :     fprintf(cfp, "\nstatic const com::sun::star::i18n::Hangul_Index Hangul2HanjaIndex[] = {\n");
     122         503 :     for (i = 0; i < count; i++)
     123             :         fprintf(cfp, "\t{ 0x%04x, 0x%04x, 0x%02x },\n",
     124         502 :                         Hangul2HanjaData[i][0],
     125         502 :                         Hangul2HanjaData[i][1],
     126        1506 :                         Hangul2HanjaData[i][2]);
     127           1 :     fprintf(cfp, "};\n");
     128             : 
     129           1 :     fprintf(cfp, "\nstatic const sal_uInt16 Hanja2HangulIndex[] = {");
     130             : 
     131           1 :     address=0;
     132          17 :     for (i = 0; i < 0x10; i++) {
     133          16 :         fprintf(cfp, "\n\t");
     134         272 :         for (j = 0; j < 0x10; j++) {
     135       44529 :             for (k = 0; k < 0x100; k++) {
     136       44357 :                 if (Hanja2HangulData[((i*0x10)+j)*0x100+k] != 0)
     137          84 :                     break;
     138             :             }
     139             :             fprintf(
     140             :                 cfp, "0x%04lx, ",
     141             :                 sal::static_int_cast< unsigned long >(
     142         256 :                     k < 0x100 ? (address++)*0x100 : 0xFFFF));
     143             :         }
     144             :     }
     145           1 :     fprintf(cfp, "\n};\n");
     146             : 
     147           1 :     fprintf(cfp, "\nstatic const sal_Unicode Hanja2HangulData[] = {");
     148             : 
     149         257 :     for (i = 0; i < 0x100; i++) {
     150       44529 :         for (j = 0; j < 0x100; j++) {
     151       44357 :             if (Hanja2HangulData[i*0x100+j] != 0)
     152          84 :                 break;
     153             :         }
     154         256 :         if (j < 0x100) {
     155        1428 :             for (j = 0; j < 0x10; j++) {
     156        1344 :                 fprintf(cfp, "\n\t");
     157       22848 :                 for (k = 0; k < 0x10; k++) {
     158       21504 :                     sal_Unicode c = Hanja2HangulData[((i*0x10+j)*0x10)+k];
     159       21504 :                     fprintf(cfp, "0x%04x, ", c ? c : 0xFFFF);
     160             :                 }
     161             :             }
     162             :         }
     163             :     }
     164           1 :     fprintf(cfp, "\n};\n");
     165             : 
     166             :     // create function to return arrays
     167           1 :     fprintf (cfp, "\tconst sal_Unicode* getHangul2HanjaData() { return Hangul2HanjaData; }\n");
     168           1 :     fprintf (cfp, "\tconst com::sun::star::i18n::Hangul_Index* getHangul2HanjaIndex() { return Hangul2HanjaIndex; }\n");
     169           1 :     fprintf (cfp, "\tsal_Int16 getHangul2HanjaIndexCount() { return sizeof(Hangul2HanjaIndex) / sizeof(com::sun::star::i18n::Hangul_Index); }\n");
     170           1 :     fprintf (cfp, "\tconst sal_uInt16* getHanja2HangulIndex() { return Hanja2HangulIndex; }\n");
     171           1 :     fprintf (cfp, "\tconst sal_Unicode* getHanja2HangulData() { return Hanja2HangulData; }\n");
     172           1 : }
     173             : 
     174             : // Simplified/Traditional Chinese character conversion
     175           1 : void make_stc_char(FILE *sfp, FILE *cfp)
     176             : {
     177             :     sal_Int32 address, i, j, k;
     178             :     sal_Unicode SChinese2TChineseData[0x10000];
     179             :     sal_Unicode SChinese2VChineseData[0x10000];
     180             :     sal_Unicode TChinese2SChineseData[0x10000];
     181       65537 :     for (i = 0; i < 0x10000; i++) {
     182       65536 :         SChinese2TChineseData[i] = 0;
     183       65536 :         SChinese2VChineseData[i] = 0;
     184       65536 :         TChinese2SChineseData[i] = 0;
     185             :     }
     186             : 
     187             :     sal_Char Cstr[1024];
     188        2836 :     while (fgets(Cstr, 1024, sfp)) {
     189             :         // input file is in UTF-8 encoding (SChinese:TChinese)
     190             :         // don't convert last new line character to Ostr.
     191        2834 :         OUString Ostr(Cstr, strlen(Cstr) - 1, RTL_TEXTENCODING_UTF8);
     192        2834 :         const sal_Unicode *Ustr = Ostr.getStr();
     193        2834 :         sal_Int32  len = Ostr.getLength();
     194        2834 :         if (Ustr[1] == 'v')
     195           0 :             SChinese2VChineseData[Ustr[0]] = Ustr[2];
     196             :         else {
     197        2834 :             SChinese2TChineseData[Ustr[0]] = Ustr[2];
     198        2834 :             if (SChinese2VChineseData[Ustr[0]] == 0)
     199        2834 :                 SChinese2VChineseData[Ustr[0]] = Ustr[2];
     200             :         }
     201        6293 :         for (i = 2; i < len; i++)
     202        3459 :             TChinese2SChineseData[Ustr[i]] = Ustr[0];
     203        2834 :     }
     204             : 
     205           1 :     fprintf(cfp, "\nstatic const sal_uInt16 STC_CharIndex_S2T[] = {");
     206             : 
     207           1 :     address=0;
     208          17 :     for (i = 0; i < 0x10; i++) {
     209          16 :         fprintf(cfp, "\n\t");
     210         272 :         for (j = 0; j < 0x10; j++) {
     211       46134 :             for (k = 0; k < 0x100; k++) {
     212       45965 :                 if (SChinese2TChineseData[((i*0x10)+j)*0x100+k] != 0)
     213          87 :                     break;
     214             :             }
     215             :             fprintf(
     216             :                 cfp, "0x%04lx, ",
     217             :                 sal::static_int_cast< unsigned long >(
     218         256 :                     k < 0x100 ? (address++)*0x100 : 0xFFFF));
     219             :         }
     220             :     }
     221           1 :     fprintf(cfp, "\n};\n");
     222             : 
     223           1 :     fprintf(cfp, "\nstatic const sal_Unicode STC_CharData_S2T[] = {");
     224             : 
     225         257 :     for (i = 0; i < 0x100; i++) {
     226       46134 :         for (j = 0; j < 0x100; j++) {
     227       45965 :             if (SChinese2TChineseData[i*0x100+j] != 0)
     228          87 :                 break;
     229             :         }
     230         256 :         if (j < 0x100) {
     231        1479 :             for (j = 0; j < 0x10; j++) {
     232        1392 :                 fprintf(cfp, "\n\t");
     233       23664 :                 for (k = 0; k < 0x10; k++) {
     234       22272 :                     sal_Unicode c = SChinese2TChineseData[((i*0x10+j)*0x10)+k];
     235       22272 :                     fprintf(cfp, "0x%04x, ", c ? c : 0xFFFF);
     236             :                 }
     237             :             }
     238             :         }
     239             :     }
     240           1 :     fprintf(cfp, "\n};\n");
     241             : 
     242           1 :     fprintf(cfp, "\nstatic const sal_uInt16 STC_CharIndex_S2V[] = {");
     243             : 
     244           1 :     address=0;
     245          17 :     for (i = 0; i < 0x10; i++) {
     246          16 :         fprintf(cfp, "\n\t");
     247         272 :         for (j = 0; j < 0x10; j++) {
     248       46134 :             for (k = 0; k < 0x100; k++) {
     249       45965 :                 if (SChinese2VChineseData[((i*0x10)+j)*0x100+k] != 0)
     250          87 :                     break;
     251             :             }
     252             :             fprintf(
     253             :                 cfp, "0x%04lx, ",
     254             :                 sal::static_int_cast< unsigned long >(
     255         256 :                     k < 0x100 ? (address++)*0x100 : 0xFFFF));
     256             :         }
     257             :     }
     258           1 :     fprintf(cfp, "\n};\n");
     259             : 
     260           1 :     fprintf(cfp, "\nstatic const sal_Unicode STC_CharData_S2V[] = {");
     261             : 
     262         257 :     for (i = 0; i < 0x100; i++) {
     263       46134 :         for (j = 0; j < 0x100; j++) {
     264       45965 :             if (SChinese2VChineseData[i*0x100+j] != 0)
     265          87 :                 break;
     266             :         }
     267         256 :         if (j < 0x100) {
     268        1479 :             for (j = 0; j < 0x10; j++) {
     269        1392 :                 fprintf(cfp, "\n\t");
     270       23664 :                 for (k = 0; k < 0x10; k++) {
     271       22272 :                     sal_Unicode c = SChinese2VChineseData[((i*0x10+j)*0x10)+k];
     272       22272 :                     fprintf(cfp, "0x%04x, ", c ? c : 0xFFFF);
     273             :                 }
     274             :             }
     275             :         }
     276             :     }
     277           1 :     fprintf(cfp, "\n};\n");
     278             : 
     279           1 :     fprintf(cfp, "\nstatic const sal_uInt16 STC_CharIndex_T2S[] = {");
     280             : 
     281           1 :     address=0;
     282          17 :     for (i = 0; i < 0x10; i++) {
     283          16 :         fprintf(cfp, "\n\t");
     284         272 :         for (j = 0; j < 0x10; j++) {
     285       43562 :             for (k = 0; k < 0x100; k++) {
     286       43399 :                 if (TChinese2SChineseData[((i*0x10)+j)*0x100+k] != 0)
     287          93 :                     break;
     288             :             }
     289             :             fprintf(
     290             :                 cfp, "0x%04lx, ",
     291             :                 sal::static_int_cast< unsigned long >(
     292         256 :                     k < 0x100 ? (address++)*0x100 : 0xFFFF));
     293             :         }
     294             :     }
     295           1 :     fprintf(cfp, "\n};\n");
     296             : 
     297           1 :     fprintf(cfp, "\nstatic const sal_Unicode STC_CharData_T2S[] = {");
     298             : 
     299         257 :     for (i = 0; i < 0x100; i++) {
     300       43562 :         for (j = 0; j < 0x100; j++) {
     301       43399 :             if (TChinese2SChineseData[i*0x100+j] != 0)
     302          93 :                 break;
     303             :         }
     304         256 :         if (j < 0x100) {
     305        1581 :             for (j = 0; j < 0x10; j++) {
     306        1488 :                 fprintf(cfp, "\n\t");
     307       25296 :                 for (k = 0; k < 0x10; k++) {
     308       23808 :                     sal_Unicode c = TChinese2SChineseData[((i*0x10+j)*0x10)+k];
     309       23808 :                     fprintf(cfp, "0x%04x, ", c ? c : 0xFFFF);
     310             :                 }
     311             :             }
     312             :         }
     313             :     }
     314           1 :     fprintf(cfp, "\n};\n");
     315             : 
     316             :     // create function to return arrays
     317           1 :     fprintf (cfp, "\tconst sal_uInt16* getSTC_CharIndex_S2T() { return STC_CharIndex_S2T; }\n");
     318           1 :     fprintf (cfp, "\tconst sal_Unicode* getSTC_CharData_S2T() { return STC_CharData_S2T; }\n");
     319           1 :     fprintf (cfp, "\tconst sal_uInt16* getSTC_CharIndex_S2V() { return STC_CharIndex_S2V; }\n");
     320           1 :     fprintf (cfp, "\tconst sal_Unicode* getSTC_CharData_S2V() { return STC_CharData_S2V; }\n");
     321           1 :     fprintf (cfp, "\tconst sal_uInt16* getSTC_CharIndex_T2S() { return STC_CharIndex_T2S; }\n");
     322           1 :     fprintf (cfp, "\tconst sal_Unicode* getSTC_CharData_T2S() { return STC_CharData_T2S; }\n");
     323           1 : }
     324             : 
     325             : 
     326             : typedef struct {
     327             :     sal_uInt16 address;
     328             :     sal_Int32 len;
     329             :     sal_Unicode *data;
     330             : } Index;
     331             : 
     332             : extern "C" {
     333       13982 : int Index_comp(const void* s1, const void* s2)
     334             : {
     335       13982 :     Index const *p1 = static_cast<Index const *>(s1), *p2 = static_cast<Index const *>(s2);
     336       13982 :     int result = p1->len - p2->len;
     337       24177 :     for (int i = 0; result == 0 && i < p1->len; i++)
     338       10195 :         result = *(p1->data+i) - *(p2->data+i);
     339       13982 :     return result;
     340             : }
     341             : }
     342             : 
     343             : // Simplified/Traditional Chinese word conversion
     344           1 : void make_stc_word(FILE *sfp, FILE *cfp)
     345             : {
     346             :     sal_Int32 count, i, length;
     347             :     sal_Unicode STC_WordData[0x10000];
     348           1 :     std::vector<Index> STC_WordEntry_S2T(0x10000);
     349           2 :     std::vector<Index> STC_WordEntry_T2S(0x10000);
     350           1 :     sal_Int32 count_S2T = 0, count_T2S = 0;
     351           1 :     sal_Int32 line = 0, char_total = 0;
     352             :     sal_Char Cstr[1024];
     353             : 
     354        1152 :     while (fgets(Cstr, 1024, sfp)) {
     355             :         // input file is in UTF-8 encoding (SChinese:TChinese)
     356             :         // don't convert last new line character to Ostr.
     357        1150 :         OUString Ostr(Cstr, strlen(Cstr) - 1, RTL_TEXTENCODING_UTF8);
     358        1150 :         sal_Int32  len = Ostr.getLength();
     359        1150 :         if (char_total + len + 1 > 0xFFFF) {
     360           0 :             fprintf(stderr, "Word Dictionary stc_word.dic is too big (line %ld)", sal::static_int_cast< long >(line));
     361           0 :             return;
     362             :         }
     363        1150 :         sal_Int32 sep=-1, eq=-1, gt=-1, lt=-1;
     364        1765 :         if (((sep = eq = Ostr.indexOf('=')) > 0) ||
     365        1230 :             ((sep = gt = Ostr.indexOf('>')) > 0) ||
     366             :             ((sep = lt = Ostr.indexOf('<')) > 0)) {
     367             : 
     368        1150 :             if (eq > 0 || gt > 0) {
     369        1070 :                 STC_WordEntry_S2T[count_S2T].address = sal::static_int_cast<sal_uInt16>( char_total );
     370        1070 :                 STC_WordEntry_S2T[count_S2T].len = sep;
     371        1070 :                 STC_WordEntry_S2T[count_S2T++].data = &STC_WordData[char_total];
     372             :             }
     373        1150 :             if (eq > 0 || lt > 0) {
     374         615 :                 STC_WordEntry_T2S[count_T2S].address = sal::static_int_cast<sal_uInt16>( char_total + sep + 1 );
     375         615 :                 STC_WordEntry_T2S[count_T2S].len = len - sep - 1;
     376         615 :                 STC_WordEntry_T2S[count_T2S++].data = &STC_WordData[char_total + sep + 1];
     377             :             }
     378        8299 :             for (i = 0; i < len; i++)
     379        7149 :                 STC_WordData[char_total++] = (i == sep) ? 0 : Ostr[i];
     380        1150 :             STC_WordData[char_total++] = 0;
     381             :         } else {
     382           0 :             fprintf(stderr, "Invalid entry in stc_word.dic (line %ld)", sal::static_int_cast< long >(line));
     383           0 :             return;
     384             :         }
     385        1150 :         line++;
     386        1150 :     }
     387             : 
     388           1 :     if (char_total > 0) {
     389           1 :         fprintf(cfp, "\nstatic const sal_Unicode STC_WordData[] = {");
     390        8300 :         for (i = 0; i < char_total; i++) {
     391        8299 :             if (i % 32 == 0) fprintf(cfp, "\n\t");
     392        8299 :             fprintf(cfp, "0x%04x, ", STC_WordData[i]);
     393             :         }
     394           1 :         fprintf(cfp, "\n};\n");
     395             : 
     396           1 :         fprintf(cfp, "\nstatic sal_Int32 STC_WordData_Count = %ld;\n", sal::static_int_cast< long >(char_total));
     397             : 
     398             :         // create function to return arrays
     399           1 :         fprintf (cfp, "\tconst sal_Unicode* getSTC_WordData(sal_Int32& count) { count = STC_WordData_Count; return STC_WordData; }\n");
     400             :     } else {
     401           0 :         fprintf (cfp, "\tconst sal_Unicode* getSTC_WordData(sal_Int32& count) { count = 0; return NULL; }\n");
     402             :     }
     403             : 
     404             :     sal_uInt16 STC_WordIndex[0x100];
     405             : 
     406           1 :     if (count_S2T > 0) {
     407           1 :         qsort(&STC_WordEntry_S2T[0], count_S2T, sizeof(Index), Index_comp);
     408             : 
     409           1 :         fprintf(cfp, "\nstatic const sal_uInt16 STC_WordEntry_S2T[] = {");
     410           1 :         count = 0;
     411           1 :         length = 0;
     412        1071 :         for (i = 0; i < count_S2T; i++) {
     413        1070 :             if (i % 32 == 0) fprintf(cfp, "\n\t");
     414        1070 :             fprintf(cfp, "0x%04x, ", STC_WordEntry_S2T[i].address);
     415        1070 :             if (STC_WordEntry_S2T[i].len != length) {
     416           8 :                 length = STC_WordEntry_S2T[i].len;
     417          25 :                 while (count <= length)
     418           9 :                     STC_WordIndex[count++] = sal::static_int_cast<sal_uInt16>(i);
     419             :             }
     420             :         }
     421           1 :         fprintf(cfp, "\n};\n");
     422           1 :         STC_WordIndex[count++] = sal::static_int_cast<sal_uInt16>(i);
     423             : 
     424           1 :         fprintf(cfp, "\nstatic const sal_uInt16 STC_WordIndex_S2T[] = {");
     425          11 :         for (i = 0; i < count; i++) {
     426          10 :             if (i % 16 == 0) fprintf(cfp, "\n\t");
     427          10 :             fprintf(cfp, "0x%04x, ", STC_WordIndex[i]);
     428             :         }
     429           1 :         fprintf(cfp, "\n};\n");
     430             : 
     431           1 :         fprintf(cfp, "\nstatic sal_Int32 STC_WordIndex_S2T_Count = %ld;\n", sal::static_int_cast< long >(length));
     432           1 :         fprintf (cfp, "\tconst sal_uInt16* getSTC_WordEntry_S2T() { return STC_WordEntry_S2T; }\n");
     433           1 :         fprintf (cfp, "\tconst sal_uInt16* getSTC_WordIndex_S2T(sal_Int32& count) { count = STC_WordIndex_S2T_Count; return STC_WordIndex_S2T; }\n");
     434             :     } else {
     435           0 :         fprintf (cfp, "\tconst sal_uInt16* getSTC_WordEntry_S2T() { return NULL; }\n");
     436           0 :         fprintf (cfp, "\tconst sal_uInt16* getSTC_WordIndex_S2T(sal_Int32& count) { count = 0; return NULL; }\n");
     437             :     }
     438             : 
     439           1 :     if (count_T2S > 0) {
     440           1 :         qsort(&STC_WordEntry_T2S[0], count_T2S, sizeof(Index), Index_comp);
     441             : 
     442           1 :         fprintf(cfp, "\nstatic const sal_uInt16 STC_WordEntry_T2S[] = {");
     443           1 :         count = 0;
     444           1 :         length = 0;
     445         616 :         for (i = 0; i < count_T2S; i++) {
     446         615 :             if (i % 32 == 0) fprintf(cfp, "\n\t");
     447         615 :             fprintf(cfp, "0x%04x, ", STC_WordEntry_T2S[i].address);
     448         615 :             if (STC_WordEntry_T2S[i].len != length) {
     449          10 :                 length = STC_WordEntry_T2S[i].len;
     450          31 :                 while (count <= length)
     451          11 :                     STC_WordIndex[count++] = sal::static_int_cast<sal_uInt16>(i);
     452             :             }
     453             :         }
     454           1 :         STC_WordIndex[count++] = sal::static_int_cast<sal_uInt16>(i);
     455           1 :         fprintf(cfp, "\n};\n");
     456             : 
     457           1 :         fprintf(cfp, "\nstatic const sal_uInt16 STC_WordIndex_T2S[] = {");
     458          13 :         for (i = 0; i < count; i++) {
     459          12 :             if (i % 16 == 0) fprintf(cfp, "\n\t");
     460          12 :             fprintf(cfp, "0x%04x, ",  STC_WordIndex[i]);
     461             :         }
     462           1 :         fprintf(cfp, "\n};\n");
     463             : 
     464           1 :         fprintf(cfp, "\nstatic sal_Int32 STC_WordIndex_T2S_Count = %ld;\n\n", sal::static_int_cast< long >(length));
     465           1 :         fprintf (cfp, "\tconst sal_uInt16* getSTC_WordEntry_T2S() { return STC_WordEntry_T2S; }\n");
     466           1 :         fprintf (cfp, "\tconst sal_uInt16* getSTC_WordIndex_T2S(sal_Int32& count) { count = STC_WordIndex_T2S_Count; return STC_WordIndex_T2S; }\n");
     467             :     } else {
     468           0 :         fprintf (cfp, "\tconst sal_uInt16* getSTC_WordEntry_T2S() { return NULL; }\n");
     469           0 :         fprintf (cfp, "\tconst sal_uInt16* getSTC_WordIndex_T2S(sal_Int32& count) { count = 0; return NULL; }\n");
     470           1 :     }
     471             : }
     472             : 
     473             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11