herb 0.8.3-x86_64-linux-musl → 0.8.4-x86_64-linux-musl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/src/ast_nodes.c CHANGED
@@ -20,7 +20,11 @@ AST_DOCUMENT_NODE_T* ast_document_node_init(hb_array_T* children, position_T sta
20
20
 
21
21
  ast_node_init(&document_node->base, AST_DOCUMENT_NODE, start_position, end_position, errors);
22
22
 
23
- document_node->children = children;
23
+ if (children == NULL) {
24
+ document_node->children = hb_array_init(8);
25
+ } else {
26
+ document_node->children = children;
27
+ }
24
28
 
25
29
  return document_node;
26
30
  }
@@ -43,7 +47,11 @@ AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, toke
43
47
  html_open_tag_node->tag_opening = token_copy(tag_opening);
44
48
  html_open_tag_node->tag_name = token_copy(tag_name);
45
49
  html_open_tag_node->tag_closing = token_copy(tag_closing);
46
- html_open_tag_node->children = children;
50
+ if (children == NULL) {
51
+ html_open_tag_node->children = hb_array_init(8);
52
+ } else {
53
+ html_open_tag_node->children = children;
54
+ }
47
55
  html_open_tag_node->is_void = is_void;
48
56
 
49
57
  return html_open_tag_node;
@@ -56,7 +64,11 @@ AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, to
56
64
 
57
65
  html_close_tag_node->tag_opening = token_copy(tag_opening);
58
66
  html_close_tag_node->tag_name = token_copy(tag_name);
59
- html_close_tag_node->children = children;
67
+ if (children == NULL) {
68
+ html_close_tag_node->children = hb_array_init(8);
69
+ } else {
70
+ html_close_tag_node->children = children;
71
+ }
60
72
  html_close_tag_node->tag_closing = token_copy(tag_closing);
61
73
 
62
74
  return html_close_tag_node;
@@ -69,7 +81,11 @@ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NOD
69
81
 
70
82
  html_element_node->open_tag = open_tag;
71
83
  html_element_node->tag_name = token_copy(tag_name);
72
- html_element_node->body = body;
84
+ if (body == NULL) {
85
+ html_element_node->body = hb_array_init(8);
86
+ } else {
87
+ html_element_node->body = body;
88
+ }
73
89
  html_element_node->close_tag = close_tag;
74
90
  html_element_node->is_void = is_void;
75
91
  html_element_node->source = source;
@@ -83,7 +99,11 @@ AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* ope
83
99
  ast_node_init(&html_attribute_value_node->base, AST_HTML_ATTRIBUTE_VALUE_NODE, start_position, end_position, errors);
84
100
 
85
101
  html_attribute_value_node->open_quote = token_copy(open_quote);
86
- html_attribute_value_node->children = children;
102
+ if (children == NULL) {
103
+ html_attribute_value_node->children = hb_array_init(8);
104
+ } else {
105
+ html_attribute_value_node->children = children;
106
+ }
87
107
  html_attribute_value_node->close_quote = token_copy(close_quote);
88
108
  html_attribute_value_node->quoted = quoted;
89
109
 
@@ -95,7 +115,11 @@ AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(hb_array_T* ch
95
115
 
96
116
  ast_node_init(&html_attribute_name_node->base, AST_HTML_ATTRIBUTE_NAME_NODE, start_position, end_position, errors);
97
117
 
98
- html_attribute_name_node->children = children;
118
+ if (children == NULL) {
119
+ html_attribute_name_node->children = hb_array_init(8);
120
+ } else {
121
+ html_attribute_name_node->children = children;
122
+ }
99
123
 
100
124
  return html_attribute_name_node;
101
125
  }
@@ -128,7 +152,11 @@ AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, hb_a
128
152
  ast_node_init(&html_comment_node->base, AST_HTML_COMMENT_NODE, start_position, end_position, errors);
129
153
 
130
154
  html_comment_node->comment_start = token_copy(comment_start);
131
- html_comment_node->children = children;
155
+ if (children == NULL) {
156
+ html_comment_node->children = hb_array_init(8);
157
+ } else {
158
+ html_comment_node->children = children;
159
+ }
132
160
  html_comment_node->comment_end = token_copy(comment_end);
133
161
 
134
162
  return html_comment_node;
@@ -140,7 +168,11 @@ AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, hb_arr
140
168
  ast_node_init(&html_doctype_node->base, AST_HTML_DOCTYPE_NODE, start_position, end_position, errors);
141
169
 
142
170
  html_doctype_node->tag_opening = token_copy(tag_opening);
143
- html_doctype_node->children = children;
171
+ if (children == NULL) {
172
+ html_doctype_node->children = hb_array_init(8);
173
+ } else {
174
+ html_doctype_node->children = children;
175
+ }
144
176
  html_doctype_node->tag_closing = token_copy(tag_closing);
145
177
 
146
178
  return html_doctype_node;
@@ -152,7 +184,11 @@ AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening,
152
184
  ast_node_init(&xml_declaration_node->base, AST_XML_DECLARATION_NODE, start_position, end_position, errors);
153
185
 
154
186
  xml_declaration_node->tag_opening = token_copy(tag_opening);
155
- xml_declaration_node->children = children;
187
+ if (children == NULL) {
188
+ xml_declaration_node->children = hb_array_init(8);
189
+ } else {
190
+ xml_declaration_node->children = children;
191
+ }
156
192
  xml_declaration_node->tag_closing = token_copy(tag_closing);
157
193
 
158
194
  return xml_declaration_node;
@@ -164,7 +200,11 @@ AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, hb_array_T* children
164
200
  ast_node_init(&cdata_node->base, AST_CDATA_NODE, start_position, end_position, errors);
165
201
 
166
202
  cdata_node->tag_opening = token_copy(tag_opening);
167
- cdata_node->children = children;
203
+ if (children == NULL) {
204
+ cdata_node->children = hb_array_init(8);
205
+ } else {
206
+ cdata_node->children = children;
207
+ }
168
208
  cdata_node->tag_closing = token_copy(tag_closing);
169
209
 
170
210
  return cdata_node;
@@ -215,7 +255,11 @@ AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* conte
215
255
  erb_else_node->tag_opening = token_copy(tag_opening);
216
256
  erb_else_node->content = token_copy(content);
217
257
  erb_else_node->tag_closing = token_copy(tag_closing);
218
- erb_else_node->statements = statements;
258
+ if (statements == NULL) {
259
+ erb_else_node->statements = hb_array_init(8);
260
+ } else {
261
+ erb_else_node->statements = statements;
262
+ }
219
263
 
220
264
  return erb_else_node;
221
265
  }
@@ -228,7 +272,11 @@ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content,
228
272
  erb_if_node->tag_opening = token_copy(tag_opening);
229
273
  erb_if_node->content = token_copy(content);
230
274
  erb_if_node->tag_closing = token_copy(tag_closing);
231
- erb_if_node->statements = statements;
275
+ if (statements == NULL) {
276
+ erb_if_node->statements = hb_array_init(8);
277
+ } else {
278
+ erb_if_node->statements = statements;
279
+ }
232
280
  erb_if_node->subsequent = subsequent;
233
281
  erb_if_node->end_node = end_node;
234
282
 
@@ -243,7 +291,11 @@ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* con
243
291
  erb_block_node->tag_opening = token_copy(tag_opening);
244
292
  erb_block_node->content = token_copy(content);
245
293
  erb_block_node->tag_closing = token_copy(tag_closing);
246
- erb_block_node->body = body;
294
+ if (body == NULL) {
295
+ erb_block_node->body = hb_array_init(8);
296
+ } else {
297
+ erb_block_node->body = body;
298
+ }
247
299
  erb_block_node->end_node = end_node;
248
300
 
249
301
  return erb_block_node;
@@ -257,7 +309,11 @@ AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* conte
257
309
  erb_when_node->tag_opening = token_copy(tag_opening);
258
310
  erb_when_node->content = token_copy(content);
259
311
  erb_when_node->tag_closing = token_copy(tag_closing);
260
- erb_when_node->statements = statements;
312
+ if (statements == NULL) {
313
+ erb_when_node->statements = hb_array_init(8);
314
+ } else {
315
+ erb_when_node->statements = statements;
316
+ }
261
317
 
262
318
  return erb_when_node;
263
319
  }
@@ -270,8 +326,16 @@ AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* conte
270
326
  erb_case_node->tag_opening = token_copy(tag_opening);
271
327
  erb_case_node->content = token_copy(content);
272
328
  erb_case_node->tag_closing = token_copy(tag_closing);
273
- erb_case_node->children = children;
274
- erb_case_node->conditions = conditions;
329
+ if (children == NULL) {
330
+ erb_case_node->children = hb_array_init(8);
331
+ } else {
332
+ erb_case_node->children = children;
333
+ }
334
+ if (conditions == NULL) {
335
+ erb_case_node->conditions = hb_array_init(8);
336
+ } else {
337
+ erb_case_node->conditions = conditions;
338
+ }
275
339
  erb_case_node->else_clause = else_clause;
276
340
  erb_case_node->end_node = end_node;
277
341
 
@@ -286,8 +350,16 @@ AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, to
286
350
  erb_case_match_node->tag_opening = token_copy(tag_opening);
287
351
  erb_case_match_node->content = token_copy(content);
288
352
  erb_case_match_node->tag_closing = token_copy(tag_closing);
289
- erb_case_match_node->children = children;
290
- erb_case_match_node->conditions = conditions;
353
+ if (children == NULL) {
354
+ erb_case_match_node->children = hb_array_init(8);
355
+ } else {
356
+ erb_case_match_node->children = children;
357
+ }
358
+ if (conditions == NULL) {
359
+ erb_case_match_node->conditions = hb_array_init(8);
360
+ } else {
361
+ erb_case_match_node->conditions = conditions;
362
+ }
291
363
  erb_case_match_node->else_clause = else_clause;
292
364
  erb_case_match_node->end_node = end_node;
293
365
 
@@ -302,7 +374,11 @@ AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* con
302
374
  erb_while_node->tag_opening = token_copy(tag_opening);
303
375
  erb_while_node->content = token_copy(content);
304
376
  erb_while_node->tag_closing = token_copy(tag_closing);
305
- erb_while_node->statements = statements;
377
+ if (statements == NULL) {
378
+ erb_while_node->statements = hb_array_init(8);
379
+ } else {
380
+ erb_while_node->statements = statements;
381
+ }
306
382
  erb_while_node->end_node = end_node;
307
383
 
308
384
  return erb_while_node;
@@ -316,7 +392,11 @@ AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* con
316
392
  erb_until_node->tag_opening = token_copy(tag_opening);
317
393
  erb_until_node->content = token_copy(content);
318
394
  erb_until_node->tag_closing = token_copy(tag_closing);
319
- erb_until_node->statements = statements;
395
+ if (statements == NULL) {
396
+ erb_until_node->statements = hb_array_init(8);
397
+ } else {
398
+ erb_until_node->statements = statements;
399
+ }
320
400
  erb_until_node->end_node = end_node;
321
401
 
322
402
  return erb_until_node;
@@ -330,7 +410,11 @@ AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content
330
410
  erb_for_node->tag_opening = token_copy(tag_opening);
331
411
  erb_for_node->content = token_copy(content);
332
412
  erb_for_node->tag_closing = token_copy(tag_closing);
333
- erb_for_node->statements = statements;
413
+ if (statements == NULL) {
414
+ erb_for_node->statements = hb_array_init(8);
415
+ } else {
416
+ erb_for_node->statements = statements;
417
+ }
334
418
  erb_for_node->end_node = end_node;
335
419
 
336
420
  return erb_for_node;
@@ -344,7 +428,11 @@ AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* c
344
428
  erb_rescue_node->tag_opening = token_copy(tag_opening);
345
429
  erb_rescue_node->content = token_copy(content);
346
430
  erb_rescue_node->tag_closing = token_copy(tag_closing);
347
- erb_rescue_node->statements = statements;
431
+ if (statements == NULL) {
432
+ erb_rescue_node->statements = hb_array_init(8);
433
+ } else {
434
+ erb_rescue_node->statements = statements;
435
+ }
348
436
  erb_rescue_node->subsequent = subsequent;
349
437
 
350
438
  return erb_rescue_node;
@@ -358,7 +446,11 @@ AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* c
358
446
  erb_ensure_node->tag_opening = token_copy(tag_opening);
359
447
  erb_ensure_node->content = token_copy(content);
360
448
  erb_ensure_node->tag_closing = token_copy(tag_closing);
361
- erb_ensure_node->statements = statements;
449
+ if (statements == NULL) {
450
+ erb_ensure_node->statements = hb_array_init(8);
451
+ } else {
452
+ erb_ensure_node->statements = statements;
453
+ }
362
454
 
363
455
  return erb_ensure_node;
364
456
  }
@@ -371,7 +463,11 @@ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* con
371
463
  erb_begin_node->tag_opening = token_copy(tag_opening);
372
464
  erb_begin_node->content = token_copy(content);
373
465
  erb_begin_node->tag_closing = token_copy(tag_closing);
374
- erb_begin_node->statements = statements;
466
+ if (statements == NULL) {
467
+ erb_begin_node->statements = hb_array_init(8);
468
+ } else {
469
+ erb_begin_node->statements = statements;
470
+ }
375
471
  erb_begin_node->rescue_clause = rescue_clause;
376
472
  erb_begin_node->else_clause = else_clause;
377
473
  erb_begin_node->ensure_clause = ensure_clause;
@@ -388,7 +484,11 @@ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* c
388
484
  erb_unless_node->tag_opening = token_copy(tag_opening);
389
485
  erb_unless_node->content = token_copy(content);
390
486
  erb_unless_node->tag_closing = token_copy(tag_closing);
391
- erb_unless_node->statements = statements;
487
+ if (statements == NULL) {
488
+ erb_unless_node->statements = hb_array_init(8);
489
+ } else {
490
+ erb_unless_node->statements = statements;
491
+ }
392
492
  erb_unless_node->else_clause = else_clause;
393
493
  erb_unless_node->end_node = end_node;
394
494
 
@@ -415,7 +515,11 @@ AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content,
415
515
  erb_in_node->tag_opening = token_copy(tag_opening);
416
516
  erb_in_node->content = token_copy(content);
417
517
  erb_in_node->tag_closing = token_copy(tag_closing);
418
- erb_in_node->statements = statements;
518
+ if (statements == NULL) {
519
+ erb_in_node->statements = hb_array_init(8);
520
+ } else {
521
+ erb_in_node->statements = statements;
522
+ }
419
523
 
420
524
  return erb_in_node;
421
525
  }
@@ -500,7 +604,7 @@ void ast_free_base_node(AST_NODE_T* node) {
500
604
  if (node == NULL) { return; }
501
605
 
502
606
  if (node->errors) {
503
- for (size_t i = 0; i < hb_array_size(node->errors); i++) {
607
+ for (size_t i = 0; i < node->errors->size; i++) {
504
608
  ERROR_T* child = hb_array_get(node->errors, i);
505
609
  if (child != NULL) { error_free(child); }
506
610
  }
@@ -514,7 +618,7 @@ void ast_free_base_node(AST_NODE_T* node) {
514
618
 
515
619
  static void ast_free_document_node(AST_DOCUMENT_NODE_T* document_node) {
516
620
  if (document_node->children != NULL) {
517
- for (size_t i = 0; i < hb_array_size(document_node->children); i++) {
621
+ for (size_t i = 0; i < document_node->children->size; i++) {
518
622
  AST_NODE_T* child = hb_array_get(document_node->children, i);
519
623
  if (child) { ast_node_free(child); }
520
624
  }
@@ -536,7 +640,7 @@ static void ast_free_html_open_tag_node(AST_HTML_OPEN_TAG_NODE_T* html_open_tag_
536
640
  if (html_open_tag_node->tag_name != NULL) { token_free(html_open_tag_node->tag_name); }
537
641
  if (html_open_tag_node->tag_closing != NULL) { token_free(html_open_tag_node->tag_closing); }
538
642
  if (html_open_tag_node->children != NULL) {
539
- for (size_t i = 0; i < hb_array_size(html_open_tag_node->children); i++) {
643
+ for (size_t i = 0; i < html_open_tag_node->children->size; i++) {
540
644
  AST_NODE_T* child = hb_array_get(html_open_tag_node->children, i);
541
645
  if (child) { ast_node_free(child); }
542
646
  }
@@ -551,7 +655,7 @@ static void ast_free_html_close_tag_node(AST_HTML_CLOSE_TAG_NODE_T* html_close_t
551
655
  if (html_close_tag_node->tag_opening != NULL) { token_free(html_close_tag_node->tag_opening); }
552
656
  if (html_close_tag_node->tag_name != NULL) { token_free(html_close_tag_node->tag_name); }
553
657
  if (html_close_tag_node->children != NULL) {
554
- for (size_t i = 0; i < hb_array_size(html_close_tag_node->children); i++) {
658
+ for (size_t i = 0; i < html_close_tag_node->children->size; i++) {
555
659
  AST_NODE_T* child = hb_array_get(html_close_tag_node->children, i);
556
660
  if (child) { ast_node_free(child); }
557
661
  }
@@ -567,7 +671,7 @@ static void ast_free_html_element_node(AST_HTML_ELEMENT_NODE_T* html_element_nod
567
671
  ast_node_free((AST_NODE_T*) html_element_node->open_tag);
568
672
  if (html_element_node->tag_name != NULL) { token_free(html_element_node->tag_name); }
569
673
  if (html_element_node->body != NULL) {
570
- for (size_t i = 0; i < hb_array_size(html_element_node->body); i++) {
674
+ for (size_t i = 0; i < html_element_node->body->size; i++) {
571
675
  AST_NODE_T* child = hb_array_get(html_element_node->body, i);
572
676
  if (child) { ast_node_free(child); }
573
677
  }
@@ -582,7 +686,7 @@ static void ast_free_html_element_node(AST_HTML_ELEMENT_NODE_T* html_element_nod
582
686
  static void ast_free_html_attribute_value_node(AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node) {
583
687
  if (html_attribute_value_node->open_quote != NULL) { token_free(html_attribute_value_node->open_quote); }
584
688
  if (html_attribute_value_node->children != NULL) {
585
- for (size_t i = 0; i < hb_array_size(html_attribute_value_node->children); i++) {
689
+ for (size_t i = 0; i < html_attribute_value_node->children->size; i++) {
586
690
  AST_NODE_T* child = hb_array_get(html_attribute_value_node->children, i);
587
691
  if (child) { ast_node_free(child); }
588
692
  }
@@ -596,7 +700,7 @@ static void ast_free_html_attribute_value_node(AST_HTML_ATTRIBUTE_VALUE_NODE_T*
596
700
 
597
701
  static void ast_free_html_attribute_name_node(AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node) {
598
702
  if (html_attribute_name_node->children != NULL) {
599
- for (size_t i = 0; i < hb_array_size(html_attribute_name_node->children); i++) {
703
+ for (size_t i = 0; i < html_attribute_name_node->children->size; i++) {
600
704
  AST_NODE_T* child = hb_array_get(html_attribute_name_node->children, i);
601
705
  if (child) { ast_node_free(child); }
602
706
  }
@@ -624,7 +728,7 @@ static void ast_free_html_text_node(AST_HTML_TEXT_NODE_T* html_text_node) {
624
728
  static void ast_free_html_comment_node(AST_HTML_COMMENT_NODE_T* html_comment_node) {
625
729
  if (html_comment_node->comment_start != NULL) { token_free(html_comment_node->comment_start); }
626
730
  if (html_comment_node->children != NULL) {
627
- for (size_t i = 0; i < hb_array_size(html_comment_node->children); i++) {
731
+ for (size_t i = 0; i < html_comment_node->children->size; i++) {
628
732
  AST_NODE_T* child = hb_array_get(html_comment_node->children, i);
629
733
  if (child) { ast_node_free(child); }
630
734
  }
@@ -639,7 +743,7 @@ static void ast_free_html_comment_node(AST_HTML_COMMENT_NODE_T* html_comment_nod
639
743
  static void ast_free_html_doctype_node(AST_HTML_DOCTYPE_NODE_T* html_doctype_node) {
640
744
  if (html_doctype_node->tag_opening != NULL) { token_free(html_doctype_node->tag_opening); }
641
745
  if (html_doctype_node->children != NULL) {
642
- for (size_t i = 0; i < hb_array_size(html_doctype_node->children); i++) {
746
+ for (size_t i = 0; i < html_doctype_node->children->size; i++) {
643
747
  AST_NODE_T* child = hb_array_get(html_doctype_node->children, i);
644
748
  if (child) { ast_node_free(child); }
645
749
  }
@@ -654,7 +758,7 @@ static void ast_free_html_doctype_node(AST_HTML_DOCTYPE_NODE_T* html_doctype_nod
654
758
  static void ast_free_xml_declaration_node(AST_XML_DECLARATION_NODE_T* xml_declaration_node) {
655
759
  if (xml_declaration_node->tag_opening != NULL) { token_free(xml_declaration_node->tag_opening); }
656
760
  if (xml_declaration_node->children != NULL) {
657
- for (size_t i = 0; i < hb_array_size(xml_declaration_node->children); i++) {
761
+ for (size_t i = 0; i < xml_declaration_node->children->size; i++) {
658
762
  AST_NODE_T* child = hb_array_get(xml_declaration_node->children, i);
659
763
  if (child) { ast_node_free(child); }
660
764
  }
@@ -669,7 +773,7 @@ static void ast_free_xml_declaration_node(AST_XML_DECLARATION_NODE_T* xml_declar
669
773
  static void ast_free_cdata_node(AST_CDATA_NODE_T* cdata_node) {
670
774
  if (cdata_node->tag_opening != NULL) { token_free(cdata_node->tag_opening); }
671
775
  if (cdata_node->children != NULL) {
672
- for (size_t i = 0; i < hb_array_size(cdata_node->children); i++) {
776
+ for (size_t i = 0; i < cdata_node->children->size; i++) {
673
777
  AST_NODE_T* child = hb_array_get(cdata_node->children, i);
674
778
  if (child) { ast_node_free(child); }
675
779
  }
@@ -711,7 +815,7 @@ static void ast_free_erb_else_node(AST_ERB_ELSE_NODE_T* erb_else_node) {
711
815
  if (erb_else_node->content != NULL) { token_free(erb_else_node->content); }
712
816
  if (erb_else_node->tag_closing != NULL) { token_free(erb_else_node->tag_closing); }
713
817
  if (erb_else_node->statements != NULL) {
714
- for (size_t i = 0; i < hb_array_size(erb_else_node->statements); i++) {
818
+ for (size_t i = 0; i < erb_else_node->statements->size; i++) {
715
819
  AST_NODE_T* child = hb_array_get(erb_else_node->statements, i);
716
820
  if (child) { ast_node_free(child); }
717
821
  }
@@ -727,7 +831,7 @@ static void ast_free_erb_if_node(AST_ERB_IF_NODE_T* erb_if_node) {
727
831
  if (erb_if_node->content != NULL) { token_free(erb_if_node->content); }
728
832
  if (erb_if_node->tag_closing != NULL) { token_free(erb_if_node->tag_closing); }
729
833
  if (erb_if_node->statements != NULL) {
730
- for (size_t i = 0; i < hb_array_size(erb_if_node->statements); i++) {
834
+ for (size_t i = 0; i < erb_if_node->statements->size; i++) {
731
835
  AST_NODE_T* child = hb_array_get(erb_if_node->statements, i);
732
836
  if (child) { ast_node_free(child); }
733
837
  }
@@ -745,7 +849,7 @@ static void ast_free_erb_block_node(AST_ERB_BLOCK_NODE_T* erb_block_node) {
745
849
  if (erb_block_node->content != NULL) { token_free(erb_block_node->content); }
746
850
  if (erb_block_node->tag_closing != NULL) { token_free(erb_block_node->tag_closing); }
747
851
  if (erb_block_node->body != NULL) {
748
- for (size_t i = 0; i < hb_array_size(erb_block_node->body); i++) {
852
+ for (size_t i = 0; i < erb_block_node->body->size; i++) {
749
853
  AST_NODE_T* child = hb_array_get(erb_block_node->body, i);
750
854
  if (child) { ast_node_free(child); }
751
855
  }
@@ -762,7 +866,7 @@ static void ast_free_erb_when_node(AST_ERB_WHEN_NODE_T* erb_when_node) {
762
866
  if (erb_when_node->content != NULL) { token_free(erb_when_node->content); }
763
867
  if (erb_when_node->tag_closing != NULL) { token_free(erb_when_node->tag_closing); }
764
868
  if (erb_when_node->statements != NULL) {
765
- for (size_t i = 0; i < hb_array_size(erb_when_node->statements); i++) {
869
+ for (size_t i = 0; i < erb_when_node->statements->size; i++) {
766
870
  AST_NODE_T* child = hb_array_get(erb_when_node->statements, i);
767
871
  if (child) { ast_node_free(child); }
768
872
  }
@@ -778,7 +882,7 @@ static void ast_free_erb_case_node(AST_ERB_CASE_NODE_T* erb_case_node) {
778
882
  if (erb_case_node->content != NULL) { token_free(erb_case_node->content); }
779
883
  if (erb_case_node->tag_closing != NULL) { token_free(erb_case_node->tag_closing); }
780
884
  if (erb_case_node->children != NULL) {
781
- for (size_t i = 0; i < hb_array_size(erb_case_node->children); i++) {
885
+ for (size_t i = 0; i < erb_case_node->children->size; i++) {
782
886
  AST_NODE_T* child = hb_array_get(erb_case_node->children, i);
783
887
  if (child) { ast_node_free(child); }
784
888
  }
@@ -786,7 +890,7 @@ static void ast_free_erb_case_node(AST_ERB_CASE_NODE_T* erb_case_node) {
786
890
  hb_array_free(&erb_case_node->children);
787
891
  }
788
892
  if (erb_case_node->conditions != NULL) {
789
- for (size_t i = 0; i < hb_array_size(erb_case_node->conditions); i++) {
893
+ for (size_t i = 0; i < erb_case_node->conditions->size; i++) {
790
894
  AST_NODE_T* child = hb_array_get(erb_case_node->conditions, i);
791
895
  if (child) { ast_node_free(child); }
792
896
  }
@@ -804,7 +908,7 @@ static void ast_free_erb_case_match_node(AST_ERB_CASE_MATCH_NODE_T* erb_case_mat
804
908
  if (erb_case_match_node->content != NULL) { token_free(erb_case_match_node->content); }
805
909
  if (erb_case_match_node->tag_closing != NULL) { token_free(erb_case_match_node->tag_closing); }
806
910
  if (erb_case_match_node->children != NULL) {
807
- for (size_t i = 0; i < hb_array_size(erb_case_match_node->children); i++) {
911
+ for (size_t i = 0; i < erb_case_match_node->children->size; i++) {
808
912
  AST_NODE_T* child = hb_array_get(erb_case_match_node->children, i);
809
913
  if (child) { ast_node_free(child); }
810
914
  }
@@ -812,7 +916,7 @@ static void ast_free_erb_case_match_node(AST_ERB_CASE_MATCH_NODE_T* erb_case_mat
812
916
  hb_array_free(&erb_case_match_node->children);
813
917
  }
814
918
  if (erb_case_match_node->conditions != NULL) {
815
- for (size_t i = 0; i < hb_array_size(erb_case_match_node->conditions); i++) {
919
+ for (size_t i = 0; i < erb_case_match_node->conditions->size; i++) {
816
920
  AST_NODE_T* child = hb_array_get(erb_case_match_node->conditions, i);
817
921
  if (child) { ast_node_free(child); }
818
922
  }
@@ -830,7 +934,7 @@ static void ast_free_erb_while_node(AST_ERB_WHILE_NODE_T* erb_while_node) {
830
934
  if (erb_while_node->content != NULL) { token_free(erb_while_node->content); }
831
935
  if (erb_while_node->tag_closing != NULL) { token_free(erb_while_node->tag_closing); }
832
936
  if (erb_while_node->statements != NULL) {
833
- for (size_t i = 0; i < hb_array_size(erb_while_node->statements); i++) {
937
+ for (size_t i = 0; i < erb_while_node->statements->size; i++) {
834
938
  AST_NODE_T* child = hb_array_get(erb_while_node->statements, i);
835
939
  if (child) { ast_node_free(child); }
836
940
  }
@@ -847,7 +951,7 @@ static void ast_free_erb_until_node(AST_ERB_UNTIL_NODE_T* erb_until_node) {
847
951
  if (erb_until_node->content != NULL) { token_free(erb_until_node->content); }
848
952
  if (erb_until_node->tag_closing != NULL) { token_free(erb_until_node->tag_closing); }
849
953
  if (erb_until_node->statements != NULL) {
850
- for (size_t i = 0; i < hb_array_size(erb_until_node->statements); i++) {
954
+ for (size_t i = 0; i < erb_until_node->statements->size; i++) {
851
955
  AST_NODE_T* child = hb_array_get(erb_until_node->statements, i);
852
956
  if (child) { ast_node_free(child); }
853
957
  }
@@ -864,7 +968,7 @@ static void ast_free_erb_for_node(AST_ERB_FOR_NODE_T* erb_for_node) {
864
968
  if (erb_for_node->content != NULL) { token_free(erb_for_node->content); }
865
969
  if (erb_for_node->tag_closing != NULL) { token_free(erb_for_node->tag_closing); }
866
970
  if (erb_for_node->statements != NULL) {
867
- for (size_t i = 0; i < hb_array_size(erb_for_node->statements); i++) {
971
+ for (size_t i = 0; i < erb_for_node->statements->size; i++) {
868
972
  AST_NODE_T* child = hb_array_get(erb_for_node->statements, i);
869
973
  if (child) { ast_node_free(child); }
870
974
  }
@@ -881,7 +985,7 @@ static void ast_free_erb_rescue_node(AST_ERB_RESCUE_NODE_T* erb_rescue_node) {
881
985
  if (erb_rescue_node->content != NULL) { token_free(erb_rescue_node->content); }
882
986
  if (erb_rescue_node->tag_closing != NULL) { token_free(erb_rescue_node->tag_closing); }
883
987
  if (erb_rescue_node->statements != NULL) {
884
- for (size_t i = 0; i < hb_array_size(erb_rescue_node->statements); i++) {
988
+ for (size_t i = 0; i < erb_rescue_node->statements->size; i++) {
885
989
  AST_NODE_T* child = hb_array_get(erb_rescue_node->statements, i);
886
990
  if (child) { ast_node_free(child); }
887
991
  }
@@ -898,7 +1002,7 @@ static void ast_free_erb_ensure_node(AST_ERB_ENSURE_NODE_T* erb_ensure_node) {
898
1002
  if (erb_ensure_node->content != NULL) { token_free(erb_ensure_node->content); }
899
1003
  if (erb_ensure_node->tag_closing != NULL) { token_free(erb_ensure_node->tag_closing); }
900
1004
  if (erb_ensure_node->statements != NULL) {
901
- for (size_t i = 0; i < hb_array_size(erb_ensure_node->statements); i++) {
1005
+ for (size_t i = 0; i < erb_ensure_node->statements->size; i++) {
902
1006
  AST_NODE_T* child = hb_array_get(erb_ensure_node->statements, i);
903
1007
  if (child) { ast_node_free(child); }
904
1008
  }
@@ -914,7 +1018,7 @@ static void ast_free_erb_begin_node(AST_ERB_BEGIN_NODE_T* erb_begin_node) {
914
1018
  if (erb_begin_node->content != NULL) { token_free(erb_begin_node->content); }
915
1019
  if (erb_begin_node->tag_closing != NULL) { token_free(erb_begin_node->tag_closing); }
916
1020
  if (erb_begin_node->statements != NULL) {
917
- for (size_t i = 0; i < hb_array_size(erb_begin_node->statements); i++) {
1021
+ for (size_t i = 0; i < erb_begin_node->statements->size; i++) {
918
1022
  AST_NODE_T* child = hb_array_get(erb_begin_node->statements, i);
919
1023
  if (child) { ast_node_free(child); }
920
1024
  }
@@ -934,7 +1038,7 @@ static void ast_free_erb_unless_node(AST_ERB_UNLESS_NODE_T* erb_unless_node) {
934
1038
  if (erb_unless_node->content != NULL) { token_free(erb_unless_node->content); }
935
1039
  if (erb_unless_node->tag_closing != NULL) { token_free(erb_unless_node->tag_closing); }
936
1040
  if (erb_unless_node->statements != NULL) {
937
- for (size_t i = 0; i < hb_array_size(erb_unless_node->statements); i++) {
1041
+ for (size_t i = 0; i < erb_unless_node->statements->size; i++) {
938
1042
  AST_NODE_T* child = hb_array_get(erb_unless_node->statements, i);
939
1043
  if (child) { ast_node_free(child); }
940
1044
  }
@@ -960,7 +1064,7 @@ static void ast_free_erb_in_node(AST_ERB_IN_NODE_T* erb_in_node) {
960
1064
  if (erb_in_node->content != NULL) { token_free(erb_in_node->content); }
961
1065
  if (erb_in_node->tag_closing != NULL) { token_free(erb_in_node->tag_closing); }
962
1066
  if (erb_in_node->statements != NULL) {
963
- for (size_t i = 0; i < hb_array_size(erb_in_node->statements); i++) {
1067
+ for (size_t i = 0; i < erb_in_node->statements->size; i++) {
964
1068
  AST_NODE_T* child = hb_array_get(erb_in_node->statements, i);
965
1069
  if (child) { ast_node_free(child); }
966
1070
  }
data/src/errors.c CHANGED
@@ -644,7 +644,7 @@ void error_pretty_print_array(
644
644
  return;
645
645
  }
646
646
 
647
- if (hb_array_size(array) == 0) {
647
+ if (array->size == 0) {
648
648
  pretty_print_property(hb_string(name), hb_string("[]"), indent, relative_indent, last_property, buffer);
649
649
 
650
650
  return;
@@ -655,17 +655,17 @@ void error_pretty_print_array(
655
655
  hb_buffer_append(buffer, "(");
656
656
 
657
657
  char count[16];
658
- sprintf(count, "%zu", hb_array_size(array));
658
+ sprintf(count, "%zu", array->size);
659
659
  hb_buffer_append(buffer, count);
660
660
  hb_buffer_append(buffer, ")\n");
661
661
 
662
662
  if (indent < 20) {
663
- for (size_t i = 0; i < hb_array_size(array); i++) {
663
+ for (size_t i = 0; i < array->size; i++) {
664
664
  ERROR_T* child = hb_array_get(array, i);
665
665
  pretty_print_indent(buffer, indent);
666
666
  pretty_print_indent(buffer, relative_indent + 1);
667
667
 
668
- if (i == hb_array_size(array) - 1) {
668
+ if (i == array->size - 1) {
669
669
  hb_buffer_append(buffer, "└── ");
670
670
  } else {
671
671
  hb_buffer_append(buffer, "├── ");
@@ -673,7 +673,7 @@ void error_pretty_print_array(
673
673
 
674
674
  error_pretty_print(child, indent + 1, relative_indent + 1, buffer);
675
675
 
676
- if (i != hb_array_size(array) - 1) { pretty_print_newline(indent + 1, relative_indent, buffer); }
676
+ if (i != array->size - 1) { pretty_print_newline(indent + 1, relative_indent, buffer); }
677
677
  }
678
678
  }
679
679
  }
data/src/extract.c CHANGED
@@ -12,7 +12,7 @@ void herb_extract_ruby_to_buffer(const char* source, hb_buffer_T* output) {
12
12
  bool skip_erb_content = false;
13
13
  bool is_comment_tag = false;
14
14
 
15
- for (size_t i = 0; i < hb_array_size(tokens); i++) {
15
+ for (size_t i = 0; i < tokens->size; i++) {
16
16
  const token_T* token = hb_array_get(tokens, i);
17
17
 
18
18
  switch (token->type) {
@@ -94,7 +94,7 @@ void herb_extract_ruby_to_buffer(const char* source, hb_buffer_T* output) {
94
94
  void herb_extract_html_to_buffer(const char* source, hb_buffer_T* output) {
95
95
  hb_array_T* tokens = herb_lex(source);
96
96
 
97
- for (size_t i = 0; i < hb_array_size(tokens); i++) {
97
+ for (size_t i = 0; i < tokens->size; i++) {
98
98
  const token_T* token = hb_array_get(tokens, i);
99
99
 
100
100
  switch (token->type) {
data/src/herb.c CHANGED
@@ -58,7 +58,7 @@ HERB_EXPORTED_FUNCTION hb_array_T* herb_lex_file(const char* path) {
58
58
  HERB_EXPORTED_FUNCTION void herb_lex_to_buffer(const char* source, hb_buffer_T* output) {
59
59
  hb_array_T* tokens = herb_lex(source);
60
60
 
61
- for (size_t i = 0; i < hb_array_size(tokens); i++) {
61
+ for (size_t i = 0; i < tokens->size; i++) {
62
62
  token_T* token = hb_array_get(tokens, i);
63
63
 
64
64
  hb_string_T type = token_to_string(token);
@@ -74,7 +74,7 @@ HERB_EXPORTED_FUNCTION void herb_lex_to_buffer(const char* source, hb_buffer_T*
74
74
  HERB_EXPORTED_FUNCTION void herb_free_tokens(hb_array_T** tokens) {
75
75
  if (!tokens || !*tokens) { return; }
76
76
 
77
- for (size_t i = 0; i < hb_array_size(*tokens); i++) {
77
+ for (size_t i = 0; i < (*tokens)->size; i++) {
78
78
  token_T* token = hb_array_get(*tokens, i);
79
79
  if (token) { token_free(token); }
80
80
  }
@@ -1,6 +1,6 @@
1
1
  #ifndef HERB_VERSION_H
2
2
  #define HERB_VERSION_H
3
3
 
4
- #define HERB_VERSION "0.8.3"
4
+ #define HERB_VERSION "0.8.4"
5
5
 
6
6
  #endif