48 lines
1.4 KiB
Diff
48 lines
1.4 KiB
Diff
|
diff -u -r ../hunspell-1.3.3/src/tools/hzip.c ./src/tools/hzip.c
|
||
|
--- ../hunspell-1.3.3/src/tools/hzip.c 2012-06-30 07:18:47.000000000 -0400
|
||
|
+++ ./src/tools/hzip.c 2016-03-06 02:30:47.121570946 -0500
|
||
|
@@ -272,7 +272,13 @@
|
||
|
strcat(out, EXTENSION);
|
||
|
f = fopen(filename, "r");
|
||
|
if (!f) return fail("hzip: %s: Permission denied\n", filename);
|
||
|
+#ifdef __ANDROID__
|
||
|
+ char tmpfile_template[] = "@TERMUX_PREFIX@/tmp/hunspell.XXXXXX";
|
||
|
+ int tmpfile_fd = mkstemp(tmpfile_template);
|
||
|
+ tempfile = fdopen(tmpfile_fd, "w+");
|
||
|
+#else
|
||
|
tempfile = tmpfile();
|
||
|
+#endif
|
||
|
if (!tempfile) {
|
||
|
fclose(f);
|
||
|
return fail("hzip: cannot create temporary file\n", NULL);
|
||
|
@@ -280,6 +286,9 @@
|
||
|
f2 = fopen(out, "wb");
|
||
|
if (!f2) {
|
||
|
fclose(tempfile);
|
||
|
+#ifdef __ANDROID__
|
||
|
+ unlink(tmpfile_template);
|
||
|
+#endif
|
||
|
fclose(f);
|
||
|
return fail("hzip: %s: Permission denied\n", out);
|
||
|
}
|
||
|
@@ -287,6 +296,9 @@
|
||
|
if (prefixcompress(f, tempfile) != 0) {
|
||
|
fclose(f2);
|
||
|
fclose(tempfile);
|
||
|
+#ifdef __ANDROID__
|
||
|
+ unlink(tmpfile_template);
|
||
|
+#endif
|
||
|
fclose(f);
|
||
|
return fail("hzip: cannot write file\n", NULL);
|
||
|
}
|
||
|
@@ -297,6 +309,9 @@
|
||
|
n = encode_file(table, n, tempfile, f2, termword, key);
|
||
|
fclose(f2);
|
||
|
fclose(tempfile);
|
||
|
+#ifdef __ANDROID__
|
||
|
+ unlink(tmpfile_template);
|
||
|
+#endif
|
||
|
fclose(f);
|
||
|
if (n != 0) return fail("hzip: cannot write file\n", NULL);
|
||
|
return n;
|