xkbcomp: simplify the include path handling

Streamline the code a bit - instead of handling all the if (!file) conditions
handle the case of where we have a file and jump to the end.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
master
Peter Hutterer 2020-07-27 11:55:32 +10:00 committed by Ran Benita
parent 351b4b9c0b
commit bbc7005b2a
1 changed files with 11 additions and 18 deletions

View File

@ -241,28 +241,21 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name,
}
file = fopen(buf, "rb");
if (!file) {
free(buf);
buf = NULL;
} else {
break;
if (file) {
if (pathRtrn) {
*pathRtrn = buf;
buf = NULL;
}
goto out;
}
}
if (!file) {
log_err(ctx, "Couldn't find file \"%s/%s\" in include paths\n",
typeDir, name);
log_err(ctx, "Couldn't find file \"%s/%s\" in include paths\n",
typeDir, name);
LogIncludePaths(ctx);
LogIncludePaths(ctx);
free(buf);
return NULL;
}
if (pathRtrn)
*pathRtrn = buf;
else
free(buf);
out:
free(buf);
return file;
}