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
Ran Benita 2019-12-28 13:49:40 +02:00
parent fe417d841e
commit da4a90c13e
11 changed files with 14 additions and 14 deletions

View File

@ -46,7 +46,7 @@ main(void)
assert(ctx);
path = test_get_path("compose/en_US.UTF-8/Compose");
file = fopen(path, "r");
file = fopen(path, "rb");
if (file == NULL) {
perror(path);
free(path);

View File

@ -31,7 +31,7 @@ main(int argc, char *argv[])
while (__AFL_LOOP(1000))
#endif
{
file = fopen(argv[1], "r");
file = fopen(argv[1], "rb");
assert(file);
table = xkb_compose_table_new_from_file(ctx, file,
"en_US.UTF-8",

View File

@ -30,7 +30,7 @@ main(int argc, char *argv[])
while (__AFL_LOOP(1000))
#endif
{
file = fopen(argv[1], "r");
file = fopen(argv[1], "rb");
assert(file);
keymap = xkb_keymap_new_from_file(ctx, file,
XKB_KEYMAP_FORMAT_TEXT_V1,

View File

@ -478,7 +478,7 @@ do_include(struct xkb_compose_table *table, struct scanner *s,
return false;
}
file = fopen(path, "r");
file = fopen(path, "rb");
if (!file) {
scanner_err(s, "failed to open included Compose file \"%s\": %s",
path, strerror(errno));

View File

@ -67,7 +67,7 @@ resolve_name(const char *filename, enum resolve_name_direction direction,
if (ret < 0 || (size_t) ret >= sizeof(path))
return false;
file = fopen(path, "r");
file = fopen(path, "rb");
if (!file)
return false;

View File

@ -178,14 +178,14 @@ xkb_compose_table_new_from_locale(struct xkb_context *ctx,
cpath = get_xcomposefile_path();
if (cpath) {
file = fopen(cpath, "r");
file = fopen(cpath, "rb");
if (file)
goto found_path;
}
cpath = path = get_home_xcompose_file_path();
if (path) {
file = fopen(path, "r");
file = fopen(path, "rb");
if (file)
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);
if (path) {
file = fopen(path, "r");
file = fopen(path, "rb");
if (file)
goto found_path;
}

View File

@ -233,7 +233,7 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name,
continue;
}
file = fopen(buf, "r");
file = fopen(buf, "rb");
if (file)
break;
}

View File

@ -411,7 +411,7 @@ matcher_include(struct matcher *m, struct scanner *parent_scanner,
return;
}
file = fopen(s.buf, "r");
file = fopen(s.buf, "rb");
if (file) {
bool ret = read_rules_file(m->ctx, m, include_depth + 1, file, s.buf);
if (!ret)

View File

@ -270,7 +270,7 @@ test_compile_file(struct xkb_context *context, const char *path_rel)
if (!path)
return NULL;
file = fopen(path, "r");
file = fopen(path, "rb");
if (!file) {
fprintf(stderr, "Failed to open path: %s\n", path);
free(path);

View File

@ -180,7 +180,7 @@ test_seqs(struct xkb_context *ctx)
FILE *file;
path = test_get_path("compose/en_US.UTF-8/Compose");
file = fopen(path, "r");
file = fopen(path, "rb");
assert(file);
free(path);
@ -354,7 +354,7 @@ test_state(struct xkb_context *ctx)
FILE *file;
path = test_get_path("compose/en_US.UTF-8/Compose");
file = fopen(path, "r");
file = fopen(path, "rb");
assert(file);
free(path);

View File

@ -445,7 +445,7 @@ main(int argc, char *argv[])
}
if (keymap_path) {
FILE *file = fopen(keymap_path, "r");
FILE *file = fopen(keymap_path, "rb");
if (!file) {
ret = EXIT_FAILURE;
fprintf(stderr, "Couldn't open '%s': %s\n",