Skip to content
Snippets Groups Projects
Commit 0705ddc0 authored by MERLINI Adrien's avatar MERLINI Adrien
Browse files

Fix handling of non ascii chars

parent e83bb0aa
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@
#include <mpi.h>
#include <openssl/sha.h>
#define FIXED_WORD_SIZE 1
const constexpr size_t word_buffer_length = 8 + 1;
bool is_same_hash(const unsigned char* hash_1, const unsigned char* hash_2)
......@@ -50,20 +51,27 @@ std::vector<std::string> read_dict(const std::filesystem::path& path, size_t wor
{
std::ifstream if_dict(path);
std::vector<std::string> words(words_to_read);
size_t w;
size_t w = 0;
for(w = 0; w < words_to_read; ++w)
{
if(!if_dict.good())
{
--w;
break;
}
std::getline(if_dict, words[w]);
#if FIXED_WORD_SIZE
if((words[w].size() + 1) != word_buffer_length)
--w;
#endif
}
if(w < words_to_read)
{
words.resize(w - 1);
words.resize(w + 1);
std::cerr << "The dictionary contained less words than requested." << std::endl;
}
std::cout << "Loaded " << w << " words." << std::endl;
std::cout << "Loaded " << words.size() << " words." << std::endl;
return words;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment