ruby_rnv 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/rnv/src/rnx.c CHANGED
@@ -13,13 +13,11 @@
13
13
  #define LEN_EXP RNX_LEN_EXP
14
14
  #define LIM_EXP RNX_LIM_EXP
15
15
 
16
- void rnx_init(rnv_t *rnv, rnx_st_t *rnx_st) {
17
- rnv->rnx_exp=(int*)m_alloc(rnx_st->len_exp=LEN_EXP,sizeof(int));
16
+ void rnx_init(rnv_t *rnv) {
17
+ rnv->rnx_exp=(int*)m_alloc(rnv->rnx_len_exp=LEN_EXP,sizeof(int));
18
18
  }
19
19
 
20
- void rnx_clear(void) {}
21
-
22
- static void expected(rnv_t *rnv, rnx_st_t *rnx_st, int p,int first,int req) {
20
+ static void expected(rnv_t *rnv, int p,int first,int req) {
23
21
  int p1,p2,px=0,i;
24
22
  if(req && rn_nullable(p)) return;
25
23
  switch(RN_P_TYP(p)) {
@@ -28,21 +26,21 @@ static void expected(rnv_t *rnv, rnx_st_t *rnx_st, int p,int first,int req) {
28
26
  case RN_P_EMPTY: break;
29
27
  case RN_P_TEXT: px=p; break;
30
28
  case RN_P_CHOICE: rn_Choice(p,p1,p2);
31
- expected(rnv, rnx_st, p1,first,req); expected(rnv, rnx_st, p2,first,req); break;
29
+ expected(rnv, p1,first,req); expected(rnv, p2,first,req); break;
32
30
  case RN_P_INTERLEAVE: rn_Interleave(p,p1,p2);
33
- expected(rnv, rnx_st, p1,first,req); expected(rnv, rnx_st, p2,first,req); break;
31
+ expected(rnv, p1,first,req); expected(rnv, p2,first,req); break;
34
32
  case RN_P_GROUP: rn_Group(p,p1,p2);
35
- expected(rnv, rnx_st, p1,first,req); expected(rnv, rnx_st, p2,first&&rn_nullable(p1),req); break;
36
- case RN_P_ONE_OR_MORE: rn_OneOrMore(p,p1); expected(rnv, rnx_st, p1,first,req); break;
37
- case RN_P_LIST: rn_List(p,p1); expected(rnv, rnx_st, p1,first,req); break;
33
+ expected(rnv, p1,first,req); expected(rnv, p2,first&&rn_nullable(p1),req); break;
34
+ case RN_P_ONE_OR_MORE: rn_OneOrMore(p,p1); expected(rnv, p1,first,req); break;
35
+ case RN_P_LIST: rn_List(p,p1); expected(rnv, p1,first,req); break;
38
36
  case RN_P_DATA: px=p; break;
39
37
  case RN_P_DATA_EXCEPT: rn_DataExcept(p,p1,p2);
40
- expected(rnv, rnx_st, p1,first,req); break;
38
+ expected(rnv, p1,first,req); break;
41
39
  case RN_P_VALUE: px=p; break;
42
40
  case RN_P_ATTRIBUTE: px=p; break;
43
41
  case RN_P_ELEMENT: px=p; break;
44
42
  case RN_P_AFTER: rn_After(p,p1,p2);
45
- expected(rnv, rnx_st, p1,first,req); if(rn_nullable(p1)) px=p; break;
43
+ expected(rnv, p1,first,req); if(rn_nullable(p1)) px=p; break;
46
44
  case RN_P_REF: break;
47
45
  default: assert(0);
48
46
  }
@@ -51,20 +49,20 @@ static void expected(rnv_t *rnv, rnx_st_t *rnx_st, int p,int first,int req) {
51
49
  if(rnv->rnx_exp[i]==px) {px=0; break;}
52
50
  }
53
51
  if(px) {
54
- if(rnv->rnx_n_exp==rnx_st->len_exp) rnv->rnx_exp=(int*)m_stretch(rnv->rnx_exp,rnx_st->len_exp=2*rnv->rnx_n_exp,rnv->rnx_n_exp,sizeof(int));
52
+ if(rnv->rnx_n_exp==rnv->rnx_len_exp) rnv->rnx_exp=(int*)m_stretch(rnv->rnx_exp,rnv->rnx_len_exp=2*rnv->rnx_n_exp,rnv->rnx_n_exp,sizeof(int));
55
53
  rnv->rnx_exp[rnv->rnx_n_exp++]=px;
56
54
  }
57
55
  }
58
56
  }
59
- void rnx_expected(rnv_t *rnv, rnx_st_t *rnx_st, int p,int req) {
57
+ void rnx_expected(rnv_t *rnv, int p,int req) {
60
58
  if(req) {
61
- if(rnx_st->len_exp>LIM_EXP) {
59
+ if(rnv->rnx_len_exp>LIM_EXP) {
62
60
  m_free(rnv->rnx_exp);
63
- rnv->rnx_exp=(int*)m_alloc(rnx_st->len_exp=LIM_EXP,sizeof(int));
61
+ rnv->rnx_exp=(int*)m_alloc(rnv->rnx_len_exp=LIM_EXP,sizeof(int));
64
62
  }
65
63
  rnv->rnx_n_exp=0;
66
64
  }
67
- expected(rnv, rnx_st, p,1,req);
65
+ expected(rnv, p,1,req);
68
66
  }
69
67
 
70
68
  char *rnx_p2str(rnv_t *rnv, int p) {
data/ext/rnv/src/rnx.h CHANGED
@@ -5,10 +5,9 @@
5
5
  #ifndef RNX_H
6
6
  #define RNX_H 1
7
7
 
8
- extern void rnx_init(rnv_t *rnv, rnx_st_t *rnx_st);
9
- extern void rnx_clear(void);
8
+ extern void rnx_init(rnv_t *rnv);
10
9
 
11
- extern void rnx_expected(rnv_t *rnv, rnx_st_t *rnx_st, int p,int req);
10
+ extern void rnx_expected(rnv_t *rnv, int p,int req);
12
11
 
13
12
  extern char *rnx_p2str(rnv_t *rnv, int p);
14
13
  extern char *rnx_nc2str(rnv_t *rnv, int nc);
data/ext/rnv/src/rx.c CHANGED
@@ -1,9 +1,10 @@
1
- #include "type.h"
2
-
3
1
  /* $Id: rx.c,v 1.33 2004/02/25 00:00:32 dvd Exp $ */
4
2
 
5
3
  #include <string.h> /*strlen,strcpy,strcmp*/
6
4
  #include <assert.h>
5
+
6
+ #include "type.h"
7
+
7
8
  #include "u.h" /*u_get,u_strlen*/
8
9
  #include "xmlc.h"
9
10
  #include "m.h"
@@ -186,9 +187,8 @@ static int add_r(rx_st_t *rx_st, char *rx) {
186
187
 
187
188
  #define ERRPOS
188
189
 
189
- #define err(msg) (*rnv->verror_handler)(rnv,erno|ERBIT_RX,msg" in \"%s\" at offset %i\n",ap)
190
- void rx_default_verror_handler(rnv_t *rnv, int erno,va_list ap) {
191
- (*er_printf)("regular expressions: ");
190
+ #define err(msg) (*handler)(data, erno|ERBIT_RX,"regular expressions: "msg" in \"%s\" at offset %i\n",ap)
191
+ void rx_default_verror_handler(void *data, int erno, int (*handler)(void *data, int erno, char *format, va_list ap), va_list ap) {
192
192
  switch(erno) {
193
193
  case RX_ER_BADCH: err("bad character"); break;
194
194
  case RX_ER_UNFIN: err("unfinished expression"); break;
@@ -206,10 +206,8 @@ void rx_default_verror_handler(rnv_t *rnv, int erno,va_list ap) {
206
206
  }
207
207
  }
208
208
 
209
- //void (*rx_verror_handler)(int erno,va_list ap)=&rx_default_verror_handler;
210
-
211
209
  static void error_handler(rx_st_t *rx_st,int erno,...) {
212
- va_list ap; va_start(ap,erno); (*rx_st->rnv->rx_verror_handler)(rx_st->rnv, erno,ap); va_end(ap);
210
+ va_list ap; va_start(ap,erno); rx_default_verror_handler(rx_st->user_data, erno, rx_st->verror_handler, ap); va_end(ap);
213
211
  }
214
212
 
215
213
  #define LEN_M RX_LEN_M
@@ -248,26 +246,40 @@ static void accept_m(rx_st_t *rx_st) {
248
246
 
249
247
  static void windup(rx_st_t *rx_st);
250
248
  void rx_init(rx_st_t *rx_st) {
251
- // memset(rx_st, 0, sizeof(rx_st_t));
249
+ rx_st->verror_handler=&verror_default_handler;
252
250
 
253
- rx_st->rnv->rx_verror_handler=&rx_default_verror_handler;
251
+ rx_st->pattern=(int *)m_alloc(rx_st->len_p=P_AVG_SIZE*LEN_P,sizeof(int));
252
+ rx_st->r2p=(int (*)[2])m_alloc(rx_st->len_2=LEN_2,sizeof(int[2]));
253
+ rx_st->regex=(char*)m_alloc(rx_st->len_r=R_AVG_SIZE*LEN_R,sizeof(char));
254
+ rx_st->memo=(int (*)[M_SIZE])m_alloc(rx_st->len_m=LEN_M,sizeof(int[M_SIZE]));
254
255
 
255
- rx_st->pattern=(int *)m_alloc(rx_st->len_p=P_AVG_SIZE*LEN_P,sizeof(int));
256
- rx_st->r2p=(int (*)[2])m_alloc(rx_st->len_2=LEN_2,sizeof(int[2]));
257
- rx_st->regex=(char*)m_alloc(rx_st->len_r=R_AVG_SIZE*LEN_R,sizeof(char));
258
- rx_st->memo=(int (*)[M_SIZE])m_alloc(rx_st->len_m=LEN_M,sizeof(int[M_SIZE]));
256
+ rx_st->ht_p.user = rx_st;
257
+ rx_st->ht_2.user = rx_st;
258
+ rx_st->ht_r.user = rx_st;
259
+ rx_st->ht_m.user = rx_st;
259
260
 
260
- rx_st->ht_p.user = rx_st;
261
- rx_st->ht_2.user = rx_st;
262
- rx_st->ht_r.user = rx_st;
263
- rx_st->ht_m.user = rx_st;
261
+ ht_init(&rx_st->ht_p,LEN_P,&hash_p,&equal_p);
262
+ ht_init(&rx_st->ht_2,LEN_2,&hash_2,&equal_2);
263
+ ht_init(&rx_st->ht_r,LEN_R,&hash_r,&equal_r);
264
+ ht_init(&rx_st->ht_m,LEN_M,&hash_m,&equal_m);
264
265
 
265
- ht_init(&rx_st->ht_p,LEN_P,&hash_p,&equal_p);
266
- ht_init(&rx_st->ht_2,LEN_2,&hash_2,&equal_2);
267
- ht_init(&rx_st->ht_r,LEN_R,&hash_r,&equal_r);
268
- ht_init(&rx_st->ht_m,LEN_M,&hash_m,&equal_m);
266
+ windup(rx_st);
267
+ }
269
268
 
270
- windup(rx_st);
269
+ void rx_dispose(rx_st_t *rx_st) {
270
+ ht_dispose(&rx_st->ht_r);
271
+ ht_dispose(&rx_st->ht_p);
272
+ ht_dispose(&rx_st->ht_2);
273
+ ht_dispose(&rx_st->ht_m);
274
+ if (rx_st->regex)
275
+ m_free(rx_st->regex);
276
+ if (rx_st->pattern)
277
+ m_free(rx_st->pattern);
278
+ if (rx_st->memo)
279
+ m_free(rx_st->memo);
280
+ if (rx_st->r2p)
281
+ m_free(rx_st->r2p);
282
+ m_free(rx_st);
271
283
  }
272
284
 
273
285
  void rx_clear(rx_st_t *rx_st) {
@@ -503,11 +515,11 @@ static void bind(rx_st_t *rx_st, int r) {
503
515
  getsym(rx_st);
504
516
  }
505
517
 
506
- static int compile(rnv_t *rnv, rx_st_t *rx_st, char *rx) {
518
+ static int compile(rx_st_t *rx_st, char *rx) {
507
519
  int r=0,p=0,d_r;
508
520
  d_r=add_r(rx_st, rx);
509
521
  if((r=ht_get(&rx_st->ht_r,rx_st->i_r))==-1) {
510
- if(rnv->rx_compact&&rx_st->i_p>=P_AVG_SIZE*LIM_P) {rx_clear(rx_st); d_r=add_r(rx_st, rx);}
522
+ if(rx_st->rx_compact&&rx_st->i_p>=P_AVG_SIZE*LIM_P) {rx_clear(rx_st); d_r=add_r(rx_st, rx);}
511
523
  ht_put(&rx_st->ht_r,r=rx_st->i_r);
512
524
  rx_st->i_r+=d_r;
513
525
  bind(rx_st, r); p=expression(rx_st); if(rx_st->sym!=SYM_END) error(rx_st, RX_ER_BADCH);
@@ -687,10 +699,10 @@ static int drv(rx_st_t *rx_st, int p,int c) {
687
699
  return ret;
688
700
  }
689
701
 
690
- int rx_check(rnv_t *rnv, rx_st_t *rx_st, char *rx) {(void)compile(rnv, rx_st, rx); return !rx_st->errors;}
702
+ int rx_check(rx_st_t *rx_st, char *rx) {(void)compile(rx_st, rx); return !rx_st->errors;}
691
703
 
692
- int rx_match(rnv_t *rnv, rx_st_t *rx_st, char *rx,char *s,int n) {
693
- int p=compile(rnv, rx_st, rx);
704
+ int rx_match(rx_st_t *rx_st, char *rx,char *s,int n) {
705
+ int p=compile(rx_st, rx);
694
706
  if(!rx_st->errors) {
695
707
  char *end=s+n;
696
708
  int u;
@@ -703,8 +715,8 @@ int rx_match(rnv_t *rnv, rx_st_t *rx_st, char *rx,char *s,int n) {
703
715
  } else return 0;
704
716
  }
705
717
 
706
- int rx_rmatch(rnv_t *rnv, rx_st_t *rx_st, char *rx,char *s,int n) {
707
- int p=compile(rnv, rx_st, rx);
718
+ int rx_rmatch(rx_st_t *rx_st, char *rx,char *s,int n) {
719
+ int p=compile(rx_st, rx);
708
720
  if(!rx_st->errors) {
709
721
  char *end=s+n;
710
722
  int u;
@@ -718,8 +730,8 @@ int rx_rmatch(rnv_t *rnv, rx_st_t *rx_st, char *rx,char *s,int n) {
718
730
  } else return 0;
719
731
  }
720
732
 
721
- int rx_cmatch(rnv_t *rnv, rx_st_t *rx_st, char *rx,char *s,int n) {
722
- int p=compile(rnv, rx_st, rx);
733
+ int rx_cmatch(rx_st_t *rx_st, char *rx,char *s,int n) {
734
+ int p=compile(rx_st, rx);
723
735
  if(!rx_st->errors) {
724
736
  char *end=s+n;
725
737
  int u;
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);