From 76c762558a4f31d030cf55dacf0e1913db5c6d60 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 16 Oct 2018 12:09:10 +0200 Subject: 3rdparty/xkbcommon: update bundled version 0.4.1 -> 0.8.2 0.8.2 + subsequent commits up to 31f1f355700870c6615399fbfa7934934b3a9a57. There were couple commits after 0.8.2. Mostly minor stuff, with 2 exceptions: fix off-by-one error in xkb_file_type_to_string() and undefined behavior in src/x11/keymap.c We currently don't use any of the features added in later releases of libxkbcommon, therefore the minimal required version in src/gui/configure.json remains the same. [ChangeLog][Third-Party Code] updated bundled libxkbcommon 0.4.1 -> 0.8.2 (up to 31f1f355700870c6615399fbfa7934934b3a9a57) Task-number: QTBUG-71109 Change-Id: Ia03c3dc31c5f39e78dcb5915a45e82797b065ccb Reviewed-by: Lars Knoll --- src/3rdparty/xkbcommon/src/utils.c | 70 ++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 7 deletions(-) (limited to 'src/3rdparty/xkbcommon/src/utils.c') diff --git a/src/3rdparty/xkbcommon/src/utils.c b/src/3rdparty/xkbcommon/src/utils.c index a00b04eeec..a71b570b34 100644 --- a/src/3rdparty/xkbcommon/src/utils.c +++ b/src/3rdparty/xkbcommon/src/utils.c @@ -32,13 +32,16 @@ #include bool -map_file(FILE *file, const char **string_out, size_t *size_out) +map_file(FILE *file, char **string_out, size_t *size_out) { struct stat stat_buf; - const int fd = fileno(file); + int fd; char *string; /* Make sure to keep the errno on failure! */ + fd = fileno(file); + if (fd < 0) + return false; if (fstat(fd, &stat_buf) != 0) return false; @@ -53,15 +56,15 @@ map_file(FILE *file, const char **string_out, size_t *size_out) } void -unmap_file(const char *str, size_t size) +unmap_file(char *str, size_t size) { - munmap(UNCONSTIFY(str), size); + munmap(str, size); } #else bool -map_file(FILE *file, const char **string_out, size_t *size_out) +map_file(FILE *file, char **string_out, size_t *size_out) { long ret; size_t ret_s; @@ -99,9 +102,62 @@ map_file(FILE *file, const char **string_out, size_t *size_out) } void -unmap_file(const char *str, size_t size) +unmap_file(char *str, size_t size) { - free(UNCONSTIFY(str)); + free(str); } #endif + +// ASCII lower-case map. +static const unsigned char lower_map[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, + 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, + 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, + 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, + 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 +}; + +// ASCII tolower (to avoid locale issues). +char +to_lower(char c) +{ + return (char) lower_map[(unsigned char) c]; +} + +// ASCII strcasecmp (to avoid locale issues). +int +istrcmp(const char *a, const char *b) +{ + for (size_t i = 0; ; i++) { + if (to_lower(a[i]) != to_lower(b[i])) + return (int) to_lower(a[i]) - (int) to_lower(b[i]); + if (!a[i]) + break; + } + return 0; +} + +// ASCII strncasecmp (to avoid locale issues). +int +istrncmp(const char *a, const char *b, size_t n) +{ + for (size_t i = 0; i < n; i++) { + if (to_lower(a[i]) != to_lower(b[i])) + return (int) to_lower(a[i]) - (int) to_lower(b[i]); + if (!a[i]) + break; + } + return 0; +} -- cgit v1.2.3