mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-07-04 12:03:41 +02:00
core/dictionary.cpp: use readLines() from file.h
This commit is contained in:
parent
c5a5ba40f6
commit
06a2f7be33
1 changed files with 10 additions and 14 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include "file.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "dictionary.h"
|
#include "dictionary.h"
|
||||||
|
|
||||||
|
|
@ -22,26 +23,21 @@ struct StringContains {
|
||||||
|
|
||||||
bool Dictionary::loadFromFile(const std::string& filename)
|
bool Dictionary::loadFromFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
FILE *fd;
|
strlist_t lines;
|
||||||
char buf[1024];
|
|
||||||
|
|
||||||
fd = fopen(filename.c_str(), "r");
|
|
||||||
if (!fd) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear before adding.
|
// Clear before adding.
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
// Read each line and add to the dictionary.
|
if (readLines(filename, lines)) {
|
||||||
while(fgets(buf, sizeof(buf), fd) != NULL) {
|
|
||||||
std::string word(buf);
|
|
||||||
add(trim(word));
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fd);
|
// Read each line and add to the dictionary.
|
||||||
|
for(auto it = lines.begin(); it != lines.end(); it++) {
|
||||||
|
add(*it);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Dictionary::add(const std::string& word)
|
void Dictionary::add(const std::string& word)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue