Open files in binary mode
This turns off some misfeatures on Windows, and does nothing on POSIX. Signed-off-by: Ran Benita <ran@unusedvar.com>master
parent
fe417d841e
commit
da4a90c13e
|
@ -46,7 +46,7 @@ main(void)
|
||||||
assert(ctx);
|
assert(ctx);
|
||||||
|
|
||||||
path = test_get_path("compose/en_US.UTF-8/Compose");
|
path = test_get_path("compose/en_US.UTF-8/Compose");
|
||||||
file = fopen(path, "r");
|
file = fopen(path, "rb");
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
perror(path);
|
perror(path);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
|
@ -31,7 +31,7 @@ main(int argc, char *argv[])
|
||||||
while (__AFL_LOOP(1000))
|
while (__AFL_LOOP(1000))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
file = fopen(argv[1], "r");
|
file = fopen(argv[1], "rb");
|
||||||
assert(file);
|
assert(file);
|
||||||
table = xkb_compose_table_new_from_file(ctx, file,
|
table = xkb_compose_table_new_from_file(ctx, file,
|
||||||
"en_US.UTF-8",
|
"en_US.UTF-8",
|
||||||
|
|
|
@ -30,7 +30,7 @@ main(int argc, char *argv[])
|
||||||
while (__AFL_LOOP(1000))
|
while (__AFL_LOOP(1000))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
file = fopen(argv[1], "r");
|
file = fopen(argv[1], "rb");
|
||||||
assert(file);
|
assert(file);
|
||||||
keymap = xkb_keymap_new_from_file(ctx, file,
|
keymap = xkb_keymap_new_from_file(ctx, file,
|
||||||
XKB_KEYMAP_FORMAT_TEXT_V1,
|
XKB_KEYMAP_FORMAT_TEXT_V1,
|
||||||
|
|
|
@ -478,7 +478,7 @@ do_include(struct xkb_compose_table *table, struct scanner *s,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(path, "r");
|
file = fopen(path, "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
scanner_err(s, "failed to open included Compose file \"%s\": %s",
|
scanner_err(s, "failed to open included Compose file \"%s\": %s",
|
||||||
path, strerror(errno));
|
path, strerror(errno));
|
||||||
|
|
|
@ -67,7 +67,7 @@ resolve_name(const char *filename, enum resolve_name_direction direction,
|
||||||
if (ret < 0 || (size_t) ret >= sizeof(path))
|
if (ret < 0 || (size_t) ret >= sizeof(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
file = fopen(path, "r");
|
file = fopen(path, "rb");
|
||||||
if (!file)
|
if (!file)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -178,14 +178,14 @@ xkb_compose_table_new_from_locale(struct xkb_context *ctx,
|
||||||
|
|
||||||
cpath = get_xcomposefile_path();
|
cpath = get_xcomposefile_path();
|
||||||
if (cpath) {
|
if (cpath) {
|
||||||
file = fopen(cpath, "r");
|
file = fopen(cpath, "rb");
|
||||||
if (file)
|
if (file)
|
||||||
goto found_path;
|
goto found_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpath = path = get_home_xcompose_file_path();
|
cpath = path = get_home_xcompose_file_path();
|
||||||
if (path) {
|
if (path) {
|
||||||
file = fopen(path, "r");
|
file = fopen(path, "rb");
|
||||||
if (file)
|
if (file)
|
||||||
goto found_path;
|
goto found_path;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ xkb_compose_table_new_from_locale(struct xkb_context *ctx,
|
||||||
|
|
||||||
cpath = path = get_locale_compose_file_path(table->locale);
|
cpath = path = get_locale_compose_file_path(table->locale);
|
||||||
if (path) {
|
if (path) {
|
||||||
file = fopen(path, "r");
|
file = fopen(path, "rb");
|
||||||
if (file)
|
if (file)
|
||||||
goto found_path;
|
goto found_path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(buf, "r");
|
file = fopen(buf, "rb");
|
||||||
if (file)
|
if (file)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,7 +411,7 @@ matcher_include(struct matcher *m, struct scanner *parent_scanner,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(s.buf, "r");
|
file = fopen(s.buf, "rb");
|
||||||
if (file) {
|
if (file) {
|
||||||
bool ret = read_rules_file(m->ctx, m, include_depth + 1, file, s.buf);
|
bool ret = read_rules_file(m->ctx, m, include_depth + 1, file, s.buf);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
|
|
@ -270,7 +270,7 @@ test_compile_file(struct xkb_context *context, const char *path_rel)
|
||||||
if (!path)
|
if (!path)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
file = fopen(path, "r");
|
file = fopen(path, "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
fprintf(stderr, "Failed to open path: %s\n", path);
|
fprintf(stderr, "Failed to open path: %s\n", path);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
|
@ -180,7 +180,7 @@ test_seqs(struct xkb_context *ctx)
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
path = test_get_path("compose/en_US.UTF-8/Compose");
|
path = test_get_path("compose/en_US.UTF-8/Compose");
|
||||||
file = fopen(path, "r");
|
file = fopen(path, "rb");
|
||||||
assert(file);
|
assert(file);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ test_state(struct xkb_context *ctx)
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
path = test_get_path("compose/en_US.UTF-8/Compose");
|
path = test_get_path("compose/en_US.UTF-8/Compose");
|
||||||
file = fopen(path, "r");
|
file = fopen(path, "rb");
|
||||||
assert(file);
|
assert(file);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
|
|
|
@ -445,7 +445,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keymap_path) {
|
if (keymap_path) {
|
||||||
FILE *file = fopen(keymap_path, "r");
|
FILE *file = fopen(keymap_path, "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
fprintf(stderr, "Couldn't open '%s': %s\n",
|
fprintf(stderr, "Couldn't open '%s': %s\n",
|
||||||
|
|
Loading…
Reference in New Issue