| 1 | diff -u -r ../hunspell-1.3.3/src/tools/hzip.c ./src/tools/hzip.c |
| 2 | --- ../hunspell-1.3.3/src/tools/hzip.c 2012-06-30 07:18:47.000000000 -0400 |
| 3 | +++ ./src/tools/hzip.c 2016-03-06 02:30:47.121570946 -0500 |
| 4 | @@ -272,7 +272,13 @@ |
| 5 | strcat(out, EXTENSION); |
| 6 | f = fopen(filename, "r"); |
| 7 | if (!f) return fail("hzip: %s: Permission denied\n", filename); |
| 8 | +#ifdef __ANDROID__ |
| 9 | + char tmpfile_template[] = "@TERMUX_PREFIX@/tmp/hunspell.XXXXXX"; |
| 10 | + int tmpfile_fd = mkstemp(tmpfile_template); |
| 11 | + tempfile = fdopen(tmpfile_fd, "w+"); |
| 12 | +#else |
| 13 | tempfile = tmpfile(); |
| 14 | +#endif |
| 15 | if (!tempfile) { |
| 16 | fclose(f); |
| 17 | return fail("hzip: cannot create temporary file\n", NULL); |
| 18 | @@ -280,6 +286,9 @@ |
| 19 | f2 = fopen(out, "wb"); |
| 20 | if (!f2) { |
| 21 | fclose(tempfile); |
| 22 | +#ifdef __ANDROID__ |
| 23 | + unlink(tmpfile_template); |
| 24 | +#endif |
| 25 | fclose(f); |
| 26 | return fail("hzip: %s: Permission denied\n", out); |
| 27 | } |
| 28 | @@ -287,6 +296,9 @@ |
| 29 | if (prefixcompress(f, tempfile) != 0) { |
| 30 | fclose(f2); |
| 31 | fclose(tempfile); |
| 32 | +#ifdef __ANDROID__ |
| 33 | + unlink(tmpfile_template); |
| 34 | +#endif |
| 35 | fclose(f); |
| 36 | return fail("hzip: cannot write file\n", NULL); |
| 37 | } |
| 38 | @@ -297,6 +309,9 @@ |
| 39 | n = encode_file(table, n, tempfile, f2, termword, key); |
| 40 | fclose(f2); |
| 41 | fclose(tempfile); |
| 42 | +#ifdef __ANDROID__ |
| 43 | + unlink(tmpfile_template); |
| 44 | +#endif |
| 45 | fclose(f); |
| 46 | if (n != 0) return fail("hzip: cannot write file\n", NULL); |
| 47 | return n; |