Created
August 31, 2018 20:23
-
-
Save Furkanzmc/d24b14171688134423ce912998f2d093 to your computer and use it in GitHub Desktop.
Patch for zxcvbn-c to make it work with Qt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/zxcvbn.c b/zxcvbn.c | |
index ebe9e31..5b2dcf3 100644 | |
--- a/zxcvbn.c | |
+++ b/zxcvbn.c | |
@@ -41,6 +41,7 @@ | |
#include <stdio.h> | |
#else | |
#include <fstream> | |
+#include <QFile> | |
#endif | |
#endif | |
@@ -263,11 +264,12 @@ typedef FILE *FileHandle; | |
#else | |
/* Use the C++ iostreams */ | |
-typedef std::ifstream FileHandle; | |
+typedef QFile FileHandle; | |
static inline void MyOpenFile(FileHandle & f, const char *Name) | |
{ | |
- f.open(Name, std::ifstream::in | std::ifstream::binary); | |
+ f.setFileName(QString(Name)); | |
+ f.open(QIODevice::ReadOnly); | |
} | |
static inline bool MyReadFile(FileHandle & f, void *Buf, unsigned int Num) | |
{ | |
@@ -342,8 +344,8 @@ int ZxcvbnInit(const char *Filename) | |
uint64_t Crc = CHK_INIT; | |
if (DictNodes) | |
return 1; | |
- MyOpenFile(f, Filename); | |
- if (f) | |
+ MyOpenFile(f, Filename); | |
+ if (f.isOpen()) | |
{ | |
unsigned int i, DictSize; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment