adamh-hpricot 0.6.211 → 0.7.229

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+
1
2
  #line 1 "hpricot_scan.rl"
2
3
  /*
3
4
  * hpricot_scan.rl
@@ -20,20 +21,26 @@ VALUE hpricot_css(VALUE, VALUE, VALUE, VALUE, VALUE);
20
21
  #define NO_WAY_SERIOUSLY "*** This should not happen, please send a bug report with the HTML you're parsing to why@whytheluckystiff.net. So sorry!"
21
22
 
22
23
  static VALUE sym_xmldecl, sym_doctype, sym_procins, sym_stag, sym_etag, sym_emptytag, sym_comment,
23
- sym_cdata, sym_text, sym_EMPTY, sym_CDATA;
24
+ sym_cdata, sym_name, sym_parent, sym_raw_attributes, sym_raw_string, sym_tagno,
25
+ sym_allowed, sym_text, sym_children, sym_EMPTY, sym_CDATA;
24
26
  static VALUE mHpricot, rb_eHpricotParseError;
25
- static VALUE cBaseEle, cBogusETag, cCData, cComment, cDoc, cDocType, cElem, cETag, cText,
27
+ static VALUE cBogusETag, cCData, cComment, cDoc, cDocType, cElem, cText,
26
28
  cXMLDecl, cProcIns, symAllow, symDeny;
27
29
  static ID s_ElementContent;
28
30
  static ID s_downcase, s_new, s_parent, s_read, s_to_str;
29
- static ID iv_parent;
30
31
  static VALUE reProcInsParse;
31
32
 
32
- typedef struct {
33
- int name;
34
- VALUE tag, attr, etag, raw, EC;
35
- VALUE parent, children;
36
- } hpricot_ele;
33
+ #define H_ELE_TAG 0
34
+ #define H_ELE_PARENT 1
35
+ #define H_ELE_ATTR 2
36
+ #define H_ELE_ETAG 3
37
+ #define H_ELE_RAW 4
38
+ #define H_ELE_EC 5
39
+ #define H_ELE_HASH 6
40
+ #define H_ELE_CHILDREN 7
41
+
42
+ #define H_ELE_GET(ele, idx) RSTRUCT_PTR(ele)[idx]
43
+ #define H_ELE_SET(ele, idx, val) RSTRUCT_PTR(ele)[idx] = val
37
44
 
38
45
  #define OPT(opts, key) (!NIL_P(opts) && RTEST(rb_hash_aref(opts, ID2SYM(rb_intern("" # key)))))
39
46
 
@@ -61,7 +68,7 @@ typedef struct {
61
68
 
62
69
  #define CAT(N, E) if (NIL_P(N)) { SET(N, E); } else { rb_str_cat(N, mark_##N, E - mark_##N); }
63
70
 
64
- #define SLIDE(N) if ( mark_##N > ts ) mark_##N = buf + (mark_##N - ts);
71
+ #define SLIDE(N) if (mark_##N > ts) mark_##N = buf + (mark_##N - ts);
65
72
 
66
73
  #define ATTR(K, V) \
67
74
  if (!NIL_P(K)) { \
@@ -87,11 +94,12 @@ typedef struct {
87
94
 
88
95
  #define EBLK(N, T) CAT(tag, p - T + 1); ELE(N);
89
96
 
90
- #line 134 "hpricot_scan.rl"
97
+
98
+ #line 142 "hpricot_scan.rl"
91
99
 
92
100
 
93
101
 
94
- #line 95 "hpricot_scan.c"
102
+ #line 103 "hpricot_scan.c"
95
103
  static const int hpricot_scan_start = 204;
96
104
  static const int hpricot_scan_error = -1;
97
105
 
@@ -100,7 +108,8 @@ static const int hpricot_scan_en_html_cdata = 216;
100
108
  static const int hpricot_scan_en_html_procins = 218;
101
109
  static const int hpricot_scan_en_main = 204;
102
110
 
103
- #line 137 "hpricot_scan.rl"
111
+
112
+ #line 145 "hpricot_scan.rl"
104
113
 
105
114
  #define BUFSIZE 16384
106
115
 
@@ -111,7 +120,7 @@ void rb_yield_tokens(VALUE sym, VALUE tag, VALUE attr, VALUE raw, int taint)
111
120
  raw = tag;
112
121
  }
113
122
  ary = rb_ary_new3(4, sym, tag, attr, raw);
114
- if (taint) {
123
+ if (taint) {
115
124
  OBJ_TAINT(ary);
116
125
  OBJ_TAINT(tag);
117
126
  OBJ_TAINT(attr);
@@ -120,6 +129,7 @@ void rb_yield_tokens(VALUE sym, VALUE tag, VALUE attr, VALUE raw, int taint)
120
129
  rb_yield(ary);
121
130
  }
122
131
 
132
+ #ifndef RHASH_TBL
123
133
  /* rb_hash_lookup() is only in Ruby 1.8.7 */
124
134
  static VALUE
125
135
  our_rb_hash_lookup(VALUE hash, VALUE key)
@@ -132,17 +142,17 @@ our_rb_hash_lookup(VALUE hash, VALUE key)
132
142
 
133
143
  return val;
134
144
  }
145
+ #define rb_hash_lookup our_rb_hash_lookup
146
+ #endif
135
147
 
136
148
  static void
137
149
  rb_hpricot_add(VALUE focus, VALUE ele)
138
150
  {
139
- hpricot_ele *he, *he2;
140
- Data_Get_Struct(focus, hpricot_ele, he);
141
- Data_Get_Struct(ele, hpricot_ele, he2);
142
- if (NIL_P(he->children))
143
- he->children = rb_ary_new();
144
- rb_ary_push(he->children, ele);
145
- he2->parent = focus;
151
+ VALUE children = H_ELE_GET(focus, H_ELE_CHILDREN);
152
+ if (NIL_P(children))
153
+ H_ELE_SET(focus, H_ELE_CHILDREN, (children = rb_ary_new2(1)));
154
+ rb_ary_push(children, ele);
155
+ H_ELE_SET(ele, H_ELE_PARENT, focus);
146
156
  }
147
157
 
148
158
  typedef struct {
@@ -153,102 +163,70 @@ typedef struct {
153
163
  unsigned char xml, strict, fixup;
154
164
  } hpricot_state;
155
165
 
156
- static void
157
- hpricot_ele_mark(hpricot_ele *he)
158
- {
159
- rb_gc_mark(he->tag);
160
- rb_gc_mark(he->attr);
161
- rb_gc_mark(he->etag);
162
- rb_gc_mark(he->raw);
163
- rb_gc_mark(he->parent);
164
- rb_gc_mark(he->children);
165
- }
166
-
167
- static void
168
- hpricot_ele_free(hpricot_ele *he)
169
- {
170
- free(he);
171
- }
172
-
173
- #define H_PROP(prop) \
166
+ #define H_PROP(prop, idx) \
174
167
  static VALUE hpricot_ele_set_##prop(VALUE self, VALUE x) { \
175
- hpricot_ele *he; \
176
- Data_Get_Struct(self, hpricot_ele, he); \
177
- he->prop = x; \
168
+ H_ELE_SET(self, idx, x); \
178
169
  return self; \
179
170
  } \
171
+ static VALUE hpricot_ele_clear_##prop(VALUE self) { \
172
+ H_ELE_SET(self, idx, Qnil); \
173
+ return Qtrue; \
174
+ } \
180
175
  static VALUE hpricot_ele_get_##prop(VALUE self) { \
181
- hpricot_ele *he; \
182
- Data_Get_Struct(self, hpricot_ele, he); \
183
- return he->prop; \
176
+ return H_ELE_GET(self, idx); \
184
177
  }
185
178
 
186
179
  #define H_ATTR(prop) \
187
180
  static VALUE hpricot_ele_set_##prop(VALUE self, VALUE x) { \
188
- hpricot_ele *he; \
189
- Data_Get_Struct(self, hpricot_ele, he); \
190
- rb_hash_aset(he->attr, ID2SYM(rb_intern("" # prop)), x); \
181
+ rb_hash_aset(H_ELE_GET(self, H_ELE_ATTR), ID2SYM(rb_intern("" # prop)), x); \
191
182
  return self; \
192
183
  } \
193
184
  static VALUE hpricot_ele_get_##prop(VALUE self) { \
194
- hpricot_ele *he; \
195
- Data_Get_Struct(self, hpricot_ele, he); \
196
- return rb_hash_aref(he->attr, ID2SYM(rb_intern("" # prop))); \
185
+ return rb_hash_aref(H_ELE_GET(self, H_ELE_ATTR), ID2SYM(rb_intern("" # prop))); \
197
186
  }
198
187
 
199
- H_PROP(tag);
200
- H_PROP(attr);
201
- H_PROP(etag);
202
- H_PROP(parent);
203
- H_PROP(children);
188
+ H_PROP(name, H_ELE_TAG);
189
+ H_PROP(raw, H_ELE_RAW);
190
+ H_PROP(parent, H_ELE_PARENT);
191
+ H_PROP(attr, H_ELE_ATTR);
192
+ H_PROP(etag, H_ELE_ETAG);
193
+ H_PROP(children, H_ELE_CHILDREN);
194
+ H_ATTR(target);
204
195
  H_ATTR(encoding);
205
196
  H_ATTR(version);
206
197
  H_ATTR(standalone);
207
198
  H_ATTR(system_id);
208
199
  H_ATTR(public_id);
209
200
 
210
- static VALUE
211
- hpricot_ele_get_raw(VALUE self, VALUE x) {
212
- hpricot_ele *he;
213
- Data_Get_Struct(self, hpricot_ele, he);
214
- return he->raw;
215
- }
216
-
217
- static VALUE
218
- hpricot_ele_clear_raw(VALUE self)
219
- {
220
- hpricot_ele *he;
221
- Data_Get_Struct(self, hpricot_ele, he);
222
- he->raw = Qnil;
223
- return Qtrue;
224
- }
225
-
226
201
  #define H_ELE(klass) \
227
- hpricot_ele *he = ALLOC(hpricot_ele); \
228
- he->name = 0; \
229
- he->tag = tag; \
230
- he->attr = attr; \
231
- he->raw = Qnil; \
232
- he->EC = ec; \
233
- he->etag = he->parent = he->children = Qnil; \
234
- if (raw != NULL && (sym == sym_emptytag || sym == sym_stag || sym == sym_etag || sym == sym_doctype)) { \
235
- he->raw = rb_str_new(raw, rawlen); \
202
+ ele = rb_obj_alloc(klass); \
203
+ if (klass == cElem) { \
204
+ H_ELE_SET(ele, H_ELE_TAG, tag); \
205
+ H_ELE_SET(ele, H_ELE_ATTR, attr); \
206
+ H_ELE_SET(ele, H_ELE_EC, ec); \
207
+ if (raw != NULL && (sym == sym_emptytag || sym == sym_stag || sym == sym_doctype)) { \
208
+ H_ELE_SET(ele, H_ELE_RAW, rb_str_new(raw, rawlen)); \
209
+ } \
210
+ } else if (klass == cDocType || klass == cProcIns || klass == cXMLDecl || klass == cBogusETag) { \
211
+ if (klass == cBogusETag) { \
212
+ H_ELE_SET(ele, H_ELE_TAG, tag); \
213
+ if (raw != NULL) \
214
+ H_ELE_SET(ele, H_ELE_ATTR, rb_str_new(raw, rawlen)); \
215
+ } else { \
216
+ if (klass == cDocType) \
217
+ ATTR(ID2SYM(rb_intern("target")), tag); \
218
+ H_ELE_SET(ele, H_ELE_ATTR, attr); \
219
+ if (klass != cProcIns) { \
220
+ tag = Qnil; \
221
+ if (raw != NULL) tag = rb_str_new(raw, rawlen); \
222
+ } \
223
+ H_ELE_SET(ele, H_ELE_TAG, tag); \
224
+ } \
225
+ } else { \
226
+ H_ELE_SET(ele, H_ELE_TAG, tag); \
236
227
  } \
237
- ele = Data_Wrap_Struct(klass, hpricot_ele_mark, hpricot_ele_free, he); \
238
228
  S->last = ele
239
229
 
240
- VALUE
241
- hpricot_ele_alloc(VALUE klass)
242
- {
243
- VALUE ele;
244
- hpricot_ele *he = ALLOC(hpricot_ele);
245
- he->name = 0;
246
- he->tag = he->attr = he->raw = he->EC = Qnil;
247
- he->etag = he->parent = he->children = Qnil;
248
- ele = Data_Wrap_Struct(klass, hpricot_ele_mark, hpricot_ele_free, he);
249
- return ele;
250
- }
251
-
252
230
  //
253
231
  // the swift, compact parser logic. most of the complicated stuff is done
254
232
  // in the lexer. this step just pairs up the start and end tags.
@@ -262,22 +240,23 @@ rb_hpricot_token(hpricot_state *S, VALUE sym, VALUE tag, VALUE attr, char *raw,
262
240
  // in html mode, fix up start tags incorrectly formed as empty tags
263
241
  //
264
242
  if (!S->xml) {
265
- hpricot_ele *last;
266
- Data_Get_Struct(S->focus, hpricot_ele, last);
267
- if (last->EC == sym_CDATA &&
268
- (sym != sym_procins && sym != sym_comment && sym != sym_cdata && sym != sym_text) &&
269
- !(sym == sym_etag && rb_str_hash(tag) == last->name))
270
- {
271
- sym = sym_text;
272
- tag = rb_str_new(raw, rawlen);
273
- }
274
-
275
243
  if (sym == sym_emptytag || sym == sym_stag || sym == sym_etag) {
276
244
  ec = rb_hash_aref(S->EC, tag);
277
245
  if (NIL_P(ec)) {
278
246
  tag = rb_funcall(tag, s_downcase, 0);
279
247
  ec = rb_hash_aref(S->EC, tag);
280
248
  }
249
+ }
250
+
251
+ if (H_ELE_GET(S->focus, H_ELE_EC) == sym_CDATA &&
252
+ (sym != sym_procins && sym != sym_comment && sym != sym_cdata && sym != sym_text) &&
253
+ !(sym == sym_etag && INT2FIX(rb_str_hash(tag)) == H_ELE_GET(S->focus, H_ELE_HASH)))
254
+ {
255
+ sym = sym_text;
256
+ tag = rb_str_new(raw, rawlen);
257
+ }
258
+
259
+ if (!NIL_P(ec)) {
281
260
  if (sym == sym_emptytag) {
282
261
  if (ec != sym_EMPTY)
283
262
  sym = sym_stag;
@@ -289,19 +268,19 @@ rb_hpricot_token(hpricot_state *S, VALUE sym, VALUE tag, VALUE attr, char *raw,
289
268
  }
290
269
 
291
270
  if (sym == sym_emptytag || sym == sym_stag) {
271
+ VALUE name = INT2FIX(rb_str_hash(tag));
292
272
  H_ELE(cElem);
293
- he->name = rb_str_hash(tag);
273
+ H_ELE_SET(ele, H_ELE_HASH, name);
294
274
 
295
275
  if (!S->xml) {
296
276
  VALUE match = Qnil, e = S->focus;
297
277
  while (e != S->doc)
298
278
  {
299
- hpricot_ele *hee;
300
- Data_Get_Struct(e, hpricot_ele, hee);
279
+ VALUE hEC = H_ELE_GET(e, H_ELE_EC);
301
280
 
302
- if (TYPE(hee->EC) == T_HASH)
281
+ if (TYPE(hEC) == T_HASH)
303
282
  {
304
- VALUE has = our_rb_hash_lookup(hee->EC, INT2NUM(he->name));
283
+ VALUE has = rb_hash_lookup(hEC, name);
305
284
  if (has != Qnil) {
306
285
  if (has == Qtrue) {
307
286
  if (match == Qnil)
@@ -314,7 +293,7 @@ rb_hpricot_token(hpricot_state *S, VALUE sym, VALUE tag, VALUE attr, char *raw,
314
293
  }
315
294
  }
316
295
 
317
- e = hee->parent;
296
+ e = H_ELE_GET(e, H_ELE_PARENT);
318
297
  }
319
298
 
320
299
  if (match == Qnil)
@@ -336,8 +315,7 @@ rb_hpricot_token(hpricot_state *S, VALUE sym, VALUE tag, VALUE attr, char *raw,
336
315
  }
337
316
  }
338
317
  } else if (sym == sym_etag) {
339
- int name;
340
- VALUE match = Qnil, e = S->focus;
318
+ VALUE name, match = Qnil, e = S->focus;
341
319
  if (S->strict) {
342
320
  if (NIL_P(rb_hash_aref(S->EC, tag))) {
343
321
  tag = rb_str_new2("div");
@@ -350,19 +328,16 @@ rb_hpricot_token(hpricot_state *S, VALUE sym, VALUE tag, VALUE attr, char *raw,
350
328
  //
351
329
  // (see also: the search above for fixups)
352
330
  //
353
- name = rb_str_hash(tag);
331
+ name = INT2FIX(rb_str_hash(tag));
354
332
  while (e != S->doc)
355
333
  {
356
- hpricot_ele *he;
357
- Data_Get_Struct(e, hpricot_ele, he);
358
-
359
- if (he->name == name)
334
+ if (H_ELE_GET(e, H_ELE_HASH) == name)
360
335
  {
361
336
  match = e;
362
337
  break;
363
338
  }
364
339
 
365
- e = he->parent;
340
+ e = H_ELE_GET(e, H_ELE_PARENT);
366
341
  }
367
342
 
368
343
  if (NIL_P(match))
@@ -372,10 +347,11 @@ rb_hpricot_token(hpricot_state *S, VALUE sym, VALUE tag, VALUE attr, char *raw,
372
347
  }
373
348
  else
374
349
  {
375
- H_ELE(cETag);
376
- Data_Get_Struct(match, hpricot_ele, he);
377
- he->etag = ele;
378
- S->focus = he->parent;
350
+ VALUE ele = Qnil;
351
+ if (raw != NULL)
352
+ ele = rb_str_new(raw, rawlen);
353
+ H_ELE_SET(match, H_ELE_ETAG, ele);
354
+ S->focus = H_ELE_GET(match, H_ELE_PARENT);
379
355
  S->last = Qnil;
380
356
  }
381
357
  } else if (sym == sym_cdata) {
@@ -396,15 +372,13 @@ rb_hpricot_token(hpricot_state *S, VALUE sym, VALUE tag, VALUE attr, char *raw,
396
372
  tag = rb_reg_nth_match(1, match);
397
373
  attr = rb_reg_nth_match(2, match);
398
374
  {
399
- H_ELE(cProcIns);
400
- rb_hpricot_add(S->focus, ele);
375
+ H_ELE(cProcIns);
376
+ rb_hpricot_add(S->focus, ele);
401
377
  }
402
378
  } else if (sym == sym_text) {
403
379
  // TODO: add raw_string as well?
404
380
  if (!NIL_P(S->last) && RBASIC(S->last)->klass == cText) {
405
- hpricot_ele *he;
406
- Data_Get_Struct(S->last, hpricot_ele, he);
407
- rb_str_append(he->tag, tag);
381
+ rb_str_append(H_ELE_GET(S->last, H_ELE_TAG), tag);
408
382
  } else {
409
383
  H_ELE(cText);
410
384
  rb_hpricot_add(S->focus, ele);
@@ -417,7 +391,7 @@ rb_hpricot_token(hpricot_state *S, VALUE sym, VALUE tag, VALUE attr, char *raw,
417
391
 
418
392
  VALUE hpricot_scan(int argc, VALUE *argv, VALUE self)
419
393
  {
420
- int cs, act, have = 0, nread = 0, curline = 1, text = 0;
394
+ int cs, act, have = 0, nread = 0, curline = 1, text = 0, io = 0;
421
395
  char *ts = 0, *te = 0, *buf = NULL, *eof = NULL;
422
396
 
423
397
  hpricot_state *S = NULL;
@@ -427,12 +401,13 @@ VALUE hpricot_scan(int argc, VALUE *argv, VALUE self)
427
401
  int done = 0, ele_open = 0, buffer_size = 0, taint = 0;
428
402
 
429
403
  rb_scan_args(argc, argv, "11", &port, &opts);
430
- taint = OBJ_TAINTED( port );
431
- if ( !rb_respond_to( port, s_read ) )
404
+ taint = OBJ_TAINTED(port);
405
+ io = rb_respond_to(port, s_read);
406
+ if (!io)
432
407
  {
433
- if ( rb_respond_to( port, s_to_str ) )
408
+ if (rb_respond_to(port, s_to_str))
434
409
  {
435
- port = rb_funcall( port, s_to_str, 0 );
410
+ port = rb_funcall(port, s_to_str, 0);
436
411
  StringValue(port);
437
412
  }
438
413
  else
@@ -446,11 +421,8 @@ VALUE hpricot_scan(int argc, VALUE *argv, VALUE self)
446
421
 
447
422
  if (!rb_block_given_p())
448
423
  {
449
- hpricot_ele *he = ALLOC(hpricot_ele);
450
424
  S = ALLOC(hpricot_state);
451
- MEMZERO(he, hpricot_ele, 1);
452
- he->tag = he->attr = he->etag = he->parent = he->children = Qnil;
453
- S->doc = Data_Wrap_Struct(cDoc, hpricot_ele_mark, hpricot_ele_free, he);
425
+ S->doc = rb_obj_alloc(cDoc);
454
426
  rb_gc_register_address(&S->doc);
455
427
  S->focus = S->doc;
456
428
  S->last = Qnil;
@@ -470,70 +442,73 @@ VALUE hpricot_scan(int argc, VALUE *argv, VALUE self)
470
442
  buffer_size = NUM2INT(bufsize);
471
443
  }
472
444
  }
473
- buf = ALLOC_N(char, buffer_size);
445
+
446
+ if (io)
447
+ buf = ALLOC_N(char, buffer_size);
474
448
 
475
449
 
476
- #line 477 "hpricot_scan.c"
450
+ #line 451 "hpricot_scan.c"
477
451
  {
478
452
  cs = hpricot_scan_start;
479
453
  ts = 0;
480
454
  te = 0;
481
455
  act = 0;
482
456
  }
483
- #line 509 "hpricot_scan.rl"
484
-
485
- while ( !done ) {
457
+
458
+ #line 482 "hpricot_scan.rl"
459
+
460
+ while (!done) {
486
461
  VALUE str;
487
462
  char *p, *pe;
488
463
  int len, space = buffer_size - have, tokstart_diff, tokend_diff, mark_tag_diff, mark_akey_diff, mark_aval_diff;
489
464
 
490
- if ( space == 0 ) {
491
- /* We've used up the entire buffer storing an already-parsed token
492
- * prefix that must be preserved. Likely caused by super-long attributes.
493
- * Increase buffer size and continue */
494
- tokstart_diff = ts - buf;
495
- tokend_diff = te - buf;
496
- mark_tag_diff = mark_tag - buf;
497
- mark_akey_diff = mark_akey - buf;
498
- mark_aval_diff = mark_aval - buf;
465
+ if (io)
466
+ {
467
+ if (space == 0) {
468
+ /* We've used up the entire buffer storing an already-parsed token
469
+ * prefix that must be preserved. Likely caused by super-long attributes.
470
+ * Increase buffer size and continue */
471
+ tokstart_diff = ts - buf;
472
+ tokend_diff = te - buf;
473
+ mark_tag_diff = mark_tag - buf;
474
+ mark_akey_diff = mark_akey - buf;
475
+ mark_aval_diff = mark_aval - buf;
499
476
 
500
- buffer_size += BUFSIZE;
501
- REALLOC_N(buf, char, buffer_size);
477
+ buffer_size += BUFSIZE;
478
+ REALLOC_N(buf, char, buffer_size);
502
479
 
503
- space = buffer_size - have;
480
+ space = buffer_size - have;
504
481
 
505
- ts= buf + tokstart_diff;
506
- te = buf + tokend_diff;
507
- mark_tag = buf + mark_tag_diff;
508
- mark_akey = buf + mark_akey_diff;
509
- mark_aval = buf + mark_aval_diff;
510
- }
511
- p = buf + have;
482
+ ts = buf + tokstart_diff;
483
+ te = buf + tokend_diff;
484
+ mark_tag = buf + mark_tag_diff;
485
+ mark_akey = buf + mark_akey_diff;
486
+ mark_aval = buf + mark_aval_diff;
487
+ }
488
+ p = buf + have;
512
489
 
513
- if ( rb_respond_to( port, s_read ) )
514
- {
515
490
  str = rb_funcall(port, s_read, 1, INT2FIX(space));
516
491
  len = RSTRING_LEN(str);
517
492
  memcpy(p, StringValuePtr(str), len);
518
493
  }
519
494
  else
520
495
  {
521
- len = RSTRING_LEN(port) - nread;
522
- if (len > space) len = space;
523
- memcpy(p, StringValuePtr(port) + nread, len);
496
+ p = RSTRING_PTR(port);
497
+ len = RSTRING_LEN(port) + 1;
498
+ done = 1;
524
499
  }
525
500
 
526
501
  nread += len;
527
502
 
528
503
  /* If this is the last buffer, tack on an EOF. */
529
- if ( len < space ) {
504
+ if (io && len < space) {
530
505
  p[len++] = 0;
531
506
  done = 1;
532
507
  }
533
508
 
534
509
  pe = p + len;
535
510
 
536
- #line 537 "hpricot_scan.c"
511
+ #line 512 "hpricot_scan.c"
537
512
  {
538
513
  if ( p == pe )
539
514
  goto _test_eof;
@@ -548,7 +523,7 @@ tr4:
548
523
  {te = p+1;{ {goto st214;} }}
549
524
  goto st204;
550
525
  tr15:
551
- #line 107 "hpricot_scan.rl"
526
+ #line 113 "hpricot_scan.rl"
552
527
  { SET(tag, p); }
553
528
  #line 66 "hpricot_scan.rl"
554
529
  {te = p+1;{ ELE(doctype); }}
@@ -580,7 +555,7 @@ tr93:
580
555
  {te = p+1;{ {goto st216;} }}
581
556
  goto st204;
582
557
  tr97:
583
- #line 107 "hpricot_scan.rl"
558
+ #line 113 "hpricot_scan.rl"
584
559
  { SET(tag, p); }
585
560
  #line 69 "hpricot_scan.rl"
586
561
  {te = p+1;{ ELE(etag); }}
@@ -590,7 +565,7 @@ tr99:
590
565
  {te = p+1;{ ELE(etag); }}
591
566
  goto st204;
592
567
  tr103:
593
- #line 107 "hpricot_scan.rl"
568
+ #line 113 "hpricot_scan.rl"
594
569
  { SET(tag, p); }
595
570
  #line 68 "hpricot_scan.rl"
596
571
  {te = p+1;{ ELE(stag); }}
@@ -600,18 +575,22 @@ tr107:
600
575
  {te = p+1;{ ELE(stag); }}
601
576
  goto st204;
602
577
  tr112:
603
- #line 114 "hpricot_scan.rl"
578
+ #line 120 "hpricot_scan.rl"
604
579
  { SET(akey, p); }
605
- #line 128 "hpricot_scan.rl"
606
- {
580
+ #line 134 "hpricot_scan.rl"
581
+ {
582
+ if (!S->xml)
583
+ akey = rb_funcall(akey, s_downcase, 0);
607
584
  ATTR(akey, aval);
608
585
  }
609
586
  #line 68 "hpricot_scan.rl"
610
587
  {te = p+1;{ ELE(stag); }}
611
588
  goto st204;
612
589
  tr117:
613
- #line 128 "hpricot_scan.rl"
614
- {
590
+ #line 134 "hpricot_scan.rl"
591
+ {
592
+ if (!S->xml)
593
+ akey = rb_funcall(akey, s_downcase, 0);
615
594
  ATTR(akey, aval);
616
595
  }
617
596
  #line 68 "hpricot_scan.rl"
@@ -622,25 +601,29 @@ tr118:
622
601
  {te = p+1;{ ELE(emptytag); }}
623
602
  goto st204;
624
603
  tr129:
625
- #line 110 "hpricot_scan.rl"
626
- {
604
+ #line 116 "hpricot_scan.rl"
605
+ {
627
606
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
628
607
  else { SET(aval, p); }
629
608
  }
630
- #line 128 "hpricot_scan.rl"
631
- {
609
+ #line 134 "hpricot_scan.rl"
610
+ {
611
+ if (!S->xml)
612
+ akey = rb_funcall(akey, s_downcase, 0);
632
613
  ATTR(akey, aval);
633
614
  }
634
615
  #line 68 "hpricot_scan.rl"
635
616
  {te = p+1;{ ELE(stag); }}
636
617
  goto st204;
637
618
  tr133:
638
- #line 128 "hpricot_scan.rl"
639
- {
619
+ #line 134 "hpricot_scan.rl"
620
+ {
621
+ if (!S->xml)
622
+ akey = rb_funcall(akey, s_downcase, 0);
640
623
  ATTR(akey, aval);
641
624
  }
642
- #line 110 "hpricot_scan.rl"
643
- {
625
+ #line 116 "hpricot_scan.rl"
626
+ {
644
627
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
645
628
  else { SET(aval, p); }
646
629
  }
@@ -648,15 +631,17 @@ tr133:
648
631
  {te = p+1;{ ELE(stag); }}
649
632
  goto st204;
650
633
  tr139:
651
- #line 110 "hpricot_scan.rl"
652
- {
634
+ #line 116 "hpricot_scan.rl"
635
+ {
653
636
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
654
637
  else { SET(aval, p); }
655
638
  }
656
- #line 114 "hpricot_scan.rl"
639
+ #line 120 "hpricot_scan.rl"
657
640
  { SET(akey, p); }
658
- #line 128 "hpricot_scan.rl"
659
- {
641
+ #line 134 "hpricot_scan.rl"
642
+ {
643
+ if (!S->xml)
644
+ akey = rb_funcall(akey, s_downcase, 0);
660
645
  ATTR(akey, aval);
661
646
  }
662
647
  #line 68 "hpricot_scan.rl"
@@ -700,7 +685,7 @@ st204:
700
685
  case 204:
701
686
  #line 1 "hpricot_scan.rl"
702
687
  {ts = p;}
703
- #line 704 "hpricot_scan.c"
688
+ #line 689 "hpricot_scan.c"
704
689
  switch( (*p) ) {
705
690
  case 10: goto tr412;
706
691
  case 60: goto tr413;
@@ -709,7 +694,7 @@ case 204:
709
694
  tr413:
710
695
  #line 1 "hpricot_scan.rl"
711
696
  {te = p+1;}
712
- #line 92 "hpricot_scan.rl"
697
+ #line 98 "hpricot_scan.rl"
713
698
  {
714
699
  if (text == 1) {
715
700
  CAT(tag, p);
@@ -728,7 +713,7 @@ st205:
728
713
  if ( ++p == pe )
729
714
  goto _test_eof205;
730
715
  case 205:
731
- #line 732 "hpricot_scan.c"
716
+ #line 717 "hpricot_scan.c"
732
717
  switch( (*p) ) {
733
718
  case 33: goto st0;
734
719
  case 47: goto st59;
@@ -829,14 +814,14 @@ case 9:
829
814
  goto tr12;
830
815
  goto tr0;
831
816
  tr12:
832
- #line 104 "hpricot_scan.rl"
817
+ #line 110 "hpricot_scan.rl"
833
818
  { mark_tag = p; }
834
819
  goto st10;
835
820
  st10:
836
821
  if ( ++p == pe )
837
822
  goto _test_eof10;
838
823
  case 10:
839
- #line 840 "hpricot_scan.c"
824
+ #line 825 "hpricot_scan.c"
840
825
  switch( (*p) ) {
841
826
  case 32: goto tr13;
842
827
  case 62: goto tr15;
@@ -860,14 +845,14 @@ case 10:
860
845
  goto st10;
861
846
  goto tr0;
862
847
  tr13:
863
- #line 107 "hpricot_scan.rl"
848
+ #line 113 "hpricot_scan.rl"
864
849
  { SET(tag, p); }
865
850
  goto st11;
866
851
  st11:
867
852
  if ( ++p == pe )
868
853
  goto _test_eof11;
869
854
  case 11:
870
- #line 871 "hpricot_scan.c"
855
+ #line 856 "hpricot_scan.c"
871
856
  switch( (*p) ) {
872
857
  case 32: goto st11;
873
858
  case 62: goto tr18;
@@ -957,14 +942,14 @@ case 19:
957
942
  goto tr30;
958
943
  goto tr0;
959
944
  tr30:
960
- #line 105 "hpricot_scan.rl"
945
+ #line 111 "hpricot_scan.rl"
961
946
  { mark_aval = p; }
962
947
  goto st20;
963
948
  st20:
964
949
  if ( ++p == pe )
965
950
  goto _test_eof20;
966
951
  case 20:
967
- #line 968 "hpricot_scan.c"
952
+ #line 953 "hpricot_scan.c"
968
953
  switch( (*p) ) {
969
954
  case 9: goto st20;
970
955
  case 34: goto tr33;
@@ -984,20 +969,20 @@ case 20:
984
969
  goto st20;
985
970
  goto tr0;
986
971
  tr31:
987
- #line 105 "hpricot_scan.rl"
972
+ #line 111 "hpricot_scan.rl"
988
973
  { mark_aval = p; }
989
- #line 118 "hpricot_scan.rl"
974
+ #line 124 "hpricot_scan.rl"
990
975
  { SET(aval, p); ATTR(ID2SYM(rb_intern("public_id")), aval); }
991
976
  goto st21;
992
977
  tr33:
993
- #line 118 "hpricot_scan.rl"
978
+ #line 124 "hpricot_scan.rl"
994
979
  { SET(aval, p); ATTR(ID2SYM(rb_intern("public_id")), aval); }
995
980
  goto st21;
996
981
  st21:
997
982
  if ( ++p == pe )
998
983
  goto _test_eof21;
999
984
  case 21:
1000
- #line 1001 "hpricot_scan.c"
985
+ #line 986 "hpricot_scan.c"
1001
986
  switch( (*p) ) {
1002
987
  case 32: goto st22;
1003
988
  case 62: goto tr18;
@@ -1028,32 +1013,32 @@ case 23:
1028
1013
  goto tr38;
1029
1014
  goto tr37;
1030
1015
  tr37:
1031
- #line 105 "hpricot_scan.rl"
1016
+ #line 111 "hpricot_scan.rl"
1032
1017
  { mark_aval = p; }
1033
1018
  goto st24;
1034
1019
  st24:
1035
1020
  if ( ++p == pe )
1036
1021
  goto _test_eof24;
1037
1022
  case 24:
1038
- #line 1039 "hpricot_scan.c"
1023
+ #line 1024 "hpricot_scan.c"
1039
1024
  if ( (*p) == 34 )
1040
1025
  goto tr41;
1041
1026
  goto st24;
1042
1027
  tr38:
1043
- #line 105 "hpricot_scan.rl"
1028
+ #line 111 "hpricot_scan.rl"
1044
1029
  { mark_aval = p; }
1045
- #line 119 "hpricot_scan.rl"
1030
+ #line 125 "hpricot_scan.rl"
1046
1031
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1047
1032
  goto st25;
1048
1033
  tr41:
1049
- #line 119 "hpricot_scan.rl"
1034
+ #line 125 "hpricot_scan.rl"
1050
1035
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1051
1036
  goto st25;
1052
1037
  st25:
1053
1038
  if ( ++p == pe )
1054
1039
  goto _test_eof25;
1055
1040
  case 25:
1056
- #line 1057 "hpricot_scan.c"
1041
+ #line 1042 "hpricot_scan.c"
1057
1042
  switch( (*p) ) {
1058
1043
  case 32: goto st25;
1059
1044
  case 62: goto tr18;
@@ -1063,14 +1048,14 @@ case 25:
1063
1048
  goto st25;
1064
1049
  goto tr39;
1065
1050
  tr16:
1066
- #line 107 "hpricot_scan.rl"
1051
+ #line 113 "hpricot_scan.rl"
1067
1052
  { SET(tag, p); }
1068
1053
  goto st26;
1069
1054
  st26:
1070
1055
  if ( ++p == pe )
1071
1056
  goto _test_eof26;
1072
1057
  case 26:
1073
- #line 1074 "hpricot_scan.c"
1058
+ #line 1059 "hpricot_scan.c"
1074
1059
  if ( (*p) == 93 )
1075
1060
  goto st27;
1076
1061
  goto st26;
@@ -1093,14 +1078,14 @@ case 28:
1093
1078
  goto tr38;
1094
1079
  goto tr44;
1095
1080
  tr44:
1096
- #line 105 "hpricot_scan.rl"
1081
+ #line 111 "hpricot_scan.rl"
1097
1082
  { mark_aval = p; }
1098
1083
  goto st29;
1099
1084
  st29:
1100
1085
  if ( ++p == pe )
1101
1086
  goto _test_eof29;
1102
1087
  case 29:
1103
- #line 1104 "hpricot_scan.c"
1088
+ #line 1089 "hpricot_scan.c"
1104
1089
  if ( (*p) == 39 )
1105
1090
  goto tr41;
1106
1091
  goto st29;
@@ -1130,14 +1115,14 @@ case 30:
1130
1115
  goto tr46;
1131
1116
  goto tr0;
1132
1117
  tr46:
1133
- #line 105 "hpricot_scan.rl"
1118
+ #line 111 "hpricot_scan.rl"
1134
1119
  { mark_aval = p; }
1135
1120
  goto st31;
1136
1121
  st31:
1137
1122
  if ( ++p == pe )
1138
1123
  goto _test_eof31;
1139
1124
  case 31:
1140
- #line 1141 "hpricot_scan.c"
1125
+ #line 1126 "hpricot_scan.c"
1141
1126
  switch( (*p) ) {
1142
1127
  case 9: goto st31;
1143
1128
  case 39: goto tr49;
@@ -1160,34 +1145,34 @@ case 31:
1160
1145
  goto st31;
1161
1146
  goto tr0;
1162
1147
  tr47:
1163
- #line 105 "hpricot_scan.rl"
1148
+ #line 111 "hpricot_scan.rl"
1164
1149
  { mark_aval = p; }
1165
- #line 118 "hpricot_scan.rl"
1150
+ #line 124 "hpricot_scan.rl"
1166
1151
  { SET(aval, p); ATTR(ID2SYM(rb_intern("public_id")), aval); }
1167
1152
  goto st32;
1168
1153
  tr49:
1169
- #line 118 "hpricot_scan.rl"
1154
+ #line 124 "hpricot_scan.rl"
1170
1155
  { SET(aval, p); ATTR(ID2SYM(rb_intern("public_id")), aval); }
1171
1156
  goto st32;
1172
1157
  tr55:
1173
- #line 118 "hpricot_scan.rl"
1158
+ #line 124 "hpricot_scan.rl"
1174
1159
  { SET(aval, p); ATTR(ID2SYM(rb_intern("public_id")), aval); }
1175
- #line 105 "hpricot_scan.rl"
1160
+ #line 111 "hpricot_scan.rl"
1176
1161
  { mark_aval = p; }
1177
- #line 119 "hpricot_scan.rl"
1162
+ #line 125 "hpricot_scan.rl"
1178
1163
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1179
1164
  goto st32;
1180
1165
  tr82:
1181
- #line 118 "hpricot_scan.rl"
1166
+ #line 124 "hpricot_scan.rl"
1182
1167
  { SET(aval, p); ATTR(ID2SYM(rb_intern("public_id")), aval); }
1183
- #line 119 "hpricot_scan.rl"
1168
+ #line 125 "hpricot_scan.rl"
1184
1169
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1185
1170
  goto st32;
1186
1171
  st32:
1187
1172
  if ( ++p == pe )
1188
1173
  goto _test_eof32;
1189
1174
  case 32:
1190
- #line 1191 "hpricot_scan.c"
1175
+ #line 1176 "hpricot_scan.c"
1191
1176
  switch( (*p) ) {
1192
1177
  case 9: goto st33;
1193
1178
  case 32: goto st33;
@@ -1241,20 +1226,20 @@ case 33:
1241
1226
  goto st31;
1242
1227
  goto tr0;
1243
1228
  tr51:
1244
- #line 118 "hpricot_scan.rl"
1229
+ #line 124 "hpricot_scan.rl"
1245
1230
  { SET(aval, p); ATTR(ID2SYM(rb_intern("public_id")), aval); }
1246
1231
  goto st34;
1247
1232
  tr62:
1248
- #line 118 "hpricot_scan.rl"
1233
+ #line 124 "hpricot_scan.rl"
1249
1234
  { SET(aval, p); ATTR(ID2SYM(rb_intern("public_id")), aval); }
1250
- #line 119 "hpricot_scan.rl"
1235
+ #line 125 "hpricot_scan.rl"
1251
1236
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1252
1237
  goto st34;
1253
1238
  st34:
1254
1239
  if ( ++p == pe )
1255
1240
  goto _test_eof34;
1256
1241
  case 34:
1257
- #line 1258 "hpricot_scan.c"
1242
+ #line 1243 "hpricot_scan.c"
1258
1243
  switch( (*p) ) {
1259
1244
  case 9: goto tr52;
1260
1245
  case 32: goto tr52;
@@ -1280,14 +1265,14 @@ case 34:
1280
1265
  goto tr54;
1281
1266
  goto tr44;
1282
1267
  tr52:
1283
- #line 105 "hpricot_scan.rl"
1268
+ #line 111 "hpricot_scan.rl"
1284
1269
  { mark_aval = p; }
1285
1270
  goto st35;
1286
1271
  st35:
1287
1272
  if ( ++p == pe )
1288
1273
  goto _test_eof35;
1289
1274
  case 35:
1290
- #line 1291 "hpricot_scan.c"
1275
+ #line 1276 "hpricot_scan.c"
1291
1276
  switch( (*p) ) {
1292
1277
  case 9: goto st35;
1293
1278
  case 32: goto st35;
@@ -1313,14 +1298,14 @@ case 35:
1313
1298
  goto st47;
1314
1299
  goto st29;
1315
1300
  tr53:
1316
- #line 105 "hpricot_scan.rl"
1301
+ #line 111 "hpricot_scan.rl"
1317
1302
  { mark_aval = p; }
1318
1303
  goto st36;
1319
1304
  st36:
1320
1305
  if ( ++p == pe )
1321
1306
  goto _test_eof36;
1322
1307
  case 36:
1323
- #line 1324 "hpricot_scan.c"
1308
+ #line 1309 "hpricot_scan.c"
1324
1309
  switch( (*p) ) {
1325
1310
  case 32: goto st36;
1326
1311
  case 34: goto st37;
@@ -1341,38 +1326,38 @@ case 37:
1341
1326
  }
1342
1327
  goto tr66;
1343
1328
  tr66:
1344
- #line 105 "hpricot_scan.rl"
1329
+ #line 111 "hpricot_scan.rl"
1345
1330
  { mark_aval = p; }
1346
1331
  goto st38;
1347
1332
  st38:
1348
1333
  if ( ++p == pe )
1349
1334
  goto _test_eof38;
1350
1335
  case 38:
1351
- #line 1352 "hpricot_scan.c"
1336
+ #line 1337 "hpricot_scan.c"
1352
1337
  switch( (*p) ) {
1353
1338
  case 34: goto tr70;
1354
1339
  case 39: goto tr71;
1355
1340
  }
1356
1341
  goto st38;
1357
1342
  tr81:
1358
- #line 105 "hpricot_scan.rl"
1343
+ #line 111 "hpricot_scan.rl"
1359
1344
  { mark_aval = p; }
1360
1345
  goto st39;
1361
1346
  tr67:
1362
- #line 105 "hpricot_scan.rl"
1347
+ #line 111 "hpricot_scan.rl"
1363
1348
  { mark_aval = p; }
1364
- #line 119 "hpricot_scan.rl"
1349
+ #line 125 "hpricot_scan.rl"
1365
1350
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1366
1351
  goto st39;
1367
1352
  tr70:
1368
- #line 119 "hpricot_scan.rl"
1353
+ #line 125 "hpricot_scan.rl"
1369
1354
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1370
1355
  goto st39;
1371
1356
  st39:
1372
1357
  if ( ++p == pe )
1373
1358
  goto _test_eof39;
1374
1359
  case 39:
1375
- #line 1376 "hpricot_scan.c"
1360
+ #line 1361 "hpricot_scan.c"
1376
1361
  switch( (*p) ) {
1377
1362
  case 32: goto st39;
1378
1363
  case 39: goto tr41;
@@ -1385,7 +1370,7 @@ case 39:
1385
1370
  tr56:
1386
1371
  #line 1 "hpricot_scan.rl"
1387
1372
  {te = p+1;}
1388
- #line 105 "hpricot_scan.rl"
1373
+ #line 111 "hpricot_scan.rl"
1389
1374
  { mark_aval = p; }
1390
1375
  #line 66 "hpricot_scan.rl"
1391
1376
  {act = 8;}
@@ -1400,33 +1385,33 @@ st206:
1400
1385
  if ( ++p == pe )
1401
1386
  goto _test_eof206;
1402
1387
  case 206:
1403
- #line 1404 "hpricot_scan.c"
1388
+ #line 1389 "hpricot_scan.c"
1404
1389
  if ( (*p) == 39 )
1405
1390
  goto tr41;
1406
1391
  goto st29;
1407
1392
  tr57:
1408
- #line 105 "hpricot_scan.rl"
1393
+ #line 111 "hpricot_scan.rl"
1409
1394
  { mark_aval = p; }
1410
1395
  goto st40;
1411
1396
  st40:
1412
1397
  if ( ++p == pe )
1413
1398
  goto _test_eof40;
1414
1399
  case 40:
1415
- #line 1416 "hpricot_scan.c"
1400
+ #line 1401 "hpricot_scan.c"
1416
1401
  switch( (*p) ) {
1417
1402
  case 39: goto tr73;
1418
1403
  case 93: goto st42;
1419
1404
  }
1420
1405
  goto st40;
1421
1406
  tr73:
1422
- #line 119 "hpricot_scan.rl"
1407
+ #line 125 "hpricot_scan.rl"
1423
1408
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1424
1409
  goto st41;
1425
1410
  st41:
1426
1411
  if ( ++p == pe )
1427
1412
  goto _test_eof41;
1428
1413
  case 41:
1429
- #line 1430 "hpricot_scan.c"
1414
+ #line 1415 "hpricot_scan.c"
1430
1415
  switch( (*p) ) {
1431
1416
  case 32: goto st41;
1432
1417
  case 62: goto tr76;
@@ -1445,7 +1430,7 @@ st207:
1445
1430
  if ( ++p == pe )
1446
1431
  goto _test_eof207;
1447
1432
  case 207:
1448
- #line 1449 "hpricot_scan.c"
1433
+ #line 1434 "hpricot_scan.c"
1449
1434
  if ( (*p) == 93 )
1450
1435
  goto st27;
1451
1436
  goto st26;
@@ -1462,20 +1447,20 @@ case 42:
1462
1447
  goto st42;
1463
1448
  goto st29;
1464
1449
  tr68:
1465
- #line 105 "hpricot_scan.rl"
1450
+ #line 111 "hpricot_scan.rl"
1466
1451
  { mark_aval = p; }
1467
- #line 119 "hpricot_scan.rl"
1452
+ #line 125 "hpricot_scan.rl"
1468
1453
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1469
1454
  goto st43;
1470
1455
  tr71:
1471
- #line 119 "hpricot_scan.rl"
1456
+ #line 125 "hpricot_scan.rl"
1472
1457
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1473
1458
  goto st43;
1474
1459
  st43:
1475
1460
  if ( ++p == pe )
1476
1461
  goto _test_eof43;
1477
1462
  case 43:
1478
- #line 1479 "hpricot_scan.c"
1463
+ #line 1464 "hpricot_scan.c"
1479
1464
  switch( (*p) ) {
1480
1465
  case 32: goto st43;
1481
1466
  case 34: goto tr41;
@@ -1495,7 +1480,7 @@ st208:
1495
1480
  if ( ++p == pe )
1496
1481
  goto _test_eof208;
1497
1482
  case 208:
1498
- #line 1499 "hpricot_scan.c"
1483
+ #line 1484 "hpricot_scan.c"
1499
1484
  if ( (*p) == 34 )
1500
1485
  goto tr41;
1501
1486
  goto st24;
@@ -1521,14 +1506,14 @@ case 45:
1521
1506
  goto st45;
1522
1507
  goto st24;
1523
1508
  tr65:
1524
- #line 119 "hpricot_scan.rl"
1509
+ #line 125 "hpricot_scan.rl"
1525
1510
  { SET(aval, p); ATTR(ID2SYM(rb_intern("system_id")), aval); }
1526
1511
  goto st46;
1527
1512
  st46:
1528
1513
  if ( ++p == pe )
1529
1514
  goto _test_eof46;
1530
1515
  case 46:
1531
- #line 1532 "hpricot_scan.c"
1516
+ #line 1517 "hpricot_scan.c"
1532
1517
  switch( (*p) ) {
1533
1518
  case 32: goto tr81;
1534
1519
  case 39: goto tr38;
@@ -1539,14 +1524,14 @@ case 46:
1539
1524
  goto tr81;
1540
1525
  goto tr44;
1541
1526
  tr54:
1542
- #line 105 "hpricot_scan.rl"
1527
+ #line 111 "hpricot_scan.rl"
1543
1528
  { mark_aval = p; }
1544
1529
  goto st47;
1545
1530
  st47:
1546
1531
  if ( ++p == pe )
1547
1532
  goto _test_eof47;
1548
1533
  case 47:
1549
- #line 1550 "hpricot_scan.c"
1534
+ #line 1535 "hpricot_scan.c"
1550
1535
  switch( (*p) ) {
1551
1536
  case 9: goto st47;
1552
1537
  case 39: goto tr82;
@@ -1660,14 +1645,14 @@ case 59:
1660
1645
  goto tr94;
1661
1646
  goto tr0;
1662
1647
  tr94:
1663
- #line 104 "hpricot_scan.rl"
1648
+ #line 110 "hpricot_scan.rl"
1664
1649
  { mark_tag = p; }
1665
1650
  goto st60;
1666
1651
  st60:
1667
1652
  if ( ++p == pe )
1668
1653
  goto _test_eof60;
1669
1654
  case 60:
1670
- #line 1671 "hpricot_scan.c"
1655
+ #line 1656 "hpricot_scan.c"
1671
1656
  switch( (*p) ) {
1672
1657
  case 32: goto tr95;
1673
1658
  case 62: goto tr97;
@@ -1690,14 +1675,14 @@ case 60:
1690
1675
  goto st60;
1691
1676
  goto tr0;
1692
1677
  tr95:
1693
- #line 107 "hpricot_scan.rl"
1678
+ #line 113 "hpricot_scan.rl"
1694
1679
  { SET(tag, p); }
1695
1680
  goto st61;
1696
1681
  st61:
1697
1682
  if ( ++p == pe )
1698
1683
  goto _test_eof61;
1699
1684
  case 61:
1700
- #line 1701 "hpricot_scan.c"
1685
+ #line 1686 "hpricot_scan.c"
1701
1686
  switch( (*p) ) {
1702
1687
  case 32: goto st61;
1703
1688
  case 62: goto tr99;
@@ -1706,14 +1691,14 @@ case 61:
1706
1691
  goto st61;
1707
1692
  goto tr0;
1708
1693
  tr417:
1709
- #line 104 "hpricot_scan.rl"
1694
+ #line 110 "hpricot_scan.rl"
1710
1695
  { mark_tag = p; }
1711
1696
  goto st62;
1712
1697
  st62:
1713
1698
  if ( ++p == pe )
1714
1699
  goto _test_eof62;
1715
1700
  case 62:
1716
- #line 1717 "hpricot_scan.c"
1701
+ #line 1702 "hpricot_scan.c"
1717
1702
  switch( (*p) ) {
1718
1703
  case 32: goto tr100;
1719
1704
  case 47: goto tr102;
@@ -1734,14 +1719,14 @@ case 62:
1734
1719
  goto st62;
1735
1720
  goto tr0;
1736
1721
  tr100:
1737
- #line 107 "hpricot_scan.rl"
1722
+ #line 113 "hpricot_scan.rl"
1738
1723
  { SET(tag, p); }
1739
1724
  goto st63;
1740
1725
  st63:
1741
1726
  if ( ++p == pe )
1742
1727
  goto _test_eof63;
1743
1728
  case 63:
1744
- #line 1745 "hpricot_scan.c"
1729
+ #line 1730 "hpricot_scan.c"
1745
1730
  switch( (*p) ) {
1746
1731
  case 32: goto st63;
1747
1732
  case 47: goto st66;
@@ -1762,36 +1747,38 @@ case 63:
1762
1747
  goto tr105;
1763
1748
  goto tr0;
1764
1749
  tr105:
1765
- #line 121 "hpricot_scan.rl"
1766
- {
1750
+ #line 127 "hpricot_scan.rl"
1751
+ {
1767
1752
  akey = Qnil;
1768
1753
  aval = Qnil;
1769
1754
  mark_akey = NULL;
1770
1755
  mark_aval = NULL;
1771
1756
  }
1772
- #line 106 "hpricot_scan.rl"
1757
+ #line 112 "hpricot_scan.rl"
1773
1758
  { mark_akey = p; }
1774
1759
  goto st64;
1775
1760
  tr114:
1776
- #line 128 "hpricot_scan.rl"
1777
- {
1761
+ #line 134 "hpricot_scan.rl"
1762
+ {
1763
+ if (!S->xml)
1764
+ akey = rb_funcall(akey, s_downcase, 0);
1778
1765
  ATTR(akey, aval);
1779
1766
  }
1780
- #line 121 "hpricot_scan.rl"
1781
- {
1767
+ #line 127 "hpricot_scan.rl"
1768
+ {
1782
1769
  akey = Qnil;
1783
1770
  aval = Qnil;
1784
1771
  mark_akey = NULL;
1785
1772
  mark_aval = NULL;
1786
1773
  }
1787
- #line 106 "hpricot_scan.rl"
1774
+ #line 112 "hpricot_scan.rl"
1788
1775
  { mark_akey = p; }
1789
1776
  goto st64;
1790
1777
  st64:
1791
1778
  if ( ++p == pe )
1792
1779
  goto _test_eof64;
1793
1780
  case 64:
1794
- #line 1795 "hpricot_scan.c"
1781
+ #line 1782 "hpricot_scan.c"
1795
1782
  switch( (*p) ) {
1796
1783
  case 32: goto tr108;
1797
1784
  case 47: goto tr110;
@@ -1813,21 +1800,21 @@ case 64:
1813
1800
  goto st64;
1814
1801
  goto tr39;
1815
1802
  tr108:
1816
- #line 114 "hpricot_scan.rl"
1803
+ #line 120 "hpricot_scan.rl"
1817
1804
  { SET(akey, p); }
1818
1805
  goto st65;
1819
1806
  tr140:
1820
- #line 110 "hpricot_scan.rl"
1821
- {
1807
+ #line 116 "hpricot_scan.rl"
1808
+ {
1822
1809
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
1823
1810
  else { SET(aval, p); }
1824
1811
  }
1825
1812
  goto st65;
1826
1813
  tr134:
1827
- #line 114 "hpricot_scan.rl"
1814
+ #line 120 "hpricot_scan.rl"
1828
1815
  { SET(akey, p); }
1829
- #line 110 "hpricot_scan.rl"
1830
- {
1816
+ #line 116 "hpricot_scan.rl"
1817
+ {
1831
1818
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
1832
1819
  else { SET(aval, p); }
1833
1820
  }
@@ -1836,7 +1823,7 @@ st65:
1836
1823
  if ( ++p == pe )
1837
1824
  goto _test_eof65;
1838
1825
  case 65:
1839
- #line 1840 "hpricot_scan.c"
1826
+ #line 1827 "hpricot_scan.c"
1840
1827
  switch( (*p) ) {
1841
1828
  case 32: goto st65;
1842
1829
  case 47: goto tr115;
@@ -1858,20 +1845,24 @@ case 65:
1858
1845
  goto tr114;
1859
1846
  goto tr39;
1860
1847
  tr102:
1861
- #line 107 "hpricot_scan.rl"
1848
+ #line 113 "hpricot_scan.rl"
1862
1849
  { SET(tag, p); }
1863
1850
  goto st66;
1864
1851
  tr110:
1865
- #line 114 "hpricot_scan.rl"
1852
+ #line 120 "hpricot_scan.rl"
1866
1853
  { SET(akey, p); }
1867
- #line 128 "hpricot_scan.rl"
1868
- {
1854
+ #line 134 "hpricot_scan.rl"
1855
+ {
1856
+ if (!S->xml)
1857
+ akey = rb_funcall(akey, s_downcase, 0);
1869
1858
  ATTR(akey, aval);
1870
1859
  }
1871
1860
  goto st66;
1872
1861
  tr115:
1873
- #line 128 "hpricot_scan.rl"
1874
- {
1862
+ #line 134 "hpricot_scan.rl"
1863
+ {
1864
+ if (!S->xml)
1865
+ akey = rb_funcall(akey, s_downcase, 0);
1875
1866
  ATTR(akey, aval);
1876
1867
  }
1877
1868
  goto st66;
@@ -1879,19 +1870,19 @@ st66:
1879
1870
  if ( ++p == pe )
1880
1871
  goto _test_eof66;
1881
1872
  case 66:
1882
- #line 1883 "hpricot_scan.c"
1873
+ #line 1874 "hpricot_scan.c"
1883
1874
  if ( (*p) == 62 )
1884
1875
  goto tr118;
1885
1876
  goto tr39;
1886
1877
  tr111:
1887
- #line 114 "hpricot_scan.rl"
1878
+ #line 120 "hpricot_scan.rl"
1888
1879
  { SET(akey, p); }
1889
1880
  goto st67;
1890
1881
  st67:
1891
1882
  if ( ++p == pe )
1892
1883
  goto _test_eof67;
1893
1884
  case 67:
1894
- #line 1895 "hpricot_scan.c"
1885
+ #line 1886 "hpricot_scan.c"
1895
1886
  switch( (*p) ) {
1896
1887
  case 13: goto tr120;
1897
1888
  case 32: goto tr120;
@@ -1908,14 +1899,14 @@ case 67:
1908
1899
  goto tr120;
1909
1900
  goto tr119;
1910
1901
  tr119:
1911
- #line 105 "hpricot_scan.rl"
1902
+ #line 111 "hpricot_scan.rl"
1912
1903
  { mark_aval = p; }
1913
1904
  goto st68;
1914
1905
  st68:
1915
1906
  if ( ++p == pe )
1916
1907
  goto _test_eof68;
1917
1908
  case 68:
1918
- #line 1919 "hpricot_scan.c"
1909
+ #line 1910 "hpricot_scan.c"
1919
1910
  switch( (*p) ) {
1920
1911
  case 13: goto tr126;
1921
1912
  case 32: goto tr126;
@@ -1930,27 +1921,27 @@ case 68:
1930
1921
  goto tr126;
1931
1922
  goto st68;
1932
1923
  tr126:
1933
- #line 110 "hpricot_scan.rl"
1934
- {
1924
+ #line 116 "hpricot_scan.rl"
1925
+ {
1935
1926
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
1936
1927
  else { SET(aval, p); }
1937
1928
  }
1938
1929
  goto st69;
1939
1930
  tr331:
1940
- #line 105 "hpricot_scan.rl"
1931
+ #line 111 "hpricot_scan.rl"
1941
1932
  { mark_aval = p; }
1942
- #line 109 "hpricot_scan.rl"
1933
+ #line 115 "hpricot_scan.rl"
1943
1934
  { SET(aval, p); }
1944
1935
  goto st69;
1945
1936
  tr169:
1946
- #line 109 "hpricot_scan.rl"
1937
+ #line 115 "hpricot_scan.rl"
1947
1938
  { SET(aval, p); }
1948
1939
  goto st69;
1949
1940
  st69:
1950
1941
  if ( ++p == pe )
1951
1942
  goto _test_eof69;
1952
1943
  case 69:
1953
- #line 1954 "hpricot_scan.c"
1944
+ #line 1945 "hpricot_scan.c"
1954
1945
  switch( (*p) ) {
1955
1946
  case 32: goto st69;
1956
1947
  case 47: goto tr115;
@@ -1971,27 +1962,27 @@ case 69:
1971
1962
  goto tr114;
1972
1963
  goto tr39;
1973
1964
  tr127:
1974
- #line 110 "hpricot_scan.rl"
1975
- {
1965
+ #line 116 "hpricot_scan.rl"
1966
+ {
1976
1967
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
1977
1968
  else { SET(aval, p); }
1978
1969
  }
1979
1970
  goto st70;
1980
1971
  tr155:
1981
- #line 105 "hpricot_scan.rl"
1972
+ #line 111 "hpricot_scan.rl"
1982
1973
  { mark_aval = p; }
1983
- #line 109 "hpricot_scan.rl"
1974
+ #line 115 "hpricot_scan.rl"
1984
1975
  { SET(aval, p); }
1985
1976
  goto st70;
1986
1977
  tr163:
1987
- #line 109 "hpricot_scan.rl"
1978
+ #line 115 "hpricot_scan.rl"
1988
1979
  { SET(aval, p); }
1989
1980
  goto st70;
1990
1981
  st70:
1991
1982
  if ( ++p == pe )
1992
1983
  goto _test_eof70;
1993
1984
  case 70:
1994
- #line 1995 "hpricot_scan.c"
1985
+ #line 1986 "hpricot_scan.c"
1995
1986
  switch( (*p) ) {
1996
1987
  case 13: goto tr126;
1997
1988
  case 32: goto tr126;
@@ -2017,42 +2008,46 @@ case 70:
2017
2008
  goto tr131;
2018
2009
  goto st68;
2019
2010
  tr131:
2020
- #line 128 "hpricot_scan.rl"
2021
- {
2011
+ #line 134 "hpricot_scan.rl"
2012
+ {
2013
+ if (!S->xml)
2014
+ akey = rb_funcall(akey, s_downcase, 0);
2022
2015
  ATTR(akey, aval);
2023
2016
  }
2024
- #line 121 "hpricot_scan.rl"
2025
- {
2017
+ #line 127 "hpricot_scan.rl"
2018
+ {
2026
2019
  akey = Qnil;
2027
2020
  aval = Qnil;
2028
2021
  mark_akey = NULL;
2029
2022
  mark_aval = NULL;
2030
2023
  }
2031
- #line 106 "hpricot_scan.rl"
2024
+ #line 112 "hpricot_scan.rl"
2032
2025
  { mark_akey = p; }
2033
2026
  goto st71;
2034
2027
  tr150:
2035
- #line 105 "hpricot_scan.rl"
2028
+ #line 111 "hpricot_scan.rl"
2036
2029
  { mark_aval = p; }
2037
- #line 128 "hpricot_scan.rl"
2038
- {
2030
+ #line 134 "hpricot_scan.rl"
2031
+ {
2032
+ if (!S->xml)
2033
+ akey = rb_funcall(akey, s_downcase, 0);
2039
2034
  ATTR(akey, aval);
2040
2035
  }
2041
- #line 121 "hpricot_scan.rl"
2042
- {
2036
+ #line 127 "hpricot_scan.rl"
2037
+ {
2043
2038
  akey = Qnil;
2044
2039
  aval = Qnil;
2045
2040
  mark_akey = NULL;
2046
2041
  mark_aval = NULL;
2047
2042
  }
2048
- #line 106 "hpricot_scan.rl"
2043
+ #line 112 "hpricot_scan.rl"
2049
2044
  { mark_akey = p; }
2050
2045
  goto st71;
2051
2046
  st71:
2052
2047
  if ( ++p == pe )
2053
2048
  goto _test_eof71;
2054
2049
  case 71:
2055
- #line 2056 "hpricot_scan.c"
2050
+ #line 2051 "hpricot_scan.c"
2056
2051
  switch( (*p) ) {
2057
2052
  case 13: goto tr134;
2058
2053
  case 32: goto tr134;
@@ -2079,17 +2074,17 @@ case 71:
2079
2074
  goto st71;
2080
2075
  goto st68;
2081
2076
  tr141:
2082
- #line 110 "hpricot_scan.rl"
2083
- {
2077
+ #line 116 "hpricot_scan.rl"
2078
+ {
2084
2079
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2085
2080
  else { SET(aval, p); }
2086
2081
  }
2087
2082
  goto st72;
2088
2083
  tr135:
2089
- #line 114 "hpricot_scan.rl"
2084
+ #line 120 "hpricot_scan.rl"
2090
2085
  { SET(akey, p); }
2091
- #line 110 "hpricot_scan.rl"
2092
- {
2086
+ #line 116 "hpricot_scan.rl"
2087
+ {
2093
2088
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2094
2089
  else { SET(aval, p); }
2095
2090
  }
@@ -2098,7 +2093,7 @@ st72:
2098
2093
  if ( ++p == pe )
2099
2094
  goto _test_eof72;
2100
2095
  case 72:
2101
- #line 2102 "hpricot_scan.c"
2096
+ #line 2097 "hpricot_scan.c"
2102
2097
  switch( (*p) ) {
2103
2098
  case 13: goto tr140;
2104
2099
  case 32: goto tr140;
@@ -2125,70 +2120,82 @@ case 72:
2125
2120
  goto tr131;
2126
2121
  goto st68;
2127
2122
  tr124:
2128
- #line 105 "hpricot_scan.rl"
2123
+ #line 111 "hpricot_scan.rl"
2129
2124
  { mark_aval = p; }
2130
- #line 128 "hpricot_scan.rl"
2131
- {
2125
+ #line 134 "hpricot_scan.rl"
2126
+ {
2127
+ if (!S->xml)
2128
+ akey = rb_funcall(akey, s_downcase, 0);
2132
2129
  ATTR(akey, aval);
2133
2130
  }
2134
2131
  goto st73;
2135
2132
  tr128:
2136
- #line 110 "hpricot_scan.rl"
2137
- {
2133
+ #line 116 "hpricot_scan.rl"
2134
+ {
2138
2135
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2139
2136
  else { SET(aval, p); }
2140
2137
  }
2141
- #line 128 "hpricot_scan.rl"
2142
- {
2138
+ #line 134 "hpricot_scan.rl"
2139
+ {
2140
+ if (!S->xml)
2141
+ akey = rb_funcall(akey, s_downcase, 0);
2143
2142
  ATTR(akey, aval);
2144
2143
  }
2145
2144
  goto st73;
2146
2145
  tr132:
2147
- #line 128 "hpricot_scan.rl"
2148
- {
2146
+ #line 134 "hpricot_scan.rl"
2147
+ {
2148
+ if (!S->xml)
2149
+ akey = rb_funcall(akey, s_downcase, 0);
2149
2150
  ATTR(akey, aval);
2150
2151
  }
2151
- #line 110 "hpricot_scan.rl"
2152
- {
2152
+ #line 116 "hpricot_scan.rl"
2153
+ {
2153
2154
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2154
2155
  else { SET(aval, p); }
2155
2156
  }
2156
2157
  goto st73;
2157
2158
  tr137:
2158
- #line 110 "hpricot_scan.rl"
2159
- {
2159
+ #line 116 "hpricot_scan.rl"
2160
+ {
2160
2161
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2161
2162
  else { SET(aval, p); }
2162
2163
  }
2163
- #line 114 "hpricot_scan.rl"
2164
+ #line 120 "hpricot_scan.rl"
2164
2165
  { SET(akey, p); }
2165
- #line 128 "hpricot_scan.rl"
2166
- {
2166
+ #line 134 "hpricot_scan.rl"
2167
+ {
2168
+ if (!S->xml)
2169
+ akey = rb_funcall(akey, s_downcase, 0);
2167
2170
  ATTR(akey, aval);
2168
2171
  }
2169
2172
  goto st73;
2170
2173
  tr147:
2171
- #line 105 "hpricot_scan.rl"
2174
+ #line 111 "hpricot_scan.rl"
2172
2175
  { mark_aval = p; }
2173
- #line 110 "hpricot_scan.rl"
2174
- {
2176
+ #line 116 "hpricot_scan.rl"
2177
+ {
2175
2178
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2176
2179
  else { SET(aval, p); }
2177
2180
  }
2178
- #line 128 "hpricot_scan.rl"
2179
- {
2181
+ #line 134 "hpricot_scan.rl"
2182
+ {
2183
+ if (!S->xml)
2184
+ akey = rb_funcall(akey, s_downcase, 0);
2180
2185
  ATTR(akey, aval);
2181
2186
  }
2182
2187
  goto st73;
2183
2188
  tr151:
2184
- #line 105 "hpricot_scan.rl"
2189
+ #line 111 "hpricot_scan.rl"
2185
2190
  { mark_aval = p; }
2186
- #line 128 "hpricot_scan.rl"
2187
- {
2191
+ #line 134 "hpricot_scan.rl"
2192
+ {
2193
+ if (!S->xml)
2194
+ akey = rb_funcall(akey, s_downcase, 0);
2188
2195
  ATTR(akey, aval);
2189
2196
  }
2190
- #line 110 "hpricot_scan.rl"
2191
- {
2197
+ #line 116 "hpricot_scan.rl"
2198
+ {
2192
2199
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2193
2200
  else { SET(aval, p); }
2194
2201
  }
@@ -2197,7 +2204,7 @@ st73:
2197
2204
  if ( ++p == pe )
2198
2205
  goto _test_eof73;
2199
2206
  case 73:
2200
- #line 2201 "hpricot_scan.c"
2207
+ #line 2208 "hpricot_scan.c"
2201
2208
  switch( (*p) ) {
2202
2209
  case 13: goto tr126;
2203
2210
  case 32: goto tr126;
@@ -2212,18 +2219,18 @@ case 73:
2212
2219
  goto tr126;
2213
2220
  goto st68;
2214
2221
  tr121:
2215
- #line 105 "hpricot_scan.rl"
2222
+ #line 111 "hpricot_scan.rl"
2216
2223
  { mark_aval = p; }
2217
2224
  goto st74;
2218
2225
  tr138:
2219
- #line 114 "hpricot_scan.rl"
2226
+ #line 120 "hpricot_scan.rl"
2220
2227
  { SET(akey, p); }
2221
2228
  goto st74;
2222
2229
  st74:
2223
2230
  if ( ++p == pe )
2224
2231
  goto _test_eof74;
2225
2232
  case 74:
2226
- #line 2227 "hpricot_scan.c"
2233
+ #line 2234 "hpricot_scan.c"
2227
2234
  switch( (*p) ) {
2228
2235
  case 13: goto tr143;
2229
2236
  case 32: goto tr143;
@@ -2240,14 +2247,14 @@ case 74:
2240
2247
  goto tr143;
2241
2248
  goto tr119;
2242
2249
  tr148:
2243
- #line 105 "hpricot_scan.rl"
2250
+ #line 111 "hpricot_scan.rl"
2244
2251
  { mark_aval = p; }
2245
2252
  goto st75;
2246
2253
  tr143:
2247
- #line 105 "hpricot_scan.rl"
2254
+ #line 111 "hpricot_scan.rl"
2248
2255
  { mark_aval = p; }
2249
- #line 110 "hpricot_scan.rl"
2250
- {
2256
+ #line 116 "hpricot_scan.rl"
2257
+ {
2251
2258
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2252
2259
  else { SET(aval, p); }
2253
2260
  }
@@ -2256,7 +2263,7 @@ st75:
2256
2263
  if ( ++p == pe )
2257
2264
  goto _test_eof75;
2258
2265
  case 75:
2259
- #line 2260 "hpricot_scan.c"
2266
+ #line 2267 "hpricot_scan.c"
2260
2267
  switch( (*p) ) {
2261
2268
  case 13: goto tr148;
2262
2269
  case 32: goto tr148;
@@ -2284,14 +2291,14 @@ case 75:
2284
2291
  goto tr150;
2285
2292
  goto tr119;
2286
2293
  tr149:
2287
- #line 105 "hpricot_scan.rl"
2294
+ #line 111 "hpricot_scan.rl"
2288
2295
  { mark_aval = p; }
2289
2296
  goto st76;
2290
2297
  tr144:
2291
- #line 105 "hpricot_scan.rl"
2298
+ #line 111 "hpricot_scan.rl"
2292
2299
  { mark_aval = p; }
2293
- #line 110 "hpricot_scan.rl"
2294
- {
2300
+ #line 116 "hpricot_scan.rl"
2301
+ {
2295
2302
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2296
2303
  else { SET(aval, p); }
2297
2304
  }
@@ -2300,7 +2307,7 @@ st76:
2300
2307
  if ( ++p == pe )
2301
2308
  goto _test_eof76;
2302
2309
  case 76:
2303
- #line 2304 "hpricot_scan.c"
2310
+ #line 2311 "hpricot_scan.c"
2304
2311
  switch( (*p) ) {
2305
2312
  case 13: goto tr143;
2306
2313
  case 32: goto tr143;
@@ -2347,14 +2354,14 @@ case 77:
2347
2354
  goto tr153;
2348
2355
  goto tr152;
2349
2356
  tr152:
2350
- #line 105 "hpricot_scan.rl"
2357
+ #line 111 "hpricot_scan.rl"
2351
2358
  { mark_aval = p; }
2352
2359
  goto st78;
2353
2360
  st78:
2354
2361
  if ( ++p == pe )
2355
2362
  goto _test_eof78;
2356
2363
  case 78:
2357
- #line 2358 "hpricot_scan.c"
2364
+ #line 2365 "hpricot_scan.c"
2358
2365
  switch( (*p) ) {
2359
2366
  case 13: goto tr161;
2360
2367
  case 32: goto tr161;
@@ -2371,40 +2378,40 @@ case 78:
2371
2378
  goto tr161;
2372
2379
  goto st78;
2373
2380
  tr336:
2374
- #line 105 "hpricot_scan.rl"
2381
+ #line 111 "hpricot_scan.rl"
2375
2382
  { mark_aval = p; }
2376
2383
  goto st79;
2377
2384
  tr161:
2378
- #line 110 "hpricot_scan.rl"
2379
- {
2385
+ #line 116 "hpricot_scan.rl"
2386
+ {
2380
2387
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2381
2388
  else { SET(aval, p); }
2382
2389
  }
2383
2390
  goto st79;
2384
2391
  tr153:
2385
- #line 105 "hpricot_scan.rl"
2392
+ #line 111 "hpricot_scan.rl"
2386
2393
  { mark_aval = p; }
2387
- #line 110 "hpricot_scan.rl"
2388
- {
2394
+ #line 116 "hpricot_scan.rl"
2395
+ {
2389
2396
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2390
2397
  else { SET(aval, p); }
2391
2398
  }
2392
2399
  goto st79;
2393
2400
  tr317:
2394
- #line 105 "hpricot_scan.rl"
2401
+ #line 111 "hpricot_scan.rl"
2395
2402
  { mark_aval = p; }
2396
- #line 109 "hpricot_scan.rl"
2403
+ #line 115 "hpricot_scan.rl"
2397
2404
  { SET(aval, p); }
2398
2405
  goto st79;
2399
2406
  tr174:
2400
- #line 109 "hpricot_scan.rl"
2407
+ #line 115 "hpricot_scan.rl"
2401
2408
  { SET(aval, p); }
2402
2409
  goto st79;
2403
2410
  st79:
2404
2411
  if ( ++p == pe )
2405
2412
  goto _test_eof79;
2406
2413
  case 79:
2407
- #line 2408 "hpricot_scan.c"
2414
+ #line 2415 "hpricot_scan.c"
2408
2415
  switch( (*p) ) {
2409
2416
  case 32: goto st79;
2410
2417
  case 34: goto tr169;
@@ -2427,70 +2434,74 @@ case 79:
2427
2434
  goto tr170;
2428
2435
  goto st80;
2429
2436
  tr157:
2430
- #line 105 "hpricot_scan.rl"
2437
+ #line 111 "hpricot_scan.rl"
2431
2438
  { mark_aval = p; }
2432
2439
  goto st80;
2433
2440
  st80:
2434
2441
  if ( ++p == pe )
2435
2442
  goto _test_eof80;
2436
2443
  case 80:
2437
- #line 2438 "hpricot_scan.c"
2444
+ #line 2445 "hpricot_scan.c"
2438
2445
  switch( (*p) ) {
2439
2446
  case 34: goto tr169;
2440
2447
  case 92: goto st81;
2441
2448
  }
2442
2449
  goto st80;
2443
2450
  tr340:
2444
- #line 105 "hpricot_scan.rl"
2451
+ #line 111 "hpricot_scan.rl"
2445
2452
  { mark_aval = p; }
2446
2453
  goto st81;
2447
2454
  st81:
2448
2455
  if ( ++p == pe )
2449
2456
  goto _test_eof81;
2450
2457
  case 81:
2451
- #line 2452 "hpricot_scan.c"
2458
+ #line 2459 "hpricot_scan.c"
2452
2459
  switch( (*p) ) {
2453
2460
  case 34: goto tr174;
2454
2461
  case 92: goto st81;
2455
2462
  }
2456
2463
  goto st80;
2457
2464
  tr170:
2458
- #line 128 "hpricot_scan.rl"
2459
- {
2465
+ #line 134 "hpricot_scan.rl"
2466
+ {
2467
+ if (!S->xml)
2468
+ akey = rb_funcall(akey, s_downcase, 0);
2460
2469
  ATTR(akey, aval);
2461
2470
  }
2462
- #line 121 "hpricot_scan.rl"
2463
- {
2471
+ #line 127 "hpricot_scan.rl"
2472
+ {
2464
2473
  akey = Qnil;
2465
2474
  aval = Qnil;
2466
2475
  mark_akey = NULL;
2467
2476
  mark_aval = NULL;
2468
2477
  }
2469
- #line 106 "hpricot_scan.rl"
2478
+ #line 112 "hpricot_scan.rl"
2470
2479
  { mark_akey = p; }
2471
2480
  goto st82;
2472
2481
  tr337:
2473
- #line 105 "hpricot_scan.rl"
2482
+ #line 111 "hpricot_scan.rl"
2474
2483
  { mark_aval = p; }
2475
- #line 128 "hpricot_scan.rl"
2476
- {
2484
+ #line 134 "hpricot_scan.rl"
2485
+ {
2486
+ if (!S->xml)
2487
+ akey = rb_funcall(akey, s_downcase, 0);
2477
2488
  ATTR(akey, aval);
2478
2489
  }
2479
- #line 121 "hpricot_scan.rl"
2480
- {
2490
+ #line 127 "hpricot_scan.rl"
2491
+ {
2481
2492
  akey = Qnil;
2482
2493
  aval = Qnil;
2483
2494
  mark_akey = NULL;
2484
2495
  mark_aval = NULL;
2485
2496
  }
2486
- #line 106 "hpricot_scan.rl"
2497
+ #line 112 "hpricot_scan.rl"
2487
2498
  { mark_akey = p; }
2488
2499
  goto st82;
2489
2500
  st82:
2490
2501
  if ( ++p == pe )
2491
2502
  goto _test_eof82;
2492
2503
  case 82:
2493
- #line 2494 "hpricot_scan.c"
2504
+ #line 2505 "hpricot_scan.c"
2494
2505
  switch( (*p) ) {
2495
2506
  case 32: goto tr175;
2496
2507
  case 34: goto tr169;
@@ -2514,21 +2525,21 @@ case 82:
2514
2525
  goto st82;
2515
2526
  goto st80;
2516
2527
  tr175:
2517
- #line 114 "hpricot_scan.rl"
2528
+ #line 120 "hpricot_scan.rl"
2518
2529
  { SET(akey, p); }
2519
2530
  goto st83;
2520
2531
  tr206:
2521
- #line 110 "hpricot_scan.rl"
2522
- {
2532
+ #line 116 "hpricot_scan.rl"
2533
+ {
2523
2534
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2524
2535
  else { SET(aval, p); }
2525
2536
  }
2526
2537
  goto st83;
2527
2538
  tr200:
2528
- #line 114 "hpricot_scan.rl"
2539
+ #line 120 "hpricot_scan.rl"
2529
2540
  { SET(akey, p); }
2530
- #line 110 "hpricot_scan.rl"
2531
- {
2541
+ #line 116 "hpricot_scan.rl"
2542
+ {
2532
2543
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2533
2544
  else { SET(aval, p); }
2534
2545
  }
@@ -2537,7 +2548,7 @@ st83:
2537
2548
  if ( ++p == pe )
2538
2549
  goto _test_eof83;
2539
2550
  case 83:
2540
- #line 2541 "hpricot_scan.c"
2551
+ #line 2552 "hpricot_scan.c"
2541
2552
  switch( (*p) ) {
2542
2553
  case 32: goto st83;
2543
2554
  case 34: goto tr169;
@@ -2561,24 +2572,30 @@ case 83:
2561
2572
  goto tr170;
2562
2573
  goto st80;
2563
2574
  tr177:
2564
- #line 114 "hpricot_scan.rl"
2575
+ #line 120 "hpricot_scan.rl"
2565
2576
  { SET(akey, p); }
2566
- #line 128 "hpricot_scan.rl"
2567
- {
2577
+ #line 134 "hpricot_scan.rl"
2578
+ {
2579
+ if (!S->xml)
2580
+ akey = rb_funcall(akey, s_downcase, 0);
2568
2581
  ATTR(akey, aval);
2569
2582
  }
2570
2583
  goto st84;
2571
2584
  tr171:
2572
- #line 128 "hpricot_scan.rl"
2573
- {
2585
+ #line 134 "hpricot_scan.rl"
2586
+ {
2587
+ if (!S->xml)
2588
+ akey = rb_funcall(akey, s_downcase, 0);
2574
2589
  ATTR(akey, aval);
2575
2590
  }
2576
2591
  goto st84;
2577
2592
  tr338:
2578
- #line 105 "hpricot_scan.rl"
2593
+ #line 111 "hpricot_scan.rl"
2579
2594
  { mark_aval = p; }
2580
- #line 128 "hpricot_scan.rl"
2581
- {
2595
+ #line 134 "hpricot_scan.rl"
2596
+ {
2597
+ if (!S->xml)
2598
+ akey = rb_funcall(akey, s_downcase, 0);
2582
2599
  ATTR(akey, aval);
2583
2600
  }
2584
2601
  goto st84;
@@ -2586,7 +2603,7 @@ st84:
2586
2603
  if ( ++p == pe )
2587
2604
  goto _test_eof84;
2588
2605
  case 84:
2589
- #line 2590 "hpricot_scan.c"
2606
+ #line 2607 "hpricot_scan.c"
2590
2607
  switch( (*p) ) {
2591
2608
  case 34: goto tr169;
2592
2609
  case 62: goto tr182;
@@ -2596,15 +2613,17 @@ case 84:
2596
2613
  tr158:
2597
2614
  #line 1 "hpricot_scan.rl"
2598
2615
  {te = p+1;}
2599
- #line 105 "hpricot_scan.rl"
2616
+ #line 111 "hpricot_scan.rl"
2600
2617
  { mark_aval = p; }
2601
- #line 110 "hpricot_scan.rl"
2602
- {
2618
+ #line 116 "hpricot_scan.rl"
2619
+ {
2603
2620
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2604
2621
  else { SET(aval, p); }
2605
2622
  }
2606
- #line 128 "hpricot_scan.rl"
2607
- {
2623
+ #line 134 "hpricot_scan.rl"
2624
+ {
2625
+ if (!S->xml)
2626
+ akey = rb_funcall(akey, s_downcase, 0);
2608
2627
  ATTR(akey, aval);
2609
2628
  }
2610
2629
  #line 68 "hpricot_scan.rl"
@@ -2613,13 +2632,15 @@ tr158:
2613
2632
  tr166:
2614
2633
  #line 1 "hpricot_scan.rl"
2615
2634
  {te = p+1;}
2616
- #line 110 "hpricot_scan.rl"
2617
- {
2635
+ #line 116 "hpricot_scan.rl"
2636
+ {
2618
2637
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2619
2638
  else { SET(aval, p); }
2620
2639
  }
2621
- #line 128 "hpricot_scan.rl"
2622
- {
2640
+ #line 134 "hpricot_scan.rl"
2641
+ {
2642
+ if (!S->xml)
2643
+ akey = rb_funcall(akey, s_downcase, 0);
2623
2644
  ATTR(akey, aval);
2624
2645
  }
2625
2646
  #line 68 "hpricot_scan.rl"
@@ -2628,8 +2649,10 @@ tr166:
2628
2649
  tr172:
2629
2650
  #line 1 "hpricot_scan.rl"
2630
2651
  {te = p+1;}
2631
- #line 128 "hpricot_scan.rl"
2632
- {
2652
+ #line 134 "hpricot_scan.rl"
2653
+ {
2654
+ if (!S->xml)
2655
+ akey = rb_funcall(akey, s_downcase, 0);
2633
2656
  ATTR(akey, aval);
2634
2657
  }
2635
2658
  #line 68 "hpricot_scan.rl"
@@ -2638,10 +2661,12 @@ tr172:
2638
2661
  tr179:
2639
2662
  #line 1 "hpricot_scan.rl"
2640
2663
  {te = p+1;}
2641
- #line 114 "hpricot_scan.rl"
2664
+ #line 120 "hpricot_scan.rl"
2642
2665
  { SET(akey, p); }
2643
- #line 128 "hpricot_scan.rl"
2644
- {
2666
+ #line 134 "hpricot_scan.rl"
2667
+ {
2668
+ if (!S->xml)
2669
+ akey = rb_funcall(akey, s_downcase, 0);
2645
2670
  ATTR(akey, aval);
2646
2671
  }
2647
2672
  #line 68 "hpricot_scan.rl"
@@ -2656,12 +2681,14 @@ tr182:
2656
2681
  tr196:
2657
2682
  #line 1 "hpricot_scan.rl"
2658
2683
  {te = p+1;}
2659
- #line 128 "hpricot_scan.rl"
2660
- {
2684
+ #line 134 "hpricot_scan.rl"
2685
+ {
2686
+ if (!S->xml)
2687
+ akey = rb_funcall(akey, s_downcase, 0);
2661
2688
  ATTR(akey, aval);
2662
2689
  }
2663
- #line 110 "hpricot_scan.rl"
2664
- {
2690
+ #line 116 "hpricot_scan.rl"
2691
+ {
2665
2692
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2666
2693
  else { SET(aval, p); }
2667
2694
  }
@@ -2671,14 +2698,16 @@ tr196:
2671
2698
  tr197:
2672
2699
  #line 1 "hpricot_scan.rl"
2673
2700
  {te = p+1;}
2674
- #line 105 "hpricot_scan.rl"
2701
+ #line 111 "hpricot_scan.rl"
2675
2702
  { mark_aval = p; }
2676
- #line 128 "hpricot_scan.rl"
2677
- {
2703
+ #line 134 "hpricot_scan.rl"
2704
+ {
2705
+ if (!S->xml)
2706
+ akey = rb_funcall(akey, s_downcase, 0);
2678
2707
  ATTR(akey, aval);
2679
2708
  }
2680
- #line 110 "hpricot_scan.rl"
2681
- {
2709
+ #line 116 "hpricot_scan.rl"
2710
+ {
2682
2711
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2683
2712
  else { SET(aval, p); }
2684
2713
  }
@@ -2688,15 +2717,17 @@ tr197:
2688
2717
  tr205:
2689
2718
  #line 1 "hpricot_scan.rl"
2690
2719
  {te = p+1;}
2691
- #line 110 "hpricot_scan.rl"
2692
- {
2720
+ #line 116 "hpricot_scan.rl"
2721
+ {
2693
2722
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2694
2723
  else { SET(aval, p); }
2695
2724
  }
2696
- #line 114 "hpricot_scan.rl"
2725
+ #line 120 "hpricot_scan.rl"
2697
2726
  { SET(akey, p); }
2698
- #line 128 "hpricot_scan.rl"
2699
- {
2727
+ #line 134 "hpricot_scan.rl"
2728
+ {
2729
+ if (!S->xml)
2730
+ akey = rb_funcall(akey, s_downcase, 0);
2700
2731
  ATTR(akey, aval);
2701
2732
  }
2702
2733
  #line 68 "hpricot_scan.rl"
@@ -2705,10 +2736,12 @@ tr205:
2705
2736
  tr339:
2706
2737
  #line 1 "hpricot_scan.rl"
2707
2738
  {te = p+1;}
2708
- #line 105 "hpricot_scan.rl"
2739
+ #line 111 "hpricot_scan.rl"
2709
2740
  { mark_aval = p; }
2710
- #line 128 "hpricot_scan.rl"
2711
- {
2741
+ #line 134 "hpricot_scan.rl"
2742
+ {
2743
+ if (!S->xml)
2744
+ akey = rb_funcall(akey, s_downcase, 0);
2712
2745
  ATTR(akey, aval);
2713
2746
  }
2714
2747
  #line 68 "hpricot_scan.rl"
@@ -2718,21 +2751,21 @@ st209:
2718
2751
  if ( ++p == pe )
2719
2752
  goto _test_eof209;
2720
2753
  case 209:
2721
- #line 2722 "hpricot_scan.c"
2754
+ #line 2755 "hpricot_scan.c"
2722
2755
  switch( (*p) ) {
2723
2756
  case 34: goto tr169;
2724
2757
  case 92: goto st81;
2725
2758
  }
2726
2759
  goto st80;
2727
2760
  tr178:
2728
- #line 114 "hpricot_scan.rl"
2761
+ #line 120 "hpricot_scan.rl"
2729
2762
  { SET(akey, p); }
2730
2763
  goto st85;
2731
2764
  st85:
2732
2765
  if ( ++p == pe )
2733
2766
  goto _test_eof85;
2734
2767
  case 85:
2735
- #line 2736 "hpricot_scan.c"
2768
+ #line 2769 "hpricot_scan.c"
2736
2769
  switch( (*p) ) {
2737
2770
  case 13: goto tr183;
2738
2771
  case 32: goto tr183;
@@ -2750,14 +2783,14 @@ case 85:
2750
2783
  goto tr183;
2751
2784
  goto tr152;
2752
2785
  tr183:
2753
- #line 105 "hpricot_scan.rl"
2786
+ #line 111 "hpricot_scan.rl"
2754
2787
  { mark_aval = p; }
2755
2788
  goto st86;
2756
2789
  st86:
2757
2790
  if ( ++p == pe )
2758
2791
  goto _test_eof86;
2759
2792
  case 86:
2760
- #line 2761 "hpricot_scan.c"
2793
+ #line 2794 "hpricot_scan.c"
2761
2794
  switch( (*p) ) {
2762
2795
  case 13: goto tr188;
2763
2796
  case 32: goto tr188;
@@ -2775,14 +2808,14 @@ case 86:
2775
2808
  goto tr188;
2776
2809
  goto tr152;
2777
2810
  tr188:
2778
- #line 105 "hpricot_scan.rl"
2811
+ #line 111 "hpricot_scan.rl"
2779
2812
  { mark_aval = p; }
2780
2813
  goto st87;
2781
2814
  tr191:
2782
- #line 105 "hpricot_scan.rl"
2815
+ #line 111 "hpricot_scan.rl"
2783
2816
  { mark_aval = p; }
2784
- #line 110 "hpricot_scan.rl"
2785
- {
2817
+ #line 116 "hpricot_scan.rl"
2818
+ {
2786
2819
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2787
2820
  else { SET(aval, p); }
2788
2821
  }
@@ -2791,7 +2824,7 @@ st87:
2791
2824
  if ( ++p == pe )
2792
2825
  goto _test_eof87;
2793
2826
  case 87:
2794
- #line 2795 "hpricot_scan.c"
2827
+ #line 2828 "hpricot_scan.c"
2795
2828
  switch( (*p) ) {
2796
2829
  case 13: goto tr188;
2797
2830
  case 32: goto tr188;
@@ -2820,14 +2853,14 @@ case 87:
2820
2853
  goto tr190;
2821
2854
  goto tr152;
2822
2855
  tr189:
2823
- #line 105 "hpricot_scan.rl"
2856
+ #line 111 "hpricot_scan.rl"
2824
2857
  { mark_aval = p; }
2825
2858
  goto st88;
2826
2859
  tr192:
2827
- #line 105 "hpricot_scan.rl"
2860
+ #line 111 "hpricot_scan.rl"
2828
2861
  { mark_aval = p; }
2829
- #line 110 "hpricot_scan.rl"
2830
- {
2862
+ #line 116 "hpricot_scan.rl"
2863
+ {
2831
2864
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2832
2865
  else { SET(aval, p); }
2833
2866
  }
@@ -2836,7 +2869,7 @@ st88:
2836
2869
  if ( ++p == pe )
2837
2870
  goto _test_eof88;
2838
2871
  case 88:
2839
- #line 2840 "hpricot_scan.c"
2872
+ #line 2873 "hpricot_scan.c"
2840
2873
  switch( (*p) ) {
2841
2874
  case 13: goto tr191;
2842
2875
  case 32: goto tr191;
@@ -2865,14 +2898,14 @@ case 88:
2865
2898
  goto tr190;
2866
2899
  goto tr152;
2867
2900
  tr193:
2868
- #line 109 "hpricot_scan.rl"
2901
+ #line 115 "hpricot_scan.rl"
2869
2902
  { SET(aval, p); }
2870
2903
  goto st89;
2871
2904
  st89:
2872
2905
  if ( ++p == pe )
2873
2906
  goto _test_eof89;
2874
2907
  case 89:
2875
- #line 2876 "hpricot_scan.c"
2908
+ #line 2909 "hpricot_scan.c"
2876
2909
  switch( (*p) ) {
2877
2910
  case 13: goto tr153;
2878
2911
  case 32: goto tr153;
@@ -2900,36 +2933,36 @@ case 89:
2900
2933
  goto tr190;
2901
2934
  goto tr152;
2902
2935
  tr162:
2903
- #line 110 "hpricot_scan.rl"
2904
- {
2936
+ #line 116 "hpricot_scan.rl"
2937
+ {
2905
2938
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2906
2939
  else { SET(aval, p); }
2907
2940
  }
2908
2941
  goto st90;
2909
2942
  tr154:
2910
- #line 105 "hpricot_scan.rl"
2943
+ #line 111 "hpricot_scan.rl"
2911
2944
  { mark_aval = p; }
2912
- #line 110 "hpricot_scan.rl"
2913
- {
2945
+ #line 116 "hpricot_scan.rl"
2946
+ {
2914
2947
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
2915
2948
  else { SET(aval, p); }
2916
2949
  }
2917
2950
  goto st90;
2918
2951
  tr214:
2919
- #line 105 "hpricot_scan.rl"
2952
+ #line 111 "hpricot_scan.rl"
2920
2953
  { mark_aval = p; }
2921
- #line 109 "hpricot_scan.rl"
2954
+ #line 115 "hpricot_scan.rl"
2922
2955
  { SET(aval, p); }
2923
2956
  goto st90;
2924
2957
  tr209:
2925
- #line 109 "hpricot_scan.rl"
2958
+ #line 115 "hpricot_scan.rl"
2926
2959
  { SET(aval, p); }
2927
2960
  goto st90;
2928
2961
  st90:
2929
2962
  if ( ++p == pe )
2930
2963
  goto _test_eof90;
2931
2964
  case 90:
2932
- #line 2933 "hpricot_scan.c"
2965
+ #line 2966 "hpricot_scan.c"
2933
2966
  switch( (*p) ) {
2934
2967
  case 13: goto tr161;
2935
2968
  case 32: goto tr161;
@@ -2957,42 +2990,46 @@ case 90:
2957
2990
  goto tr198;
2958
2991
  goto st78;
2959
2992
  tr198:
2960
- #line 128 "hpricot_scan.rl"
2961
- {
2993
+ #line 134 "hpricot_scan.rl"
2994
+ {
2995
+ if (!S->xml)
2996
+ akey = rb_funcall(akey, s_downcase, 0);
2962
2997
  ATTR(akey, aval);
2963
2998
  }
2964
- #line 121 "hpricot_scan.rl"
2965
- {
2999
+ #line 127 "hpricot_scan.rl"
3000
+ {
2966
3001
  akey = Qnil;
2967
3002
  aval = Qnil;
2968
3003
  mark_akey = NULL;
2969
3004
  mark_aval = NULL;
2970
3005
  }
2971
- #line 106 "hpricot_scan.rl"
3006
+ #line 112 "hpricot_scan.rl"
2972
3007
  { mark_akey = p; }
2973
3008
  goto st91;
2974
3009
  tr190:
2975
- #line 105 "hpricot_scan.rl"
3010
+ #line 111 "hpricot_scan.rl"
2976
3011
  { mark_aval = p; }
2977
- #line 128 "hpricot_scan.rl"
2978
- {
3012
+ #line 134 "hpricot_scan.rl"
3013
+ {
3014
+ if (!S->xml)
3015
+ akey = rb_funcall(akey, s_downcase, 0);
2979
3016
  ATTR(akey, aval);
2980
3017
  }
2981
- #line 121 "hpricot_scan.rl"
2982
- {
3018
+ #line 127 "hpricot_scan.rl"
3019
+ {
2983
3020
  akey = Qnil;
2984
3021
  aval = Qnil;
2985
3022
  mark_akey = NULL;
2986
3023
  mark_aval = NULL;
2987
3024
  }
2988
- #line 106 "hpricot_scan.rl"
3025
+ #line 112 "hpricot_scan.rl"
2989
3026
  { mark_akey = p; }
2990
3027
  goto st91;
2991
3028
  st91:
2992
3029
  if ( ++p == pe )
2993
3030
  goto _test_eof91;
2994
3031
  case 91:
2995
- #line 2996 "hpricot_scan.c"
3032
+ #line 3033 "hpricot_scan.c"
2996
3033
  switch( (*p) ) {
2997
3034
  case 13: goto tr200;
2998
3035
  case 32: goto tr200;
@@ -3021,17 +3058,17 @@ case 91:
3021
3058
  goto st91;
3022
3059
  goto st78;
3023
3060
  tr207:
3024
- #line 110 "hpricot_scan.rl"
3025
- {
3061
+ #line 116 "hpricot_scan.rl"
3062
+ {
3026
3063
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3027
3064
  else { SET(aval, p); }
3028
3065
  }
3029
3066
  goto st92;
3030
3067
  tr201:
3031
- #line 114 "hpricot_scan.rl"
3068
+ #line 120 "hpricot_scan.rl"
3032
3069
  { SET(akey, p); }
3033
- #line 110 "hpricot_scan.rl"
3034
- {
3070
+ #line 116 "hpricot_scan.rl"
3071
+ {
3035
3072
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3036
3073
  else { SET(aval, p); }
3037
3074
  }
@@ -3040,7 +3077,7 @@ st92:
3040
3077
  if ( ++p == pe )
3041
3078
  goto _test_eof92;
3042
3079
  case 92:
3043
- #line 3044 "hpricot_scan.c"
3080
+ #line 3081 "hpricot_scan.c"
3044
3081
  switch( (*p) ) {
3045
3082
  case 13: goto tr206;
3046
3083
  case 32: goto tr206;
@@ -3069,70 +3106,82 @@ case 92:
3069
3106
  goto tr198;
3070
3107
  goto st78;
3071
3108
  tr187:
3072
- #line 105 "hpricot_scan.rl"
3109
+ #line 111 "hpricot_scan.rl"
3073
3110
  { mark_aval = p; }
3074
- #line 128 "hpricot_scan.rl"
3075
- {
3111
+ #line 134 "hpricot_scan.rl"
3112
+ {
3113
+ if (!S->xml)
3114
+ akey = rb_funcall(akey, s_downcase, 0);
3076
3115
  ATTR(akey, aval);
3077
3116
  }
3078
3117
  goto st93;
3079
3118
  tr164:
3080
- #line 110 "hpricot_scan.rl"
3081
- {
3119
+ #line 116 "hpricot_scan.rl"
3120
+ {
3082
3121
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3083
3122
  else { SET(aval, p); }
3084
3123
  }
3085
- #line 128 "hpricot_scan.rl"
3086
- {
3124
+ #line 134 "hpricot_scan.rl"
3125
+ {
3126
+ if (!S->xml)
3127
+ akey = rb_funcall(akey, s_downcase, 0);
3087
3128
  ATTR(akey, aval);
3088
3129
  }
3089
3130
  goto st93;
3090
3131
  tr199:
3091
- #line 128 "hpricot_scan.rl"
3092
- {
3132
+ #line 134 "hpricot_scan.rl"
3133
+ {
3134
+ if (!S->xml)
3135
+ akey = rb_funcall(akey, s_downcase, 0);
3093
3136
  ATTR(akey, aval);
3094
3137
  }
3095
- #line 110 "hpricot_scan.rl"
3096
- {
3138
+ #line 116 "hpricot_scan.rl"
3139
+ {
3097
3140
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3098
3141
  else { SET(aval, p); }
3099
3142
  }
3100
3143
  goto st93;
3101
3144
  tr203:
3102
- #line 110 "hpricot_scan.rl"
3103
- {
3145
+ #line 116 "hpricot_scan.rl"
3146
+ {
3104
3147
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3105
3148
  else { SET(aval, p); }
3106
3149
  }
3107
- #line 114 "hpricot_scan.rl"
3150
+ #line 120 "hpricot_scan.rl"
3108
3151
  { SET(akey, p); }
3109
- #line 128 "hpricot_scan.rl"
3110
- {
3152
+ #line 134 "hpricot_scan.rl"
3153
+ {
3154
+ if (!S->xml)
3155
+ akey = rb_funcall(akey, s_downcase, 0);
3111
3156
  ATTR(akey, aval);
3112
3157
  }
3113
3158
  goto st93;
3114
3159
  tr156:
3115
- #line 105 "hpricot_scan.rl"
3160
+ #line 111 "hpricot_scan.rl"
3116
3161
  { mark_aval = p; }
3117
- #line 110 "hpricot_scan.rl"
3118
- {
3162
+ #line 116 "hpricot_scan.rl"
3163
+ {
3119
3164
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3120
3165
  else { SET(aval, p); }
3121
3166
  }
3122
- #line 128 "hpricot_scan.rl"
3123
- {
3167
+ #line 134 "hpricot_scan.rl"
3168
+ {
3169
+ if (!S->xml)
3170
+ akey = rb_funcall(akey, s_downcase, 0);
3124
3171
  ATTR(akey, aval);
3125
3172
  }
3126
3173
  goto st93;
3127
3174
  tr195:
3128
- #line 105 "hpricot_scan.rl"
3175
+ #line 111 "hpricot_scan.rl"
3129
3176
  { mark_aval = p; }
3130
- #line 128 "hpricot_scan.rl"
3131
- {
3177
+ #line 134 "hpricot_scan.rl"
3178
+ {
3179
+ if (!S->xml)
3180
+ akey = rb_funcall(akey, s_downcase, 0);
3132
3181
  ATTR(akey, aval);
3133
3182
  }
3134
- #line 110 "hpricot_scan.rl"
3135
- {
3183
+ #line 116 "hpricot_scan.rl"
3184
+ {
3136
3185
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3137
3186
  else { SET(aval, p); }
3138
3187
  }
@@ -3141,7 +3190,7 @@ st93:
3141
3190
  if ( ++p == pe )
3142
3191
  goto _test_eof93;
3143
3192
  case 93:
3144
- #line 3145 "hpricot_scan.c"
3193
+ #line 3194 "hpricot_scan.c"
3145
3194
  switch( (*p) ) {
3146
3195
  case 13: goto tr161;
3147
3196
  case 32: goto tr161;
@@ -3158,14 +3207,14 @@ case 93:
3158
3207
  goto tr161;
3159
3208
  goto st78;
3160
3209
  tr159:
3161
- #line 105 "hpricot_scan.rl"
3210
+ #line 111 "hpricot_scan.rl"
3162
3211
  { mark_aval = p; }
3163
3212
  goto st94;
3164
3213
  st94:
3165
3214
  if ( ++p == pe )
3166
3215
  goto _test_eof94;
3167
3216
  case 94:
3168
- #line 3169 "hpricot_scan.c"
3217
+ #line 3218 "hpricot_scan.c"
3169
3218
  switch( (*p) ) {
3170
3219
  case 13: goto tr161;
3171
3220
  case 32: goto tr161;
@@ -3182,18 +3231,18 @@ case 94:
3182
3231
  goto tr161;
3183
3232
  goto st78;
3184
3233
  tr184:
3185
- #line 105 "hpricot_scan.rl"
3234
+ #line 111 "hpricot_scan.rl"
3186
3235
  { mark_aval = p; }
3187
3236
  goto st95;
3188
3237
  tr204:
3189
- #line 114 "hpricot_scan.rl"
3238
+ #line 120 "hpricot_scan.rl"
3190
3239
  { SET(akey, p); }
3191
3240
  goto st95;
3192
3241
  st95:
3193
3242
  if ( ++p == pe )
3194
3243
  goto _test_eof95;
3195
3244
  case 95:
3196
- #line 3197 "hpricot_scan.c"
3245
+ #line 3246 "hpricot_scan.c"
3197
3246
  switch( (*p) ) {
3198
3247
  case 13: goto tr191;
3199
3248
  case 32: goto tr191;
@@ -3231,14 +3280,14 @@ case 96:
3231
3280
  goto tr211;
3232
3281
  goto tr210;
3233
3282
  tr210:
3234
- #line 105 "hpricot_scan.rl"
3283
+ #line 111 "hpricot_scan.rl"
3235
3284
  { mark_aval = p; }
3236
3285
  goto st97;
3237
3286
  st97:
3238
3287
  if ( ++p == pe )
3239
3288
  goto _test_eof97;
3240
3289
  case 97:
3241
- #line 3242 "hpricot_scan.c"
3290
+ #line 3291 "hpricot_scan.c"
3242
3291
  switch( (*p) ) {
3243
3292
  case 13: goto tr220;
3244
3293
  case 32: goto tr220;
@@ -3256,34 +3305,34 @@ case 97:
3256
3305
  goto tr220;
3257
3306
  goto st97;
3258
3307
  tr315:
3259
- #line 105 "hpricot_scan.rl"
3308
+ #line 111 "hpricot_scan.rl"
3260
3309
  { mark_aval = p; }
3261
3310
  goto st98;
3262
3311
  tr220:
3263
- #line 110 "hpricot_scan.rl"
3264
- {
3312
+ #line 116 "hpricot_scan.rl"
3313
+ {
3265
3314
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3266
3315
  else { SET(aval, p); }
3267
3316
  }
3268
3317
  goto st98;
3269
3318
  tr211:
3270
- #line 105 "hpricot_scan.rl"
3319
+ #line 111 "hpricot_scan.rl"
3271
3320
  { mark_aval = p; }
3272
- #line 110 "hpricot_scan.rl"
3273
- {
3321
+ #line 116 "hpricot_scan.rl"
3322
+ {
3274
3323
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3275
3324
  else { SET(aval, p); }
3276
3325
  }
3277
3326
  goto st98;
3278
3327
  tr299:
3279
- #line 109 "hpricot_scan.rl"
3328
+ #line 115 "hpricot_scan.rl"
3280
3329
  { SET(aval, p); }
3281
3330
  goto st98;
3282
3331
  st98:
3283
3332
  if ( ++p == pe )
3284
3333
  goto _test_eof98;
3285
3334
  case 98:
3286
- #line 3287 "hpricot_scan.c"
3335
+ #line 3336 "hpricot_scan.c"
3287
3336
  switch( (*p) ) {
3288
3337
  case 32: goto st98;
3289
3338
  case 34: goto tr228;
@@ -3307,14 +3356,14 @@ case 98:
3307
3356
  goto tr229;
3308
3357
  goto st99;
3309
3358
  tr216:
3310
- #line 105 "hpricot_scan.rl"
3359
+ #line 111 "hpricot_scan.rl"
3311
3360
  { mark_aval = p; }
3312
3361
  goto st99;
3313
3362
  st99:
3314
3363
  if ( ++p == pe )
3315
3364
  goto _test_eof99;
3316
3365
  case 99:
3317
- #line 3318 "hpricot_scan.c"
3366
+ #line 3367 "hpricot_scan.c"
3318
3367
  switch( (*p) ) {
3319
3368
  case 34: goto tr228;
3320
3369
  case 39: goto tr174;
@@ -3322,46 +3371,46 @@ case 99:
3322
3371
  }
3323
3372
  goto st99;
3324
3373
  tr330:
3325
- #line 105 "hpricot_scan.rl"
3374
+ #line 111 "hpricot_scan.rl"
3326
3375
  { mark_aval = p; }
3327
3376
  goto st100;
3328
3377
  tr255:
3329
- #line 110 "hpricot_scan.rl"
3330
- {
3378
+ #line 116 "hpricot_scan.rl"
3379
+ {
3331
3380
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3332
3381
  else { SET(aval, p); }
3333
3382
  }
3334
3383
  goto st100;
3335
3384
  tr326:
3336
- #line 105 "hpricot_scan.rl"
3385
+ #line 111 "hpricot_scan.rl"
3337
3386
  { mark_aval = p; }
3338
- #line 110 "hpricot_scan.rl"
3339
- {
3387
+ #line 116 "hpricot_scan.rl"
3388
+ {
3340
3389
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3341
3390
  else { SET(aval, p); }
3342
3391
  }
3343
3392
  goto st100;
3344
3393
  tr316:
3345
- #line 105 "hpricot_scan.rl"
3394
+ #line 111 "hpricot_scan.rl"
3346
3395
  { mark_aval = p; }
3347
- #line 109 "hpricot_scan.rl"
3396
+ #line 115 "hpricot_scan.rl"
3348
3397
  { SET(aval, p); }
3349
3398
  goto st100;
3350
3399
  tr228:
3351
- #line 109 "hpricot_scan.rl"
3400
+ #line 115 "hpricot_scan.rl"
3352
3401
  { SET(aval, p); }
3353
3402
  goto st100;
3354
3403
  tr322:
3355
- #line 109 "hpricot_scan.rl"
3404
+ #line 115 "hpricot_scan.rl"
3356
3405
  { SET(aval, p); }
3357
- #line 105 "hpricot_scan.rl"
3406
+ #line 111 "hpricot_scan.rl"
3358
3407
  { mark_aval = p; }
3359
3408
  goto st100;
3360
3409
  st100:
3361
3410
  if ( ++p == pe )
3362
3411
  goto _test_eof100;
3363
3412
  case 100:
3364
- #line 3365 "hpricot_scan.c"
3413
+ #line 3414 "hpricot_scan.c"
3365
3414
  switch( (*p) ) {
3366
3415
  case 32: goto st100;
3367
3416
  case 39: goto tr169;
@@ -3384,70 +3433,74 @@ case 100:
3384
3433
  goto tr235;
3385
3434
  goto st101;
3386
3435
  tr328:
3387
- #line 105 "hpricot_scan.rl"
3436
+ #line 111 "hpricot_scan.rl"
3388
3437
  { mark_aval = p; }
3389
3438
  goto st101;
3390
3439
  st101:
3391
3440
  if ( ++p == pe )
3392
3441
  goto _test_eof101;
3393
3442
  case 101:
3394
- #line 3395 "hpricot_scan.c"
3443
+ #line 3444 "hpricot_scan.c"
3395
3444
  switch( (*p) ) {
3396
3445
  case 39: goto tr169;
3397
3446
  case 92: goto st102;
3398
3447
  }
3399
3448
  goto st101;
3400
3449
  tr335:
3401
- #line 105 "hpricot_scan.rl"
3450
+ #line 111 "hpricot_scan.rl"
3402
3451
  { mark_aval = p; }
3403
3452
  goto st102;
3404
3453
  st102:
3405
3454
  if ( ++p == pe )
3406
3455
  goto _test_eof102;
3407
3456
  case 102:
3408
- #line 3409 "hpricot_scan.c"
3457
+ #line 3458 "hpricot_scan.c"
3409
3458
  switch( (*p) ) {
3410
3459
  case 39: goto tr228;
3411
3460
  case 92: goto st102;
3412
3461
  }
3413
3462
  goto st101;
3414
3463
  tr235:
3415
- #line 128 "hpricot_scan.rl"
3416
- {
3464
+ #line 134 "hpricot_scan.rl"
3465
+ {
3466
+ if (!S->xml)
3467
+ akey = rb_funcall(akey, s_downcase, 0);
3417
3468
  ATTR(akey, aval);
3418
3469
  }
3419
- #line 121 "hpricot_scan.rl"
3420
- {
3470
+ #line 127 "hpricot_scan.rl"
3471
+ {
3421
3472
  akey = Qnil;
3422
3473
  aval = Qnil;
3423
3474
  mark_akey = NULL;
3424
3475
  mark_aval = NULL;
3425
3476
  }
3426
- #line 106 "hpricot_scan.rl"
3477
+ #line 112 "hpricot_scan.rl"
3427
3478
  { mark_akey = p; }
3428
3479
  goto st103;
3429
3480
  tr332:
3430
- #line 105 "hpricot_scan.rl"
3481
+ #line 111 "hpricot_scan.rl"
3431
3482
  { mark_aval = p; }
3432
- #line 128 "hpricot_scan.rl"
3433
- {
3483
+ #line 134 "hpricot_scan.rl"
3484
+ {
3485
+ if (!S->xml)
3486
+ akey = rb_funcall(akey, s_downcase, 0);
3434
3487
  ATTR(akey, aval);
3435
3488
  }
3436
- #line 121 "hpricot_scan.rl"
3437
- {
3489
+ #line 127 "hpricot_scan.rl"
3490
+ {
3438
3491
  akey = Qnil;
3439
3492
  aval = Qnil;
3440
3493
  mark_akey = NULL;
3441
3494
  mark_aval = NULL;
3442
3495
  }
3443
- #line 106 "hpricot_scan.rl"
3496
+ #line 112 "hpricot_scan.rl"
3444
3497
  { mark_akey = p; }
3445
3498
  goto st103;
3446
3499
  st103:
3447
3500
  if ( ++p == pe )
3448
3501
  goto _test_eof103;
3449
3502
  case 103:
3450
- #line 3451 "hpricot_scan.c"
3503
+ #line 3504 "hpricot_scan.c"
3451
3504
  switch( (*p) ) {
3452
3505
  case 32: goto tr239;
3453
3506
  case 39: goto tr169;
@@ -3471,21 +3524,21 @@ case 103:
3471
3524
  goto st103;
3472
3525
  goto st101;
3473
3526
  tr239:
3474
- #line 114 "hpricot_scan.rl"
3527
+ #line 120 "hpricot_scan.rl"
3475
3528
  { SET(akey, p); }
3476
3529
  goto st104;
3477
3530
  tr269:
3478
- #line 110 "hpricot_scan.rl"
3479
- {
3531
+ #line 116 "hpricot_scan.rl"
3532
+ {
3480
3533
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3481
3534
  else { SET(aval, p); }
3482
3535
  }
3483
3536
  goto st104;
3484
3537
  tr263:
3485
- #line 114 "hpricot_scan.rl"
3538
+ #line 120 "hpricot_scan.rl"
3486
3539
  { SET(akey, p); }
3487
- #line 110 "hpricot_scan.rl"
3488
- {
3540
+ #line 116 "hpricot_scan.rl"
3541
+ {
3489
3542
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3490
3543
  else { SET(aval, p); }
3491
3544
  }
@@ -3494,7 +3547,7 @@ st104:
3494
3547
  if ( ++p == pe )
3495
3548
  goto _test_eof104;
3496
3549
  case 104:
3497
- #line 3498 "hpricot_scan.c"
3550
+ #line 3551 "hpricot_scan.c"
3498
3551
  switch( (*p) ) {
3499
3552
  case 32: goto st104;
3500
3553
  case 39: goto tr169;
@@ -3518,24 +3571,30 @@ case 104:
3518
3571
  goto tr235;
3519
3572
  goto st101;
3520
3573
  tr241:
3521
- #line 114 "hpricot_scan.rl"
3574
+ #line 120 "hpricot_scan.rl"
3522
3575
  { SET(akey, p); }
3523
- #line 128 "hpricot_scan.rl"
3524
- {
3576
+ #line 134 "hpricot_scan.rl"
3577
+ {
3578
+ if (!S->xml)
3579
+ akey = rb_funcall(akey, s_downcase, 0);
3525
3580
  ATTR(akey, aval);
3526
3581
  }
3527
3582
  goto st105;
3528
3583
  tr236:
3529
- #line 128 "hpricot_scan.rl"
3530
- {
3584
+ #line 134 "hpricot_scan.rl"
3585
+ {
3586
+ if (!S->xml)
3587
+ akey = rb_funcall(akey, s_downcase, 0);
3531
3588
  ATTR(akey, aval);
3532
3589
  }
3533
3590
  goto st105;
3534
3591
  tr333:
3535
- #line 105 "hpricot_scan.rl"
3592
+ #line 111 "hpricot_scan.rl"
3536
3593
  { mark_aval = p; }
3537
- #line 128 "hpricot_scan.rl"
3538
- {
3594
+ #line 134 "hpricot_scan.rl"
3595
+ {
3596
+ if (!S->xml)
3597
+ akey = rb_funcall(akey, s_downcase, 0);
3539
3598
  ATTR(akey, aval);
3540
3599
  }
3541
3600
  goto st105;
@@ -3543,7 +3602,7 @@ st105:
3543
3602
  if ( ++p == pe )
3544
3603
  goto _test_eof105;
3545
3604
  case 105:
3546
- #line 3547 "hpricot_scan.c"
3605
+ #line 3606 "hpricot_scan.c"
3547
3606
  switch( (*p) ) {
3548
3607
  case 39: goto tr169;
3549
3608
  case 62: goto tr246;
@@ -3553,15 +3612,17 @@ case 105:
3553
3612
  tr341:
3554
3613
  #line 1 "hpricot_scan.rl"
3555
3614
  {te = p+1;}
3556
- #line 105 "hpricot_scan.rl"
3615
+ #line 111 "hpricot_scan.rl"
3557
3616
  { mark_aval = p; }
3558
- #line 110 "hpricot_scan.rl"
3559
- {
3617
+ #line 116 "hpricot_scan.rl"
3618
+ {
3560
3619
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3561
3620
  else { SET(aval, p); }
3562
3621
  }
3563
- #line 128 "hpricot_scan.rl"
3564
- {
3622
+ #line 134 "hpricot_scan.rl"
3623
+ {
3624
+ if (!S->xml)
3625
+ akey = rb_funcall(akey, s_downcase, 0);
3565
3626
  ATTR(akey, aval);
3566
3627
  }
3567
3628
  #line 68 "hpricot_scan.rl"
@@ -3570,13 +3631,15 @@ tr341:
3570
3631
  tr258:
3571
3632
  #line 1 "hpricot_scan.rl"
3572
3633
  {te = p+1;}
3573
- #line 110 "hpricot_scan.rl"
3574
- {
3634
+ #line 116 "hpricot_scan.rl"
3635
+ {
3575
3636
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3576
3637
  else { SET(aval, p); }
3577
3638
  }
3578
- #line 128 "hpricot_scan.rl"
3579
- {
3639
+ #line 134 "hpricot_scan.rl"
3640
+ {
3641
+ if (!S->xml)
3642
+ akey = rb_funcall(akey, s_downcase, 0);
3580
3643
  ATTR(akey, aval);
3581
3644
  }
3582
3645
  #line 68 "hpricot_scan.rl"
@@ -3585,8 +3648,10 @@ tr258:
3585
3648
  tr237:
3586
3649
  #line 1 "hpricot_scan.rl"
3587
3650
  {te = p+1;}
3588
- #line 128 "hpricot_scan.rl"
3589
- {
3651
+ #line 134 "hpricot_scan.rl"
3652
+ {
3653
+ if (!S->xml)
3654
+ akey = rb_funcall(akey, s_downcase, 0);
3590
3655
  ATTR(akey, aval);
3591
3656
  }
3592
3657
  #line 68 "hpricot_scan.rl"
@@ -3595,10 +3660,12 @@ tr237:
3595
3660
  tr243:
3596
3661
  #line 1 "hpricot_scan.rl"
3597
3662
  {te = p+1;}
3598
- #line 114 "hpricot_scan.rl"
3663
+ #line 120 "hpricot_scan.rl"
3599
3664
  { SET(akey, p); }
3600
- #line 128 "hpricot_scan.rl"
3601
- {
3665
+ #line 134 "hpricot_scan.rl"
3666
+ {
3667
+ if (!S->xml)
3668
+ akey = rb_funcall(akey, s_downcase, 0);
3602
3669
  ATTR(akey, aval);
3603
3670
  }
3604
3671
  #line 68 "hpricot_scan.rl"
@@ -3613,12 +3680,14 @@ tr246:
3613
3680
  tr262:
3614
3681
  #line 1 "hpricot_scan.rl"
3615
3682
  {te = p+1;}
3616
- #line 128 "hpricot_scan.rl"
3617
- {
3683
+ #line 134 "hpricot_scan.rl"
3684
+ {
3685
+ if (!S->xml)
3686
+ akey = rb_funcall(akey, s_downcase, 0);
3618
3687
  ATTR(akey, aval);
3619
3688
  }
3620
- #line 110 "hpricot_scan.rl"
3621
- {
3689
+ #line 116 "hpricot_scan.rl"
3690
+ {
3622
3691
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3623
3692
  else { SET(aval, p); }
3624
3693
  }
@@ -3628,14 +3697,16 @@ tr262:
3628
3697
  tr329:
3629
3698
  #line 1 "hpricot_scan.rl"
3630
3699
  {te = p+1;}
3631
- #line 105 "hpricot_scan.rl"
3700
+ #line 111 "hpricot_scan.rl"
3632
3701
  { mark_aval = p; }
3633
- #line 128 "hpricot_scan.rl"
3634
- {
3702
+ #line 134 "hpricot_scan.rl"
3703
+ {
3704
+ if (!S->xml)
3705
+ akey = rb_funcall(akey, s_downcase, 0);
3635
3706
  ATTR(akey, aval);
3636
3707
  }
3637
- #line 110 "hpricot_scan.rl"
3638
- {
3708
+ #line 116 "hpricot_scan.rl"
3709
+ {
3639
3710
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3640
3711
  else { SET(aval, p); }
3641
3712
  }
@@ -3645,15 +3716,17 @@ tr329:
3645
3716
  tr268:
3646
3717
  #line 1 "hpricot_scan.rl"
3647
3718
  {te = p+1;}
3648
- #line 110 "hpricot_scan.rl"
3649
- {
3719
+ #line 116 "hpricot_scan.rl"
3720
+ {
3650
3721
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3651
3722
  else { SET(aval, p); }
3652
3723
  }
3653
- #line 114 "hpricot_scan.rl"
3724
+ #line 120 "hpricot_scan.rl"
3654
3725
  { SET(akey, p); }
3655
- #line 128 "hpricot_scan.rl"
3656
- {
3726
+ #line 134 "hpricot_scan.rl"
3727
+ {
3728
+ if (!S->xml)
3729
+ akey = rb_funcall(akey, s_downcase, 0);
3657
3730
  ATTR(akey, aval);
3658
3731
  }
3659
3732
  #line 68 "hpricot_scan.rl"
@@ -3662,10 +3735,12 @@ tr268:
3662
3735
  tr334:
3663
3736
  #line 1 "hpricot_scan.rl"
3664
3737
  {te = p+1;}
3665
- #line 105 "hpricot_scan.rl"
3738
+ #line 111 "hpricot_scan.rl"
3666
3739
  { mark_aval = p; }
3667
- #line 128 "hpricot_scan.rl"
3668
- {
3740
+ #line 134 "hpricot_scan.rl"
3741
+ {
3742
+ if (!S->xml)
3743
+ akey = rb_funcall(akey, s_downcase, 0);
3669
3744
  ATTR(akey, aval);
3670
3745
  }
3671
3746
  #line 68 "hpricot_scan.rl"
@@ -3675,21 +3750,21 @@ st210:
3675
3750
  if ( ++p == pe )
3676
3751
  goto _test_eof210;
3677
3752
  case 210:
3678
- #line 3679 "hpricot_scan.c"
3753
+ #line 3754 "hpricot_scan.c"
3679
3754
  switch( (*p) ) {
3680
3755
  case 39: goto tr169;
3681
3756
  case 92: goto st102;
3682
3757
  }
3683
3758
  goto st101;
3684
3759
  tr242:
3685
- #line 114 "hpricot_scan.rl"
3760
+ #line 120 "hpricot_scan.rl"
3686
3761
  { SET(akey, p); }
3687
3762
  goto st106;
3688
3763
  st106:
3689
3764
  if ( ++p == pe )
3690
3765
  goto _test_eof106;
3691
3766
  case 106:
3692
- #line 3693 "hpricot_scan.c"
3767
+ #line 3768 "hpricot_scan.c"
3693
3768
  switch( (*p) ) {
3694
3769
  case 13: goto tr248;
3695
3770
  case 32: goto tr248;
@@ -3707,14 +3782,14 @@ case 106:
3707
3782
  goto tr248;
3708
3783
  goto tr247;
3709
3784
  tr247:
3710
- #line 105 "hpricot_scan.rl"
3785
+ #line 111 "hpricot_scan.rl"
3711
3786
  { mark_aval = p; }
3712
3787
  goto st107;
3713
3788
  st107:
3714
3789
  if ( ++p == pe )
3715
3790
  goto _test_eof107;
3716
3791
  case 107:
3717
- #line 3718 "hpricot_scan.c"
3792
+ #line 3793 "hpricot_scan.c"
3718
3793
  switch( (*p) ) {
3719
3794
  case 13: goto tr255;
3720
3795
  case 32: goto tr255;
@@ -3731,42 +3806,42 @@ case 107:
3731
3806
  goto tr255;
3732
3807
  goto st107;
3733
3808
  tr256:
3734
- #line 110 "hpricot_scan.rl"
3735
- {
3809
+ #line 116 "hpricot_scan.rl"
3810
+ {
3736
3811
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3737
3812
  else { SET(aval, p); }
3738
3813
  }
3739
3814
  goto st108;
3740
3815
  tr327:
3741
- #line 105 "hpricot_scan.rl"
3816
+ #line 111 "hpricot_scan.rl"
3742
3817
  { mark_aval = p; }
3743
- #line 110 "hpricot_scan.rl"
3744
- {
3818
+ #line 116 "hpricot_scan.rl"
3819
+ {
3745
3820
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3746
3821
  else { SET(aval, p); }
3747
3822
  }
3748
3823
  goto st108;
3749
3824
  tr281:
3750
- #line 105 "hpricot_scan.rl"
3825
+ #line 111 "hpricot_scan.rl"
3751
3826
  { mark_aval = p; }
3752
- #line 109 "hpricot_scan.rl"
3827
+ #line 115 "hpricot_scan.rl"
3753
3828
  { SET(aval, p); }
3754
3829
  goto st108;
3755
3830
  tr222:
3756
- #line 109 "hpricot_scan.rl"
3831
+ #line 115 "hpricot_scan.rl"
3757
3832
  { SET(aval, p); }
3758
3833
  goto st108;
3759
3834
  tr213:
3760
- #line 109 "hpricot_scan.rl"
3835
+ #line 115 "hpricot_scan.rl"
3761
3836
  { SET(aval, p); }
3762
- #line 105 "hpricot_scan.rl"
3837
+ #line 111 "hpricot_scan.rl"
3763
3838
  { mark_aval = p; }
3764
3839
  goto st108;
3765
3840
  st108:
3766
3841
  if ( ++p == pe )
3767
3842
  goto _test_eof108;
3768
3843
  case 108:
3769
- #line 3770 "hpricot_scan.c"
3844
+ #line 3845 "hpricot_scan.c"
3770
3845
  switch( (*p) ) {
3771
3846
  case 13: goto tr255;
3772
3847
  case 32: goto tr255;
@@ -3794,42 +3869,46 @@ case 108:
3794
3869
  goto tr260;
3795
3870
  goto st107;
3796
3871
  tr260:
3797
- #line 128 "hpricot_scan.rl"
3798
- {
3872
+ #line 134 "hpricot_scan.rl"
3873
+ {
3874
+ if (!S->xml)
3875
+ akey = rb_funcall(akey, s_downcase, 0);
3799
3876
  ATTR(akey, aval);
3800
3877
  }
3801
- #line 121 "hpricot_scan.rl"
3802
- {
3878
+ #line 127 "hpricot_scan.rl"
3879
+ {
3803
3880
  akey = Qnil;
3804
3881
  aval = Qnil;
3805
3882
  mark_akey = NULL;
3806
3883
  mark_aval = NULL;
3807
3884
  }
3808
- #line 106 "hpricot_scan.rl"
3885
+ #line 112 "hpricot_scan.rl"
3809
3886
  { mark_akey = p; }
3810
3887
  goto st109;
3811
3888
  tr279:
3812
- #line 105 "hpricot_scan.rl"
3889
+ #line 111 "hpricot_scan.rl"
3813
3890
  { mark_aval = p; }
3814
- #line 128 "hpricot_scan.rl"
3815
- {
3891
+ #line 134 "hpricot_scan.rl"
3892
+ {
3893
+ if (!S->xml)
3894
+ akey = rb_funcall(akey, s_downcase, 0);
3816
3895
  ATTR(akey, aval);
3817
3896
  }
3818
- #line 121 "hpricot_scan.rl"
3819
- {
3897
+ #line 127 "hpricot_scan.rl"
3898
+ {
3820
3899
  akey = Qnil;
3821
3900
  aval = Qnil;
3822
3901
  mark_akey = NULL;
3823
3902
  mark_aval = NULL;
3824
3903
  }
3825
- #line 106 "hpricot_scan.rl"
3904
+ #line 112 "hpricot_scan.rl"
3826
3905
  { mark_akey = p; }
3827
3906
  goto st109;
3828
3907
  st109:
3829
3908
  if ( ++p == pe )
3830
3909
  goto _test_eof109;
3831
3910
  case 109:
3832
- #line 3833 "hpricot_scan.c"
3911
+ #line 3912 "hpricot_scan.c"
3833
3912
  switch( (*p) ) {
3834
3913
  case 13: goto tr263;
3835
3914
  case 32: goto tr263;
@@ -3858,17 +3937,17 @@ case 109:
3858
3937
  goto st109;
3859
3938
  goto st107;
3860
3939
  tr270:
3861
- #line 110 "hpricot_scan.rl"
3862
- {
3940
+ #line 116 "hpricot_scan.rl"
3941
+ {
3863
3942
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3864
3943
  else { SET(aval, p); }
3865
3944
  }
3866
3945
  goto st110;
3867
3946
  tr264:
3868
- #line 114 "hpricot_scan.rl"
3947
+ #line 120 "hpricot_scan.rl"
3869
3948
  { SET(akey, p); }
3870
- #line 110 "hpricot_scan.rl"
3871
- {
3949
+ #line 116 "hpricot_scan.rl"
3950
+ {
3872
3951
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3873
3952
  else { SET(aval, p); }
3874
3953
  }
@@ -3877,7 +3956,7 @@ st110:
3877
3956
  if ( ++p == pe )
3878
3957
  goto _test_eof110;
3879
3958
  case 110:
3880
- #line 3881 "hpricot_scan.c"
3959
+ #line 3960 "hpricot_scan.c"
3881
3960
  switch( (*p) ) {
3882
3961
  case 13: goto tr269;
3883
3962
  case 32: goto tr269;
@@ -3906,70 +3985,82 @@ case 110:
3906
3985
  goto tr260;
3907
3986
  goto st107;
3908
3987
  tr252:
3909
- #line 105 "hpricot_scan.rl"
3988
+ #line 111 "hpricot_scan.rl"
3910
3989
  { mark_aval = p; }
3911
- #line 128 "hpricot_scan.rl"
3912
- {
3990
+ #line 134 "hpricot_scan.rl"
3991
+ {
3992
+ if (!S->xml)
3993
+ akey = rb_funcall(akey, s_downcase, 0);
3913
3994
  ATTR(akey, aval);
3914
3995
  }
3915
3996
  goto st111;
3916
3997
  tr257:
3917
- #line 110 "hpricot_scan.rl"
3918
- {
3998
+ #line 116 "hpricot_scan.rl"
3999
+ {
3919
4000
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3920
4001
  else { SET(aval, p); }
3921
4002
  }
3922
- #line 128 "hpricot_scan.rl"
3923
- {
4003
+ #line 134 "hpricot_scan.rl"
4004
+ {
4005
+ if (!S->xml)
4006
+ akey = rb_funcall(akey, s_downcase, 0);
3924
4007
  ATTR(akey, aval);
3925
4008
  }
3926
4009
  goto st111;
3927
4010
  tr261:
3928
- #line 128 "hpricot_scan.rl"
3929
- {
4011
+ #line 134 "hpricot_scan.rl"
4012
+ {
4013
+ if (!S->xml)
4014
+ akey = rb_funcall(akey, s_downcase, 0);
3930
4015
  ATTR(akey, aval);
3931
4016
  }
3932
- #line 110 "hpricot_scan.rl"
3933
- {
4017
+ #line 116 "hpricot_scan.rl"
4018
+ {
3934
4019
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3935
4020
  else { SET(aval, p); }
3936
4021
  }
3937
4022
  goto st111;
3938
4023
  tr266:
3939
- #line 110 "hpricot_scan.rl"
3940
- {
4024
+ #line 116 "hpricot_scan.rl"
4025
+ {
3941
4026
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3942
4027
  else { SET(aval, p); }
3943
4028
  }
3944
- #line 114 "hpricot_scan.rl"
4029
+ #line 120 "hpricot_scan.rl"
3945
4030
  { SET(akey, p); }
3946
- #line 128 "hpricot_scan.rl"
3947
- {
4031
+ #line 134 "hpricot_scan.rl"
4032
+ {
4033
+ if (!S->xml)
4034
+ akey = rb_funcall(akey, s_downcase, 0);
3948
4035
  ATTR(akey, aval);
3949
4036
  }
3950
4037
  goto st111;
3951
4038
  tr276:
3952
- #line 105 "hpricot_scan.rl"
4039
+ #line 111 "hpricot_scan.rl"
3953
4040
  { mark_aval = p; }
3954
- #line 110 "hpricot_scan.rl"
3955
- {
4041
+ #line 116 "hpricot_scan.rl"
4042
+ {
3956
4043
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3957
4044
  else { SET(aval, p); }
3958
4045
  }
3959
- #line 128 "hpricot_scan.rl"
3960
- {
4046
+ #line 134 "hpricot_scan.rl"
4047
+ {
4048
+ if (!S->xml)
4049
+ akey = rb_funcall(akey, s_downcase, 0);
3961
4050
  ATTR(akey, aval);
3962
4051
  }
3963
4052
  goto st111;
3964
4053
  tr280:
3965
- #line 105 "hpricot_scan.rl"
4054
+ #line 111 "hpricot_scan.rl"
3966
4055
  { mark_aval = p; }
3967
- #line 128 "hpricot_scan.rl"
3968
- {
4056
+ #line 134 "hpricot_scan.rl"
4057
+ {
4058
+ if (!S->xml)
4059
+ akey = rb_funcall(akey, s_downcase, 0);
3969
4060
  ATTR(akey, aval);
3970
4061
  }
3971
- #line 110 "hpricot_scan.rl"
3972
- {
4062
+ #line 116 "hpricot_scan.rl"
4063
+ {
3973
4064
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
3974
4065
  else { SET(aval, p); }
3975
4066
  }
@@ -3978,7 +4069,7 @@ st111:
3978
4069
  if ( ++p == pe )
3979
4070
  goto _test_eof111;
3980
4071
  case 111:
3981
- #line 3982 "hpricot_scan.c"
4072
+ #line 4073 "hpricot_scan.c"
3982
4073
  switch( (*p) ) {
3983
4074
  case 13: goto tr255;
3984
4075
  case 32: goto tr255;
@@ -3995,14 +4086,14 @@ case 111:
3995
4086
  goto tr255;
3996
4087
  goto st107;
3997
4088
  tr253:
3998
- #line 105 "hpricot_scan.rl"
4089
+ #line 111 "hpricot_scan.rl"
3999
4090
  { mark_aval = p; }
4000
4091
  goto st112;
4001
4092
  st112:
4002
4093
  if ( ++p == pe )
4003
4094
  goto _test_eof112;
4004
4095
  case 112:
4005
- #line 4006 "hpricot_scan.c"
4096
+ #line 4097 "hpricot_scan.c"
4006
4097
  switch( (*p) ) {
4007
4098
  case 13: goto tr255;
4008
4099
  case 32: goto tr255;
@@ -4019,18 +4110,18 @@ case 112:
4019
4110
  goto tr255;
4020
4111
  goto st107;
4021
4112
  tr249:
4022
- #line 105 "hpricot_scan.rl"
4113
+ #line 111 "hpricot_scan.rl"
4023
4114
  { mark_aval = p; }
4024
4115
  goto st113;
4025
4116
  tr267:
4026
- #line 114 "hpricot_scan.rl"
4117
+ #line 120 "hpricot_scan.rl"
4027
4118
  { SET(akey, p); }
4028
4119
  goto st113;
4029
4120
  st113:
4030
4121
  if ( ++p == pe )
4031
4122
  goto _test_eof113;
4032
4123
  case 113:
4033
- #line 4034 "hpricot_scan.c"
4124
+ #line 4125 "hpricot_scan.c"
4034
4125
  switch( (*p) ) {
4035
4126
  case 13: goto tr272;
4036
4127
  case 32: goto tr272;
@@ -4048,14 +4139,14 @@ case 113:
4048
4139
  goto tr272;
4049
4140
  goto tr247;
4050
4141
  tr277:
4051
- #line 105 "hpricot_scan.rl"
4142
+ #line 111 "hpricot_scan.rl"
4052
4143
  { mark_aval = p; }
4053
4144
  goto st114;
4054
4145
  tr272:
4055
- #line 105 "hpricot_scan.rl"
4146
+ #line 111 "hpricot_scan.rl"
4056
4147
  { mark_aval = p; }
4057
- #line 110 "hpricot_scan.rl"
4058
- {
4148
+ #line 116 "hpricot_scan.rl"
4149
+ {
4059
4150
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4060
4151
  else { SET(aval, p); }
4061
4152
  }
@@ -4064,7 +4155,7 @@ st114:
4064
4155
  if ( ++p == pe )
4065
4156
  goto _test_eof114;
4066
4157
  case 114:
4067
- #line 4068 "hpricot_scan.c"
4158
+ #line 4159 "hpricot_scan.c"
4068
4159
  switch( (*p) ) {
4069
4160
  case 13: goto tr277;
4070
4161
  case 32: goto tr277;
@@ -4093,14 +4184,14 @@ case 114:
4093
4184
  goto tr279;
4094
4185
  goto tr247;
4095
4186
  tr278:
4096
- #line 105 "hpricot_scan.rl"
4187
+ #line 111 "hpricot_scan.rl"
4097
4188
  { mark_aval = p; }
4098
4189
  goto st115;
4099
4190
  tr273:
4100
- #line 105 "hpricot_scan.rl"
4191
+ #line 111 "hpricot_scan.rl"
4101
4192
  { mark_aval = p; }
4102
- #line 110 "hpricot_scan.rl"
4103
- {
4193
+ #line 116 "hpricot_scan.rl"
4194
+ {
4104
4195
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4105
4196
  else { SET(aval, p); }
4106
4197
  }
@@ -4109,7 +4200,7 @@ st115:
4109
4200
  if ( ++p == pe )
4110
4201
  goto _test_eof115;
4111
4202
  case 115:
4112
- #line 4113 "hpricot_scan.c"
4203
+ #line 4204 "hpricot_scan.c"
4113
4204
  switch( (*p) ) {
4114
4205
  case 13: goto tr272;
4115
4206
  case 32: goto tr272;
@@ -4158,30 +4249,30 @@ case 116:
4158
4249
  goto tr211;
4159
4250
  goto tr210;
4160
4251
  tr221:
4161
- #line 110 "hpricot_scan.rl"
4162
- {
4252
+ #line 116 "hpricot_scan.rl"
4253
+ {
4163
4254
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4164
4255
  else { SET(aval, p); }
4165
4256
  }
4166
4257
  goto st117;
4167
4258
  tr212:
4168
- #line 105 "hpricot_scan.rl"
4259
+ #line 111 "hpricot_scan.rl"
4169
4260
  { mark_aval = p; }
4170
- #line 110 "hpricot_scan.rl"
4171
- {
4261
+ #line 116 "hpricot_scan.rl"
4262
+ {
4172
4263
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4173
4264
  else { SET(aval, p); }
4174
4265
  }
4175
4266
  goto st117;
4176
4267
  tr314:
4177
- #line 109 "hpricot_scan.rl"
4268
+ #line 115 "hpricot_scan.rl"
4178
4269
  { SET(aval, p); }
4179
4270
  goto st117;
4180
4271
  st117:
4181
4272
  if ( ++p == pe )
4182
4273
  goto _test_eof117;
4183
4274
  case 117:
4184
- #line 4185 "hpricot_scan.c"
4275
+ #line 4276 "hpricot_scan.c"
4185
4276
  switch( (*p) ) {
4186
4277
  case 13: goto tr220;
4187
4278
  case 32: goto tr220;
@@ -4210,42 +4301,46 @@ case 117:
4210
4301
  goto tr282;
4211
4302
  goto st97;
4212
4303
  tr282:
4213
- #line 128 "hpricot_scan.rl"
4214
- {
4304
+ #line 134 "hpricot_scan.rl"
4305
+ {
4306
+ if (!S->xml)
4307
+ akey = rb_funcall(akey, s_downcase, 0);
4215
4308
  ATTR(akey, aval);
4216
4309
  }
4217
- #line 121 "hpricot_scan.rl"
4218
- {
4310
+ #line 127 "hpricot_scan.rl"
4311
+ {
4219
4312
  akey = Qnil;
4220
4313
  aval = Qnil;
4221
4314
  mark_akey = NULL;
4222
4315
  mark_aval = NULL;
4223
4316
  }
4224
- #line 106 "hpricot_scan.rl"
4317
+ #line 112 "hpricot_scan.rl"
4225
4318
  { mark_akey = p; }
4226
4319
  goto st118;
4227
4320
  tr307:
4228
- #line 105 "hpricot_scan.rl"
4321
+ #line 111 "hpricot_scan.rl"
4229
4322
  { mark_aval = p; }
4230
- #line 128 "hpricot_scan.rl"
4231
- {
4323
+ #line 134 "hpricot_scan.rl"
4324
+ {
4325
+ if (!S->xml)
4326
+ akey = rb_funcall(akey, s_downcase, 0);
4232
4327
  ATTR(akey, aval);
4233
4328
  }
4234
- #line 121 "hpricot_scan.rl"
4235
- {
4329
+ #line 127 "hpricot_scan.rl"
4330
+ {
4236
4331
  akey = Qnil;
4237
4332
  aval = Qnil;
4238
4333
  mark_akey = NULL;
4239
4334
  mark_aval = NULL;
4240
4335
  }
4241
- #line 106 "hpricot_scan.rl"
4336
+ #line 112 "hpricot_scan.rl"
4242
4337
  { mark_akey = p; }
4243
4338
  goto st118;
4244
4339
  st118:
4245
4340
  if ( ++p == pe )
4246
4341
  goto _test_eof118;
4247
4342
  case 118:
4248
- #line 4249 "hpricot_scan.c"
4343
+ #line 4344 "hpricot_scan.c"
4249
4344
  switch( (*p) ) {
4250
4345
  case 13: goto tr285;
4251
4346
  case 32: goto tr285;
@@ -4275,21 +4370,21 @@ case 118:
4275
4370
  goto st118;
4276
4371
  goto st97;
4277
4372
  tr293:
4278
- #line 114 "hpricot_scan.rl"
4373
+ #line 120 "hpricot_scan.rl"
4279
4374
  { SET(akey, p); }
4280
4375
  goto st119;
4281
4376
  tr323:
4282
- #line 110 "hpricot_scan.rl"
4283
- {
4377
+ #line 116 "hpricot_scan.rl"
4378
+ {
4284
4379
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4285
4380
  else { SET(aval, p); }
4286
4381
  }
4287
4382
  goto st119;
4288
4383
  tr285:
4289
- #line 114 "hpricot_scan.rl"
4384
+ #line 120 "hpricot_scan.rl"
4290
4385
  { SET(akey, p); }
4291
- #line 110 "hpricot_scan.rl"
4292
- {
4386
+ #line 116 "hpricot_scan.rl"
4387
+ {
4293
4388
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4294
4389
  else { SET(aval, p); }
4295
4390
  }
@@ -4298,7 +4393,7 @@ st119:
4298
4393
  if ( ++p == pe )
4299
4394
  goto _test_eof119;
4300
4395
  case 119:
4301
- #line 4302 "hpricot_scan.c"
4396
+ #line 4397 "hpricot_scan.c"
4302
4397
  switch( (*p) ) {
4303
4398
  case 32: goto st119;
4304
4399
  case 34: goto tr228;
@@ -4323,42 +4418,46 @@ case 119:
4323
4418
  goto tr229;
4324
4419
  goto st99;
4325
4420
  tr229:
4326
- #line 128 "hpricot_scan.rl"
4327
- {
4421
+ #line 134 "hpricot_scan.rl"
4422
+ {
4423
+ if (!S->xml)
4424
+ akey = rb_funcall(akey, s_downcase, 0);
4328
4425
  ATTR(akey, aval);
4329
4426
  }
4330
- #line 121 "hpricot_scan.rl"
4331
- {
4427
+ #line 127 "hpricot_scan.rl"
4428
+ {
4332
4429
  akey = Qnil;
4333
4430
  aval = Qnil;
4334
4431
  mark_akey = NULL;
4335
4432
  mark_aval = NULL;
4336
4433
  }
4337
- #line 106 "hpricot_scan.rl"
4434
+ #line 112 "hpricot_scan.rl"
4338
4435
  { mark_akey = p; }
4339
4436
  goto st120;
4340
4437
  tr318:
4341
- #line 105 "hpricot_scan.rl"
4438
+ #line 111 "hpricot_scan.rl"
4342
4439
  { mark_aval = p; }
4343
- #line 128 "hpricot_scan.rl"
4344
- {
4440
+ #line 134 "hpricot_scan.rl"
4441
+ {
4442
+ if (!S->xml)
4443
+ akey = rb_funcall(akey, s_downcase, 0);
4345
4444
  ATTR(akey, aval);
4346
4445
  }
4347
- #line 121 "hpricot_scan.rl"
4348
- {
4446
+ #line 127 "hpricot_scan.rl"
4447
+ {
4349
4448
  akey = Qnil;
4350
4449
  aval = Qnil;
4351
4450
  mark_akey = NULL;
4352
4451
  mark_aval = NULL;
4353
4452
  }
4354
- #line 106 "hpricot_scan.rl"
4453
+ #line 112 "hpricot_scan.rl"
4355
4454
  { mark_akey = p; }
4356
4455
  goto st120;
4357
4456
  st120:
4358
4457
  if ( ++p == pe )
4359
4458
  goto _test_eof120;
4360
4459
  case 120:
4361
- #line 4362 "hpricot_scan.c"
4460
+ #line 4461 "hpricot_scan.c"
4362
4461
  switch( (*p) ) {
4363
4462
  case 32: goto tr293;
4364
4463
  case 34: goto tr228;
@@ -4383,24 +4482,30 @@ case 120:
4383
4482
  goto st120;
4384
4483
  goto st99;
4385
4484
  tr295:
4386
- #line 114 "hpricot_scan.rl"
4485
+ #line 120 "hpricot_scan.rl"
4387
4486
  { SET(akey, p); }
4388
- #line 128 "hpricot_scan.rl"
4389
- {
4487
+ #line 134 "hpricot_scan.rl"
4488
+ {
4489
+ if (!S->xml)
4490
+ akey = rb_funcall(akey, s_downcase, 0);
4390
4491
  ATTR(akey, aval);
4391
4492
  }
4392
4493
  goto st121;
4393
4494
  tr230:
4394
- #line 128 "hpricot_scan.rl"
4395
- {
4495
+ #line 134 "hpricot_scan.rl"
4496
+ {
4497
+ if (!S->xml)
4498
+ akey = rb_funcall(akey, s_downcase, 0);
4396
4499
  ATTR(akey, aval);
4397
4500
  }
4398
4501
  goto st121;
4399
4502
  tr319:
4400
- #line 105 "hpricot_scan.rl"
4503
+ #line 111 "hpricot_scan.rl"
4401
4504
  { mark_aval = p; }
4402
- #line 128 "hpricot_scan.rl"
4403
- {
4505
+ #line 134 "hpricot_scan.rl"
4506
+ {
4507
+ if (!S->xml)
4508
+ akey = rb_funcall(akey, s_downcase, 0);
4404
4509
  ATTR(akey, aval);
4405
4510
  }
4406
4511
  goto st121;
@@ -4408,7 +4513,7 @@ st121:
4408
4513
  if ( ++p == pe )
4409
4514
  goto _test_eof121;
4410
4515
  case 121:
4411
- #line 4412 "hpricot_scan.c"
4516
+ #line 4517 "hpricot_scan.c"
4412
4517
  switch( (*p) ) {
4413
4518
  case 34: goto tr228;
4414
4519
  case 39: goto tr174;
@@ -4419,15 +4524,17 @@ case 121:
4419
4524
  tr217:
4420
4525
  #line 1 "hpricot_scan.rl"
4421
4526
  {te = p+1;}
4422
- #line 105 "hpricot_scan.rl"
4527
+ #line 111 "hpricot_scan.rl"
4423
4528
  { mark_aval = p; }
4424
- #line 110 "hpricot_scan.rl"
4425
- {
4529
+ #line 116 "hpricot_scan.rl"
4530
+ {
4426
4531
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4427
4532
  else { SET(aval, p); }
4428
4533
  }
4429
- #line 128 "hpricot_scan.rl"
4430
- {
4534
+ #line 134 "hpricot_scan.rl"
4535
+ {
4536
+ if (!S->xml)
4537
+ akey = rb_funcall(akey, s_downcase, 0);
4431
4538
  ATTR(akey, aval);
4432
4539
  }
4433
4540
  #line 68 "hpricot_scan.rl"
@@ -4436,13 +4543,15 @@ tr217:
4436
4543
  tr225:
4437
4544
  #line 1 "hpricot_scan.rl"
4438
4545
  {te = p+1;}
4439
- #line 110 "hpricot_scan.rl"
4440
- {
4546
+ #line 116 "hpricot_scan.rl"
4547
+ {
4441
4548
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4442
4549
  else { SET(aval, p); }
4443
4550
  }
4444
- #line 128 "hpricot_scan.rl"
4445
- {
4551
+ #line 134 "hpricot_scan.rl"
4552
+ {
4553
+ if (!S->xml)
4554
+ akey = rb_funcall(akey, s_downcase, 0);
4446
4555
  ATTR(akey, aval);
4447
4556
  }
4448
4557
  #line 68 "hpricot_scan.rl"
@@ -4451,8 +4560,10 @@ tr225:
4451
4560
  tr231:
4452
4561
  #line 1 "hpricot_scan.rl"
4453
4562
  {te = p+1;}
4454
- #line 128 "hpricot_scan.rl"
4455
- {
4563
+ #line 134 "hpricot_scan.rl"
4564
+ {
4565
+ if (!S->xml)
4566
+ akey = rb_funcall(akey, s_downcase, 0);
4456
4567
  ATTR(akey, aval);
4457
4568
  }
4458
4569
  #line 68 "hpricot_scan.rl"
@@ -4461,10 +4572,12 @@ tr231:
4461
4572
  tr297:
4462
4573
  #line 1 "hpricot_scan.rl"
4463
4574
  {te = p+1;}
4464
- #line 114 "hpricot_scan.rl"
4575
+ #line 120 "hpricot_scan.rl"
4465
4576
  { SET(akey, p); }
4466
- #line 128 "hpricot_scan.rl"
4467
- {
4577
+ #line 134 "hpricot_scan.rl"
4578
+ {
4579
+ if (!S->xml)
4580
+ akey = rb_funcall(akey, s_downcase, 0);
4468
4581
  ATTR(akey, aval);
4469
4582
  }
4470
4583
  #line 68 "hpricot_scan.rl"
@@ -4479,12 +4592,14 @@ tr298:
4479
4592
  tr284:
4480
4593
  #line 1 "hpricot_scan.rl"
4481
4594
  {te = p+1;}
4482
- #line 128 "hpricot_scan.rl"
4483
- {
4595
+ #line 134 "hpricot_scan.rl"
4596
+ {
4597
+ if (!S->xml)
4598
+ akey = rb_funcall(akey, s_downcase, 0);
4484
4599
  ATTR(akey, aval);
4485
4600
  }
4486
- #line 110 "hpricot_scan.rl"
4487
- {
4601
+ #line 116 "hpricot_scan.rl"
4602
+ {
4488
4603
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4489
4604
  else { SET(aval, p); }
4490
4605
  }
@@ -4494,14 +4609,16 @@ tr284:
4494
4609
  tr313:
4495
4610
  #line 1 "hpricot_scan.rl"
4496
4611
  {te = p+1;}
4497
- #line 105 "hpricot_scan.rl"
4612
+ #line 111 "hpricot_scan.rl"
4498
4613
  { mark_aval = p; }
4499
- #line 128 "hpricot_scan.rl"
4500
- {
4614
+ #line 134 "hpricot_scan.rl"
4615
+ {
4616
+ if (!S->xml)
4617
+ akey = rb_funcall(akey, s_downcase, 0);
4501
4618
  ATTR(akey, aval);
4502
4619
  }
4503
- #line 110 "hpricot_scan.rl"
4504
- {
4620
+ #line 116 "hpricot_scan.rl"
4621
+ {
4505
4622
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4506
4623
  else { SET(aval, p); }
4507
4624
  }
@@ -4511,15 +4628,17 @@ tr313:
4511
4628
  tr290:
4512
4629
  #line 1 "hpricot_scan.rl"
4513
4630
  {te = p+1;}
4514
- #line 110 "hpricot_scan.rl"
4515
- {
4631
+ #line 116 "hpricot_scan.rl"
4632
+ {
4516
4633
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4517
4634
  else { SET(aval, p); }
4518
4635
  }
4519
- #line 114 "hpricot_scan.rl"
4636
+ #line 120 "hpricot_scan.rl"
4520
4637
  { SET(akey, p); }
4521
- #line 128 "hpricot_scan.rl"
4522
- {
4638
+ #line 134 "hpricot_scan.rl"
4639
+ {
4640
+ if (!S->xml)
4641
+ akey = rb_funcall(akey, s_downcase, 0);
4523
4642
  ATTR(akey, aval);
4524
4643
  }
4525
4644
  #line 68 "hpricot_scan.rl"
@@ -4528,10 +4647,12 @@ tr290:
4528
4647
  tr320:
4529
4648
  #line 1 "hpricot_scan.rl"
4530
4649
  {te = p+1;}
4531
- #line 105 "hpricot_scan.rl"
4650
+ #line 111 "hpricot_scan.rl"
4532
4651
  { mark_aval = p; }
4533
- #line 128 "hpricot_scan.rl"
4534
- {
4652
+ #line 134 "hpricot_scan.rl"
4653
+ {
4654
+ if (!S->xml)
4655
+ akey = rb_funcall(akey, s_downcase, 0);
4535
4656
  ATTR(akey, aval);
4536
4657
  }
4537
4658
  #line 68 "hpricot_scan.rl"
@@ -4541,7 +4662,7 @@ st211:
4541
4662
  if ( ++p == pe )
4542
4663
  goto _test_eof211;
4543
4664
  case 211:
4544
- #line 4545 "hpricot_scan.c"
4665
+ #line 4666 "hpricot_scan.c"
4545
4666
  switch( (*p) ) {
4546
4667
  case 34: goto tr228;
4547
4668
  case 39: goto tr174;
@@ -4549,14 +4670,14 @@ case 211:
4549
4670
  }
4550
4671
  goto st99;
4551
4672
  tr321:
4552
- #line 105 "hpricot_scan.rl"
4673
+ #line 111 "hpricot_scan.rl"
4553
4674
  { mark_aval = p; }
4554
4675
  goto st122;
4555
4676
  st122:
4556
4677
  if ( ++p == pe )
4557
4678
  goto _test_eof122;
4558
4679
  case 122:
4559
- #line 4560 "hpricot_scan.c"
4680
+ #line 4681 "hpricot_scan.c"
4560
4681
  switch( (*p) ) {
4561
4682
  case 34: goto tr299;
4562
4683
  case 39: goto tr299;
@@ -4564,14 +4685,14 @@ case 122:
4564
4685
  }
4565
4686
  goto st99;
4566
4687
  tr296:
4567
- #line 114 "hpricot_scan.rl"
4688
+ #line 120 "hpricot_scan.rl"
4568
4689
  { SET(akey, p); }
4569
4690
  goto st123;
4570
4691
  st123:
4571
4692
  if ( ++p == pe )
4572
4693
  goto _test_eof123;
4573
4694
  case 123:
4574
- #line 4575 "hpricot_scan.c"
4695
+ #line 4696 "hpricot_scan.c"
4575
4696
  switch( (*p) ) {
4576
4697
  case 13: goto tr300;
4577
4698
  case 32: goto tr300;
@@ -4589,14 +4710,14 @@ case 123:
4589
4710
  goto tr300;
4590
4711
  goto tr210;
4591
4712
  tr300:
4592
- #line 105 "hpricot_scan.rl"
4713
+ #line 111 "hpricot_scan.rl"
4593
4714
  { mark_aval = p; }
4594
4715
  goto st124;
4595
4716
  st124:
4596
4717
  if ( ++p == pe )
4597
4718
  goto _test_eof124;
4598
4719
  case 124:
4599
- #line 4600 "hpricot_scan.c"
4720
+ #line 4721 "hpricot_scan.c"
4600
4721
  switch( (*p) ) {
4601
4722
  case 13: goto tr305;
4602
4723
  case 32: goto tr305;
@@ -4614,14 +4735,14 @@ case 124:
4614
4735
  goto tr305;
4615
4736
  goto tr210;
4616
4737
  tr305:
4617
- #line 105 "hpricot_scan.rl"
4738
+ #line 111 "hpricot_scan.rl"
4618
4739
  { mark_aval = p; }
4619
4740
  goto st125;
4620
4741
  tr308:
4621
- #line 105 "hpricot_scan.rl"
4742
+ #line 111 "hpricot_scan.rl"
4622
4743
  { mark_aval = p; }
4623
- #line 110 "hpricot_scan.rl"
4624
- {
4744
+ #line 116 "hpricot_scan.rl"
4745
+ {
4625
4746
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4626
4747
  else { SET(aval, p); }
4627
4748
  }
@@ -4630,7 +4751,7 @@ st125:
4630
4751
  if ( ++p == pe )
4631
4752
  goto _test_eof125;
4632
4753
  case 125:
4633
- #line 4634 "hpricot_scan.c"
4754
+ #line 4755 "hpricot_scan.c"
4634
4755
  switch( (*p) ) {
4635
4756
  case 13: goto tr305;
4636
4757
  case 32: goto tr305;
@@ -4659,14 +4780,14 @@ case 125:
4659
4780
  goto tr307;
4660
4781
  goto tr210;
4661
4782
  tr306:
4662
- #line 105 "hpricot_scan.rl"
4783
+ #line 111 "hpricot_scan.rl"
4663
4784
  { mark_aval = p; }
4664
4785
  goto st126;
4665
4786
  tr309:
4666
- #line 105 "hpricot_scan.rl"
4787
+ #line 111 "hpricot_scan.rl"
4667
4788
  { mark_aval = p; }
4668
- #line 110 "hpricot_scan.rl"
4669
- {
4789
+ #line 116 "hpricot_scan.rl"
4790
+ {
4670
4791
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4671
4792
  else { SET(aval, p); }
4672
4793
  }
@@ -4675,7 +4796,7 @@ st126:
4675
4796
  if ( ++p == pe )
4676
4797
  goto _test_eof126;
4677
4798
  case 126:
4678
- #line 4679 "hpricot_scan.c"
4799
+ #line 4800 "hpricot_scan.c"
4679
4800
  switch( (*p) ) {
4680
4801
  case 13: goto tr308;
4681
4802
  case 32: goto tr308;
@@ -4704,14 +4825,14 @@ case 126:
4704
4825
  goto tr307;
4705
4826
  goto tr210;
4706
4827
  tr310:
4707
- #line 109 "hpricot_scan.rl"
4828
+ #line 115 "hpricot_scan.rl"
4708
4829
  { SET(aval, p); }
4709
4830
  goto st127;
4710
4831
  st127:
4711
4832
  if ( ++p == pe )
4712
4833
  goto _test_eof127;
4713
4834
  case 127:
4714
- #line 4715 "hpricot_scan.c"
4835
+ #line 4836 "hpricot_scan.c"
4715
4836
  switch( (*p) ) {
4716
4837
  case 13: goto tr211;
4717
4838
  case 32: goto tr211;
@@ -4740,70 +4861,82 @@ case 127:
4740
4861
  goto tr307;
4741
4862
  goto tr210;
4742
4863
  tr304:
4743
- #line 105 "hpricot_scan.rl"
4864
+ #line 111 "hpricot_scan.rl"
4744
4865
  { mark_aval = p; }
4745
- #line 128 "hpricot_scan.rl"
4746
- {
4866
+ #line 134 "hpricot_scan.rl"
4867
+ {
4868
+ if (!S->xml)
4869
+ akey = rb_funcall(akey, s_downcase, 0);
4747
4870
  ATTR(akey, aval);
4748
4871
  }
4749
4872
  goto st128;
4750
4873
  tr223:
4751
- #line 110 "hpricot_scan.rl"
4752
- {
4874
+ #line 116 "hpricot_scan.rl"
4875
+ {
4753
4876
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4754
4877
  else { SET(aval, p); }
4755
4878
  }
4756
- #line 128 "hpricot_scan.rl"
4757
- {
4879
+ #line 134 "hpricot_scan.rl"
4880
+ {
4881
+ if (!S->xml)
4882
+ akey = rb_funcall(akey, s_downcase, 0);
4758
4883
  ATTR(akey, aval);
4759
4884
  }
4760
4885
  goto st128;
4761
4886
  tr283:
4762
- #line 128 "hpricot_scan.rl"
4763
- {
4887
+ #line 134 "hpricot_scan.rl"
4888
+ {
4889
+ if (!S->xml)
4890
+ akey = rb_funcall(akey, s_downcase, 0);
4764
4891
  ATTR(akey, aval);
4765
4892
  }
4766
- #line 110 "hpricot_scan.rl"
4767
- {
4893
+ #line 116 "hpricot_scan.rl"
4894
+ {
4768
4895
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4769
4896
  else { SET(aval, p); }
4770
4897
  }
4771
4898
  goto st128;
4772
4899
  tr288:
4773
- #line 110 "hpricot_scan.rl"
4774
- {
4900
+ #line 116 "hpricot_scan.rl"
4901
+ {
4775
4902
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4776
4903
  else { SET(aval, p); }
4777
4904
  }
4778
- #line 114 "hpricot_scan.rl"
4905
+ #line 120 "hpricot_scan.rl"
4779
4906
  { SET(akey, p); }
4780
- #line 128 "hpricot_scan.rl"
4781
- {
4907
+ #line 134 "hpricot_scan.rl"
4908
+ {
4909
+ if (!S->xml)
4910
+ akey = rb_funcall(akey, s_downcase, 0);
4782
4911
  ATTR(akey, aval);
4783
4912
  }
4784
4913
  goto st128;
4785
4914
  tr215:
4786
- #line 105 "hpricot_scan.rl"
4915
+ #line 111 "hpricot_scan.rl"
4787
4916
  { mark_aval = p; }
4788
- #line 110 "hpricot_scan.rl"
4789
- {
4917
+ #line 116 "hpricot_scan.rl"
4918
+ {
4790
4919
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4791
4920
  else { SET(aval, p); }
4792
4921
  }
4793
- #line 128 "hpricot_scan.rl"
4794
- {
4922
+ #line 134 "hpricot_scan.rl"
4923
+ {
4924
+ if (!S->xml)
4925
+ akey = rb_funcall(akey, s_downcase, 0);
4795
4926
  ATTR(akey, aval);
4796
4927
  }
4797
4928
  goto st128;
4798
4929
  tr312:
4799
- #line 105 "hpricot_scan.rl"
4930
+ #line 111 "hpricot_scan.rl"
4800
4931
  { mark_aval = p; }
4801
- #line 128 "hpricot_scan.rl"
4802
- {
4932
+ #line 134 "hpricot_scan.rl"
4933
+ {
4934
+ if (!S->xml)
4935
+ akey = rb_funcall(akey, s_downcase, 0);
4803
4936
  ATTR(akey, aval);
4804
4937
  }
4805
- #line 110 "hpricot_scan.rl"
4806
- {
4938
+ #line 116 "hpricot_scan.rl"
4939
+ {
4807
4940
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4808
4941
  else { SET(aval, p); }
4809
4942
  }
@@ -4812,7 +4945,7 @@ st128:
4812
4945
  if ( ++p == pe )
4813
4946
  goto _test_eof128;
4814
4947
  case 128:
4815
- #line 4816 "hpricot_scan.c"
4948
+ #line 4949 "hpricot_scan.c"
4816
4949
  switch( (*p) ) {
4817
4950
  case 13: goto tr220;
4818
4951
  case 32: goto tr220;
@@ -4830,14 +4963,14 @@ case 128:
4830
4963
  goto tr220;
4831
4964
  goto st97;
4832
4965
  tr218:
4833
- #line 105 "hpricot_scan.rl"
4966
+ #line 111 "hpricot_scan.rl"
4834
4967
  { mark_aval = p; }
4835
4968
  goto st129;
4836
4969
  st129:
4837
4970
  if ( ++p == pe )
4838
4971
  goto _test_eof129;
4839
4972
  case 129:
4840
- #line 4841 "hpricot_scan.c"
4973
+ #line 4974 "hpricot_scan.c"
4841
4974
  switch( (*p) ) {
4842
4975
  case 13: goto tr220;
4843
4976
  case 32: goto tr220;
@@ -4855,14 +4988,14 @@ case 129:
4855
4988
  goto tr220;
4856
4989
  goto st97;
4857
4990
  tr311:
4858
- #line 109 "hpricot_scan.rl"
4991
+ #line 115 "hpricot_scan.rl"
4859
4992
  { SET(aval, p); }
4860
4993
  goto st130;
4861
4994
  st130:
4862
4995
  if ( ++p == pe )
4863
4996
  goto _test_eof130;
4864
4997
  case 130:
4865
- #line 4866 "hpricot_scan.c"
4998
+ #line 4999 "hpricot_scan.c"
4866
4999
  switch( (*p) ) {
4867
5000
  case 13: goto tr211;
4868
5001
  case 32: goto tr211;
@@ -4891,14 +5024,14 @@ case 130:
4891
5024
  goto tr307;
4892
5025
  goto tr210;
4893
5026
  tr302:
4894
- #line 109 "hpricot_scan.rl"
5027
+ #line 115 "hpricot_scan.rl"
4895
5028
  { SET(aval, p); }
4896
5029
  goto st131;
4897
5030
  st131:
4898
5031
  if ( ++p == pe )
4899
5032
  goto _test_eof131;
4900
5033
  case 131:
4901
- #line 4902 "hpricot_scan.c"
5034
+ #line 5035 "hpricot_scan.c"
4902
5035
  switch( (*p) ) {
4903
5036
  case 32: goto tr315;
4904
5037
  case 34: goto tr316;
@@ -4922,14 +5055,14 @@ case 131:
4922
5055
  goto tr318;
4923
5056
  goto tr216;
4924
5057
  tr303:
4925
- #line 109 "hpricot_scan.rl"
5058
+ #line 115 "hpricot_scan.rl"
4926
5059
  { SET(aval, p); }
4927
5060
  goto st132;
4928
5061
  st132:
4929
5062
  if ( ++p == pe )
4930
5063
  goto _test_eof132;
4931
5064
  case 132:
4932
- #line 4933 "hpricot_scan.c"
5065
+ #line 5066 "hpricot_scan.c"
4933
5066
  switch( (*p) ) {
4934
5067
  case 32: goto tr315;
4935
5068
  case 34: goto tr322;
@@ -4953,18 +5086,18 @@ case 132:
4953
5086
  goto tr318;
4954
5087
  goto tr216;
4955
5088
  tr301:
4956
- #line 105 "hpricot_scan.rl"
5089
+ #line 111 "hpricot_scan.rl"
4957
5090
  { mark_aval = p; }
4958
5091
  goto st133;
4959
5092
  tr289:
4960
- #line 114 "hpricot_scan.rl"
5093
+ #line 120 "hpricot_scan.rl"
4961
5094
  { SET(akey, p); }
4962
5095
  goto st133;
4963
5096
  st133:
4964
5097
  if ( ++p == pe )
4965
5098
  goto _test_eof133;
4966
5099
  case 133:
4967
- #line 4968 "hpricot_scan.c"
5100
+ #line 5101 "hpricot_scan.c"
4968
5101
  switch( (*p) ) {
4969
5102
  case 13: goto tr308;
4970
5103
  case 32: goto tr308;
@@ -4982,17 +5115,17 @@ case 133:
4982
5115
  goto tr308;
4983
5116
  goto tr210;
4984
5117
  tr324:
4985
- #line 110 "hpricot_scan.rl"
4986
- {
5118
+ #line 116 "hpricot_scan.rl"
5119
+ {
4987
5120
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4988
5121
  else { SET(aval, p); }
4989
5122
  }
4990
5123
  goto st134;
4991
5124
  tr286:
4992
- #line 114 "hpricot_scan.rl"
5125
+ #line 120 "hpricot_scan.rl"
4993
5126
  { SET(akey, p); }
4994
- #line 110 "hpricot_scan.rl"
4995
- {
5127
+ #line 116 "hpricot_scan.rl"
5128
+ {
4996
5129
  if (*(p-1) == '"' || *(p-1) == '\'') { SET(aval, p-1); }
4997
5130
  else { SET(aval, p); }
4998
5131
  }
@@ -5001,7 +5134,7 @@ st134:
5001
5134
  if ( ++p == pe )
5002
5135
  goto _test_eof134;
5003
5136
  case 134:
5004
- #line 5005 "hpricot_scan.c"
5137
+ #line 5138 "hpricot_scan.c"
5005
5138
  switch( (*p) ) {
5006
5139
  case 13: goto tr323;
5007
5140
  case 32: goto tr323;
@@ -5031,14 +5164,14 @@ case 134:
5031
5164
  goto tr282;
5032
5165
  goto st97;
5033
5166
  tr275:
5034
- #line 109 "hpricot_scan.rl"
5167
+ #line 115 "hpricot_scan.rl"
5035
5168
  { SET(aval, p); }
5036
5169
  goto st135;
5037
5170
  st135:
5038
5171
  if ( ++p == pe )
5039
5172
  goto _test_eof135;
5040
5173
  case 135:
5041
- #line 5042 "hpricot_scan.c"
5174
+ #line 5175 "hpricot_scan.c"
5042
5175
  switch( (*p) ) {
5043
5176
  case 13: goto tr326;
5044
5177
  case 32: goto tr326;
@@ -5076,14 +5209,14 @@ case 136:
5076
5209
  }
5077
5210
  goto tr216;
5078
5211
  tr251:
5079
- #line 109 "hpricot_scan.rl"
5212
+ #line 115 "hpricot_scan.rl"
5080
5213
  { SET(aval, p); }
5081
5214
  goto st137;
5082
5215
  st137:
5083
5216
  if ( ++p == pe )
5084
5217
  goto _test_eof137;
5085
5218
  case 137:
5086
- #line 5087 "hpricot_scan.c"
5219
+ #line 5220 "hpricot_scan.c"
5087
5220
  switch( (*p) ) {
5088
5221
  case 32: goto tr330;
5089
5222
  case 39: goto tr331;
@@ -5106,14 +5239,14 @@ case 137:
5106
5239
  goto tr332;
5107
5240
  goto tr328;
5108
5241
  tr248:
5109
- #line 105 "hpricot_scan.rl"
5242
+ #line 111 "hpricot_scan.rl"
5110
5243
  { mark_aval = p; }
5111
5244
  goto st138;
5112
5245
  st138:
5113
5246
  if ( ++p == pe )
5114
5247
  goto _test_eof138;
5115
5248
  case 138:
5116
- #line 5117 "hpricot_scan.c"
5249
+ #line 5250 "hpricot_scan.c"
5117
5250
  switch( (*p) ) {
5118
5251
  case 13: goto tr277;
5119
5252
  case 32: goto tr277;
@@ -5131,14 +5264,14 @@ case 138:
5131
5264
  goto tr277;
5132
5265
  goto tr247;
5133
5266
  tr185:
5134
- #line 109 "hpricot_scan.rl"
5267
+ #line 115 "hpricot_scan.rl"
5135
5268
  { SET(aval, p); }
5136
5269
  goto st139;
5137
5270
  st139:
5138
5271
  if ( ++p == pe )
5139
5272
  goto _test_eof139;
5140
5273
  case 139:
5141
- #line 5142 "hpricot_scan.c"
5274
+ #line 5275 "hpricot_scan.c"
5142
5275
  switch( (*p) ) {
5143
5276
  case 32: goto tr336;
5144
5277
  case 34: goto tr331;
@@ -5208,14 +5341,14 @@ case 143:
5208
5341
  }
5209
5342
  goto tr328;
5210
5343
  tr120:
5211
- #line 105 "hpricot_scan.rl"
5344
+ #line 111 "hpricot_scan.rl"
5212
5345
  { mark_aval = p; }
5213
5346
  goto st144;
5214
5347
  st144:
5215
5348
  if ( ++p == pe )
5216
5349
  goto _test_eof144;
5217
5350
  case 144:
5218
- #line 5219 "hpricot_scan.c"
5351
+ #line 5352 "hpricot_scan.c"
5219
5352
  switch( (*p) ) {
5220
5353
  case 13: goto tr148;
5221
5354
  case 32: goto tr148;
@@ -5254,7 +5387,7 @@ st146:
5254
5387
  if ( ++p == pe )
5255
5388
  goto _test_eof146;
5256
5389
  case 146:
5257
- #line 5258 "hpricot_scan.c"
5390
+ #line 5391 "hpricot_scan.c"
5258
5391
  switch( (*p) ) {
5259
5392
  case 32: goto st212;
5260
5393
  case 63: goto st146;
@@ -5292,7 +5425,7 @@ st147:
5292
5425
  if ( ++p == pe )
5293
5426
  goto _test_eof147;
5294
5427
  case 147:
5295
- #line 5296 "hpricot_scan.c"
5428
+ #line 5429 "hpricot_scan.c"
5296
5429
  switch( (*p) ) {
5297
5430
  case 32: goto st212;
5298
5431
  case 63: goto st146;
@@ -5371,7 +5504,7 @@ st213:
5371
5504
  if ( ++p == pe )
5372
5505
  goto _test_eof213;
5373
5506
  case 213:
5374
- #line 5375 "hpricot_scan.c"
5507
+ #line 5508 "hpricot_scan.c"
5375
5508
  switch( (*p) ) {
5376
5509
  case 32: goto tr348;
5377
5510
  case 118: goto st150;
@@ -5463,14 +5596,14 @@ case 158:
5463
5596
  goto tr359;
5464
5597
  goto tr349;
5465
5598
  tr359:
5466
- #line 105 "hpricot_scan.rl"
5599
+ #line 111 "hpricot_scan.rl"
5467
5600
  { mark_aval = p; }
5468
5601
  goto st159;
5469
5602
  st159:
5470
5603
  if ( ++p == pe )
5471
5604
  goto _test_eof159;
5472
5605
  case 159:
5473
- #line 5474 "hpricot_scan.c"
5606
+ #line 5607 "hpricot_scan.c"
5474
5607
  switch( (*p) ) {
5475
5608
  case 34: goto tr360;
5476
5609
  case 95: goto st159;
@@ -5488,14 +5621,14 @@ case 159:
5488
5621
  goto st159;
5489
5622
  goto tr349;
5490
5623
  tr360:
5491
- #line 115 "hpricot_scan.rl"
5624
+ #line 121 "hpricot_scan.rl"
5492
5625
  { SET(aval, p); ATTR(ID2SYM(rb_intern("version")), aval); }
5493
5626
  goto st160;
5494
5627
  st160:
5495
5628
  if ( ++p == pe )
5496
5629
  goto _test_eof160;
5497
5630
  case 160:
5498
- #line 5499 "hpricot_scan.c"
5631
+ #line 5632 "hpricot_scan.c"
5499
5632
  switch( (*p) ) {
5500
5633
  case 32: goto st161;
5501
5634
  case 62: goto tr363;
@@ -5608,14 +5741,14 @@ case 172:
5608
5741
  goto tr377;
5609
5742
  goto tr349;
5610
5743
  tr377:
5611
- #line 105 "hpricot_scan.rl"
5744
+ #line 111 "hpricot_scan.rl"
5612
5745
  { mark_aval = p; }
5613
5746
  goto st173;
5614
5747
  st173:
5615
5748
  if ( ++p == pe )
5616
5749
  goto _test_eof173;
5617
5750
  case 173:
5618
- #line 5619 "hpricot_scan.c"
5751
+ #line 5752 "hpricot_scan.c"
5619
5752
  switch( (*p) ) {
5620
5753
  case 34: goto tr378;
5621
5754
  case 95: goto st173;
@@ -5633,14 +5766,14 @@ case 173:
5633
5766
  goto st173;
5634
5767
  goto tr349;
5635
5768
  tr378:
5636
- #line 116 "hpricot_scan.rl"
5769
+ #line 122 "hpricot_scan.rl"
5637
5770
  { SET(aval, p); ATTR(ID2SYM(rb_intern("encoding")), aval); }
5638
5771
  goto st174;
5639
5772
  st174:
5640
5773
  if ( ++p == pe )
5641
5774
  goto _test_eof174;
5642
5775
  case 174:
5643
- #line 5644 "hpricot_scan.c"
5776
+ #line 5777 "hpricot_scan.c"
5644
5777
  switch( (*p) ) {
5645
5778
  case 32: goto st175;
5646
5779
  case 62: goto tr363;
@@ -5758,14 +5891,14 @@ case 187:
5758
5891
  }
5759
5892
  goto tr349;
5760
5893
  tr393:
5761
- #line 105 "hpricot_scan.rl"
5894
+ #line 111 "hpricot_scan.rl"
5762
5895
  { mark_aval = p; }
5763
5896
  goto st188;
5764
5897
  st188:
5765
5898
  if ( ++p == pe )
5766
5899
  goto _test_eof188;
5767
5900
  case 188:
5768
- #line 5769 "hpricot_scan.c"
5901
+ #line 5902 "hpricot_scan.c"
5769
5902
  if ( (*p) == 111 )
5770
5903
  goto st189;
5771
5904
  goto tr349;
@@ -5777,14 +5910,14 @@ case 189:
5777
5910
  goto tr396;
5778
5911
  goto tr349;
5779
5912
  tr396:
5780
- #line 117 "hpricot_scan.rl"
5913
+ #line 123 "hpricot_scan.rl"
5781
5914
  { SET(aval, p); ATTR(ID2SYM(rb_intern("standalone")), aval); }
5782
5915
  goto st190;
5783
5916
  st190:
5784
5917
  if ( ++p == pe )
5785
5918
  goto _test_eof190;
5786
5919
  case 190:
5787
- #line 5788 "hpricot_scan.c"
5920
+ #line 5921 "hpricot_scan.c"
5788
5921
  switch( (*p) ) {
5789
5922
  case 32: goto st190;
5790
5923
  case 62: goto tr363;
@@ -5794,14 +5927,14 @@ case 190:
5794
5927
  goto st190;
5795
5928
  goto tr349;
5796
5929
  tr394:
5797
- #line 105 "hpricot_scan.rl"
5930
+ #line 111 "hpricot_scan.rl"
5798
5931
  { mark_aval = p; }
5799
5932
  goto st191;
5800
5933
  st191:
5801
5934
  if ( ++p == pe )
5802
5935
  goto _test_eof191;
5803
5936
  case 191:
5804
- #line 5805 "hpricot_scan.c"
5937
+ #line 5938 "hpricot_scan.c"
5805
5938
  if ( (*p) == 101 )
5806
5939
  goto st192;
5807
5940
  goto tr349;
@@ -5822,14 +5955,14 @@ case 193:
5822
5955
  }
5823
5956
  goto tr349;
5824
5957
  tr399:
5825
- #line 105 "hpricot_scan.rl"
5958
+ #line 111 "hpricot_scan.rl"
5826
5959
  { mark_aval = p; }
5827
5960
  goto st194;
5828
5961
  st194:
5829
5962
  if ( ++p == pe )
5830
5963
  goto _test_eof194;
5831
5964
  case 194:
5832
- #line 5833 "hpricot_scan.c"
5965
+ #line 5966 "hpricot_scan.c"
5833
5966
  if ( (*p) == 111 )
5834
5967
  goto st195;
5835
5968
  goto tr349;
@@ -5841,14 +5974,14 @@ case 195:
5841
5974
  goto tr396;
5842
5975
  goto tr349;
5843
5976
  tr400:
5844
- #line 105 "hpricot_scan.rl"
5977
+ #line 111 "hpricot_scan.rl"
5845
5978
  { mark_aval = p; }
5846
5979
  goto st196;
5847
5980
  st196:
5848
5981
  if ( ++p == pe )
5849
5982
  goto _test_eof196;
5850
5983
  case 196:
5851
- #line 5852 "hpricot_scan.c"
5984
+ #line 5985 "hpricot_scan.c"
5852
5985
  if ( (*p) == 101 )
5853
5986
  goto st197;
5854
5987
  goto tr349;
@@ -5870,14 +6003,14 @@ case 198:
5870
6003
  goto tr403;
5871
6004
  goto tr349;
5872
6005
  tr403:
5873
- #line 105 "hpricot_scan.rl"
6006
+ #line 111 "hpricot_scan.rl"
5874
6007
  { mark_aval = p; }
5875
6008
  goto st199;
5876
6009
  st199:
5877
6010
  if ( ++p == pe )
5878
6011
  goto _test_eof199;
5879
6012
  case 199:
5880
- #line 5881 "hpricot_scan.c"
6013
+ #line 6014 "hpricot_scan.c"
5881
6014
  switch( (*p) ) {
5882
6015
  case 39: goto tr378;
5883
6016
  case 95: goto st199;
@@ -5913,14 +6046,14 @@ case 200:
5913
6046
  goto tr405;
5914
6047
  goto tr349;
5915
6048
  tr405:
5916
- #line 105 "hpricot_scan.rl"
6049
+ #line 111 "hpricot_scan.rl"
5917
6050
  { mark_aval = p; }
5918
6051
  goto st201;
5919
6052
  st201:
5920
6053
  if ( ++p == pe )
5921
6054
  goto _test_eof201;
5922
6055
  case 201:
5923
- #line 5924 "hpricot_scan.c"
6056
+ #line 6057 "hpricot_scan.c"
5924
6057
  switch( (*p) ) {
5925
6058
  case 39: goto tr360;
5926
6059
  case 95: goto st201;
@@ -5969,7 +6102,7 @@ st214:
5969
6102
  case 214:
5970
6103
  #line 1 "hpricot_scan.rl"
5971
6104
  {ts = p;}
5972
- #line 5973 "hpricot_scan.c"
6105
+ #line 6106 "hpricot_scan.c"
5973
6106
  switch( (*p) ) {
5974
6107
  case 10: goto tr423;
5975
6108
  case 45: goto tr424;
@@ -5983,7 +6116,7 @@ st215:
5983
6116
  if ( ++p == pe )
5984
6117
  goto _test_eof215;
5985
6118
  case 215:
5986
- #line 5987 "hpricot_scan.c"
6119
+ #line 6120 "hpricot_scan.c"
5987
6120
  if ( (*p) == 45 )
5988
6121
  goto st202;
5989
6122
  goto tr425;
@@ -6026,7 +6159,7 @@ st216:
6026
6159
  case 216:
6027
6160
  #line 1 "hpricot_scan.rl"
6028
6161
  {ts = p;}
6029
- #line 6030 "hpricot_scan.c"
6162
+ #line 6163 "hpricot_scan.c"
6030
6163
  switch( (*p) ) {
6031
6164
  case 10: goto tr428;
6032
6165
  case 93: goto tr429;
@@ -6040,7 +6173,7 @@ st217:
6040
6173
  if ( ++p == pe )
6041
6174
  goto _test_eof217;
6042
6175
  case 217:
6043
- #line 6044 "hpricot_scan.c"
6176
+ #line 6177 "hpricot_scan.c"
6044
6177
  if ( (*p) == 93 )
6045
6178
  goto st203;
6046
6179
  goto tr430;
@@ -6079,7 +6212,7 @@ st218:
6079
6212
  case 218:
6080
6213
  #line 1 "hpricot_scan.rl"
6081
6214
  {ts = p;}
6082
- #line 6083 "hpricot_scan.c"
6215
+ #line 6216 "hpricot_scan.c"
6083
6216
  switch( (*p) ) {
6084
6217
  case 10: goto tr433;
6085
6218
  case 62: goto tr434;
@@ -6539,11 +6672,13 @@ case 219:
6539
6672
  }
6540
6673
 
6541
6674
  }
6542
- #line 561 "hpricot_scan.rl"
6543
-
6544
- if ( cs == hpricot_scan_error ) {
6545
- free(buf);
6546
- if ( !NIL_P(tag) )
6675
+
6676
+ #line 534 "hpricot_scan.rl"
6677
+
6678
+ if (cs == hpricot_scan_error) {
6679
+ if (buf != NULL)
6680
+ free(buf);
6681
+ if (!NIL_P(tag))
6547
6682
  {
6548
6683
  rb_raise(rb_eHpricotParseError, "parse error on element <%s>, starting on line %d.\n" NO_WAY_SERIOUSLY, RSTRING_PTR(tag), curline);
6549
6684
  }
@@ -6552,8 +6687,8 @@ case 219:
6552
6687
  rb_raise(rb_eHpricotParseError, "parse error on line %d.\n" NO_WAY_SERIOUSLY, curline);
6553
6688
  }
6554
6689
  }
6555
-
6556
- if ( done && ele_open )
6690
+
6691
+ if (done && ele_open)
6557
6692
  {
6558
6693
  ele_open = 0;
6559
6694
  if (ts > 0) {
@@ -6563,11 +6698,11 @@ case 219:
6563
6698
  }
6564
6699
  }
6565
6700
 
6566
- if ( ts == 0 )
6701
+ if (ts == 0)
6567
6702
  {
6568
6703
  have = 0;
6569
6704
  /* text nodes have no ts because each byte is parsed alone */
6570
- if ( mark_tag != NULL && text == 1 )
6705
+ if (mark_tag != NULL && text == 1)
6571
6706
  {
6572
6707
  if (done)
6573
6708
  {
@@ -6582,12 +6717,15 @@ case 219:
6582
6717
  CAT(tag, p);
6583
6718
  }
6584
6719
  }
6585
- mark_tag = buf;
6720
+ if (io)
6721
+ mark_tag = buf;
6722
+ else
6723
+ mark_tag = RSTRING_PTR(port);
6586
6724
  }
6587
- else
6725
+ else if (io)
6588
6726
  {
6589
6727
  have = pe - ts;
6590
- memmove( buf, ts, have );
6728
+ memmove(buf, ts, have);
6591
6729
  SLIDE(tag);
6592
6730
  SLIDE(akey);
6593
6731
  SLIDE(aval);
@@ -6595,7 +6733,9 @@ case 219:
6595
6733
  ts = buf;
6596
6734
  }
6597
6735
  }
6598
- free(buf);
6736
+
6737
+ if (buf != NULL)
6738
+ free(buf);
6599
6739
 
6600
6740
  if (S != NULL)
6601
6741
  {
@@ -6608,66 +6748,103 @@ case 219:
6608
6748
  return Qnil;
6609
6749
  }
6610
6750
 
6611
- void Init_hpricot_scan()
6751
+ static VALUE
6752
+ alloc_hpricot_struct(VALUE klass)
6612
6753
  {
6613
- mHpricot = rb_define_module("Hpricot");
6614
- rb_define_attr(rb_singleton_class(mHpricot), "buffer_size", 1, 1);
6615
- rb_define_singleton_method(mHpricot, "scan", hpricot_scan, -1);
6616
- rb_define_singleton_method(mHpricot, "css", hpricot_css, 3);
6617
- rb_eHpricotParseError = rb_define_class_under(mHpricot, "ParseError", rb_eStandardError);
6754
+ VALUE size;
6755
+ long n;
6756
+ NEWOBJ(st, struct RStruct);
6757
+ OBJSETUP(st, klass, T_STRUCT);
6618
6758
 
6619
- cDoc = rb_define_class_under(mHpricot, "Doc", rb_cObject);
6620
- rb_define_alloc_func(cDoc, hpricot_ele_alloc);
6621
- rb_define_method(cDoc, "children", hpricot_ele_get_children, 0);
6622
- rb_define_method(cDoc, "children=", hpricot_ele_set_children, 1);
6759
+ size = rb_struct_iv_get(klass, "__size__");
6760
+ n = FIX2LONG(size);
6623
6761
 
6624
- cBaseEle = rb_define_class_under(mHpricot, "BaseEle", rb_cObject);
6625
- rb_define_alloc_func(cBaseEle, hpricot_ele_alloc);
6626
- rb_define_method(cBaseEle, "raw_string", hpricot_ele_get_raw, 0);
6627
- rb_define_method(cBaseEle, "clear_raw", hpricot_ele_clear_raw, 0);
6628
- rb_define_method(cBaseEle, "parent", hpricot_ele_get_parent, 0);
6629
- rb_define_method(cBaseEle, "parent=", hpricot_ele_set_parent, 1);
6630
- cCData = rb_define_class_under(mHpricot, "CData", cBaseEle);
6631
- rb_define_method(cCData, "content", hpricot_ele_get_tag, 0);
6632
- rb_define_method(cCData, "content=", hpricot_ele_set_tag, 1);
6633
- cComment = rb_define_class_under(mHpricot, "Comment", cBaseEle);
6634
- rb_define_method(cComment, "content", hpricot_ele_get_tag, 0);
6635
- rb_define_method(cComment, "content=", hpricot_ele_set_tag, 1);
6636
- cDocType = rb_define_class_under(mHpricot, "DocType", cBaseEle);
6637
- rb_define_method(cDocType, "target", hpricot_ele_get_tag, 0);
6638
- rb_define_method(cDocType, "target=", hpricot_ele_set_tag, 1);
6639
- rb_define_method(cDocType, "public_id", hpricot_ele_get_public_id, 0);
6640
- rb_define_method(cDocType, "public_id=", hpricot_ele_set_public_id, 1);
6641
- rb_define_method(cDocType, "system_id", hpricot_ele_get_system_id, 0);
6642
- rb_define_method(cDocType, "system_id=", hpricot_ele_set_system_id, 1);
6643
- cElem = rb_define_class_under(mHpricot, "Elem", cBaseEle);
6644
- rb_define_method(cElem, "raw_attributes", hpricot_ele_get_attr, 0);
6645
- rb_define_method(cElem, "raw_attributes=", hpricot_ele_set_attr, 1);
6646
- rb_define_method(cElem, "children", hpricot_ele_get_children, 0);
6647
- rb_define_method(cElem, "children=", hpricot_ele_set_children, 1);
6648
- rb_define_method(cElem, "etag", hpricot_ele_get_etag, 0);
6649
- rb_define_method(cElem, "etag=", hpricot_ele_set_etag, 1);
6650
- rb_define_method(cElem, "name", hpricot_ele_get_tag, 0);
6651
- rb_define_method(cElem, "name=", hpricot_ele_set_tag, 1);
6652
- cETag = rb_define_class_under(mHpricot, "ETag", cBaseEle);
6653
- rb_define_method(cETag, "name", hpricot_ele_get_tag, 0);
6654
- rb_define_method(cETag, "name=", hpricot_ele_set_tag, 1);
6655
- cBogusETag = rb_define_class_under(mHpricot, "BogusETag", cETag);
6656
- cText = rb_define_class_under(mHpricot, "Text", cBaseEle);
6657
- rb_define_method(cText, "content", hpricot_ele_get_tag, 0);
6658
- rb_define_method(cText, "content=", hpricot_ele_set_tag, 1);
6659
- cXMLDecl = rb_define_class_under(mHpricot, "XMLDecl", cBaseEle);
6660
- rb_define_method(cXMLDecl, "encoding", hpricot_ele_get_encoding, 0);
6661
- rb_define_method(cXMLDecl, "encoding=", hpricot_ele_set_encoding, 1);
6662
- rb_define_method(cXMLDecl, "standalone", hpricot_ele_get_standalone, 0);
6663
- rb_define_method(cXMLDecl, "standalone=", hpricot_ele_set_standalone, 1);
6664
- rb_define_method(cXMLDecl, "version", hpricot_ele_get_version, 0);
6665
- rb_define_method(cXMLDecl, "version=", hpricot_ele_set_version, 1);
6666
- cProcIns = rb_define_class_under(mHpricot, "ProcIns", cBaseEle);
6667
- rb_define_method(cProcIns, "target", hpricot_ele_get_tag, 0);
6668
- rb_define_method(cProcIns, "target=", hpricot_ele_set_tag, 1);
6669
- rb_define_method(cProcIns, "content", hpricot_ele_get_attr, 0);
6670
- rb_define_method(cProcIns, "content=", hpricot_ele_set_attr, 1);
6762
+ #ifndef RSTRUCT_EMBED_LEN_MAX
6763
+ st->ptr = ALLOC_N(VALUE, n);
6764
+ rb_mem_clear(st->ptr, n);
6765
+ st->len = n;
6766
+ #else
6767
+ if (0 < n && n <= RSTRUCT_EMBED_LEN_MAX) {
6768
+ RBASIC(st)->flags &= ~RSTRUCT_EMBED_LEN_MASK;
6769
+ RBASIC(st)->flags |= n << RSTRUCT_EMBED_LEN_SHIFT;
6770
+ rb_mem_clear(st->as.ary, n);
6771
+ } else {
6772
+ st->as.heap.ptr = ALLOC_N(VALUE, n);
6773
+ rb_mem_clear(st->as.heap.ptr, n);
6774
+ st->as.heap.len = n;
6775
+ }
6776
+ #endif
6777
+
6778
+ return (VALUE)st;
6779
+ }
6780
+
6781
+ static VALUE hpricot_struct_ref0(VALUE obj) {return H_ELE_GET(obj, 0);}
6782
+ static VALUE hpricot_struct_ref1(VALUE obj) {return H_ELE_GET(obj, 1);}
6783
+ static VALUE hpricot_struct_ref2(VALUE obj) {return H_ELE_GET(obj, 2);}
6784
+ static VALUE hpricot_struct_ref3(VALUE obj) {return H_ELE_GET(obj, 3);}
6785
+ static VALUE hpricot_struct_ref4(VALUE obj) {return H_ELE_GET(obj, 4);}
6786
+ static VALUE hpricot_struct_ref5(VALUE obj) {return H_ELE_GET(obj, 5);}
6787
+ static VALUE hpricot_struct_ref6(VALUE obj) {return H_ELE_GET(obj, 6);}
6788
+ static VALUE hpricot_struct_ref7(VALUE obj) {return H_ELE_GET(obj, 7);}
6789
+ static VALUE hpricot_struct_ref8(VALUE obj) {return H_ELE_GET(obj, 8);}
6790
+ static VALUE hpricot_struct_ref9(VALUE obj) {return H_ELE_GET(obj, 9);}
6791
+
6792
+ static VALUE (*ref_func[10])() = {
6793
+ hpricot_struct_ref0,
6794
+ hpricot_struct_ref1,
6795
+ hpricot_struct_ref2,
6796
+ hpricot_struct_ref3,
6797
+ hpricot_struct_ref4,
6798
+ hpricot_struct_ref5,
6799
+ hpricot_struct_ref6,
6800
+ hpricot_struct_ref7,
6801
+ hpricot_struct_ref8,
6802
+ hpricot_struct_ref9,
6803
+ };
6804
+
6805
+ static VALUE hpricot_struct_set0(VALUE obj, VALUE val) {return H_ELE_SET(obj, 0, val);}
6806
+ static VALUE hpricot_struct_set1(VALUE obj, VALUE val) {return H_ELE_SET(obj, 1, val);}
6807
+ static VALUE hpricot_struct_set2(VALUE obj, VALUE val) {return H_ELE_SET(obj, 2, val);}
6808
+ static VALUE hpricot_struct_set3(VALUE obj, VALUE val) {return H_ELE_SET(obj, 3, val);}
6809
+ static VALUE hpricot_struct_set4(VALUE obj, VALUE val) {return H_ELE_SET(obj, 4, val);}
6810
+ static VALUE hpricot_struct_set5(VALUE obj, VALUE val) {return H_ELE_SET(obj, 5, val);}
6811
+ static VALUE hpricot_struct_set6(VALUE obj, VALUE val) {return H_ELE_SET(obj, 6, val);}
6812
+ static VALUE hpricot_struct_set7(VALUE obj, VALUE val) {return H_ELE_SET(obj, 7, val);}
6813
+ static VALUE hpricot_struct_set8(VALUE obj, VALUE val) {return H_ELE_SET(obj, 8, val);}
6814
+ static VALUE hpricot_struct_set9(VALUE obj, VALUE val) {return H_ELE_SET(obj, 9, val);}
6815
+
6816
+ static VALUE (*set_func[10])() = {
6817
+ hpricot_struct_set0,
6818
+ hpricot_struct_set1,
6819
+ hpricot_struct_set2,
6820
+ hpricot_struct_set3,
6821
+ hpricot_struct_set4,
6822
+ hpricot_struct_set5,
6823
+ hpricot_struct_set6,
6824
+ hpricot_struct_set7,
6825
+ hpricot_struct_set8,
6826
+ hpricot_struct_set9,
6827
+ };
6828
+
6829
+ static VALUE
6830
+ make_hpricot_struct(VALUE members)
6831
+ {
6832
+ int i = 0;
6833
+ VALUE klass = rb_class_new(rb_cObject);
6834
+ rb_iv_set(klass, "__size__", INT2NUM(RARRAY_LEN(members)));
6835
+ rb_define_alloc_func(klass, alloc_hpricot_struct);
6836
+ rb_define_singleton_method(klass, "new", rb_class_new_instance, -1);
6837
+ for (i = 0; i < RARRAY_LEN(members); i++) {
6838
+ ID id = SYM2ID(RARRAY_PTR(members)[i]);
6839
+ rb_define_method_id(klass, id, ref_func[i], 0);
6840
+ rb_define_method_id(klass, rb_id_attrset(id), set_func[i], 1);
6841
+ }
6842
+ return klass;
6843
+ }
6844
+
6845
+ void Init_hpricot_scan()
6846
+ {
6847
+ VALUE structElem, structAttr, structBasic;
6671
6848
 
6672
6849
  s_ElementContent = rb_intern("ElementContent");
6673
6850
  symAllow = ID2SYM(rb_intern("allow"));
@@ -6677,19 +6854,78 @@ void Init_hpricot_scan()
6677
6854
  s_parent = rb_intern("parent");
6678
6855
  s_read = rb_intern("read");
6679
6856
  s_to_str = rb_intern("to_str");
6680
- iv_parent = rb_intern("parent");
6681
6857
  sym_xmldecl = ID2SYM(rb_intern("xmldecl"));
6682
6858
  sym_doctype = ID2SYM(rb_intern("doctype"));
6683
6859
  sym_procins = ID2SYM(rb_intern("procins"));
6684
6860
  sym_stag = ID2SYM(rb_intern("stag"));
6685
6861
  sym_etag = ID2SYM(rb_intern("etag"));
6686
6862
  sym_emptytag = ID2SYM(rb_intern("emptytag"));
6863
+ sym_allowed = ID2SYM(rb_intern("allowed"));
6864
+ sym_children = ID2SYM(rb_intern("children"));
6687
6865
  sym_comment = ID2SYM(rb_intern("comment"));
6688
6866
  sym_cdata = ID2SYM(rb_intern("cdata"));
6867
+ sym_name = ID2SYM(rb_intern("name"));
6868
+ sym_parent = ID2SYM(rb_intern("parent"));
6869
+ sym_raw_attributes = ID2SYM(rb_intern("raw_attributes"));
6870
+ sym_raw_string = ID2SYM(rb_intern("raw_string"));
6871
+ sym_tagno = ID2SYM(rb_intern("tagno"));
6689
6872
  sym_text = ID2SYM(rb_intern("text"));
6690
6873
  sym_EMPTY = ID2SYM(rb_intern("EMPTY"));
6691
6874
  sym_CDATA = ID2SYM(rb_intern("CDATA"));
6692
6875
 
6876
+ mHpricot = rb_define_module("Hpricot");
6877
+ rb_define_attr(rb_singleton_class(mHpricot), "buffer_size", 1, 1);
6878
+ rb_define_singleton_method(mHpricot, "scan", hpricot_scan, -1);
6879
+ rb_define_singleton_method(mHpricot, "css", hpricot_css, 3);
6880
+ rb_eHpricotParseError = rb_define_class_under(mHpricot, "ParseError", rb_eStandardError);
6881
+
6882
+ structElem = make_hpricot_struct(rb_ary_new3(8, sym_name, sym_parent,
6883
+ sym_raw_attributes, sym_etag, sym_raw_string, sym_allowed,
6884
+ sym_tagno, sym_children));
6885
+ structAttr = make_hpricot_struct(rb_ary_new3(3, sym_name, sym_parent, sym_raw_attributes));
6886
+ structBasic = make_hpricot_struct(rb_ary_new3(2, sym_name, sym_parent));
6887
+
6888
+ cDoc = rb_define_class_under(mHpricot, "Doc", structElem);
6889
+ cCData = rb_define_class_under(mHpricot, "CData", structBasic);
6890
+ rb_define_method(cCData, "content", hpricot_ele_get_name, 0);
6891
+ rb_define_method(cCData, "content=", hpricot_ele_set_name, 1);
6892
+ cComment = rb_define_class_under(mHpricot, "Comment", structBasic);
6893
+ rb_define_method(cComment, "content", hpricot_ele_get_name, 0);
6894
+ rb_define_method(cComment, "content=", hpricot_ele_set_name, 1);
6895
+ cDocType = rb_define_class_under(mHpricot, "DocType", structAttr);
6896
+ rb_define_method(cDocType, "raw_string", hpricot_ele_get_name, 0);
6897
+ rb_define_method(cDocType, "clear_raw", hpricot_ele_clear_name, 0);
6898
+ rb_define_method(cDocType, "target", hpricot_ele_get_target, 0);
6899
+ rb_define_method(cDocType, "target=", hpricot_ele_set_target, 1);
6900
+ rb_define_method(cDocType, "public_id", hpricot_ele_get_public_id, 0);
6901
+ rb_define_method(cDocType, "public_id=", hpricot_ele_set_public_id, 1);
6902
+ rb_define_method(cDocType, "system_id", hpricot_ele_get_system_id, 0);
6903
+ rb_define_method(cDocType, "system_id=", hpricot_ele_set_system_id, 1);
6904
+ cElem = rb_define_class_under(mHpricot, "Elem", structElem);
6905
+ rb_define_method(cElem, "clear_raw", hpricot_ele_clear_raw, 0);
6906
+ cBogusETag = rb_define_class_under(mHpricot, "BogusETag", structAttr);
6907
+ rb_define_method(cBogusETag, "raw_string", hpricot_ele_get_attr, 0);
6908
+ rb_define_method(cBogusETag, "clear_raw", hpricot_ele_clear_attr, 0);
6909
+ cText = rb_define_class_under(mHpricot, "Text", structBasic);
6910
+ rb_define_method(cText, "raw_string", hpricot_ele_get_name, 0);
6911
+ rb_define_method(cText, "clear_raw", hpricot_ele_clear_name, 0);
6912
+ rb_define_method(cText, "content", hpricot_ele_get_name, 0);
6913
+ rb_define_method(cText, "content=", hpricot_ele_set_name, 1);
6914
+ cXMLDecl = rb_define_class_under(mHpricot, "XMLDecl", structAttr);
6915
+ rb_define_method(cXMLDecl, "raw_string", hpricot_ele_get_name, 0);
6916
+ rb_define_method(cXMLDecl, "clear_raw", hpricot_ele_clear_name, 0);
6917
+ rb_define_method(cXMLDecl, "encoding", hpricot_ele_get_encoding, 0);
6918
+ rb_define_method(cXMLDecl, "encoding=", hpricot_ele_set_encoding, 1);
6919
+ rb_define_method(cXMLDecl, "standalone", hpricot_ele_get_standalone, 0);
6920
+ rb_define_method(cXMLDecl, "standalone=", hpricot_ele_set_standalone, 1);
6921
+ rb_define_method(cXMLDecl, "version", hpricot_ele_get_version, 0);
6922
+ rb_define_method(cXMLDecl, "version=", hpricot_ele_set_version, 1);
6923
+ cProcIns = rb_define_class_under(mHpricot, "ProcIns", structAttr);
6924
+ rb_define_method(cProcIns, "target", hpricot_ele_get_name, 0);
6925
+ rb_define_method(cProcIns, "target=", hpricot_ele_set_name, 1);
6926
+ rb_define_method(cProcIns, "content", hpricot_ele_get_attr, 0);
6927
+ rb_define_method(cProcIns, "content=", hpricot_ele_set_attr, 1);
6928
+
6693
6929
  rb_const_set(mHpricot, rb_intern("ProcInsParse"),
6694
6930
  reProcInsParse = rb_eval_string("/\\A<\\?(\\S+)\\s+(.+)/m"));
6695
6931
  }