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

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

Issue 173468: The first step towards fixing valgrind errors in the new hunspell.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/deps/
Patch Set: '' Created 11 years, 3 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
« no previous file with comments | « third_party/hunspell128/src/hunspell/filemgr.hxx ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « third_party/hunspell128/src/hunspell/filemgr.hxx ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698