diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2023-08-06 16:54:57 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2023-08-06 16:54:57 (GMT) |
commit | 4fcc35a52ccb025b6d803d85e017931cd2452960 (patch) | |
tree | e95920f16c273e41f9cae1ea2f02571c221a514e /src/common | |
parent | 74d062d4ec55d7ac3914bbf64b8b6c5ab52227df (diff) |
Extend the ROST grammar with a first batch of new features.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/szstr.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/common/szstr.h b/src/common/szstr.h index 54beb9a..d73e489 100644 --- a/src/common/szstr.h +++ b/src/common/szstr.h @@ -29,6 +29,9 @@ #include <sys/types.h> +#include "sort.h" + + /* Structure associant une chaƮne et sa taille */ typedef struct _sized_string_t @@ -66,9 +69,28 @@ typedef struct _sized_string_t } \ } \ while (0) - -#define szstrcmp(ss, rs) \ - strncmp((ss)->data, (rs)/*->data*/, (ss)->len) + +#define szstrcmp(s1, s2) \ + ({ \ + int __ret; \ + size_t __n; \ + __n = (s1)->len < (s2)->len ? (s1)->len : (s2)->len; \ + __ret = strncmp((s1)->data, (s2)->data, __n); \ + if (__ret == 0) \ + __ret = sort_unsigned_long_long((s1)->len, (s2)->len); \ + __ret; \ + }) + +#define szmemcmp(s1, s2) \ + ({ \ + int __ret; \ + size_t __n; \ + __n = (s1)->len < (s2)->len ? (s1)->len : (s2)->len; \ + __ret = memcmp((s1)->data, (s2)->data, __n); \ + if (__ret == 0) \ + __ret = sort_unsigned_long_long((s1)->len, (s2)->len); \ + __ret; \ + }) |