Skip to content

Commit 4d10bd9

Browse files
committed
Add script for upgrading lexbor
Also upgrade patches, and apply them properly.
1 parent b61ee87 commit 4d10bd9

16 files changed

Lines changed: 146 additions & 85 deletions

ext/dom/lexbor/lexbor/css/rule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,15 @@ lxb_css_rule_ref_dec(lxb_css_rule_t *rule)
361361
lxb_inline void
362362
lxb_css_rule_ref_dec_destroy(lxb_css_rule_t *rule)
363363
{
364+
#if 0
364365
if (rule->ref_count > 0) {
365366
rule->ref_count--;
366367
}
367368

368369
if (rule->ref_count == 0) {
369370
(void) lxb_css_rule_destroy(rule, true);
370371
}
372+
#endif
371373
}
372374

373375
lxb_inline void

ext/dom/lexbor/lexbor/encoding/multi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Alexander Borisov
2+
* Copyright (C) 2026 Alexander Borisov
33
*
44
* Author: Alexander Borisov <borisov@lexbor.com>
55
*/

ext/dom/lexbor/lexbor/html/tokenizer/res.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4946,4 +4946,5 @@ static const lexbor_sbst_entry_static_t lxb_html_tokenizer_res_entities_sbst[] =
49464946
{0x66, {0}, 0, 0, 0, 9853}, {0x3b, "\xf0\x9d\x95\xaa", 4, 0, 0, 0}
49474947
};
49484948

4949+
49494950
#endif /* LXB_HTML_TOKENIZER_RES */

ext/dom/lexbor/lexbor/html/tree/error.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ lxb_html_tree_error_add(lexbor_array_obj_t *parse_errors,
2424
entry->id = id;
2525
entry->line = token->line;
2626
entry->column = token->column;
27-
entry->begin = token->begin;
28-
entry->end = token->end;
27+
entry->length = token->end - token->begin;
2928

3029
return entry;
3130
}

ext/dom/lexbor/lexbor/html/tree/error.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ typedef struct {
111111
lxb_html_tree_error_id_t id;
112112
size_t line;
113113
size_t column;
114-
const lxb_char_t *begin;
115-
const lxb_char_t *end;
114+
size_t length;
116115
}
117116
lxb_html_tree_error_t;
118117

ext/dom/lexbor/lexbor/html/tree/insertion_mode/before_head.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ lxb_html_tree_insertion_mode_before_head_open(lxb_html_tree_t *tree,
6868
}
6969

7070
tree->has_explicit_head_tag = true;
71+
7172
tree->mode = lxb_html_tree_insertion_mode_in_head;
7273

7374
break;

ext/dom/lexbor/lexbor/html/tree/insertion_mode/before_html.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ lxb_html_tree_insertion_mode_before_html_open(lxb_html_tree_t *tree,
7979
}
8080

8181
tree->has_explicit_html_tag = true;
82+
8283
tree->mode = lxb_html_tree_insertion_mode_before_head;
8384

8485
break;

ext/dom/lexbor/lexbor/tag/res.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ static const lxb_tag_data_t lxb_tag_res_data_default[LXB_TAG__LAST_ENTRY] =
226226
{{.u.short_str = "xmp", .length = 3, .next = NULL}, LXB_TAG_XMP, 1, true}
227227
};
228228

229+
#if 0
229230
static const lxb_tag_data_t lxb_tag_res_data_upper_default[LXB_TAG__LAST_ENTRY] =
230231
{
231232
{{.u.short_str = "#UNDEF", .length = 6, .next = NULL}, LXB_TAG__UNDEF, 1, true},
@@ -427,6 +428,7 @@ static const lxb_tag_data_t lxb_tag_res_data_upper_default[LXB_TAG__LAST_ENTRY]
427428
{{.u.short_str = "WBR", .length = 3, .next = NULL}, LXB_TAG_WBR, 1, true},
428429
{{.u.short_str = "XMP", .length = 3, .next = NULL}, LXB_TAG_XMP, 1, true}
429430
};
431+
#endif
430432

431433
static const lexbor_shs_entry_t lxb_tag_res_shs_data_default[263] =
432434
{

ext/dom/lexbor/lexbor/tag/tag.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ lxb_tag_data_by_name(lexbor_hash_t *hash, const lxb_char_t *name, size_t len)
9292
lexbor_hash_search_lower, name, len);
9393
}
9494

95+
#if 0
9596
const lxb_tag_data_t *
9697
lxb_tag_data_by_name_upper(lexbor_hash_t *hash,
9798
const lxb_char_t *name, size_t len)
@@ -114,6 +115,7 @@ lxb_tag_data_by_name_upper(lexbor_hash_t *hash,
114115
return (const lxb_tag_data_t *) lexbor_hash_search(hash,
115116
lexbor_hash_search_upper, name, len);
116117
}
118+
#endif
117119

118120
/*
119121
* No inline functions for ABI.

ext/dom/lexbor/patches/0001-Expose-line-and-column-information-for-use-in-PHP.patch

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 4c133fe5adfe4b8ccdd8b014d884b685143b9e66 Mon Sep 17 00:00:00 2001
1+
From 0cd2add6c46400b808329442f81451b369863983 Mon Sep 17 00:00:00 2001
22
From: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
33
Date: Sat, 26 Aug 2023 15:08:59 +0200
44
Subject: [PATCH 1/6] Expose line and column information for use in PHP
@@ -15,10 +15,10 @@ Subject: [PATCH 1/6] Expose line and column information for use in PHP
1515
8 files changed, 48 insertions(+), 5 deletions(-)
1616

1717
diff --git a/source/lexbor/dom/interfaces/node.h b/source/lexbor/dom/interfaces/node.h
18-
index b052cf5..b5d2c50 100644
18+
index 6c74ac5..b95373c 100644
1919
--- a/source/lexbor/dom/interfaces/node.h
2020
+++ b/source/lexbor/dom/interfaces/node.h
21-
@@ -83,6 +83,8 @@ struct lxb_dom_node {
21+
@@ -86,6 +86,8 @@ struct lxb_dom_node {
2222

2323
lxb_dom_node_type_t type;
2424

@@ -41,18 +41,18 @@ index 79accd0..0b7f4fd 100644
4141
const lxb_char_t *text_start;
4242
const lxb_char_t *text_end;
4343
diff --git a/source/lexbor/html/tokenizer.c b/source/lexbor/html/tokenizer.c
44-
index 741bced..0bd9aec 100644
44+
index 22b88ed..1d9f378 100644
4545
--- a/source/lexbor/html/tokenizer.c
4646
+++ b/source/lexbor/html/tokenizer.c
47-
@@ -91,6 +91,7 @@ lxb_html_tokenizer_init(lxb_html_tokenizer_t *tkz)
47+
@@ -92,6 +92,7 @@ lxb_html_tokenizer_init(lxb_html_tokenizer_t *tkz)
4848

4949
tkz->pos = tkz->start;
5050
tkz->end = tkz->start + LXB_HTML_TKZ_TEMP_SIZE;
5151
+ /* current_line & current_column already initialized by calloc (zero-based) */
5252

5353
tkz->tree = NULL;
5454
tkz->tags = NULL;
55-
@@ -152,6 +153,8 @@ lxb_html_tokenizer_inherit(lxb_html_tokenizer_t *tkz_to,
55+
@@ -153,6 +154,8 @@ lxb_html_tokenizer_inherit(lxb_html_tokenizer_t *tkz_to,
5656
tkz_to->start = tkz_from->start;
5757
tkz_to->end = tkz_from->end;
5858
tkz_to->pos = tkz_to->start;
@@ -61,7 +61,7 @@ index 741bced..0bd9aec 100644
6161

6262
return LXB_STATUS_OK;
6363
}
64-
@@ -312,7 +315,26 @@ lxb_html_tokenizer_chunk(lxb_html_tokenizer_t *tkz, const lxb_char_t *data,
64+
@@ -571,7 +574,26 @@ lxb_html_tokenizer_chunk(lxb_html_tokenizer_t *tkz, const lxb_char_t *data,
6565
tkz->last = end;
6666

6767
while (data < end) {
@@ -90,10 +90,10 @@ index 741bced..0bd9aec 100644
9090

9191
return tkz->status;
9292
diff --git a/source/lexbor/html/tokenizer.h b/source/lexbor/html/tokenizer.h
93-
index ba9602f..74bb55e 100644
93+
index 12b7c81..aa1ac37 100644
9494
--- a/source/lexbor/html/tokenizer.h
9595
+++ b/source/lexbor/html/tokenizer.h
96-
@@ -73,6 +73,8 @@ struct lxb_html_tokenizer {
96+
@@ -79,6 +79,8 @@ struct lxb_html_tokenizer {
9797
const lxb_char_t *end;
9898
const lxb_char_t *begin;
9999
const lxb_char_t *last;
@@ -103,7 +103,7 @@ index ba9602f..74bb55e 100644
103103
/* Entities */
104104
const lexbor_sbst_entry_static_t *entity;
105105
diff --git a/source/lexbor/html/tokenizer/state.h b/source/lexbor/html/tokenizer/state.h
106-
index 17939b9..5b095b4 100644
106+
index 5e91444..52eaa9a 100644
107107
--- a/source/lexbor/html/tokenizer/state.h
108108
+++ b/source/lexbor/html/tokenizer/state.h
109109
@@ -90,6 +90,8 @@ extern "C" {
@@ -116,10 +116,10 @@ index 17939b9..5b095b4 100644
116116
while (0)
117117

118118
diff --git a/source/lexbor/html/tree.c b/source/lexbor/html/tree.c
119-
index ece26e9..91bfd17 100644
119+
index 062ea56..3f4c18d 100644
120120
--- a/source/lexbor/html/tree.c
121121
+++ b/source/lexbor/html/tree.c
122-
@@ -427,6 +427,9 @@ lxb_html_tree_create_element_for_token(lxb_html_tree_t *tree,
122+
@@ -431,6 +431,9 @@ lxb_html_tree_create_element_for_token(lxb_html_tree_t *tree,
123123
return NULL;
124124
}
125125

@@ -129,7 +129,7 @@ index ece26e9..91bfd17 100644
129129
lxb_status_t status;
130130
lxb_dom_element_t *element = lxb_dom_interface_element(node);
131131

132-
@@ -763,6 +766,11 @@ lxb_html_tree_insert_character_for_data(lxb_html_tree_t *tree,
132+
@@ -767,6 +770,11 @@ lxb_html_tree_insert_character_for_data(lxb_html_tree_t *tree,
133133

134134
lxb_dom_interface_text(text)->char_data.data = *str;
135135

@@ -141,7 +141,7 @@ index ece26e9..91bfd17 100644
141141
if (ret_node != NULL) {
142142
*ret_node = text;
143143
}
144-
@@ -802,6 +810,9 @@ lxb_html_tree_insert_comment(lxb_html_tree_t *tree,
144+
@@ -806,6 +814,9 @@ lxb_html_tree_insert_comment(lxb_html_tree_t *tree,
145145
return NULL;
146146
}
147147

@@ -152,10 +152,10 @@ index ece26e9..91bfd17 100644
152152
tree->document->dom_document.text);
153153
if (tree->status != LXB_STATUS_OK) {
154154
diff --git a/source/lexbor/html/tree/error.c b/source/lexbor/html/tree/error.c
155-
index e6e43f4..88ad8c4 100644
155+
index ffdc55c..ef36eab 100644
156156
--- a/source/lexbor/html/tree/error.c
157157
+++ b/source/lexbor/html/tree/error.c
158-
@@ -21,8 +21,9 @@ lxb_html_tree_error_add(lexbor_array_obj_t *parse_errors,
158+
@@ -22,8 +22,9 @@ lxb_html_tree_error_add(lexbor_array_obj_t *parse_errors,
159159
}
160160

161161
entry->id = id;
@@ -168,10 +168,10 @@ index e6e43f4..88ad8c4 100644
168168
return entry;
169169
}
170170
diff --git a/source/lexbor/html/tree/error.h b/source/lexbor/html/tree/error.h
171-
index 2fd06cb..ed1859f 100644
171+
index 7a212af..b186772 100644
172172
--- a/source/lexbor/html/tree/error.h
173173
+++ b/source/lexbor/html/tree/error.h
174-
@@ -97,8 +97,9 @@ lxb_html_tree_error_id_t;
174+
@@ -109,8 +109,9 @@ lxb_html_tree_error_id_t;
175175

176176
typedef struct {
177177
lxb_html_tree_error_id_t id;
@@ -184,5 +184,5 @@ index 2fd06cb..ed1859f 100644
184184
lxb_html_tree_error_t;
185185

186186
--
187-
2.49.0
187+
2.51.2
188188

0 commit comments

Comments
 (0)