~ubuntu-branches/debian/jessie/cuneiform/jessie

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rstr/src/cg_hcut.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:
57
57
#include <string.h>
58
58
#include <stdlib.h>
59
59
 
60
 
#include "nt_types.h"
61
60
#include "struct.h"
62
61
#include "func.h"
63
62
#include "cut_glue.h"
70
69
#include "compat_defs.h"
71
70
#include "minmax.h"
72
71
 
73
 
INT gbCol1,gbCol2;
 
72
int16_t gbCol1,gbCol2;
74
73
 
75
74
typedef struct tagRecogStat
76
75
{
77
 
  INT nbig,ndust,weight;
 
76
  int16_t nbig,ndust,weight;
78
77
} RecogStat;
79
78
 
80
79
static B_LINES bl;
81
 
static BOOL fb1;
82
 
static BOOL fb2;
83
 
static BOOL fb3;
84
 
static BOOL fb4;
85
 
static INT bl_lim=3;
 
80
static Bool fb1;
 
81
static Bool fb2;
 
82
static Bool fb3;
 
83
static Bool fb4;
 
84
static int16_t bl_lim=3;
86
85
 
87
 
static INT dirt_frag(cell **B, cell **E, cell *first, cell *last, BOOL stop_first);
88
 
static void bl_cut(cell *B, cell *E, INT cut);
89
 
static BOOL find_clust(BYTE let);
90
 
static BOOL clip_cell(INT j, cell *c, INT b1, INT b2, INT b3, INT b4, INT st_inc);
91
 
static void save_frag(cell *B, cell *E, RecogStat *rs, cell **sv_frag, INT *st_inc);
 
86
static int16_t dirt_frag(cell **B, cell **E, cell *first, cell *last, Bool stop_first);
 
87
static void bl_cut(cell *B, cell *E, int16_t cut);
 
88
static Bool find_clust(uchar let);
 
89
static Bool clip_cell(int16_t j, cell *c, int16_t b1, int16_t b2, int16_t b3, int16_t b4, int16_t st_inc);
 
90
static void save_frag(cell *B, cell *E, RecogStat *rs, cell **sv_frag, int16_t *st_inc);
92
91
static void replace_frag(cell *B, cell *E, RecogStat *rs, cell *sv_frag);
93
 
static  INT create_cells(cell *whither, raster *r, cell *celist[], INT st_inc);
 
92
static  int16_t create_cells(cell *whither, raster *r, cell *celist[], int16_t st_inc);
94
93
static cell *hide(cell *c, cell **clink);
95
94
static void restore(cell *clink, cell *wherever);
96
95
static void del_hided(cell *clink);
97
 
static BOOL capital(BYTE let);
 
96
static Bool capital(uchar let);
98
97
 
99
98
void  base_lines_cut()
100
99
{
101
100
  cell *BI,*EI,*B0=cell_f()->nextl,*E0=cell_l();
102
 
  INT cut=0;
 
101
  int16_t cut=0;
103
102
  get_b_lines(NULL,&bl);
104
103
  fb1=bl.n1>0 && bl.n1<255;
105
104
  fb2=bl.n2>0 && bl.n2<255;
123
122
  }
124
123
}
125
124
/*
126
 
static BOOL dirt_frag(cell **B,cell **E)
 
125
static Bool dirt_frag(cell **B,cell **E)
127
126
{
128
127
  cell *c=cell_f()->next;
129
128
  gbCol1=gbCol2=0;
142
141
}
143
142
*/
144
143
 
145
 
LONG testDirt(CSTR_rast *beg, CSTR_rast *end)
 
144
int32_t testDirt(CSTR_rast *beg, CSTR_rast *end)
146
145
{
147
146
  CSTR_rast rst=*beg,first=rst,last=CSTR_GetNext(*end);
148
147
  CSTR_rast capb=0,cape=0;
149
 
  INT dirtup=0,dirtdown=0,ncap=0;
 
148
  int16_t dirtup=0,dirtdown=0,ncap=0;
150
149
 
151
150
  get_b_lines(NULL,&bl);
152
151
  fb1=bl.n1>0 && bl.n1<255;
169
168
 
170
169
    if (uni.Alt[0].Prob<trs2)
171
170
    {
172
 
      BYTE let=uni.Alt[0].Code[0],letpos = let_linpos[let];
173
 
      INT bot=attr.row+attr.h;
174
 
      BOOL d2=attr.row<bl.b2-bl_lim,d3=bot>bl.b3+bl_lim;
 
171
      uchar let=uni.Alt[0].Code[0],letpos = let_linpos[let];
 
172
      int16_t bot=attr.row+attr.h;
 
173
      Bool d2=attr.row<bl.b2-bl_lim,d3=bot>bl.b3+bl_lim;
175
174
 
176
175
      if (uni.lnAltCnt==0)
177
176
      {
224
223
  return 0;
225
224
}
226
225
 
227
 
static INT dirt_frag(cell **B, cell **E, cell *first, cell *last, BOOL stop_first)
 
226
static int16_t dirt_frag(cell **B, cell **E, cell *first, cell *last, Bool stop_first)
228
227
{
229
228
  cell *c=*B,*end=*E;
230
229
  cell *capb=NULL,*cape=NULL;
231
 
  INT dirtup=0,dirtdown=0,ncap=0;
 
230
  int16_t dirtup=0,dirtdown=0,ncap=0;
232
231
/*
233
232
  gbCol1=gbCol2=0;
234
233
  glsnap('o',c,"Cut by bases; input r_col for begin and end");
245
244
 
246
245
    if (c->vers[0].prob<trs2)
247
246
    {
248
 
      BYTE let=c->vers[0].let;
249
 
      BYTE letpos = let_linpos[let];
250
 
      INT bot=c->row+c->h;
251
 
      BOOL d2 = (fb2) ? c->row<bl.b2-bl_lim : TRUE;
252
 
      BOOL d3 = (fb3) ? bot>bl.b3+bl_lim : TRUE;
 
247
      uchar let=c->vers[0].let;
 
248
      uchar letpos = let_linpos[let];
 
249
      int16_t bot=c->row+c->h;
 
250
      Bool d2 = (fb2) ? c->row<bl.b2-bl_lim : TRUE;
 
251
      Bool d3 = (fb3) ? bot>bl.b3+bl_lim : TRUE;
253
252
 
254
253
      if ((c->pr_vers.prob>=220 ||
255
254
                                strchr("���",c->pr_vers.let) &&
261
260
 
262
261
      if (!c->nvers)
263
262
      {
264
 
        BYTE let=c->pr_vers.let;
 
263
        uchar let=c->pr_vers.let;
265
264
//        if (c->pr_vers.prob>=220)  continue;
266
265
        if (d2)
267
266
        {
335
334
      if (d2 || d3)
336
335
      {
337
336
        ClustInfo cli;
338
 
        LONG nc=FONGetNumCluster(c->r_clink);
 
337
        int32_t nc=FONGetNumCluster(c->r_clink);
339
338
              FONGetClustInfo(&cli,nc);
340
339
        if (cli.prob>=trs2)
341
340
        {
365
364
  return 0;
366
365
}
367
366
 
368
 
static BOOL find_clust(BYTE let)
 
367
static Bool find_clust(uchar let)
369
368
{
370
369
#ifdef _USE_FON_
371
370
  ClustInfo clustinfo;
376
375
#endif
377
376
}
378
377
 
379
 
static void bl_cut(cell *B, cell *E, INT cut)
 
378
static void bl_cut(cell *B, cell *E, int16_t cut)
380
379
{
381
380
  cell *f=B,*LC=B->prev,*RC=E->next;
382
381
  RecogStat rs;
383
382
  cell *sv_frag=NULL;
384
 
  INT st_inc;          //�।��� ������
385
 
  BOOL repair=TRUE;
 
383
  int16_t st_inc;          //�।��� ������
 
384
  Bool repair=TRUE;
386
385
 
387
386
  //save current state
388
387
  save_frag(B,E,&rs,&sv_frag,&st_inc);
399
398
    }
400
399
    else
401
400
    {
402
 
      INT b1 = (fb1 && cut>0) ? bl.b1-c->row : 0;
403
 
      INT b2 = (fb2 && cut>0) ? bl.b2-c->row : 0;
404
 
      INT b3 = (fb3 && cut<0) ? bl.b3-c->row : 0;
405
 
      INT b4 = (fb4 && cut<0) ? bl.b4-c->row : 0;
 
401
      int16_t b1 = (fb1 && cut>0) ? bl.b1-c->row : 0;
 
402
      int16_t b2 = (fb2 && cut>0) ? bl.b2-c->row : 0;
 
403
      int16_t b3 = (fb3 && cut<0) ? bl.b3-c->row : 0;
 
404
      int16_t b4 = (fb4 && cut<0) ? bl.b4-c->row : 0;
406
405
 
407
406
      if (let_or_bad(c))
408
407
      {
429
428
    del_hided(sv_frag);
430
429
}
431
430
 
432
 
static BOOL clip_cell(INT j, cell *c, INT b1, INT b2, INT b3, INT b4, INT st_inc)
 
431
static Bool clip_cell(int16_t j, cell *c, int16_t b1, int16_t b2, int16_t b3, int16_t b4, int16_t st_inc)
433
432
{
434
433
//��१��� �� c ��, �� ��室�� �� b1,b4 (����� �� c->row); b2,b3 - �������⥫�� ࠧ१�,
435
434
// �᫨ �㦭�
436
 
//  INT j;
437
 
  INT crow=c->row;  //b1,b2,b3,b4 refer to crow
438
 
  BOOL repair=TRUE;
 
435
//  int16_t j;
 
436
  int16_t crow=c->row;  //b1,b2,b3,b4 refer to crow
 
437
  Bool repair=TRUE;
439
438
 
440
439
//  for (j=0; j<2 && c; j++)
441
440
  if (j<2)
442
441
  {
443
 
    BOOL cut_made=FALSE;
 
442
    Bool cut_made=FALSE;
444
443
 
445
444
    if (j==0)
446
445
    {
459
458
    {
460
459
      raster r;                   //�஬������ ����
461
460
      cell *celist[MAX_SECT+1];
462
 
      INT wbyte=(c->w+7)>>3,i,nall,size=((c->w+7)>>3)*c->h;
463
 
      INT nbig=0;
 
461
      int16_t wbyte=(c->w+7)>>3,i,nall,size=((c->w+7)>>3)*c->h;
 
462
      int16_t nbig=0;
464
463
 
465
464
      if (size>sizeof(r.pict))
466
465
        return FALSE;
467
 
      memcpy(&(r.pict),(BYTE*)save_raster(c),size);
 
466
      memcpy(&(r.pict),(uchar*)save_raster(c),size);
468
467
      r.w=c->w; r.h=c->h; r.top=c->r_row; r.left=c->r_col;
469
468
 
470
469
      if (j==0)
497
496
        if (bad(t))
498
497
        {
499
498
          full_recog(t,NULL,trs2,trs2);
500
 
          if (!let(t))  repair &= clip_cell((INT)(j+1),t,0,(INT)(crow+b2-t->row),(INT)(crow+b3-t->row),0,st_inc);
 
499
          if (!let(t))  repair &= clip_cell((int16_t)(j+1),t,0,(int16_t)(crow+b2-t->row),(int16_t)(crow+b3-t->row),0,st_inc);
501
500
        }
502
501
      }
503
502
      del_cell(c);
505
504
      return repair && nbig != 0;
506
505
    }
507
506
    else
508
 
      return clip_cell((INT)(j+1),c,0,(INT)(crow+b2-c->row),(INT)(crow+b3-c->row),0,st_inc);
 
507
      return clip_cell((int16_t)(j+1),c,0,(int16_t)(crow+b2-c->row),(int16_t)(crow+b3-c->row),0,st_inc);
509
508
  }
510
509
  return let(c) != 0;
511
510
}
512
511
 
513
 
static INT create_cells(cell *whither, raster *r, cell *celist[], INT st_inc)
 
512
static int16_t create_cells(cell *whither, raster *r, cell *celist[], int16_t st_inc)
514
513
{
515
 
  INT i;
516
 
  MN  *mn=c_locomp(r->pict,(INT)((r->w+7)>>3),r->h,r->top,r->left);
 
514
  int16_t i;
 
515
  MN  *mn=c_locomp(r->pict,(int16_t)((r->w+7)>>3),r->h,r->top,r->left);
517
516
  for (i=0; i<MAX_SECT && mn; i++,mn=mn->mnnext)
518
517
  {
519
518
    cell *c=create_my_cell(mn,whither,0,0);
524
523
  return i;
525
524
}
526
525
 
527
 
static void save_frag(cell *B, cell *E, RecogStat *rs, cell **sv_frag, INT *st_inc)
 
526
static void save_frag(cell *B, cell *E, RecogStat *rs, cell **sv_frag, int16_t *st_inc)
528
527
{
529
528
  cell *celist[MAX_SECT];
530
 
  INT n=0;
 
529
  int16_t n=0;
531
530
  E=E->next;
532
531
  B->complist=NULL;
533
532
  rs->weight=256;  rs->nbig=rs->ndust=0;
553
552
static void replace_frag(cell *B, cell *E, RecogStat *rs, cell *sv_frag)
554
553
{
555
554
  cell *c;
556
 
  INT weight=256,nbig=0,ndust=0;
 
555
  int16_t weight=256,nbig=0,ndust=0;
557
556
//  B_LINES bs=bl;
558
557
 
559
558
  E=E->next;
604
603
  }
605
604
}
606
605
 
607
 
static BOOL capital(BYTE let)
 
606
static Bool capital(uchar let)
608
607
{
609
608
    return (let>='0' && let<='9' || let>='A' && let<='Z' || let>='�' && let<='�');
610
609
}