1 #include "license.hunspell"
2 #include "license.myspell"
10 #ifdef HUNSPELL_CHROME_CLIENT
11 #include "third_party/hunspell/google/bdict_reader.h"
13 FileMgr::FileMgr(hunspell::LineIterator
* iterator
) : iterator_(iterator
) {
19 char * FileMgr::getline() {
20 // Read one line from a BDICT file and store the line to our line buffer.
21 // To emulate the original FileMgr::getline(), this function returns
22 // the pointer to our line buffer if we can read a line without errors.
23 // Otherwise, this function returns NULL.
24 bool result
= iterator_
->AdvanceAndCopy(line_
, BUFSIZE
- 1);
25 return result
? line_
: NULL
;
28 int FileMgr::getlinenum() {
29 // This function is used only for displaying a line number that causes a
30 // parser error. For a BDICT file, providing a line number doesn't help
31 // identifying the place where causes a parser error so much since it is a
32 // binary file. So, we just return 0.
36 int FileMgr::fail(const char * err
, const char * par
) {
37 fprintf(stderr
, err
, par
);
41 FileMgr::FileMgr(const char * file
, const char * key
) {
44 fin
= fopen(file
, "r");
47 char * st
= (char *) malloc(strlen(file
) + strlen(HZIP_EXTENSION
) + 1);
50 strcat(st
, HZIP_EXTENSION
);
51 hin
= new Hunzip(st
, key
);
55 if (!fin
&& !hin
) fail(MSG_OPEN
, file
);
64 char * FileMgr::getline() {
67 if (fin
) return fgets(in
, BUFSIZE
- 1, fin
);
68 if (hin
&& ((l
= hin
->getline()) != NULL
)) return strcpy(in
, l
);
73 int FileMgr::getlinenum() {