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

Unified Diff: third_party/hyphen/google.patch

Issue 12259025: Linux: apply a different hyphen patch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/hyphen/README.chromium ('k') | third_party/hyphen/hyphen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/hyphen/google.patch
diff --git a/third_party/hyphen/google.patch b/third_party/hyphen/google.patch
index bca4d2f552f0539a1ceb7d0474c35a0e2f8334e4..fa5cac3634ccd60da2d8a030c0c4dcebe0066828 100644
--- a/third_party/hyphen/google.patch
+++ b/third_party/hyphen/google.patch
@@ -1,148 +1,69 @@
-? google.patch
Index: hyphen.c
===================================================================
RCS file: /cvsroot/hunspell/hyphen/hyphen.c,v
-retrieving revision 1.4
-diff -u -r1.4 hyphen.c
---- hyphen.c 1 Dec 2010 01:30:20 -0000 1.4
-+++ hyphen.c 1 Mar 2012 05:18:32 -0000
-@@ -242,12 +242,71 @@
- }
- #endif
-
-+#ifdef HYPHEN_CHROME_CLIENT
-+typedef struct {
-+ const unsigned char *data;
-+ size_t offset;
-+ size_t size;
-+} hnj_file;
-+
-+static hnj_file *
-+hnj_fopen (const unsigned char *data, size_t size)
-+{
-+ hnj_file *f;
-+
-+ f = hnj_malloc (sizeof(hnj_file));
+retrieving revision 1.8
+diff -u -r1.8 hyphen.c
+--- hyphen.c 13 Sep 2012 07:50:49 -0000 1.8
++++ hyphen.c 6 Feb 2013 17:31:51 -0000
+@@ -374,19 +374,28 @@
+ HyphenDict *
+ hnj_hyphen_load (const char *fn)
+ {
++ HyphenDict *result;
++ FILE *f;
++ f = fopen (fn, "r");
+ if (f == NULL)
+ return NULL;
-+ f->offset = 0;
-+ f->data = data;
-+ f->size = size;
-+ return f;
-+}
+
-+static void
-+hnj_fclose (hnj_file *f)
-+{
-+ hnj_free (f);
-+}
++ result = hnj_hyphen_load_file(f);
+
-+static char *
-+hnj_fgets (char *s, int size, hnj_file *f)
-+{
-+ int i;
-+
-+ if (f->offset >= f->size)
-+ return NULL;
-+ for (i = 0; i < size - 1; i++) {
-+ char c;
-+
-+ if (f->offset >= f->size)
-+ break;
-+ c = f->data[f->offset++];
-+ if (c == '\r' || c == '\n')
-+ break;
-+ s[i] = c;
-+ }
-+ s[i] = '\0';
-+ return s;
++ fclose(f);
++ return result;
+}
-+#else
-+typedef FILE hnj_file;
-+#define hnj_fopen(fn, mode) fopen((fn), (mode))
-+#define hnj_fclose(f) fclose(f)
-+#define hnj_fgets(s, size, f) fgets((s), (size), (f))
-+#endif
+
-+#ifdef HYPHEN_CHROME_CLIENT
+HyphenDict *
-+hnj_hyphen_load (const unsigned char *data, size_t size)
-+#else
- HyphenDict *
- hnj_hyphen_load (const char *fn)
-+#endif
- {
++hnj_hyphen_load_file (FILE *f)
++{
HyphenDict *dict[2];
HashTab *hashtab;
- FILE *f;
-+ hnj_file *f;
char buf[MAX_CHARS];
- char word[MAX_CHARS];
- char pattern[MAX_CHARS];
-@@ -261,7 +320,11 @@
- HashEntry *e;
int nextlevel = 0;
-
-+#ifdef HYPHEN_CHROME_CLIENT
-+ f = hnj_fopen (data, size);
-+#else
- f = fopen (fn, "r");
-+#endif
- if (f == NULL)
- return NULL;
-
-@@ -291,7 +354,7 @@
- /* read in character set info */
- if (k == 0) {
- for (i=0;i<MAX_NAME;i++) dict[k]->cset[i]= 0;
-- if (fgets(dict[k]->cset, sizeof(dict[k]->cset),f) != NULL) {
-+ if (hnj_fgets(dict[k]->cset, sizeof(dict[k]->cset),f) != NULL) {
- for (i=0;i<MAX_NAME;i++)
- if ((dict[k]->cset[i] == '\r') || (dict[k]->cset[i] == '\n'))
- dict[k]->cset[i] = 0;
-@@ -304,7 +367,7 @@
- dict[k]->utf8 = dict[0]->utf8;
- }
-
-- while (fgets (buf, sizeof(buf), f) != NULL)
-+ while (hnj_fgets (buf, sizeof(buf), f) != NULL)
- {
- if (buf[0] != '%')
- {
-@@ -385,7 +448,7 @@
- if (dict[k]->utf8) {
- int pu = -1; /* unicode character position */
- int ps = -1; /* unicode start position (original replindex) */
-- int pc = (*word == '.') ? 1: 0; /* 8-bit character position */
-+ size_t pc = (*word == '.') ? 1: 0; /* 8-bit character position */
- for (; pc < (strlen(word) + 1); pc++) {
- /* beginning of an UTF-8 character (not '10' start bits) */
- if ((((unsigned char) word[pc]) >> 6) != 2) pu++;
-@@ -478,7 +541,7 @@
+ int i, j, k;
+ HashEntry *e;
+ int state_num = 0;
+-
+- f = fopen (fn, "r");
+- if (f == NULL)
+- return NULL;
+-
+ // loading one or two dictionaries (separated by NEXTLEVEL keyword)
+ for (k = 0; k < 2; k++) {
+ hashtab = hnj_hash_new ();
+@@ -497,7 +506,6 @@
#endif
state_num = 0;
}
- fclose(f);
-+ hnj_fclose(f);
- if (k == 2) dict[0]->nextlevel = dict[1];
- return dict[0];
- }
+ if (nextlevel) dict[0]->nextlevel = dict[1];
+ else {
+ dict[1] -> nextlevel = dict[0];
Index: hyphen.h
===================================================================
RCS file: /cvsroot/hunspell/hyphen/hyphen.h,v
retrieving revision 1.2
diff -u -r1.2 hyphen.h
--- hyphen.h 27 Nov 2010 02:20:33 -0000 1.2
-+++ hyphen.h 1 Mar 2012 05:18:33 -0000
-@@ -93,7 +93,11 @@
++++ hyphen.h 6 Feb 2013 17:31:51 -0000
+@@ -90,7 +90,11 @@
int new_state;
};
-+#ifdef HYPHEN_CHROME_CLIENT
-+HyphenDict *hnj_hyphen_load (const unsigned char *data, size_t size);
-+#else
++#if 0
++/* DO NOT USE, there are known problems with Unicode on Windows. */
HyphenDict *hnj_hyphen_load (const char *fn);
+#endif
++HyphenDict *hnj_hyphen_load_file (FILE *f);
void hnj_hyphen_free (HyphenDict *dict);
/* obsolete, use hnj_hyphen_hyphenate2() or *hyphenate3() functions) */
« no previous file with comments | « third_party/hyphen/README.chromium ('k') | third_party/hyphen/hyphen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698