diff options
| author | 2023-12-08 06:13:08 +0100 | |
|---|---|---|
| committer | 2023-12-08 06:13:08 +0100 | |
| commit | 8bdebf278a47fba0743331feb565b64bcb5fbb6e (patch) | |
| tree | ca51f3cb3c77759de448e418339ad7874aa97e23 | |
| parent | Also check inside Update messages in is_msg_for_me(). (diff) | |
| download | snac2-8bdebf278a47fba0743331feb565b64bcb5fbb6e.tar.gz snac2-8bdebf278a47fba0743331feb565b64bcb5fbb6e.tar.xz snac2-8bdebf278a47fba0743331feb565b64bcb5fbb6e.zip | |
Backport from xs.
| -rw-r--r-- | xs_html.h | 39 | ||||
| -rw-r--r-- | xs_version.h | 2 |
2 files changed, 14 insertions, 27 deletions
| @@ -42,10 +42,8 @@ typedef enum { | |||
| 42 | struct xs_html { | 42 | struct xs_html { |
| 43 | xs_html_type type; | 43 | xs_html_type type; |
| 44 | xs_str *content; | 44 | xs_str *content; |
| 45 | xs_html *f_attr; | 45 | xs_html *attrs; |
| 46 | xs_html *l_attr; | 46 | xs_html *tags; |
| 47 | xs_html *f_tag; | ||
| 48 | xs_html *l_tag; | ||
| 49 | xs_html *next; | 47 | xs_html *next; |
| 50 | }; | 48 | }; |
| 51 | 49 | ||
| @@ -140,25 +138,14 @@ xs_html *_xs_html_add(xs_html *tag, xs_html *var[]) | |||
| 140 | while (*var) { | 138 | while (*var) { |
| 141 | xs_html *data = *var++; | 139 | xs_html *data = *var++; |
| 142 | 140 | ||
| 143 | xs_html **first; | ||
| 144 | xs_html **last; | ||
| 145 | |||
| 146 | if (data->type == XS_HTML_ATTR) { | 141 | if (data->type == XS_HTML_ATTR) { |
| 147 | first = &tag->f_attr; | 142 | data->next = tag->attrs; |
| 148 | last = &tag->l_attr; | 143 | tag->attrs = data; |
| 149 | } | 144 | } |
| 150 | else { | 145 | else { |
| 151 | first = &tag->f_tag; | 146 | data->next = tag->tags; |
| 152 | last = &tag->l_tag; | 147 | tag->tags = data; |
| 153 | } | 148 | } |
| 154 | |||
| 155 | if (*first == NULL) | ||
| 156 | *first = data; | ||
| 157 | |||
| 158 | if (*last != NULL) | ||
| 159 | (*last)->next = data; | ||
| 160 | |||
| 161 | *last = data; | ||
| 162 | } | 149 | } |
| 163 | 150 | ||
| 164 | return tag; | 151 | return tag; |
| @@ -206,17 +193,20 @@ void xs_html_render_f(xs_html *h, FILE *f) | |||
| 206 | if (h == NULL) | 193 | if (h == NULL) |
| 207 | return; | 194 | return; |
| 208 | 195 | ||
| 196 | /* follow the chain */ | ||
| 197 | xs_html_render_f(h->next, f); | ||
| 198 | |||
| 209 | switch (h->type) { | 199 | switch (h->type) { |
| 210 | case XS_HTML_TAG: | 200 | case XS_HTML_TAG: |
| 211 | fprintf(f, "<%s", h->content); | 201 | fprintf(f, "<%s", h->content); |
| 212 | 202 | ||
| 213 | /* attributes */ | 203 | /* attributes */ |
| 214 | xs_html_render_f(h->f_attr, f); | 204 | xs_html_render_f(h->attrs, f); |
| 215 | 205 | ||
| 216 | fprintf(f, ">"); | 206 | fprintf(f, ">"); |
| 217 | 207 | ||
| 218 | /* sub-tags */ | 208 | /* sub-tags */ |
| 219 | xs_html_render_f(h->f_tag, f); | 209 | xs_html_render_f(h->tags, f); |
| 220 | 210 | ||
| 221 | fprintf(f, "</%s>", h->content); | 211 | fprintf(f, "</%s>", h->content); |
| 222 | break; | 212 | break; |
| @@ -225,14 +215,14 @@ void xs_html_render_f(xs_html *h, FILE *f) | |||
| 225 | fprintf(f, "<%s", h->content); | 215 | fprintf(f, "<%s", h->content); |
| 226 | 216 | ||
| 227 | /* attributes */ | 217 | /* attributes */ |
| 228 | xs_html_render_f(h->f_attr, f); | 218 | xs_html_render_f(h->attrs, f); |
| 229 | 219 | ||
| 230 | fprintf(f, "/>"); | 220 | fprintf(f, "/>"); |
| 231 | break; | 221 | break; |
| 232 | 222 | ||
| 233 | case XS_HTML_CONTAINER: | 223 | case XS_HTML_CONTAINER: |
| 234 | /* sub-tags */ | 224 | /* sub-tags */ |
| 235 | xs_html_render_f(h->f_tag, f); | 225 | xs_html_render_f(h->tags, f); |
| 236 | break; | 226 | break; |
| 237 | 227 | ||
| 238 | case XS_HTML_ATTR: | 228 | case XS_HTML_ATTR: |
| @@ -244,9 +234,6 @@ void xs_html_render_f(xs_html *h, FILE *f) | |||
| 244 | break; | 234 | break; |
| 245 | } | 235 | } |
| 246 | 236 | ||
| 247 | /* follow the chain */ | ||
| 248 | xs_html_render_f(h->next, f); | ||
| 249 | |||
| 250 | xs_free(h->content); | 237 | xs_free(h->content); |
| 251 | xs_free(h); | 238 | xs_free(h); |
| 252 | } | 239 | } |
diff --git a/xs_version.h b/xs_version.h index 0e90e31..f25a017 100644 --- a/xs_version.h +++ b/xs_version.h | |||
| @@ -1 +1 @@ | |||
| /* 1b21549513460489504a2caa4127607c914a10da 2023-12-03T23:45:32+01:00 */ | /* 3582ff265e19407df1d532eb1d90c372fe22ca62 2023-12-08T06:10:40+01:00 */ | ||