From d233b4943fdbe63a95397dd354d5b7081cb642cd Mon Sep 17 00:00:00 2001 From: Davi de Castro Reis Date: Fri, 28 Dec 2018 00:51:37 -0200 Subject: [PATCH] Partially apply https://sourceforge.net/p/cmph/patches/3/ --- examples/struct_vector_adapter_ex3.c | 4 ++-- examples/vector_adapter_ex1.c | 4 ++-- src/main.c | 4 ++-- tests/mphf_tests.c | 2 +- tests/packed_mphf_tests.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/struct_vector_adapter_ex3.c b/examples/struct_vector_adapter_ex3.c index ed61764..6dd58af 100644 --- a/examples/struct_vector_adapter_ex3.c +++ b/examples/struct_vector_adapter_ex3.c @@ -19,7 +19,7 @@ int main(int argc, char **argv) {7, "gggggggggg", 2005}, {8, "hhhhhhhhhh", 2006}, {9, "iiiiiiiiii", 2007}, {10,"jjjjjjjjjj", 2008}}; unsigned int nkeys = 10; - FILE* mphf_fd = fopen("temp_struct_vector.mph", "w"); + FILE* mphf_fd = fopen("temp_struct_vector.mph", "wb"); // Source of keys cmph_io_adapter_t *source = cmph_io_struct_vector_adapter(vector, (cmph_uint32)sizeof(rec_t), (cmph_uint32)sizeof(cmph_uint32), 11, nkeys); @@ -34,7 +34,7 @@ int main(int argc, char **argv) fclose(mphf_fd); //Find key - mphf_fd = fopen("temp_struct_vector.mph", "r"); + mphf_fd = fopen("temp_struct_vector.mph", "rb"); hash = cmph_load(mphf_fd); while (i < nkeys) { const char *key = vector[i].key; diff --git a/examples/vector_adapter_ex1.c b/examples/vector_adapter_ex1.c index 44305dc..50d29c7 100755 --- a/examples/vector_adapter_ex1.c +++ b/examples/vector_adapter_ex1.c @@ -9,7 +9,7 @@ int main(int argc, char **argv) const char *vector[] = {"aaaaaaaaaa", "bbbbbbbbbb", "cccccccccc", "dddddddddd", "eeeeeeeeee", "ffffffffff", "gggggggggg", "hhhhhhhhhh", "iiiiiiiiii", "jjjjjjjjjj"}; unsigned int nkeys = 10; - FILE* mphf_fd = fopen("temp.mph", "w"); + FILE* mphf_fd = fopen("temp.mph", "wb"); // Source of keys cmph_io_adapter_t *source = cmph_io_vector_adapter((char **)vector, nkeys); @@ -24,7 +24,7 @@ int main(int argc, char **argv) fclose(mphf_fd); //Find key - mphf_fd = fopen("temp.mph", "r"); + mphf_fd = fopen("temp.mph", "rb"); hash = cmph_load(mphf_fd); while (i < nkeys) { const char *key = vector[i]; diff --git a/src/main.c b/src/main.c index e179768..5bbd00d 100644 --- a/src/main.c +++ b/src/main.c @@ -248,7 +248,7 @@ int main(int argc, char **argv) if (generate) { //Create mphf - mphf_fd = fopen(mphf_file, "w"); + mphf_fd = fopen(mphf_file, "wb"); config = cmph_config_new(source); cmph_config_set_algo(config, mph_algo); if (nhashes) cmph_config_set_hashfuncs(config, hashes); @@ -286,7 +286,7 @@ int main(int argc, char **argv) else { cmph_uint8 * hashtable = NULL; - mphf_fd = fopen(mphf_file, "r"); + mphf_fd = fopen(mphf_file, "rb"); if (mphf_fd == NULL) { fprintf(stderr, "Unable to open input file %s: %s\n", mphf_file, strerror(errno)); diff --git a/tests/mphf_tests.c b/tests/mphf_tests.c index 117e014..82c9505 100644 --- a/tests/mphf_tests.c +++ b/tests/mphf_tests.c @@ -107,7 +107,7 @@ int main(int argc, char **argv) else source = cmph_io_nlnkfile_adapter(keys_fd, nkeys); cmph_uint8 * hashtable = NULL; - mphf_fd = fopen(mphf_file, "r"); + mphf_fd = fopen(mphf_file, "rb"); if (mphf_fd == NULL) { fprintf(stderr, "Unable to open input file %s: %s\n", mphf_file, strerror(errno)); diff --git a/tests/packed_mphf_tests.c b/tests/packed_mphf_tests.c index d2c0589..5e7865a 100644 --- a/tests/packed_mphf_tests.c +++ b/tests/packed_mphf_tests.c @@ -122,7 +122,7 @@ int main(int argc, char **argv) else source = cmph_io_nlnkfile_adapter(keys_fd, nkeys); cmph_uint8 * hashtable = NULL; - mphf_fd = fopen(mphf_file, "r"); + mphf_fd = fopen(mphf_file, "rb"); if (mphf_fd == NULL) { fprintf(stderr, "Unable to open input file %s: %s\n", mphf_file, strerror(errno));