~ubuntu-branches/ubuntu/trusty/cuneiform/trusty

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rstr/src/match_wd.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
#include <stdio.h>
60
 
#include "nt_types.h"
 
60
 
61
61
#include "struct.h"
62
62
#include "ligas.h"
63
63
#include "func.h"
68
68
#include "wrgb.h"
69
69
#include "minmax.h"
70
70
 
71
 
extern BYTE * letters_pidx_table;
72
 
INT get_cuts (cell *C, struct cut_elm *list, INT nmax );
73
 
INT recogij(cell *C, cell **org_cells, INT N, BYTE cut_fl,
74
 
                   BYTE cut_fine,INT inc, INT *roi, BYTE *gvar,
75
 
                   SVERS *vers, INT *width );
 
71
extern uchar * letters_pidx_table;
 
72
int16_t get_cuts (cell *C, struct cut_elm *list, int16_t nmax );
 
73
int16_t recogij(cell *C, cell **org_cells, int16_t N, uchar cut_fl,
 
74
                   uchar cut_fine,int16_t inc, int16_t *roi, uchar *gvar,
 
75
                   SVERS *vers, int16_t *width );
76
76
 
77
 
extern BYTE mwInput[];
 
77
extern uchar mwInput[];
78
78
extern B_LINES my_bases;
79
79
 
80
80
#define LINE_WIDTH 8000            //line length in pixels
91
91
//cut point - graph node in dynamic matching
92
92
typedef struct tagCutPoint
93
93
{
94
 
  WORD    x;  //position
95
 
  BYTE    dh;  //cut lehgth
96
 
  BYTE     h;  //cut begin from raster bottom
97
 
  BYTE   var;  //cut point type
98
 
  BYTE     n;  //number of components
99
 
  BYTE   flg;  //for any purpose
 
94
  uint16_t    x;  //position
 
95
  uchar    dh;  //cut lehgth
 
96
  uchar     h;  //cut begin from raster bottom
 
97
  uchar   var;  //cut point type
 
98
  uchar     n;  //number of components
 
99
  uchar   flg;  //for any purpose
100
100
} CutPoint;
101
101
 
102
102
typedef struct tagGraphNode
103
103
{
104
 
  WORD   prev;  //previous node in this path
 
104
  uint16_t   prev;  //previous node in this path
105
105
  Weight weight;   //accrued weight to current node
106
 
  DWORD  monitors; //rates of monitoring letters
 
106
  uint32_t  monitors; //rates of monitoring letters
107
107
// SVERS  vers;  //versions for segment from prev to current
108
108
} GraphNode;
109
109
 
110
110
typedef struct tagStrRaster   //���� ��ப�
111
111
{
112
 
  LONG w;       //�ਭ�
113
 
  LONG h;       //����
114
 
  LONG top;     //��ப� ������ ���孥�� 㣫�
115
 
  LONG left;    //�⮫���  -""-
116
 
  BYTE pict[LINE_WIDTH*LINE_HEIGHT/8];  //����
 
112
  int32_t w;       //�ਭ�
 
113
  int32_t h;       //����
 
114
  int32_t top;     //��ப� ������ ���孥�� 㣫�
 
115
  int32_t left;    //�⮫���  -""-
 
116
  uchar pict[LINE_WIDTH*LINE_HEIGHT/8];  //����
117
117
} StrRaster;
118
118
 
119
119
typedef struct tagCutAdd
120
120
{
121
 
  INT top;
122
 
  INT left;
123
 
  INT right;
124
 
  INT bottom;
125
 
  LONG nbig;
 
121
  int16_t top;
 
122
  int16_t left;
 
123
  int16_t right;
 
124
  int16_t bottom;
 
125
  int32_t nbig;
126
126
  SVERS vers; //��� ���ᨨ
127
127
} CutAdd;
128
128
 
129
129
static void set_param (MatchWordPar *param);
130
 
static BOOL make_cell_string(CSTR_rast wb, CSTR_rast we);
 
130
static Bool make_cell_string(CSTR_rast wb, CSTR_rast we);
131
131
static void calc_bl();
132
 
static void make_alphabet(BYTE *word);
133
 
static INT compose_inc(cell *wb, cell *we);
134
 
static BOOL  make_str_raster(cell *wb, cell *we, StrRaster *raster);
 
132
static void make_alphabet(uchar *word);
 
133
static int16_t compose_inc(cell *wb, cell *we);
 
134
static Bool  make_str_raster(cell *wb, cell *we, StrRaster *raster);
135
135
static void comptorast(c_comp *cp1, StrRaster *raster);
136
 
static void inttorast( StrRaster *r, LONG h, LONG end, LONG lth);
137
 
static BOOL calc_cut_points(cell *wb, cell *we, INT rastlc, INT rastdr);
138
 
static void fict_sect(CutPoint *sec, CutAdd *sec_add, GraphNode *node, INT x, INT px);
139
 
static void close_ds(CutPoint *sec, CutAdd *sec_add, GraphNode *node, INT x, INT px);
140
 
static void cor_sect(cell *C, CutPoint *cut, INT left, INT down);
141
 
static INT get_points (cell *C, CutPoint *listn, INT nmax );
 
136
static void inttorast( StrRaster *r, int32_t h, int32_t end, int32_t lth);
 
137
static Bool calc_cut_points(cell *wb, cell *we, int16_t rastlc, int16_t rastdr);
 
138
static void fict_sect(CutPoint *sec, CutAdd *sec_add, GraphNode *node, int16_t x, int16_t px);
 
139
static void close_ds(CutPoint *sec, CutAdd *sec_add, GraphNode *node, int16_t x, int16_t px);
 
140
static void cor_sect(cell *C, CutPoint *cut, int16_t left, int16_t down);
 
141
static int16_t get_points (cell *C, CutPoint *listn, int16_t nmax );
142
142
static void save_alpha_vers(cell *C, SVERS *svers);
143
 
static INT cut_by_alpha(INT n, version vers[]);
144
 
static Weight match(BYTE *word);
145
 
static BOOL test_set(LONG prev, LONG h0, BYTE nlet, LONG tol, BOOL rerecog, LONG *imax, LONG *pmax);
146
 
static LONG inc(CutPoint **cutp, LONG i, LONG ie, LONG set);
147
 
static LONG dec(CutPoint **cutp, LONG i, LONG ie, LONG set);
148
 
static LONG add_sect(LONG il, LONG ir, BYTE nlet, BOOL rerecog, BYTE *p);
149
 
static version *find_in_vers(SVERS *svers, BYTE let);
150
 
static BOOL equal(BYTE let1, BYTE let2);
151
 
static LONG select_cells(LONG il, LONG ir, BYTE cut_fl, cell **cells);
 
143
static int16_t cut_by_alpha(int16_t n, version vers[]);
 
144
static Weight match(uchar *word);
 
145
static Bool test_set(int32_t prev, int32_t h0, uchar nlet, int32_t tol, Bool rerecog, int32_t *imax, int32_t *pmax);
 
146
static int32_t inc(CutPoint **cutp, int32_t i, int32_t ie, int32_t set);
 
147
static int32_t dec(CutPoint **cutp, int32_t i, int32_t ie, int32_t set);
 
148
static int32_t add_sect(int32_t il, int32_t ir, uchar nlet, Bool rerecog, uchar *p);
 
149
static version *find_in_vers(SVERS *svers, uchar let);
 
150
static Bool equal(uchar let1, uchar let2);
 
151
static int32_t select_cells(int32_t il, int32_t ir, uchar cut_fl, cell **cells);
152
152
static void set_bad_vers(SVERS *c);
153
 
static Weight add_weight(Weight *wp, BYTE ro, BYTE nlet);
154
 
static void add_monitors(LONG il, LONG ir, BYTE nlet, BYTE pb);
 
153
static Weight add_weight(Weight *wp, uchar ro, uchar nlet);
 
154
static void add_monitors(int32_t il, int32_t ir, uchar nlet, uchar pb);
155
155
 
156
156
static void mw_show_rast();
157
 
static void show_layer(BYTE let, LONG prev, LONG imax);
 
157
static void show_layer(uchar let, int32_t prev, int32_t imax);
158
158
 
159
159
 
160
160
StrRaster str_raster;
161
161
#define MAX_CUT_POINT LINE_WIDTH/8
162
162
static CutPoint cut_list[MAX_CUT_POINT];
163
163
static GraphNode   layer1[MAX_CUT_POINT],layer2[MAX_CUT_POINT],*cur_layer=layer1,*prev_layer=layer2;
164
 
static LONG ncut;
165
 
static BYTE *templ,alpha[256]={0};
166
 
static INT com_inc;
 
164
static int32_t ncut;
 
165
static uchar *templ,alpha[256]={0};
 
166
static int16_t com_inc;
167
167
struct dp_vers_struct vers_pool;   //��� ���ᨩ dp
168
168
#define vers_list (vers_pool.node)
169
 
static LONG min_cut_width=0;  //�� �ਭ� > min_cut_width ����� १���
170
 
static LONG wmin;
 
169
static int32_t min_cut_width=0;  //�� �ਭ� > min_cut_width ����� १���
 
170
static int32_t wmin;
171
171
static MatchWordPar *param;
172
172
 
173
173
static struct
174
174
{
175
 
  BYTE d[4];
176
 
  BYTE m[3];
177
 
  BYTE u[4];
178
 
  BYTE z[3];
179
 
  BYTE a[3];
180
 
  BYTE e2[3];
181
 
  BYTE E2[3];
182
 
  BYTE ii[3];
 
175
  uchar d[4];
 
176
  uchar m[3];
 
177
  uchar u[4];
 
178
  uchar z[3];
 
179
  uchar a[3];
 
180
  uchar e2[3];
 
181
  uchar E2[3];
 
182
  uchar ii[3];
183
183
} eq_list=
184
184
{
185
 
  {(BYTE)'�',r_cu_d,r_cu_g,0},    //   r_cu_d  0xf0     cursiv d tail up
 
185
  {(uchar)'�',r_cu_d,r_cu_g,0},    //   r_cu_d  0xf0     cursiv d tail up
186
186
                                  //   r_cu_g  0xf1     cursiv d tail down
187
 
  {(BYTE)'�',r_cu_m,0},           //   r_cu_m  0xf5     cursiv t
188
 
  {(BYTE)'�',(BYTE)'�',r_cu_u,0}, //   r_cu_u  0xf7     cursiv ee
189
 
  {(BYTE)'�',r_cu_z,0},           //   r_cu_z  0xf8     cursiv g
190
 
  {(BYTE)'�',r_cu_a,0},           //   r_cu_a  0xfd     a
191
 
  {(BYTE)'�',r_e_2dot,0},         //   r_e_2dot   0xC0  russian e ..  = 192
192
 
  {(BYTE)'�',r_EE_2dot,0},        //   r_EE_2dot  0xC8  russian E ..  = 200
193
 
  {(BYTE)'�',(BYTE)'�',0}
 
187
  {(uchar)'�',r_cu_m,0},           //   r_cu_m  0xf5     cursiv t
 
188
  {(uchar)'�',(uchar)'�',r_cu_u,0}, //   r_cu_u  0xf7     cursiv ee
 
189
  {(uchar)'�',r_cu_z,0},           //   r_cu_z  0xf8     cursiv g
 
190
  {(uchar)'�',r_cu_a,0},           //   r_cu_a  0xfd     a
 
191
  {(uchar)'�',r_e_2dot,0},         //   r_e_2dot   0xC0  russian e ..  = 192
 
192
  {(uchar)'�',r_EE_2dot,0},        //   r_EE_2dot  0xC8  russian E ..  = 200
 
193
  {(uchar)'�',(uchar)'�',0}
194
194
};
195
195
 
196
196
#define EQU_d   0
202
202
#define EQU_E2  EQU_e2+sizeof(eq_list.e2)
203
203
#define EQU_ii  EQU_E2+sizeof(eq_list.E2)
204
204
 
205
 
CHAR eq_let[256]=
 
205
char eq_let[256]=
206
206
  {
207
207
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   // 0
208
208
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   // 1
253
253
 
254
254
static void  CBS_Init() {}
255
255
static void  CBS_Calc() {}
256
 
static void  letToDust(BOOL exact) {}
257
 
static BOOL LINDefineLines(cell *f, cell *l)  { return FALSE; }
258
 
static BOOL SetBases ()   { return FALSE; }
259
 
static void StrRec(BYTE *alphabet, LONG mode) {}
 
256
static void  letToDust(Bool exact) {}
 
257
static Bool LINDefineLines(cell *f, cell *l)  { return FALSE; }
 
258
static Bool SetBases ()   { return FALSE; }
 
259
static void StrRec(uchar *alphabet, int32_t mode) {}
260
260
 
261
 
LONG match_word(CSTR_rast wb, CSTR_rast we, BYTE *word, MatchWordPar *param)
 
261
int32_t match_word(CSTR_rast wb, CSTR_rast we, uchar *word, MatchWordPar *param)
262
262
//match word to line fragment from wb to we (not include)
263
263
//returns weight ( < 0, if error occur
264
264
{
281
281
 
282
282
  if (!param->bases)
283
283
  {
284
 
    BOOL linOK=FALSE;
 
284
    Bool linOK=FALSE;
285
285
    if (LINDefineLines(cell_f(),cell_l()))
286
286
      linOK=SetBases();
287
287
    if (linOK)
299
299
  return match(word);
300
300
}
301
301
 
302
 
static BOOL make_cell_string(CSTR_rast wb, CSTR_rast we)
 
302
static Bool make_cell_string(CSTR_rast wb, CSTR_rast we)
303
303
{
304
304
  return FALSE;
305
305
}
329
329
  min_cut_width = param->cut_width;
330
330
}
331
331
 
332
 
BOOL match_word_prepare(CSTR_line ln, BYTE *alpha, MatchWordPar *param);
 
332
Bool match_word_prepare(CSTR_line ln, uchar *alpha, MatchWordPar *param);
333
333
 
334
 
RSTR_FUNC(Bool32) RSTR_recog_one_word(CSTR_line ln, Word8 *word, Int8 *points,Word8 *res)
 
334
RSTR_FUNC(Bool32) RSTR_recog_one_word(CSTR_line ln, uchar *word, char *points,uchar *res)
335
335
{
336
336
Weight      w;
337
337
MatchWordPar param={0};
338
338
int rc;
339
339
 
340
 
param.monitors=*((DWORD*)points);
 
340
param.monitors=*((uint32_t*)points);
341
341
param.p2_active=1;  //call while p2 pass
342
342
param.language=3;       // LANG_RUSSIAN
343
343
 
353
353
return TRUE;
354
354
}
355
355
 
356
 
Weight match_string(CSTR_line ln, BYTE *str, MatchWordPar *param)
 
356
Weight match_string(CSTR_line ln, uchar *str, MatchWordPar *param)
357
357
{
358
358
  Weight m1={-1,-1};
359
359
  cell *wb,*we;
383
383
    return m1;
384
384
 
385
385
  wb=cell_f()->next;
386
 
  if (!calc_cut_points(wb,we,(INT)str_raster.left,(INT)(str_raster.top+str_raster.h-1)))
 
386
  if (!calc_cut_points(wb,we,(int16_t)str_raster.left,(int16_t)(str_raster.top+str_raster.h-1)))
387
387
    return m1;
388
388
 
389
389
  if (debug_on)  mw_show_rast();
391
391
  return match(str);
392
392
}
393
393
 
394
 
Weight match_cell_word(cell *wb, cell *we, BYTE *word, MatchWordPar *param)
 
394
Weight match_cell_word(cell *wb, cell *we, uchar *word, MatchWordPar *param)
395
395
{
396
396
  Weight m1={-1,-1};
397
397
  set_param(param);
407
407
  if (!glue_overlap(wb->prev,we))
408
408
    return m1;
409
409
 
410
 
  if (!calc_cut_points(wb,we,(INT)str_raster.left,(INT)(str_raster.top+str_raster.h-1)))
 
410
  if (!calc_cut_points(wb,we,(int16_t)str_raster.left,(int16_t)(str_raster.top+str_raster.h-1)))
411
411
    return m1;
412
412
 
413
413
  if (debug_on)  mw_show_rast();
415
415
  return match(word);
416
416
}
417
417
/*
418
 
static BYTE *make_alphabet(BYTE *word)
 
418
static uchar *make_alphabet(uchar *word)
419
419
{
420
 
  static BYTE alphabet[257];
421
 
  BYTE *a=alphabet,*w;
 
420
  static uchar alphabet[257];
 
421
  uchar *a=alphabet,*w;
422
422
 
423
423
  *a=0;
424
424
  do
425
425
  {
426
 
    LONG let=256;
 
426
    int32_t let=256;
427
427
    for (w=word; *w; w++)
428
428
      if (*w>*a && *w<let)  let=*w;
429
 
    *(++a)=(BYTE)(let & 0xFF);
 
429
    *(++a)=(uchar)(let & 0xFF);
430
430
  }
431
431
  while (*a);
432
432
  return alphabet+1;
433
433
}
434
434
*/
435
 
static void make_alphabet(BYTE *word)
 
435
static void make_alphabet(uchar *word)
436
436
{
437
 
  BYTE *w,*l;
 
437
  uchar *w,*l;
438
438
 
439
439
  memset(alpha,0,256);
440
440
 
448
448
 
449
449
  for (w=word; *w; w++)
450
450
  {
451
 
    LONG add=eq_let[*w];
 
451
    int32_t add=eq_let[*w];
452
452
    if (add<0)
453
453
      alpha[*w]=1;
454
454
    else
457
457
  }
458
458
}
459
459
 
460
 
static INT compose_inc(cell *wb, cell *we)
 
460
static int16_t compose_inc(cell *wb, cell *we)
461
461
{
462
462
  cell *cells[LINE_WIDTH/8];
463
 
  INT n;
 
463
  int16_t n;
464
464
 
465
465
  for (n=0; wb != we && n<LINE_WIDTH/8; n++,wb=wb->next)  cells[n]=wb;
466
466
  return erection_compose_inc(n,cells);
467
467
}
468
468
 
469
 
static BOOL  make_str_raster(cell *wb, cell *we, StrRaster *str_raster)
 
469
static Bool  make_str_raster(cell *wb, cell *we, StrRaster *str_raster)
470
470
{
471
471
  cell *c;
472
 
  INT left=MAXINT,top=MAXINT,right=0,bottom=0;
 
472
  int16_t left=MAXINT,top=MAXINT,right=0,bottom=0;
473
473
 
474
474
//raster size
475
475
  for (c=wb; c != we; c=c->next)
479
479
    left=MIN(left,c->r_col);
480
480
    right=MAX(right,c->r_col+c->w);
481
481
  }
482
 
  str_raster->left=(LONG)left;
483
 
  str_raster->top =(LONG)top;
484
 
  str_raster->w=(LONG)(right-left);
485
 
  str_raster->h=(LONG)(bottom-top);
 
482
  str_raster->left=(int32_t)left;
 
483
  str_raster->top =(int32_t)top;
 
484
  str_raster->w=(int32_t)(right-left);
 
485
  str_raster->h=(int32_t)(bottom-top);
486
486
 
487
487
  if (str_raster->w > LINE_WIDTH || str_raster->h > LINE_HEIGHT)
488
488
    return FALSE;
498
498
 
499
499
static void comptorast(c_comp *cp1, StrRaster *str_raster)
500
500
{
501
 
 LONG Lc1=cp1->nl;   // number of lines in component
502
 
 LONG lc1,h1,y1;
 
501
 int32_t Lc1=cp1->nl;   // number of lines in component
 
502
 int32_t lc1,h1,y1;
503
503
 lnhead *lp1;
504
504
 interval *int1;
505
505
 
506
 
 lp1=(lnhead *) ( (CHAR *)cp1 + cp1->lines + 2); // beginning of first line
 
506
 lp1=(lnhead *) ( (char *)cp1 + cp1->lines + 2); // beginning of first line
507
507
 for (lc1=0; lc1 < Lc1; lc1++)
508
508
 {
509
509
   h1=lp1->row+cp1->upper-str_raster->top;
510
510
   int1=(interval *)(lp1+1);       // ptr to current interval
511
 
   for (y1=0; y1 < (LONG)lp1->h; y1++, int1++, h1++)
512
 
     inttorast(str_raster,h1,(LONG)(int1->e+cp1->left-str_raster->left),int1->l);
513
 
   lp1=(lnhead *) ((CHAR *)lp1+lp1->lth);   // next line
 
511
   for (y1=0; y1 < (int32_t)lp1->h; y1++, int1++, h1++)
 
512
     inttorast(str_raster,h1,(int32_t)(int1->e+cp1->left-str_raster->left),int1->l);
 
513
   lp1=(lnhead *) ((char *)lp1+lp1->lth);   // next line
514
514
 }
515
515
}
516
516
 
517
 
static void inttorast( StrRaster *r, LONG h, LONG end, LONG lth)
 
517
static void inttorast( StrRaster *r, int32_t h, int32_t end, int32_t lth)
518
518
 {
519
 
 LONG j,je,me,ib,jb,mb,head=(r->w+7)/8*h;
520
 
 BYTE *str_raster=r->pict;
 
519
 int32_t j,je,me,ib,jb,mb,head=(r->w+7)/8*h;
 
520
 uchar *str_raster=r->pict;
521
521
 
522
522
 ib=end-lth;
523
523
 mb = 0xff >> (ib & 7);
535
535
  str_raster[j] = 0xff;
536
536
 }
537
537
 
538
 
static BOOL calc_cut_points(cell *wb, cell *we, INT rastlc, INT rastdr)
 
538
static Bool calc_cut_points(cell *wb, cell *we, int16_t rastlc, int16_t rastdr)
539
539
{
540
 
  CHAR x;
541
 
  INT i,j,ro,wide=MAXINT;
542
 
  INT  nc;        //������⢮ �祭�� cell'�
543
 
  INT dust_sect=0;//䫠�: �祭�� �� dust'��
544
 
  INT mincl=MAXINT16,maxcl=rastlc;  //���. � ���. �業�� ��� �ࠢ��� ��� dust-ᥪ樨
 
540
  char x;
 
541
  int16_t i,j,ro,wide=MAXINT;
 
542
  int16_t  nc;        //������⢮ �祭�� cell'�
 
543
  int16_t dust_sect=0;//䫠�: �祭�� �� dust'��
 
544
  int16_t mincl=MAXINT16,maxcl=rastlc;  //���. � ���. �業�� ��� �ࠢ��� ��� dust-ᥪ樨
545
545
  CutPoint *seci=cut_list+1; //⥪�饥 �祭��
546
546
  CutAdd cut_add[MAX_CUT_POINT];
547
547
  CutAdd *seci_add=cut_add+1;
571
571
      {
572
572
        if ( dust_sect )
573
573
        {                  //����뢠�� ����� dust-ᥪ��
574
 
          close_ds(seci,seci_add,nodei,(INT)(maxcl-rastlc),(INT)(ncut-1));
 
574
          close_ds(seci,seci_add,nodei,(int16_t)(maxcl-rastlc),(int16_t)(ncut-1));
575
575
          ncut++; seci++; seci_add++; nodei++;
576
576
          if ( ncut==MAX_CUTS ) {dust_sect=0; break;}
577
577
        }
602
602
        {
603
603
          if ( maxcl>C->r_col ) x=mincl-rastlc;
604
604
          else                  x=maxcl-rastlc;
605
 
          close_ds(seci,seci_add,nodei,x,(INT)(ncut-1));
 
605
          close_ds(seci,seci_add,nodei,x,(int16_t)(ncut-1));
606
606
//          close_ds(seci,MAX(mincl,C->r_col-1)-rastlc,ncut-1);
607
607
//          close_ds(seci,MIN(maxcl,C->r_col-1)-rastlc,ncut-1);
608
608
          ncut++;  seci++;  seci_add++;  nodei++;
611
611
        else
612
612
        if (mincl==maxcl && ((seci-1)->x + rastlc + mincl)>>1 < C->r_col)
613
613
        {                                 //����뢠��  dust-ᥪ��
614
 
          close_ds(seci,seci_add,nodei,(INT)(mincl-rastlc),(INT)(ncut-1));
 
614
          close_ds(seci,seci_add,nodei,(int16_t)(mincl-rastlc),(int16_t)(ncut-1));
615
615
          ncut++;  seci++;   seci_add++;  nodei++;
616
616
          if ( ncut==MAX_CUTS )  break;
617
617
        }
636
636
      maxcl=MAX(maxcl,C->r_col+C->w);
637
637
      nc=0;
638
638
      if ( bad(C) &&
639
 
           ( C->w > (INT)min_cut_width ||
 
639
           ( C->w > (int16_t)min_cut_width ||
640
640
             C->r_col < (seci-1)->x+rastlc ||
641
641
             C->r_col+C->w > C->nextl->r_col ) //��४�뢠���� � �ᥤﬨ
642
642
         )
643
643
      {                                        //०��
644
 
        nc=get_points(C,seci,(INT)(MAX_CUT_POINT-ncut-1));
645
 
        for ( j=(INT)ncut; j<ncut+nc; j++ )         //���४��㥬 �� ���������
 
644
        nc=get_points(C,seci,(int16_t)(MAX_CUT_POINT-ncut-1));
 
645
        for ( j=(int16_t)ncut; j<ncut+nc; j++ )         //���४��㥬 �� ���������
646
646
          cor_sect(C,&cut_list[j],rastlc,rastdr);  //cell'�� � ����
647
647
        ncut+=nc;  seci+=nc;   seci_add+=nc;  nodei+=nc;
648
648
      }
649
649
      nc=ncut-nc-1;                     //�祭�� ᫥�� �� C
650
 
      fict_sect(seci,seci_add,nodei,(INT)(C->r_col+C->w-rastlc),nc);
 
650
      fict_sect(seci,seci_add,nodei,(int16_t)(C->r_col+C->w-rastlc),nc);
651
651
      if (nc==0)
652
652
      {
653
653
        cut_list->n = C->cg_flag;          //�ਧ��� ࠧ१�
663
663
  }
664
664
  if ( dust_sect )                 //��᫥���� ᥪ�� -  dust-ᥪ��
665
665
  {
666
 
    close_ds(seci,seci_add,nodei,(INT)(maxcl-rastlc),(INT)(ncut-1));
 
666
    close_ds(seci,seci_add,nodei,(int16_t)(maxcl-rastlc),(int16_t)(ncut-1));
667
667
    ncut++;
668
668
  }
669
669
  else
710
710
      if (wide==MAXINT && seci->x>=wmin)  wide=seci->x;
711
711
      if (seci_add->vers.flg != 0)           //�ᯮ�������� - ��࠭塞
712
712
      {
713
 
        vers_list[0]->px=(INT)nodei->prev;
 
713
        vers_list[0]->px=(int16_t)nodei->prev;
714
714
        vers_list[0]->ro = (seci->n > 1) ? -1 : 0;  //�⮡� �ᯮ������� � dust'���
715
715
        memcpy(&vers_list[0]->vers,&seci_add->vers,sizeof(SVERS));
716
716
        vers_list[0]->next=vers_list[i];
723
723
  return TRUE;
724
724
}
725
725
 
726
 
static void fict_sect(CutPoint *sec, CutAdd *sec_add, GraphNode *node, INT x, INT px)
 
726
static void fict_sect(CutPoint *sec, CutAdd *sec_add, GraphNode *node, int16_t x, int16_t px)
727
727
{
728
728
  memset(sec,0,sizeof(CutPoint));
729
729
  memset(sec_add,0,sizeof(CutAdd));
732
732
  sec_add->top=sec_add->left=MAXINT;  sec_add->right=sec_add->bottom=MININT;
733
733
}
734
734
 
735
 
static void close_ds(CutPoint *sec, CutAdd *sec_add, GraphNode *node, INT x, INT px)
 
735
static void close_ds(CutPoint *sec, CutAdd *sec_add, GraphNode *node, int16_t x, int16_t px)
736
736
{
737
737
  fict_sect(sec,sec_add,node,x,px);
738
738
  set_dust(&sec_add->vers);  set_bad_vers(&sec_add->vers);
739
739
//  cut->duflr=1;
740
740
}
741
741
 
742
 
static void cor_sect(cell *C, CutPoint *cut, INT left, INT down)
 
742
static void cor_sect(cell *C, CutPoint *cut, int16_t left, int16_t down)
743
743
{
744
744
   cut->x+=C->r_col-left;
745
745
   cut->h+=down-(C->r_row+C->h-1);
746
746
}
747
747
 
748
 
static INT get_points (cell *C, CutPoint *listn, INT nmax )
 
748
static int16_t get_points (cell *C, CutPoint *listn, int16_t nmax )
749
749
{
750
750
  struct cut_elm list0[128],*li,*le;
751
 
  INT n;
752
 
  n=get_cuts(C,list0,(INT)MIN(nmax,127));
 
751
  int16_t n;
 
752
  n=get_cuts(C,list0,(int16_t)MIN(nmax,127));
753
753
  for (li=list0,le=li+n; li<le; li++,listn++)
754
754
  {
755
755
    listn->x=li->x;  listn->dh=li->dh;  listn->h=li->h;  listn->var=li->var;  listn->n=0;
766
766
  svers->nvers=cut_by_alpha(svers->nvers,svers->vers);
767
767
}
768
768
 
769
 
static INT cut_by_alpha(INT n, version vers[])
 
769
static int16_t cut_by_alpha(int16_t n, version vers[])
770
770
//remove not alphabet versions
771
771
{
772
772
  version *vo=vers,*vn=vers;
773
 
  INT i;
 
773
  int16_t i;
774
774
 
775
775
  if (n==0)
776
776
    return 0;
782
782
}
783
783
 
784
784
 
785
 
static Weight match(BYTE *word)
 
785
static Weight match(uchar *word)
786
786
{
787
 
  LONG i,l,prev=0,curh=my_bases.ps;
 
787
  int32_t i,l,prev=0,curh=my_bases.ps;
788
788
  Weight weight;
789
 
  BYTE *bt;
 
789
  uchar *bt;
790
790
  GraphNode *nodei;
791
791
 
792
792
  templ=word;
803
803
  for (l=0; templ[l] && l<256; l++)
804
804
  {
805
805
    GraphNode *layer=prev_layer;
806
 
    LONG imax,pmax=-1;
807
 
    BOOL rerecog=FALSE;
808
 
    DWORD numbers=param->monitors;
809
 
    BYTE l1=(BYTE)(l+1);
 
806
    int32_t imax,pmax=-1;
 
807
    Bool rerecog=FALSE;
 
808
    uint32_t numbers=param->monitors;
 
809
    uchar l1=(uchar)(l+1);
810
810
    if (numbers)
811
811
      do
812
812
      {
822
822
      nodei->monitors=0;
823
823
    }
824
824
 
825
 
    if (!test_set(prev,curh,(BYTE)l,RELY,rerecog,&imax,&pmax))   //first from prev
 
825
    if (!test_set(prev,curh,(uchar)l,RELY,rerecog,&imax,&pmax))   //first from prev
826
826
    {
827
 
      LONG il=prev-1,ir=prev+1;
828
 
      LONG ile=MAX(0,il-1),ire=MIN(ncut-1,ir+1);
829
 
      LONG x=cut_list[prev].x;
 
827
      int32_t il=prev-1,ir=prev+1;
 
828
      int32_t ile=MAX(0,il-1),ire=MIN(ncut-1,ir+1);
 
829
      int32_t x=cut_list[prev].x;
830
830
      while (il>=ile || ir<ire)
831
831
      {
832
 
        LONG i0;
 
832
        int32_t i0;
833
833
        if (il<ile)  i0=ir++;
834
834
        else
835
835
        if (ir>ire)  i0=il--;
836
836
        else
837
837
        if (x-cut_list[il].x < cut_list[ir].x-x)  i0=il--;
838
838
        else                                      i0=ir++;
839
 
        if (test_set(i0,curh,(BYTE)l,RELY,rerecog,&imax,&pmax))  break;
 
839
        if (test_set(i0,curh,(uchar)l,RELY,rerecog,&imax,&pmax))  break;
840
840
      }
841
841
    }
842
842
    if (pmax<0)
852
852
  else
853
853
  {
854
854
    if (param->monitors)
855
 
      param->monitors=(LONG)prev_layer[prev].monitors;
 
855
      param->monitors=(int32_t)prev_layer[prev].monitors;
856
856
    weight=prev_layer[prev].weight;
857
 
    for (i=0,bt=(BYTE *)&weight.meas; i<3; i++,bt++)  *bt=255-(*bt);
 
857
    for (i=0,bt=(uchar *)&weight.meas; i<3; i++,bt++)  *bt=255-(*bt);
858
858
  }
859
859
  return  weight;
860
860
}
861
861
 
862
 
static BOOL test_set(LONG prev, LONG h0, BYTE nlet, LONG tol, BOOL rerecog, LONG *imax, LONG *pmax)
 
862
static Bool test_set(int32_t prev, int32_t h0, uchar nlet, int32_t tol, Bool rerecog, int32_t *imax, int32_t *pmax)
863
863
{
864
 
  BYTE let=templ[nlet];
 
864
  uchar let=templ[nlet];
865
865
  CutPoint *cut,*cute=cut_list+ncut,*cutr,*cutl;
866
 
  LONG let2=let*2;
867
 
  LONG prmin=letters_pidx_table[let2],prmax=letters_pidx_table[let2+1],pr=(prmin+prmax)/2;
868
 
  LONG w0 = (pr<=64) ? pr*h0/64 : h0*64/(128-pr);
869
 
  LONG xb=cut_list[prev].x,x0=xb+w0;
870
 
  LONG set,cc;
871
 
  LONG  il,ir;
872
 
  BYTE p;
873
 
  BOOL rv=FALSE;
 
866
  int32_t let2=let*2;
 
867
  int32_t prmin=letters_pidx_table[let2],prmax=letters_pidx_table[let2+1],pr=(prmin+prmax)/2;
 
868
  int32_t w0 = (pr<=64) ? pr*h0/64 : h0*64/(128-pr);
 
869
  int32_t xb=cut_list[prev].x,x0=xb+w0;
 
870
  int32_t set,cc;
 
871
  int32_t  il,ir;
 
872
  uchar p;
 
873
  Bool rv=FALSE;
874
874
 
875
875
//  set_user_alphbet(alpha);
876
876
 
879
879
  for (set=1; set<=4; set++)
880
880
  {
881
881
  //���� ࠧ१ �� ����ﭨ� ����� w0 ����� ᬥ頥��� � ��� ��஭�
882
 
    LONG i=prev+1; cut=cut_list+i; il=ir=-128;
 
882
    int32_t i=prev+1; cut=cut_list+i; il=ir=-128;
883
883
    while (cut<cute)
884
884
    {
885
 
      BYTE var=cut->var & 0x7F;
 
885
      uchar var=cut->var & 0x7F;
886
886
      if (cut->x > xb && in_set(var,set))
887
887
        if(cut->x <= x0)  { il=i;  cutl=cut; }
888
888
        else              { ir=i;  cutr=cut; break; }
943
943
  return rv;
944
944
}
945
945
 
946
 
static LONG inc(CutPoint **cutp, LONG i, LONG ie, LONG set)
 
946
static int32_t inc(CutPoint **cutp, int32_t i, int32_t ie, int32_t set)
947
947
{
948
948
  if (i>=ie) return -128;
949
949
  (*cutp)++; i++;
950
950
  while (1)
951
951
  {
952
 
    CHAR var=(*cutp)->var & 0x7F;
 
952
    char var=(*cutp)->var & 0x7F;
953
953
    if (i==ie || in_set(var,set))  return i;
954
954
    (*cutp)++; i++;
955
955
  }
956
956
  return -128;
957
957
}
958
958
 
959
 
static LONG dec(CutPoint **cutp, LONG i, LONG ie, LONG set)
 
959
static int32_t dec(CutPoint **cutp, int32_t i, int32_t ie, int32_t set)
960
960
{
961
961
  if (i<=ie) return -128;
962
962
  (*cutp)--; i--;
963
963
  while (1)
964
964
  {
965
 
    CHAR var=(*cutp)->var & 0x7F;
 
965
    char var=(*cutp)->var & 0x7F;
966
966
    if (i==ie || in_set(var,set))  return i;
967
967
    (*cutp)--; i--;
968
968
  }
969
969
  return -128;
970
970
}
971
971
 
972
 
static LONG add_sect(LONG il, LONG ir, BYTE nlet, BOOL rerecog, BYTE *p)
 
972
static int32_t add_sect(int32_t il, int32_t ir, uchar nlet, Bool rerecog, uchar *p)
973
973
{
974
 
  BYTE let=templ[nlet];
 
974
  uchar let=templ[nlet];
975
975
  version *v;
976
976
  void *kit;       //㪠��⥫� �⥪� kit
977
977
  cell *cells[MAX_CUTS];
978
978
  cell **cp,*lc;
979
979
  CutPoint *cutl=cut_list+il,*cutr=cut_list+ir;
980
 
  LONG xl=cutl->x,xr=cutr->x;
981
 
  LONG dh;
982
 
  LONG n;
983
 
  BYTE cut_fl = (( cutl->dh != 0 ) ? c_cg_cutl : 0) +
 
980
  int32_t xl=cutl->x,xr=cutr->x;
 
981
  int32_t dh;
 
982
  int32_t n;
 
983
  uchar cut_fl = (( cutl->dh != 0 ) ? c_cg_cutl : 0) +
984
984
                 (( cutr->dh != 0 ) ? c_cg_cutr : 0);
985
 
  BYTE left_let=0;
 
985
  uchar left_let=0;
986
986
  SVERS vers;      //���ᨨ ᥣ���� (i1,i0)
987
 
  INT width;       //��� �ਭ�
988
 
  Int8  gvar;       //ᯮᮡ ᡮન
 
987
  int16_t width;       //��� �ਭ�
 
988
  char  gvar;       //ᯮᮡ ᡮન
989
989
#define ROI_LEN 4
990
 
  INT ro,roi[ROI_LEN]; //ro � ��� ��⠢���騥
 
990
  int16_t ro,roi[ROI_LEN]; //ro � ��� ��⠢���騥
991
991
  Weight wp=prev_layer[il].weight,wc=cur_layer[ir].weight,wt;
992
 
  BOOL change=TRUE;
 
992
  Bool change=TRUE;
993
993
  seg_vers *cur_vers;
994
994
 
995
995
  if (xr-xl-1 < wmin)
1001
1001
//�饬 �।� ࠭�� �ᯮ�������
1002
1002
 
1003
1003
  if (!rerecog)
1004
 
    if ( cur_vers=find_vers((INT)il,(INT)ir,vers_list) )
 
1004
    if ( cur_vers=find_vers((int16_t)il,(int16_t)ir,vers_list) )
1005
1005
    {
1006
1006
      if (v=find_in_vers(&cur_vers->vers,let))
1007
1007
      {
1043
1043
         )
1044
1044
  {
1045
1045
    left_let=lc->vers[0].let;
1046
 
    lc->vers[0].let=(BYTE)'�';
 
1046
    lc->vers[0].let=(uchar)'�';
1047
1047
  }
1048
1048
 
1049
1049
  memset(&vers,0,sizeof(SVERS));
1050
 
  ro=recogij(lc,cells,(INT)n,cut_fl,0,com_inc,roi,&gvar,&vers,&width);
 
1050
  ro=recogij(lc,cells,(int16_t)n,cut_fl,0,com_inc,roi,&gvar,&vers,&width);
1051
1051
  take_kit_addr(kit);
1052
1052
  if (left_let) lc->vers[0].let=left_let;
1053
1053
//  vers.nvers=cut_by_alpha(vers.nvers,vers.vers);
1058
1058
  ro = MAX_RO-(*p);
1059
1059
//  wt = (wp & ~0xFF) + ro;
1060
1060
//  wt = MAX(wt,wp);
1061
 
  wt = add_weight(&wp,(BYTE)ro,nlet);
 
1061
  wt = add_weight(&wp,(uchar)ro,nlet);
1062
1062
  if (wc.meas<0 || wc.meas>wt.meas)
1063
1063
  {
1064
 
    wc=wt;  cur_layer[ir].prev=(WORD)il;  add_monitors(il,ir,(BYTE)(nlet+1),(*p));
 
1064
    wc=wt;  cur_layer[ir].prev=(uint16_t)il;  add_monitors(il,ir,(uchar)(nlet+1),(*p));
1065
1065
  }
1066
1066
  else
1067
1067
    change=FALSE;
1071
1071
  if (change)
1072
1072
    if (debug_on && det_trace)
1073
1073
    {
1074
 
      BYTE msg[80];
1075
 
      LONG wpm=wp.meas,wcm=wc.meas;
 
1074
      uchar msg[80];
 
1075
      int32_t wpm=wp.meas,wcm=wc.meas;
1076
1076
 
1077
1077
      sprintf(msg,"%c p=%d (%d) %d %d %d (%d) %d %d %d\n",let,*p,
1078
1078
              il,wpm>>16,(wpm>>8)&0xFF,wpm&0xFF,ir,wcm>>16,(wcm>>8)&0xFF,wcm&0xFF);
1087
1087
  return 0;
1088
1088
}
1089
1089
 
1090
 
static version *find_in_vers(SVERS *svers, BYTE let)
 
1090
static version *find_in_vers(SVERS *svers, uchar let)
1091
1091
{
1092
1092
  version *v=&svers->vers[0];
1093
 
  LONG i;
 
1093
  int32_t i;
1094
1094
  for (i=0; i<svers->nvers; i++,v++)
1095
1095
    if (equal(v->let,let))
1096
1096
      return v;
1097
1097
  return NULL;
1098
1098
}
1099
1099
 
1100
 
static BOOL equal(BYTE let1, BYTE let2)
 
1100
static Bool equal(uchar let1, uchar let2)
1101
1101
{
1102
1102
  if (let1==let2)
1103
1103
    return TRUE;
1104
1104
  else
1105
1105
  {
1106
 
    LONG offset=eq_let[let1];
 
1106
    int32_t offset=eq_let[let1];
1107
1107
    if (offset<0)
1108
1108
      return FALSE;
1109
1109
    return strchr(eq_list.d+offset,let2) != 0;
1112
1112
 
1113
1113
 
1114
1114
 
1115
 
static LONG select_cells(LONG il, LONG ir, BYTE cut_fl, cell **cells)
 
1115
static int32_t select_cells(int32_t il, int32_t ir, uchar cut_fl, cell **cells)
1116
1116
{
1117
 
  LONG i;
 
1117
  int32_t i;
1118
1118
  cell *CI=cell_f();
1119
 
  INT minrow=my_bases.b2;
 
1119
  int16_t minrow=my_bases.b2;
1120
1120
  CutPoint *cuti;
1121
 
  BYTE csv[32];       //��ࠬ���� �祭��
 
1121
  uchar csv[32];       //��ࠬ���� �祭��
1122
1122
  cut_pos    cpos={0};
1123
1123
  struct cut_elm  cutl,cutr;
1124
 
  LONG xl=cut_list[il].x,xr=cut_list[ir].x;
1125
 
  LONG xla=str_raster.left+xl,xra=str_raster.left+xr;
1126
 
  BYTE seg_rast[RASTER_WIDTH*RASTER_HEIGHT/8],*sr=seg_rast,*wr;
1127
 
  LONG rwb,wwb=(str_raster.w+7)/8;
1128
 
  LONG beg=(LONG)xl/8-1,end=(LONG)(xr+7)/8+1;
1129
 
  LONG row,col;
 
1124
  int32_t xl=cut_list[il].x,xr=cut_list[ir].x;
 
1125
  int32_t xla=str_raster.left+xl,xra=str_raster.left+xr;
 
1126
  uchar seg_rast[RASTER_WIDTH*RASTER_HEIGHT/8],*sr=seg_rast,*wr;
 
1127
  int32_t rwb,wwb=(str_raster.w+7)/8;
 
1128
  int32_t beg=(int32_t)xl/8-1,end=(int32_t)(xr+7)/8+1;
 
1129
  int32_t row,col;
1130
1130
  MN *mn;
1131
1131
  beg=MAX(0,beg);  end=MIN(end,wwb-1);
1132
1132
  rwb=end-beg+1;
1144
1144
 
1145
1145
  cuti=cut_list+il;
1146
1146
  cutl.x=xl-beg*8;  cutl.dh=cuti->dh;  cutl.h=cuti->h;  cutl.var=cuti->var;
1147
 
  mn=cut_rast(seg_rast,(INT)(rwb*8),(INT)str_raster.h,(INT)str_raster.top,(INT)(str_raster.left+beg*8),
 
1147
  mn=cut_rast(seg_rast,(int16_t)(rwb*8),(int16_t)str_raster.h,(int16_t)str_raster.top,(int16_t)(str_raster.left+beg*8),
1148
1148
              &cutl,0,1,csv,&cpos);
1149
1149
  cuti=cut_list+ir;
1150
1150
  cutr.x=xr-beg*8;  cutr.dh=cuti->dh;  cutr.h=cuti->h;  cutr.var=cuti->var;
1151
 
  mn=cut_rast(seg_rast,(INT)(rwb*8),(INT)str_raster.h,(INT)str_raster.top,(INT)(str_raster.left+beg*8),
 
1151
  mn=cut_rast(seg_rast,(int16_t)(rwb*8),(int16_t)str_raster.h,(int16_t)str_raster.top,(int16_t)(str_raster.left+beg*8),
1152
1152
              &cutr,0,2,csv,&cpos);
1153
1153
 
1154
1154
  for ( i=0; i<MAX_CUTS-1 && mn; i++ )
1178
1178
  return my_bases.b3-minrow;
1179
1179
}
1180
1180
 
1181
 
static Weight add_weight(Weight *w0, BYTE ro, BYTE nlet)
 
1181
static Weight add_weight(Weight *w0, uchar ro, uchar nlet)
1182
1182
{
1183
1183
  Weight wp=*w0;
1184
 
  BYTE *wi=(BYTE *)&wp.meas,*li=(BYTE *)&wp.nlet;
 
1184
  uchar *wi=(uchar *)&wp.meas,*li=(uchar *)&wp.nlet;
1185
1185
 
1186
1186
  if (ro > *wi)
1187
1187
  {
1188
 
    LONG i;
1189
 
    BYTE *w1=wi+1,*l1=li+1;
 
1188
    int32_t i;
 
1189
    uchar *w1=wi+1,*l1=li+1;
1190
1190
    *wi=ro;  *li=nlet;
1191
1191
    for (i=0; i<2; i++,wi++,w1++,li++,l1++)
1192
1192
      if (*wi > *w1)
1193
1193
      {
1194
 
        BYTE t=*w1;  *w1=*wi;  *wi=t;
 
1194
        uchar t=*w1;  *w1=*wi;  *wi=t;
1195
1195
             t=*l1;  *l1=*li;  *li=t;
1196
1196
      }
1197
1197
      else
1200
1200
  return wp;
1201
1201
}
1202
1202
 
1203
 
static void add_monitors(LONG il, LONG ir, BYTE nlet, BYTE pb)
 
1203
static void add_monitors(int32_t il, int32_t ir, uchar nlet, uchar pb)
1204
1204
{
1205
 
  DWORD numbers=param->monitors;
 
1205
  uint32_t numbers=param->monitors;
1206
1206
  if (numbers)
1207
1207
  {
1208
 
    DWORD monitors=prev_layer[il].monitors,p=pb;
 
1208
    uint32_t monitors=prev_layer[il].monitors,p=pb;
1209
1209
    do
1210
1210
    {
1211
1211
      if ((numbers & 0xFF)==nlet)
1234
1234
{
1235
1235
  raster r;
1236
1236
  struct cut_elm cut_el[MAX_CUTS];
1237
 
  LONG i;
 
1237
  int32_t i;
1238
1238
  cell *c=cell_f()->next;
1239
1239
 
1240
1240
  if (str_raster.w>128 || str_raster.h>64)
1241
1241
  {
1242
 
    Word32 key=1;
 
1242
    uint32_t key=1;
1243
1243
    for (i=1; i<ncut-1; i++)
1244
1244
    {
1245
1245
      Point16 vh,vl;
1246
 
      vh.y=(Int16)str_raster.top;  vl.y=(Int16)(str_raster.top+str_raster.h);
1247
 
      vh.x=vl.x=(Int16)(str_raster.left+cut_list[i].x);
 
1246
      vh.y=(int16_t)str_raster.top;  vl.y=(int16_t)(str_raster.top+str_raster.h);
 
1247
      vh.x=vl.x=(int16_t)(str_raster.left+cut_list[i].x);
1248
1248
      LDPUMA_DrawLine(NULL,&vh,&vl,0,wRGB(255,0,0),1,key);
1249
1249
    }
1250
1250
    glsnap('a',c,"raster too big to show");
1252
1252
    return;
1253
1253
  }
1254
1254
 
1255
 
  r.top =(INT)str_raster.top;   r.w=(INT)str_raster.w;
1256
 
  r.left=(INT)str_raster.left;  r.h=(INT)str_raster.h;
 
1255
  r.top =(int16_t)str_raster.top;   r.w=(int16_t)str_raster.w;
 
1256
  r.left=(int16_t)str_raster.left;  r.h=(int16_t)str_raster.h;
1257
1257
  memcpy(&r.pict,&str_raster.pict,str_raster.h*(str_raster.w+7)/8);
1258
1258
 
1259
1259
  for (i=0; i<ncut; i++)
1260
1260
  {
1261
1261
    struct cut_elm *ce=cut_el+i;
1262
1262
    CutPoint *cp=cut_list+i;
1263
 
    ce->x  =(CHAR)cp->x;
1264
 
    ce->dh =(CHAR)cp->dh;
1265
 
    ce->h  =(CHAR)cp->h;
1266
 
    ce->var=(CHAR)cp->var;
 
1263
    ce->x  =(char)cp->x;
 
1264
    ce->dh =(char)cp->dh;
 
1265
    ce->h  =(char)cp->h;
 
1266
    ce->var=(char)cp->var;
1267
1267
  }
1268
1268
  cut_el[ncut].x=127;
1269
1269
 
1270
1270
  cg_show_rast(c,&r,"",cut_el);
1271
1271
}
1272
1272
 
1273
 
static void show_layer(BYTE let, LONG prev, LONG imax)
 
1273
static void show_layer(uchar let, int32_t prev, int32_t imax)
1274
1274
{
1275
1275
  char msg[600],*s=msg;
1276
1276
  GraphNode *layer=prev_layer;
1277
 
  LONG i2=imax+3,i1,i,j,shift;
 
1277
  int32_t i2=imax+3,i1,i,j,shift;
1278
1278
  i2=MIN(i2,ncut-1);
1279
1279
  i1=i2-15;  i1=MAX(i1,0);
1280
1280
 
1288
1288
    {
1289
1289
      for (i=i1; i<=i2; i++)
1290
1290
      {
1291
 
        LONG w=layer[i].weight.meas;
 
1291
        int32_t w=layer[i].weight.meas;
1292
1292
        if (w>0) w = (w>>shift) & 0xFF;
1293
1293
        s += sprintf(s,"%4d",w);
1294
1294
      }
1302
1302
 
1303
1303
#ifdef MATCH_WORD
1304
1304
 
1305
 
void myCharToOem(Word8 ansi[], Word8 ascii[]);
 
1305
void myCharToOem(uchar ansi[], uchar ascii[]);
1306
1306
 
1307
 
void test_match_cell_word(B_LINES *my_bases, INT cut_width)
 
1307
void test_match_cell_word(B_LINES *my_bases, int16_t cut_width)
1308
1308
{
1309
 
  BYTE *e,*b,msg[36];
1310
 
  INT col1=-10000,col2=-10000;
 
1309
  uchar *e,*b,msg[36];
 
1310
  int16_t col1=-10000,col2=-10000;
1311
1311
  Weight match;
1312
 
  LONG m,n;
 
1312
  int32_t m,n;
1313
1313
  cell *wb=cell_f()->next,*we;
1314
1314
  MatchWordPar  param;
1315
 
  CHAR wascii[80];
1316
 
  DWORD mon;
 
1315
  char wascii[80];
 
1316
  uint32_t mon;
1317
1317
 
1318
1318
  strcpy(mwInput,"");
1319
1319
  glsnap('a',wb,"match_word: input col for begin and last cell and string");