~ubuntu-branches/ubuntu/precise/cuneiform/precise

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/fon/src/clu_div.c

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk, c-assert.diff, slovenian-slv.diff
  • Date: 2011-01-26 21:53:07 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110126215307-62x61mcesr607qb7
Tags: 1.0.0+dfsg-2
* Upload to unstable.
* Explicitly build-depend on pkg-config. Thanks to Stefano Rivera for the
  bug report.
* Add Vcs-* fields.
* Use the standard C assert() macro, rather than custom Cuneiform one.
  [c-assert.diff]
* Pass CFLAGS, CXXFLAGS and LDFLAGS (get from dpkg-buildflags) to cmake
  (closes: #608345). Thanks to Sami Liedes for the bug report.
  + Build depend on dpkg-dev (>= 1.15.7).
* Pass --parallel to dh.
  + Bump debhelper minimum version to 7.4.10.
* Update debian/copyright to the latest DEP-5 version.
* Bump year in debian/copyright.
* Explicitly link to GraphicsMagick (rather than via the ImageMagick
  compatibility layer).
* Don't ship /usr/lib/cuneiform/*.so symlinks. These libraries are
  considered private, at least until #598616 is fixed.
* Rename some private variables in debian/rules to make them lowercase.
* Update patch headers.
* Provide proper ‘build-arch’ and ‘build-indep’ targets in debian/rules.
* Document input format in the manual page (closes: #572061). Thanks to
  Janusz S. Bień for the bug report.
* Use ‘slv’ (rather than ‘slo’) as language code for Slovenian.
  [slovenian-slv.diff]
* Fix package description: Slovenian is supported, Slovak is not.
* Improve documentation of the language (-l) option (closes: #602512).
  Thanks to Jari Aalto for the bug report.
* Install reasons file for vrms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 1993-2008, Cognitive Technologies
3
3
All rights reserved.
4
4
 
5
 
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
6
 
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
7
 
 
8
 
      * ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
9
 
        ���� ����������� �� ��������� �����, ���� ������ ������� � �����������
10
 
        ����� �� ��������.
11
 
      * ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
12
 
        ������ ����������, ������������ ��� ���������������, ������ �����������
13
 
        ��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
14
 
        ����������� ����� �� ��������.
15
 
      * �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
16
 
        ���� ������������ � �������� �������� ��������� �/��� �����������
17
 
        ���������, ���������� �� ���� ��, ��� ���������������� �����������
18
 
        ����������.
19
 
 
20
 
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
21
 
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
22
 
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
23
 
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
24
 
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
25
 
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
26
 
������������� ������, ��������� � �������������� ��� ���������� ����������
27
 
������������� ������������� ��������� (������� ������ ������, ��� ������,
28
 
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
29
 
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
30
 
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
31
 
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
 
5
Разрешается повторное распространение и использование как в виде исходного кода,
 
6
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
 
7
 
 
8
      * При повторном распространении исходного кода должны оставаться указанное
 
9
        выше уведомление об авторском праве, этот список условий и последующий
 
10
        отказ от гарантий.
 
11
      * При повторном распространении двоичного кода в документации и/или в
 
12
        других материалах, поставляемых при распространении, должны сохраняться
 
13
        указанная выше информация об авторском праве, этот список условий и
 
14
        последующий отказ от гарантий.
 
15
      * Ни название Cognitive Technologies, ни имена ее сотрудников не могут
 
16
        быть использованы в качестве средства поддержки и/или продвижения
 
17
        продуктов, основанных на этом ПО, без предварительного письменного
 
18
        разрешения.
 
19
 
 
20
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
 
21
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
 
22
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
 
23
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
 
24
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
 
25
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
 
26
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
 
27
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
 
28
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
 
29
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
 
30
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
 
31
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
32
32
 
33
33
Redistribution and use in source and binary forms, with or without modification,
34
34
are permitted provided that the following conditions are met:
54
54
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55
55
*/
56
56
 
57
 
#include "c_types.h"
58
57
 
59
58
#include <stdlib.h>
60
59
#include <string.h>
65
64
#include "sfont.h"
66
65
#include "fonrec.h"
67
66
#include "clu_lang.h"
 
67
#include "minmax.h"
68
68
 
69
69
#define POROG_TEST 5
70
70
#define POROG_SAME 3
76
76
 
77
77
Bool32 BadCluster(InfoCluster *infoC);
78
78
void GetClusterStatistic(int numSymbol,int numCluster,Nraster_header *rh,
79
 
                                                SINT *nClus,InfoCluster *infoC,int *countC,
80
 
                                                BYTE *metkaGood,BYTE *metkaValid,BOOL addLingvo);
 
79
                                                int16_t *nClus,InfoCluster *infoC,int *countC,
 
80
                                                uchar *metkaGood,uchar *metkaValid,Bool addLingvo);
81
81
 
82
82
#define GoodCluster(infoC) (infoC.valid & LEO_VALID_LINGVO )
83
83
 
85
85
static int GetVes(Nraster_header *rh)
86
86
{
87
87
        int i=rh->xbyte*rh->h;
88
 
        BYTE *buf=rh->pHau;
 
88
        uchar *buf=rh->pHau;
89
89
        int summa;
90
90
 
91
91
        for(summa=0;i>0;i--,buf++)
94
94
    return summa;
95
95
}
96
96
///////////////
97
 
static int GetAddField(int num,Word32 *ifield,int let,
 
97
static int GetAddField(int num,uint32_t *ifield,int let,
98
98
                                                  int numCluster,InfoCluster *infoC,
99
 
                                                  Word32 *addField)
 
99
                                                  uint32_t *addField)
100
100
{
101
 
        Word32 field[NFIELDDWORD];
 
101
        uint32_t field[NFIELDDWORD];
102
102
        int i;
103
103
 
104
104
        SetFields(field,ifield);
119
119
        return 1;
120
120
}
121
121
//////////////
122
 
static Bool32 isAddField(Word8 name,InfoCluster *infoC,int numCluster,Word32 *addField)
 
122
static Bool32 isAddField(uchar name,InfoCluster *infoC,int numCluster,uint32_t *addField)
123
123
{
124
124
 int i;
125
125
 
137
137
        return FALSE;
138
138
}
139
139
///////////
140
 
// ���� - ��� ��� �� �����
141
 
// � ��������� - ��� ������
 
140
// ищем - кто еще не вошел
 
141
// и заполняем - кто смешан
142
142
static int smes[256];
143
143
static int uniqal[256];
144
 
static int GetSameField(Word32 *field,Word32 *addField,int let,
 
144
static int GetSameField(uint32_t *field,uint32_t *addField,int let,
145
145
                                                  int numCluster,InfoCluster *infoC,
146
146
                                                  int *numSmes,
147
 
                                                  Word32 *sameField)
 
147
                                                  uint32_t *sameField)
148
148
{
149
149
        int i,numSame,nSmes=0;
150
150
        int k;
160
160
 
161
161
        // if(!strchr(testLet,let))  continue;
162
162
 
163
 
                // ��� �������� � ������ ?
 
163
                // уже работали с буквой ?
164
164
                if( infoC[i].good )
165
165
                {
166
166
                        smes[infoC[i].let]=-1;
169
169
                }
170
170
 
171
171
 
172
 
                // ���� ��������� �������
 
172
                // есть отдельный кластер
173
173
                if( uniqal[infoC[i].let] ) continue;
174
174
 
175
175
                // undefined ?
180
180
 
181
181
                if( IntersectFields(addField,infoC[i].fields)  )
182
182
                {
183
 
                        // ������� ������ ?
 
183
                        // слишком мелкий ?
184
184
                        if( infoC[i].count < POROG_TEST)
185
185
                      continue;
186
186
 
187
 
                        // ����������� � ������
 
187
                        // пересечение с обоими
188
188
                        k=smes[infoC[i].let]-1;
189
189
                    if( k < 0 || infoC[k].count < infoC[i].count )
190
190
                     smes[infoC[i].let]=i+1;
200
200
        AddFields(sameField, infoC[i].fields);
201
201
 
202
202
                if( infoC[uniqal[infoC[i].let]-1].count >= POROG_TEST &&
203
 
                        isAddField((Word8)infoC[i].let,infoC,numCluster,addField)
 
203
                        isAddField((uchar)infoC[i].let,infoC,numCluster,addField)
204
204
                  )
205
205
                        numSame++;
206
206
        }
261
261
           return FALSE;
262
262
}
263
263
///////////////////
264
 
extern SINT DistanceHausDLL(BYTE  *b1,SINT xbyte1,SINT yrow1,
265
 
                                                BYTE  *b2,SINT xbyte2,SINT yrow2,
266
 
                                                SINT porog);
 
264
extern int16_t DistanceHausDLL(uchar  *b1,int16_t xbyte1,int16_t yrow1,
 
265
                                                uchar  *b2,int16_t xbyte2,int16_t yrow2,
 
266
                                                int16_t porog);
267
267
/*
268
 
static int TestRaster(int num,int numSymbol,Nraster_header *rh,SINT *nClus,
 
268
static int TestRaster(int num,int numSymbol,Nraster_header *rh,int16_t *nClus,
269
269
                                          int i1,int i2)
270
270
{
271
271
 int sum1=0;
275
275
        {
276
276
                if(nClus[i] == i1)
277
277
                {
278
 
                        sum1+=DistanceHausDLL(rh[num].pHau,rh[num].byte1,SINT yrow1,
279
 
                                                BYTE  *b2,SINT xbyte2,SINT yrow2,
280
 
                                                SINT porog);
 
278
                        sum1+=DistanceHausDLL(rh[num].pHau,rh[num].byte1,int16_t yrow1,
 
279
                                                uchar  *b2,int16_t xbyte2,int16_t yrow2,
 
280
                                                int16_t porog);
281
281
                }
282
282
 
283
283
        }
286
286
*/
287
287
////////////////////////
288
288
static int TrySubdivide(int numSymbol,Nraster_header *rh,
289
 
                            SINT *nClus,InfoCluster *infoC,
 
289
                            int16_t *nClus,InfoCluster *infoC,
290
290
                                int  nCluster,int numNew,
291
 
                                Word32 *testField,Word32 *addField,
 
291
                                uint32_t *testField,uint32_t *addField,
292
292
                                int *smes,int *uniqal )
293
293
{
294
294
   int i,let;
295
 
   Word32 field[NFIELDDWORD];
 
295
   uint32_t field[NFIELDDWORD];
296
296
   int nNul;
297
297
   int oldFir;
298
298
   InfoCluster saveInfo;
301
301
 
302
302
   for(let='0';let<256;let++)
303
303
   {
304
 
           // ���� ��� ����� ?
 
304
           // есть еще место ?
305
305
           if( nCluster + numNew >= MAXWEICLUS )
306
306
                    break;
307
307
 
412
412
}
413
413
///////////////
414
414
 
415
 
int TryDivide(int numSymbol,Nraster_header *rh,SINT *nClus,
 
415
int TryDivide(int numSymbol,Nraster_header *rh,int16_t *nClus,
416
416
                          int numCluster )
417
417
{
418
418
  int i,j;
419
 
  Word32 testField[NFIELDDWORD];
420
 
  Word32 addField[NFIELDDWORD],sameField[NFIELDDWORD];
 
419
  uint32_t testField[NFIELDDWORD];
 
420
  uint32_t addField[NFIELDDWORD],sameField[NFIELDDWORD];
421
421
  int numNew=0;
422
422
  int numSmes;
423
423
 
424
424
  InfoCluster *infoC =infoClusterStat;
425
425
  int         *countC= countCluster;
426
 
  Word32 dividedFields[NFIELDDWORD]={0,0};
 
426
  uint32_t dividedFields[NFIELDDWORD]={0,0};
427
427
 
428
428
  if(numCluster >= MAXWEICLUS )
429
429
          return numCluster;
445
445
        if( countC[i] <= 1 )
446
446
          continue;
447
447
 
448
 
        // ������� ������ �����-�����
 
448
        // смотрим только буквы-цифры
449
449
        if( !LetDigSymbol(i) )
450
450
                continue;
451
451
 
479
479
                smes,uniqal);
480
480
  }
481
481
 
482
 
  return numCluster+numNew; // ��������� �����
 
482
  return numCluster+numNew; // кластеров стало
483
483
}
484
484
///////////////////////
485
485