commit 99544bf
grunfink
·
2026-08-21 15:14:02 +0000 UTC
parent 4f27bb0
New function xs_html_xtag().
4 files changed,
+25,
-5
M
xs.h
+6,
-3
1@@ -135,6 +135,7 @@ xs_dict *xs_dict_set_path_sep(xs_dict *dict, const char *path, const xs_val *val
2 #define xs_dict_set_path(dict, path, value) xs_dict_set_path_sep(dict, path, value, ".")
3
4 xs_val *xs_val_new(xstype t);
5+xs_number *_xs_number_new(const char *str);
6 xs_number *xs_number_new(double f);
7 xs_number *xs_number_new_l(long l);
8 double xs_number_get(const xs_number *v);
9@@ -164,6 +165,7 @@ uint64_t xs_hash64_func(const char *data, int size);
10
11 #define xs_is_true(v) (xs_type((v)) == XSTYPE_TRUE)
12 #define xs_is_false(v) (xs_type((v)) == XSTYPE_FALSE)
13+#define xs_bool(v) xs_stock((v) ? XSTYPE_TRUE : XSTYPE_FALSE)
14 #define xs_not(v) xs_stock(xs_is_true((v)) ? XSTYPE_FALSE : XSTYPE_TRUE)
15 #define xs_is_string(v) (xs_type((v)) == XSTYPE_STRING)
16 #define xs_is_list(v) (xs_type((v)) == XSTYPE_LIST)
17@@ -706,7 +708,7 @@ xs_str *xs_tolower_i(xs_str *str)
18 int n;
19
20 for (n = 0; str[n]; n++)
21- str[n] = tolower(str[n]);
22+ str[n] = tolower((int)str[n]);
23
24 return str;
25 }
26@@ -720,7 +722,7 @@ xs_str *xs_toupper_i(xs_str *str)
27 int n;
28
29 for (n = 0; str[n]; n++)
30- str[n] = toupper(str[n]);
31+ str[n] = toupper((int)str[n]);
32
33 return str;
34 }
35@@ -1559,7 +1561,8 @@ xs_data *xs_data_new(const void *data, int size)
36
37 _xs_put_size(v, total_size);
38
39- memcpy(&v[1 + _XS_TYPE_SIZE], data, size);
40+ if (data)
41+ memcpy(&v[1 + _XS_TYPE_SIZE], data, size);
42
43 return v;
44 }
+17,
-0
1@@ -24,6 +24,9 @@ xs_html *_xs_html_sctag(const char *tag, xs_html *var[]);
2 xs_html *_xs_html_container(xs_html *var[]);
3 #define xs_html_container(...) _xs_html_container((xs_html *[]) { __VA_ARGS__, NULL })
4
5+xs_html *_xs_html_xtag(const char *tag, xs_html *var[]);
6+#define xs_html_xtag(tag, ...) _xs_html_xtag(tag, (xs_html *[]) { __VA_ARGS__, NULL })
7+
8 void xs_html_render_f(xs_html *h, FILE *f);
9 xs_str *xs_html_render_s(xs_html *tag, const char *prefix);
10 #define xs_html_render(tag) xs_html_render_s(tag, NULL)
11@@ -187,6 +190,20 @@ xs_html *_xs_html_container(xs_html *var[])
12 }
13
14
15+xs_html *_xs_html_xtag(const char *tag, xs_html *var[])
16+{
17+ if (xs_is_null(tag))
18+ return _xs_html_container(var);
19+ else
20+ if (xs_endswith(tag, "/")) {
21+ xs *tag2 = xs_crop_i(xs_dup(tag), 0, -1);
22+ return _xs_html_sctag(tag2, var);
23+ }
24+
25+ return _xs_html_tag(tag, var);
26+}
27+
28+
29 void xs_html_render_f(xs_html *h, FILE *f)
30 /* renders the tag and its subtags into a file */
31 {
M
xs_url.h
+1,
-1
1@@ -118,7 +118,7 @@ xs_str *xs_url_enc(const char *str)
2 xs_str *s = xs_str_new(NULL);
3
4 while (*str) {
5- if (isalnum(*str) || strchr("-._~", *str)) {
6+ if (isalnum((int)*str) || strchr("-._~", *str)) {
7 s = xs_append_m(s, str, 1);
8 }
9 else {
+1,
-1
1@@ -1 +1 @@
2-/* 4110cac45d3d8a6c86b6552c59ec9c73d7a3a4c0 2026-06-17T11:46:41+02:00 */
3+/* 243a85157ca228412b681c8c4a57aab164d50b93 2026-08-08T07:08:26+02:00 */