ruby_rnv 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/ext/rnv/src/rx.h CHANGED
@@ -19,16 +19,15 @@
19
19
  #define RX_ER_DNUOB 10
20
20
  #define RX_ER_NOTRC 11
21
21
 
22
- //extern void (*rx_verror_handler)(int erno,va_list ap);
23
- //extern int rx_compact;
24
-
25
- extern void rx_default_verror_handler(rnv_t *rnv, int erno,va_list ap);
22
+ extern void rx_default_verror_handler(void *data, int erno, int (*handler)(void *data, int erno,char *format, va_list ap), va_list ap);
26
23
 
27
24
  extern void rx_init(rx_st_t *rx_st);
28
25
  extern void rx_clear(rx_st_t *rx_st);
29
26
 
27
+ extern void rx_dispose(rx_st_t *rx_st);
28
+
30
29
  /* just compiles the expression to check the syntax */
31
- extern int rx_check(rnv_t *rnv, rx_st_t *rx_st, char *rx);
30
+ extern int rx_check(rx_st_t *rx_st, char *rx);
32
31
 
33
32
  /*
34
33
  returns positive value if the s[0..n] ~= rx, 0 if not, -1 on regex error;
@@ -36,8 +35,8 @@ extern int rx_check(rnv_t *rnv, rx_st_t *rx_st, char *rx);
36
35
  rmatch replaces white space in s with 0x20,
37
36
  cmatch collapses white space.
38
37
  */
39
- extern int rx_match(rnv_t *rnv, rx_st_t *rx_st, char *rx,char *s,int n);
40
- extern int rx_rmatch(rnv_t *rnv, rx_st_t *rx_st, char *rx,char *s,int n);
41
- extern int rx_cmatch(rnv_t *rnv, rx_st_t *rx_st, char *rx,char *s,int n);
38
+ extern int rx_match(rx_st_t *rx_st, char *rx,char *s,int n);
39
+ extern int rx_rmatch(rx_st_t *rx_st, char *rx,char *s,int n);
40
+ extern int rx_cmatch(rx_st_t *rx_st, char *rx,char *s,int n);
42
41
 
43
42
  #endif
data/ext/rnv/src/sc.c CHANGED
@@ -1,5 +1,6 @@
1
1
  /* $Id: sc.c,v 1.16 2004/03/13 13:28:02 dvd Exp $ */
2
2
 
3
+ #include <stdlib.h> /*NULL*/
3
4
  #include <assert.h> /*assert*/
4
5
  #include "m.h"
5
6
  #include "ll.h"
@@ -20,6 +21,10 @@ void sc_init(struct sc_stack *stp) {
20
21
  windup(stp);
21
22
  }
22
23
 
24
+ void sc_dispose(struct sc_stack *stp) {
25
+ m_free(stp->tab); stp->tab = NULL;
26
+ }
27
+
23
28
  void sc_clear(struct sc_stack *stp) {
24
29
  windup(stp);
25
30
  }
data/ext/rnv/src/sc.h CHANGED
@@ -12,6 +12,7 @@ struct sc_stack {
12
12
 
13
13
  extern void sc_init(struct sc_stack *stp);
14
14
  extern void sc_clear(struct sc_stack *stp);
15
+ extern void sc_dispose(struct sc_stack *stp);
15
16
 
16
17
  extern void sc_open(struct sc_stack *stp);
17
18
  extern void sc_lock(struct sc_stack *stp);
data/ext/rnv/src/type.h CHANGED
@@ -20,14 +20,54 @@ typedef struct rn_st
20
20
  int len_nc;
21
21
  int len_s;
22
22
  int adding_ps;
23
+
23
24
  } rn_st_t;
24
25
 
26
+ struct rnc_cym {
27
+ char *s; int slen;
28
+ int line,col;
29
+ int sym;
30
+ };
31
+
32
+ struct rnc_source {
33
+ int flags;
34
+ char *fn; int fd;
35
+ char *buf; int i,n;
36
+ int complete;
37
+ int line,col,prevline/*when error reported*/;
38
+ int u,v,w; int nx;
39
+ int cur;
40
+ struct rnc_cym sym[2];
41
+
42
+ int (*verror_handler)(void *data, int erno, char *format, va_list ap);
43
+ void *user_data;
44
+ };
45
+
46
+ typedef struct rnc_st
47
+ {
48
+ int len_p;
49
+ char *path;
50
+ struct sc_stack nss;
51
+ struct sc_stack dts;
52
+ struct sc_stack defs;
53
+ struct sc_stack refs;
54
+ struct sc_stack prefs;
55
+
56
+ int (*verror_handler)(void *data, int erno, char *format, va_list ap);
57
+ void *user_data;
58
+
59
+ } rnc_st_t;
60
+
25
61
  typedef struct rnd_st
26
62
  {
27
63
  int len_f;
28
64
  int n_f;
29
65
  int *flat;
30
66
  int errors;
67
+
68
+ int (*verror_handler)(void *data, int erno, char *format, va_list ap);
69
+ void *user_data;
70
+
31
71
  } rnd_st_t;
32
72
 
33
73
  typedef struct rnv rnv_t;
@@ -58,25 +98,12 @@ typedef struct rx_st
58
98
  int (*memo)[3];
59
99
  int (*r2p)[2];
60
100
 
61
- // FIXME: for error handlers
62
- rnv_t *rnv;
63
- } rx_st_t;
101
+ int rx_compact;
64
102
 
65
- typedef struct rnx_st
66
- {
67
- int len_exp;
68
- } rnx_st_t;
103
+ int (*verror_handler)(void *data, int erno, char *format, va_list ap);
104
+ void *user_data;
69
105
 
70
- typedef struct rnc_st
71
- {
72
- int len_p;
73
- char *path;
74
- struct sc_stack nss;
75
- struct sc_stack dts;
76
- struct sc_stack defs;
77
- struct sc_stack refs;
78
- struct sc_stack prefs;
79
- } rnc_st_t;
106
+ } rx_st_t;
80
107
 
81
108
  typedef struct drv_st
82
109
  {
@@ -87,6 +114,12 @@ typedef struct drv_st
87
114
  int len_m;
88
115
  struct hashtable ht_m;
89
116
  int (*memo)[5];
117
+
118
+ int drv_compact;
119
+
120
+ int (*verror_handler)(void *data, int erno, char *format, va_list ap);
121
+ void *user_data;
122
+
90
123
  } drv_st_t;
91
124
 
92
125
  typedef struct rnv
@@ -100,22 +133,13 @@ typedef struct rnv
100
133
  int rn_dt_string;
101
134
  int rn_dt_token;
102
135
  int rn_xsd_uri;
103
- int rx_compact;
136
+
104
137
  int rnx_n_exp;
105
138
  int *rnx_exp;
106
- int drv_compact;
107
-
108
- int (*verror_handler)(rnv_t *rnv, int erno, char *format,va_list ap);
109
- void (*drv_verror_handler)(rnv_t *rnv, int erno, va_list ap);
110
- void (*rnc_verror_handler)(rnv_t *rnv, int erno, va_list ap);
111
- void (*rnd_verror_handler)(rnv_t *rnv, int erno, va_list ap);
112
- void (*rnl_verror_handler)(rnv_t *rnv, int erno, va_list ap);
113
- void (*rnv_verror_handler)(rnv_t *rnv, int erno, va_list ap);
114
- void (*rx_verror_handler)(rnv_t *rnv, int erno, va_list ap);
115
- void (*xsd_verror_handler)(rnv_t *rnv, int erno, va_list ap);
139
+ int rnx_len_exp;
116
140
 
141
+ int (*verror_handler)(void *data, int erno, char *format,va_list ap);
117
142
  void *user_data;
118
-
119
143
  } rnv_t;
120
144
 
121
145
  #endif // TYPE_H
data/ext/rnv/src/xcl.c CHANGED
@@ -68,7 +68,7 @@ static int mixed = 0;
68
68
  static char *xgfile = NULL, *xgpos = NULL;
69
69
 
70
70
  #define err(msg) (*rnv->verror_handler)(rnv,erno,msg "\n", ap);
71
- static void verror_handler(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, int erno, va_list ap)
71
+ static void verror_handler(rnv_t *rnv, xcl_st_t *xcl_st, int erno, va_list ap)
72
72
  {
73
73
  if (erno & ERBIT_RNL)
74
74
  {
@@ -94,7 +94,7 @@ static void verror_handler(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, int e
94
94
  char *s;
95
95
  while (req--)
96
96
  {
97
- rnx_expected(rnv, rnx_st, xcl_st->previous, req);
97
+ rnx_expected(rnv, xcl_st->previous, req);
98
98
  if (i == rnv->rnx_n_exp)
99
99
  continue;
100
100
  if (rnv->rnx_n_exp > xcl_st->nexp)
@@ -129,18 +129,18 @@ static void verror_handler(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, int e
129
129
  }
130
130
  }
131
131
 
132
- static void verror_handler_rnl(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, int erno, va_list ap) { verror_handler(rnv, xcl_st, rnx_st, erno | ERBIT_RNL, ap); }
133
- static void verror_handler_rnv(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, int erno, va_list ap) { verror_handler(rnv, xcl_st, rnx_st, erno | ERBIT_RNV, ap); }
132
+ static void verror_handler_rnl(rnv_t *rnv, xcl_st_t *xcl_st, int erno, va_list ap) { verror_handler(rnv, xcl_st, erno | ERBIT_RNL, ap); }
133
+ static void verror_handler_rnv(rnv_t *rnv, xcl_st_t *xcl_st, int erno, va_list ap) { verror_handler(rnv, xcl_st, erno | ERBIT_RNV, ap); }
134
134
 
135
135
  static void windup(xcl_st_t *xcl_st);
136
- static void init(rnv_t *rnv, xcl_st_t *xcl_st, rn_st_t *rn_st, rnd_st_t *rnd_st, rnc_st_t *rnc_st, rnx_st_t *rnx_st, drv_st_t *drv_st, rx_st_t *rx_st)
136
+ static void init(rnv_t *rnv, xcl_st_t *xcl_st, rn_st_t *rn_st, rnc_st_t *rnc_st, rnd_st_t *rnd_st, drv_st_t *drv_st, rx_st_t *rx_st)
137
137
  {
138
138
  rnv->verror_handler=&verror_default_handler;
139
- rnl_init(rnv, rn_st, rnd_st, rnc_st);
139
+ rnl_init(rnv, rnc_st, rn_st, rnd_st);
140
140
  //rnl_verror_handler = &verror_handler_rnl;
141
141
  rnv_init(rnv, drv_st, rn_st, rx_st);
142
142
  //rnv_verror_handler = &verror_handler_rnv;
143
- rnx_init(rnv, rnx_st);
143
+ rnx_init(rnv);
144
144
  xcl_st->text = (char *)m_alloc(xcl_st->len_txt = LEN_T, sizeof(char));
145
145
  windup(xcl_st);
146
146
  }
@@ -162,11 +162,11 @@ static void windup(xcl_st_t *xcl_st)
162
162
  xcl_st->lastline = xcl_st->lastcol = -1;
163
163
  }
164
164
 
165
- static void error_handler(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, int erno, ...)
165
+ static void error_handler(rnv_t *rnv, xcl_st_t *xcl_st, int erno, ...)
166
166
  {
167
167
  va_list ap;
168
168
  va_start(ap, erno);
169
- verror_handler(rnv, xcl_st, rnx_st, erno, ap);
169
+ verror_handler(rnv, xcl_st, erno, ap);
170
170
  va_end(ap);
171
171
  }
172
172
 
@@ -258,14 +258,14 @@ static void processingInstruction(void *userData,
258
258
  }
259
259
  }
260
260
 
261
- static int pipeout(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, void *buf, int len)
261
+ static int pipeout(rnv_t *rnv, xcl_st_t *xcl_st, void *buf, int len)
262
262
  {
263
263
  int ofs = 0, iw, lenw = len;
264
264
  for (;;)
265
265
  {
266
266
  if ((iw = write(1, (char *)buf + ofs, lenw)) == -1)
267
267
  {
268
- error_handler(rnv, xcl_st, rnx_st, XCL_ER_IO, strerror(errno));
268
+ error_handler(rnv, xcl_st, XCL_ER_IO, strerror(errno));
269
269
  return 0;
270
270
  }
271
271
  ofs += iw;
@@ -275,7 +275,7 @@ static int pipeout(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, void *buf, in
275
275
  }
276
276
  }
277
277
 
278
- static int process(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, int fd)
278
+ static int process(rnv_t *rnv, xcl_st_t *xcl_st, int fd)
279
279
  {
280
280
  void *buf;
281
281
  int len;
@@ -285,11 +285,11 @@ static int process(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, int fd)
285
285
  len = read(fd, buf, BUFSIZE);
286
286
  if (len < 0)
287
287
  {
288
- error_handler(rnv, xcl_st, rnx_st, XCL_ER_IO, xcl_st->xml, strerror(errno));
288
+ error_handler(rnv, xcl_st, XCL_ER_IO, xcl_st->xml, strerror(errno));
289
289
  goto ERROR;
290
290
  }
291
291
  if (xcl_st->peipe)
292
- xcl_st->peipe = xcl_st->peipe && pipeout(rnv, xcl_st, rnx_st, buf, len);
292
+ xcl_st->peipe = xcl_st->peipe && pipeout(rnv, xcl_st, buf, len);
293
293
  if (!XML_ParseBuffer(expat, len, len == 0))
294
294
  goto PARSE_ERROR;
295
295
  if (len == 0)
@@ -298,9 +298,9 @@ static int process(rnv_t *rnv, xcl_st_t *xcl_st, rnx_st_t *rnx_st, int fd)
298
298
  return xcl_st->ok;
299
299
 
300
300
  PARSE_ERROR:
301
- error_handler(rnv, xcl_st, rnx_st, XCL_ER_XML, XML_ErrorString(XML_GetErrorCode(expat)));
301
+ error_handler(rnv, xcl_st, XCL_ER_XML, XML_ErrorString(XML_GetErrorCode(expat)));
302
302
  while (xcl_st->peipe && (len = read(fd, buf, BUFSIZE)) != 0)
303
- xcl_st->peipe = xcl_st->peipe && pipeout(rnv, xcl_st, rnx_st, buf, len);
303
+ xcl_st->peipe = xcl_st->peipe && pipeout(rnv, xcl_st, buf, len);
304
304
  ERROR:
305
305
  return 0;
306
306
  }
@@ -308,11 +308,11 @@ ERROR:
308
308
  static int externalEntityRef(XML_Parser p, const char *context,
309
309
  const char *base, const char *systemId, const char *publicId)
310
310
  {
311
- //error_handler(rnv, xcl_st, rnx_st, XCL_ER_XENT);
311
+ //error_handler(rnv, xcl_st, XCL_ER_XENT);
312
312
  return 1;
313
313
  }
314
314
 
315
- static void validate(rnv_t *rnv, xcl_st_t *xcl_st, drv_st_t *drv_st, rn_st_t *rn_st, rnx_st_t *rnx_st, int fd)
315
+ static void validate(rnv_t *rnv, xcl_st_t *xcl_st, drv_st_t *drv_st, rn_st_t *rn_st, int fd)
316
316
  {
317
317
  xcl_st->previous = xcl_st->current = xcl_st->start;
318
318
  expat = XML_ParserCreateNS(NULL, ':');
@@ -322,7 +322,7 @@ static void validate(rnv_t *rnv, xcl_st_t *xcl_st, drv_st_t *drv_st, rn_st_t *rn
322
322
  XML_SetExternalEntityRefHandler(expat, &externalEntityRef);
323
323
  XML_SetProcessingInstructionHandler(expat, &processingInstruction);
324
324
  XML_SetUserData(expat, xcl_st);
325
- xcl_st->ok = process(rnv, xcl_st, rnx_st, fd);
325
+ xcl_st->ok = process(rnv, xcl_st, fd);
326
326
  XML_ParserFree(expat);
327
327
  }
328
328
 
@@ -334,7 +334,6 @@ int main(int argc, char **argv)
334
334
  rnv_t *rnv;
335
335
  rn_st_t *rn_st;
336
336
  rnc_st_t *rnc_st;
337
- rnx_st_t *rnx_st;
338
337
  drv_st_t *drv_st;
339
338
  rx_st_t *rx_st;
340
339
  rnd_st_t *rnd_st;
@@ -343,7 +342,6 @@ int main(int argc, char **argv)
343
342
  rnv = malloc(sizeof(rnv_t));
344
343
  rn_st = malloc(sizeof(rn_st_t));
345
344
  rnc_st = malloc(sizeof(rnc_st_t));
346
- rnx_st = malloc(sizeof(rnx_st_t));
347
345
  drv_st = malloc(sizeof(drv_st_t));
348
346
  rx_st = malloc(sizeof(rx_st_t));
349
347
  rnd_st = malloc(sizeof(rnd_st_t));
@@ -354,7 +352,7 @@ int main(int argc, char **argv)
354
352
  xcl_st->rn_st = rn_st;
355
353
  xcl_st->rx_st = rx_st;
356
354
 
357
- init(rnv, xcl_st, rn_st, rnc_st, rnd_st, rnx_st, drv_st, rx_st);
355
+ init(rnv, xcl_st, rn_st, rnc_st, rnd_st, drv_st, rx_st);
358
356
 
359
357
  xcl_st->peipe = 0;
360
358
  xcl_st->verbose = 1;
@@ -378,8 +376,8 @@ int main(int argc, char **argv)
378
376
  xcl_st->nexp = atoi(*(++argv));
379
377
  goto END_OF_OPTIONS;
380
378
  case 's':
381
- rnv->drv_compact = 1;
382
- rnv->rx_compact = 1;
379
+ drv_st->drv_compact = 1;
380
+ rx_st->rx_compact = 1;
383
381
  break;
384
382
  case 'p':
385
383
  xcl_st->peipe = 1;
@@ -439,7 +437,7 @@ int main(int argc, char **argv)
439
437
  }
440
438
  if (xcl_st->verbose)
441
439
  (*er_printf)("%s\n", xcl_st->xml);
442
- validate(rnv, xcl_st, drv_st, rn_st, rnx_st, fd);
440
+ validate(rnv, xcl_st, drv_st, rn_st, fd);
443
441
  close(fd);
444
442
  clear(xcl_st);
445
443
  } while (*(++argv));
@@ -451,7 +449,7 @@ int main(int argc, char **argv)
451
449
  if (!xcl_st->rnck)
452
450
  {
453
451
  xcl_st->xml = "stdin";
454
- validate(rnv, xcl_st, drv_st, rn_st, rnx_st, 0);
452
+ validate(rnv, xcl_st, drv_st, rn_st, 0);
455
453
  clear(xcl_st);
456
454
  if (!xcl_st->ok && xcl_st->verbose)
457
455
  (*er_printf)("error: invalid input\n");
@@ -462,7 +460,6 @@ int main(int argc, char **argv)
462
460
  free(rnv);
463
461
  free(rn_st);
464
462
  free(rnc_st);
465
- free(rnx_st);
466
463
  free(drv_st);
467
464
  free(rx_st);
468
465
  free(rnd_st);
data/ext/rnv/src/xsd.c CHANGED
@@ -1,5 +1,3 @@
1
- #include "type.h"
2
-
3
1
  /* $Id: xsd.c,v 1.47 2005/01/06 21:04:06 dvd Exp $ */
4
2
 
5
3
  #include <limits.h> /*INT_MAX*/
@@ -7,6 +5,9 @@
7
5
  #include <string.h> /*strlen*/
8
6
  #include <math.h> /*HUGE_VAL*/
9
7
  #include <assert.h>
8
+
9
+ #include "type.h"
10
+
10
11
  #include "u.h"
11
12
  #include "xmlc.h"
12
13
  #include "s.h"
@@ -16,11 +17,10 @@
16
17
  #include "er.h"
17
18
  #include "xsd.h"
18
19
 
19
- #define err(msg) (*rnv->verror_handler)(rnv,erno|ERBIT_XSD,msg"\n",ap)
20
- void xsd_default_verror_handler(rnv_t *rnv, int erno,va_list ap) {
21
- (*er_printf)("XML Schema datatypes: ");
20
+ #define err(msg) (*handler)(data,erno|ERBIT_XSD,"XML Schema datatypes: "msg"\n",ap)
21
+ void xsd_default_verror_handler(void *data, int erno, int (*handler)(void *data, int erno,char *format, va_list ap), va_list ap) {
22
22
  if(erno&ERBIT_RX) {
23
- rx_default_verror_handler(rnv, erno&~ERBIT_RX,ap);
23
+ rx_default_verror_handler(data, erno&~ERBIT_RX,handler,ap);
24
24
  } else {
25
25
  switch(erno) {
26
26
  case XSD_ER_TYP: err("unknown type %s"); break;
@@ -36,24 +36,11 @@ void xsd_default_verror_handler(rnv_t *rnv, int erno,va_list ap) {
36
36
  }
37
37
 
38
38
  static void error_handler(rx_st_t *rx_st, int erno,...) {
39
- va_list ap; va_start(ap,erno); (*rx_st->rnv->xsd_verror_handler)(rx_st->rnv,erno,ap); va_end(ap);
39
+ va_list ap; va_start(ap,erno); xsd_default_verror_handler(rx_st->user_data,erno,rx_st->verror_handler,ap); va_end(ap);
40
40
  }
41
41
 
42
- static void verror_handler_rx(rnv_t *rnv, int erno,va_list ap) {xsd_default_verror_handler(rnv,erno|ERBIT_RX,ap);}
43
-
44
- static void windup(void);
45
42
  void xsd_init(rx_st_t *rx_st) {
46
- rx_st->rnv->xsd_verror_handler = &xsd_default_verror_handler;
47
43
  rx_init(rx_st);
48
- rx_st->rnv->rx_verror_handler=&verror_handler_rx;
49
- windup();
50
- }
51
-
52
- void xsd_clear(void) {
53
- windup();
54
- }
55
-
56
- static void windup(void) {
57
44
  }
58
45
 
59
46
  #define FCT_ENUMERATION 0
@@ -81,7 +68,7 @@ static char *fcttab[NFCT]={
81
68
  #define WS_REPLACE 1
82
69
  #define WS_COLLAPSE 2
83
70
 
84
- static int (*match[])(rnv_t *rnv, rx_st_t *rx_st, char *r,char *s,int n)={&rx_match, &rx_rmatch,&rx_cmatch};
71
+ static int (*match[])(rx_st_t *rx_st, char *r,char *s,int n)={&rx_match, &rx_rmatch,&rx_cmatch};
85
72
 
86
73
  #define TYP_ENTITIES 0
87
74
  #define TYP_ENTITY 1
@@ -327,7 +314,7 @@ struct facets {
327
314
  #define PAT_MONTH0 "(0[1-9]|1[0-2])"
328
315
  #define PAT_DAY0 "([0-2][0-9]|3[01])"
329
316
  #define PAT_YEAR "-?"PAT_YEAR0 PAT_ZONE"?"
330
- #define PAT_MONTH "--"PAT_MONTH0"--"PAT_ZONE"?"
317
+ #define PAT_MONTH "--"PAT_MONTH0 PAT_ZONE"?"
331
318
  #define PAT_DAY "---"PAT_DAY0 PAT_ZONE"?"
332
319
  #define PAT_YEAR_MONTH "-?"PAT_YEAR0"-"PAT_MONTH0 PAT_ZONE"?"
333
320
  #define PAT_MONTH_DAY "--"PAT_MONTH0"-"PAT_DAY0 PAT_ZONE"?"
@@ -661,7 +648,7 @@ int xsd_allows(rx_st_t *rx_st, char *typ,char *ps,char *s,int n) {
661
648
  default: assert(0);
662
649
  }
663
650
 
664
- while(fct.npat--) ok=ok&&match[fct.whiteSpace](rx_st->rnv, rx_st, fct.pattern[fct.npat],s,n);
651
+ while(fct.npat--) ok=ok&&match[fct.whiteSpace](rx_st, fct.pattern[fct.npat],s,n);
665
652
 
666
653
  if(fct.set&(1<<FCT_LENGTH)) ok=ok&&length==fct.length;
667
654
  if(fct.set&(1<<FCT_MAX_LENGTH)) ok=ok&&length<=fct.maxLength;