diff options
author | Gatis Paeglis <gatis.paeglis@digia.com> | 2014-02-05 16:25:06 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-19 15:42:13 +0100 |
commit | b19b0808940c8c54b102012be134a370b26e348e (patch) | |
tree | 63d951814f771e87508be7b0f8d4346d0079dc05 /src/3rdparty/xkbcommon/src/xkbcomp/include.c | |
parent | c6b555dac389f9a599a9ad342de56dea329fff60 (diff) |
Update bundled libxkbcommon version to 0.4.0
This release comes with important bug fixes. Also we can now
remove the workaround code which was needed for libxkbcommon 0.2.0.
Task-number: QTBUG-31712
Task-number: QTBUG-33732
Task-number: QTBUG-34056
Change-Id: I57caf7f803b9a01a15541a5ad82e464de3b8abbb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty/xkbcommon/src/xkbcomp/include.c')
-rw-r--r-- | src/3rdparty/xkbcommon/src/xkbcomp/include.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/include.c b/src/3rdparty/xkbcommon/src/xkbcomp/include.c index b4a4014635..dc3f1e49bd 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/include.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/include.c @@ -199,17 +199,34 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name, { unsigned int i; FILE *file = NULL; - char buf[PATH_MAX]; + char *buf = NULL; const char *typeDir; + size_t buf_size = 0, typeDirLen, name_len; typeDir = DirectoryForInclude(type); + typeDirLen = strlen(typeDir); + name_len = strlen(name); for (i = 0; i < xkb_context_num_include_paths(ctx); i++) { - int ret = snprintf(buf, sizeof(buf), "%s/%s/%s", - xkb_context_include_path_get(ctx, i), - typeDir, name); - if (ret >= (ssize_t) sizeof(buf)) { - log_err(ctx, "File name (%s/%s/%s) too long\n", + size_t new_buf_size = strlen(xkb_context_include_path_get(ctx, i)) + + typeDirLen + name_len + 3; + int ret; + if (new_buf_size > buf_size) { + void *buf_new = realloc(buf, new_buf_size); + if (buf_new) { + buf_size = new_buf_size; + buf = buf_new; + } else { + log_err(ctx, "Cannot realloc for name (%s/%s/%s)\n", + xkb_context_include_path_get(ctx, i), typeDir, name); + continue; + } + } + ret = snprintf(buf, buf_size, "%s/%s/%s", + xkb_context_include_path_get(ctx, i), + typeDir, name); + if (ret < 0) { + log_err(ctx, "snprintf error (%s/%s/%s)\n", xkb_context_include_path_get(ctx, i), typeDir, name); continue; } @@ -242,11 +259,14 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name, xkb_context_failed_include_path_get(ctx, i)); } + free(buf); return NULL; } if (pathRtrn) - *pathRtrn = strdup(buf); + *pathRtrn = buf; + else + free(buf); return file; } @@ -275,7 +295,7 @@ ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt, if (xkb_file->file_type != file_type) { log_err(ctx, - "Include file wrong type (expected %s, got %s); " + "Include file of wrong type (expected %s, got %s); " "Include file \"%s\" ignored\n", xkb_file_type_to_string(file_type), xkb_file_type_to_string(xkb_file->file_type), stmt->file); |