Przeglądaj źródła

New function xs_html_xtag().

grunfink 4 tygodni temu
rodzic
commit
99544bf772
4 zmienionych plików z 25 dodań i 5 usunięć
  1. 6 3
      xs.h
  2. 17 0
      xs_html.h
  3. 1 1
      xs_url.h
  4. 1 1
      xs_version.h

+ 6 - 3
xs.h

@@ -135,6 +135,7 @@ xs_dict *xs_dict_set_path_sep(xs_dict *dict, const char *path, const xs_val *val
 #define xs_dict_set_path(dict, path, value) xs_dict_set_path_sep(dict, path, value, ".")
 
 xs_val *xs_val_new(xstype t);
+xs_number *_xs_number_new(const char *str);
 xs_number *xs_number_new(double f);
 xs_number *xs_number_new_l(long l);
 double xs_number_get(const xs_number *v);
@@ -164,6 +165,7 @@ uint64_t xs_hash64_func(const char *data, int size);
 
 #define xs_is_true(v) (xs_type((v)) == XSTYPE_TRUE)
 #define xs_is_false(v) (xs_type((v)) == XSTYPE_FALSE)
+#define xs_bool(v) xs_stock((v) ? XSTYPE_TRUE : XSTYPE_FALSE)
 #define xs_not(v) xs_stock(xs_is_true((v)) ? XSTYPE_FALSE : XSTYPE_TRUE)
 #define xs_is_string(v) (xs_type((v)) == XSTYPE_STRING)
 #define xs_is_list(v) (xs_type((v)) == XSTYPE_LIST)
@@ -706,7 +708,7 @@ xs_str *xs_tolower_i(xs_str *str)
     int n;
 
     for (n = 0; str[n]; n++)
-        str[n] = tolower(str[n]);
+        str[n] = tolower((int)str[n]);
 
     return str;
 }
@@ -720,7 +722,7 @@ xs_str *xs_toupper_i(xs_str *str)
     int n;
 
     for (n = 0; str[n]; n++)
-        str[n] = toupper(str[n]);
+        str[n] = toupper((int)str[n]);
 
     return str;
 }
@@ -1559,7 +1561,8 @@ xs_data *xs_data_new(const void *data, int size)
 
     _xs_put_size(v, total_size);
 
-    memcpy(&v[1 + _XS_TYPE_SIZE], data, size);
+    if (data)
+        memcpy(&v[1 + _XS_TYPE_SIZE], data, size);
 
     return v;
 }

+ 17 - 0
xs_html.h

@@ -24,6 +24,9 @@ xs_html *_xs_html_sctag(const char *tag, xs_html *var[]);
 xs_html *_xs_html_container(xs_html *var[]);
 #define xs_html_container(...) _xs_html_container((xs_html *[]) { __VA_ARGS__, NULL })
 
+xs_html *_xs_html_xtag(const char *tag, xs_html *var[]);
+#define xs_html_xtag(tag, ...) _xs_html_xtag(tag, (xs_html *[]) { __VA_ARGS__, NULL })
+
 void xs_html_render_f(xs_html *h, FILE *f);
 xs_str *xs_html_render_s(xs_html *tag, const char *prefix);
 #define xs_html_render(tag) xs_html_render_s(tag, NULL)
@@ -187,6 +190,20 @@ xs_html *_xs_html_container(xs_html *var[])
 }
 
 
+xs_html *_xs_html_xtag(const char *tag, xs_html *var[])
+{
+    if (xs_is_null(tag))
+        return _xs_html_container(var);
+    else
+    if (xs_endswith(tag, "/")) {
+        xs *tag2 = xs_crop_i(xs_dup(tag), 0, -1);
+        return _xs_html_sctag(tag2, var);
+    }
+
+    return _xs_html_tag(tag, var);
+}
+
+
 void xs_html_render_f(xs_html *h, FILE *f)
 /* renders the tag and its subtags into a file */
 {

+ 1 - 1
xs_url.h

@@ -118,7 +118,7 @@ xs_str *xs_url_enc(const char *str)
     xs_str *s = xs_str_new(NULL);
 
     while (*str) {
-        if (isalnum(*str) || strchr("-._~", *str)) {
+        if (isalnum((int)*str) || strchr("-._~", *str)) {
             s = xs_append_m(s, str, 1);
         }
         else {

+ 1 - 1
xs_version.h

@@ -1 +1 @@
-/* 4110cac45d3d8a6c86b6552c59ec9c73d7a3a4c0 2026-06-17T11:46:41+02:00 */
+/* 243a85157ca228412b681c8c4a57aab164d50b93 2026-08-08T07:08:26+02:00 */