Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/hunspell_new/src/hunspell/filemgr.cxx

Issue 1135173004: Rename third_party/hunspell_new back to third_party/hunspell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #include "license.hunspell"
2 #include "license.myspell"
3
4 #include <stdlib.h>
5 #include <string.h>
6 #include <stdio.h>
7
8 #include "filemgr.hxx"
9
10 #ifdef HUNSPELL_CHROME_CLIENT
11 #include "third_party/hunspell_new/google/bdict_reader.h"
12
13 FileMgr::FileMgr(hunspell::LineIterator* iterator) : iterator_(iterator) {
14 }
15
16 FileMgr::~FileMgr() {
17 }
18
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;
26 }
27
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.
33 return 0;
34 }
35 #else
36 int FileMgr::fail(const char * err, const char * par) {
37 fprintf(stderr, err, par);
38 return -1;
39 }
40
41 FileMgr::FileMgr(const char * file, const char * key) {
42 linenum = 0;
43 hin = NULL;
44 fin = fopen(file, "r");
45 if (!fin) {
46 // check hzipped file
47 char * st = (char *) malloc(strlen(file) + strlen(HZIP_EXTENSION) + 1);
48 if (st) {
49 strcpy(st, file);
50 strcat(st, HZIP_EXTENSION);
51 hin = new Hunzip(st, key);
52 free(st);
53 }
54 }
55 if (!fin && !hin) fail(MSG_OPEN, file);
56 }
57
58 FileMgr::~FileMgr()
59 {
60 if (fin) fclose(fin);
61 if (hin) delete hin;
62 }
63
64 char * FileMgr::getline() {
65 const char * l;
66 linenum++;
67 if (fin) return fgets(in, BUFSIZE - 1, fin);
68 if (hin && ((l = hin->getline()) != NULL)) return strcpy(in, l);
69 linenum--;
70 return NULL;
71 }
72
73 int FileMgr::getlinenum() {
74 return linenum;
75 }
76 #endif
OLDNEW
« no previous file with comments | « third_party/hunspell_new/src/hunspell/filemgr.hxx ('k') | third_party/hunspell_new/src/hunspell/hashmgr.hxx » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698