| OLD | NEW |
| 1 #include "license.hunspell" | 1 #include "license.hunspell" |
| 2 #include "license.myspell" | 2 #include "license.myspell" |
| 3 | 3 |
| 4 #ifndef MOZILLA_CLIENT | 4 #ifndef MOZILLA_CLIENT |
| 5 #include <cstdlib> | 5 #include <cstdlib> |
| 6 #include <cstring> | 6 #include <cstring> |
| 7 #include <cstdio> | 7 #include <cstdio> |
| 8 #else | 8 #else |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #include "filemgr.hxx" | 14 #include "filemgr.hxx" |
| 15 | 15 |
| 16 #ifdef HUNSPELL_CHROME_CLIENT |
| 17 #include "third_party/hunspell/google/bdict_reader.h" |
| 18 |
| 19 FileMgr::FileMgr(hunspell::LineIterator* iterator) : iterator_(iterator) { |
| 20 } |
| 21 |
| 22 FileMgr::~FileMgr() { |
| 23 } |
| 24 |
| 25 char * FileMgr::getline() { |
| 26 // Read one line from a BDICT file and store the line to our line buffer. |
| 27 // To emulate the original FileMgr::getline(), this function returns |
| 28 // the pointer to our line buffer if we can read a line without errors. |
| 29 // Otherwise, this function returns NULL. |
| 30 bool result = iterator_->AdvanceAndCopy(line_, BUFSIZE - 1); |
| 31 return result ? line_ : NULL; |
| 32 } |
| 33 |
| 34 int FileMgr::getlinenum() { |
| 35 // This function is used only for displaying a line number that causes a |
| 36 // parser error. For a BDICT file, providing a line number doesn't help |
| 37 // identifying the place where causes a parser error so much since it is a |
| 38 // binary file. So, we just return 0. |
| 39 return 0; |
| 40 } |
| 41 #else |
| 16 int FileMgr::fail(const char * err, const char * par) { | 42 int FileMgr::fail(const char * err, const char * par) { |
| 17 fprintf(stderr, err, par); | 43 fprintf(stderr, err, par); |
| 18 return -1; | 44 return -1; |
| 19 } | 45 } |
| 20 | 46 |
| 21 FileMgr::FileMgr(const char * file, const char * key) { | 47 FileMgr::FileMgr(const char * file, const char * key) { |
| 22 linenum = 0; | 48 linenum = 0; |
| 23 hin = NULL; | 49 hin = NULL; |
| 24 fin = fopen(file, "r"); | 50 fin = fopen(file, "r"); |
| 25 if (!fin) { | 51 if (!fin) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 linenum++; | 71 linenum++; |
| 46 if (fin) return fgets(in, BUFSIZE - 1, fin); | 72 if (fin) return fgets(in, BUFSIZE - 1, fin); |
| 47 if (hin && (l = hin->getline())) return strcpy(in, l); | 73 if (hin && (l = hin->getline())) return strcpy(in, l); |
| 48 linenum--; | 74 linenum--; |
| 49 return NULL; | 75 return NULL; |
| 50 } | 76 } |
| 51 | 77 |
| 52 int FileMgr::getlinenum() { | 78 int FileMgr::getlinenum() { |
| 53 return linenum; | 79 return linenum; |
| 54 } | 80 } |
| 81 #endif |
| OLD | NEW |