diff options
author | Reuben Thomas <rrt@sc3d.org> | 2017-01-15 23:16:50 +0000 |
---|---|---|
committer | Reuben Thomas <rrt@sc3d.org> | 2017-02-09 00:28:24 +0000 |
commit | 1c8134830c778695b19ade48d7b871938fe464ad (patch) | |
tree | f7c4848fde15a8e6bb504a03336201959c1d6bcf | |
parent | 3f9a4142604bb5bceca0b3b361ef0c688afd5258 (diff) | |
download | enchant-1c8134830c778695b19ade48d7b871938fe464ad.tar.gz |
Fix issue #42: remove enchant_fopen; use g_fopen
-rw-r--r-- | src/enchant-provider.h | 3 | ||||
-rw-r--r-- | src/enchant.c | 39 | ||||
-rw-r--r-- | src/ispell/lookup.cpp | 3 | ||||
-rw-r--r-- | src/pwl.c | 8 | ||||
-rw-r--r-- | tests/enchant-ispell.c | 3 |
5 files changed, 9 insertions, 47 deletions
diff --git a/src/enchant-provider.h b/src/enchant-provider.h index 64eb814..7dc658f 100644 --- a/src/enchant-provider.h +++ b/src/enchant-provider.h @@ -71,9 +71,6 @@ ENCHANT_MODULE_EXPORT(void) ENCHANT_MODULE_EXPORT(void) enchant_provider_set_error (EnchantProvider * provider, const char * const err); -ENCHANT_MODULE_EXPORT(FILE *) - enchant_fopen (const gchar *filename, const gchar *mode); - ENCHANT_MODULE_EXPORT (GSList *) enchant_get_dirs_from_param (EnchantBroker * broker, const char * const param_name); diff --git a/src/enchant.c b/src/enchant.c index 32306b7..c9ae58c 100644 --- a/src/enchant.c +++ b/src/enchant.c @@ -330,43 +330,6 @@ enchant_get_conf_dirs (void) return conf_dirs; } -ENCHANT_MODULE_EXPORT(FILE *) -enchant_fopen (const gchar *filename, const gchar *mode) -{ -#ifdef G_OS_WIN32 - wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL); - wchar_t *wmode; - FILE *retval; - int save_errno; - - if (wfilename == NULL) - { - errno = EINVAL; - return NULL; - } - - wmode = g_utf8_to_utf16 (mode, -1, NULL, NULL, NULL); - - if (wmode == NULL) - { - g_free (wfilename); - errno = EINVAL; - return NULL; - } - - retval = _wfopen (wfilename, wmode); - save_errno = errno; - - g_free (wfilename); - g_free (wmode); - - errno = save_errno; - return retval; -#else - return fopen (filename, mode); -#endif -} - /** * enchant_get_user_config_dirs * @@ -1497,7 +1460,7 @@ enchant_load_ordering_from_file (EnchantBroker * broker, const char * file) FILE * f; - f = enchant_fopen (file, "r"); + f = g_fopen (file, "r"); if (!f) return; diff --git a/src/ispell/lookup.cpp b/src/ispell/lookup.cpp index 5d63852..cd32721 100644 --- a/src/ispell/lookup.cpp +++ b/src/ispell/lookup.cpp @@ -214,6 +214,7 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> +#include <glib/gstdio.h> #include "enchant-provider.h" #include "ispell_checker.h" @@ -249,7 +250,7 @@ int ISpellChecker::linit (char *hashname) int viazero; ichar_t * cp; - if ((fpHash = enchant_fopen (hashname, "rb")) == NULL) + if ((fpHash = g_fopen (hashname, "rb")) == NULL) { return (-1); } @@ -260,7 +260,7 @@ EnchantPWL* enchant_pwl_init_with_file(const char * file) g_return_val_if_fail (file != NULL, NULL); - fd = enchant_fopen(file, "ab+"); + fd = g_fopen(file, "ab+"); if(fd == NULL) { return NULL; @@ -296,7 +296,7 @@ static void enchant_pwl_refresh_from_file(EnchantPWL* pwl) g_hash_table_destroy (pwl->words_in_trie); pwl->words_in_trie = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - f = enchant_fopen(pwl->filename, "r"); + f = g_fopen(pwl->filename, "r"); if (!f) return; @@ -390,7 +390,7 @@ void enchant_pwl_add(EnchantPWL *pwl, { FILE *f; - f = enchant_fopen(pwl->filename, "a+"); + f = g_fopen(pwl->filename, "a+"); if (f) { struct stat stats; @@ -440,7 +440,7 @@ void enchant_pwl_remove(EnchantPWL *pwl, if(!g_file_get_contents(pwl->filename, &contents, &length, NULL)) return; - f = enchant_fopen(pwl->filename, "wb"); /*binary because g_file_get_contents reads binary*/ + f = g_fopen(pwl->filename, "wb"); /*binary because g_file_get_contents reads binary*/ if (f) { const gunichar BOM = 0xfeff; diff --git a/tests/enchant-ispell.c b/tests/enchant-ispell.c index 8a29b8c..0ccedb9 100644 --- a/tests/enchant-ispell.c +++ b/tests/enchant-ispell.c @@ -47,6 +47,7 @@ #include <string.h> #include <locale.h> #include <glib.h> +#include <glib/gstdio.h> #include "enchant.h" #include "enchant-provider.h" @@ -611,7 +612,7 @@ int main (int argc, char ** argv) } else { if (file) { - fp = enchant_fopen (file, "rb"); + fp = g_fopen (file, "rb"); if (!fp) { fprintf (stderr, "Error: Could not open the file \"%s\" for reading.\n", file); exit (1); |