summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2017-02-11 07:54:42 +0000
committerGitHub <noreply@github.com>2017-02-11 07:54:42 +0000
commit297999e05a0fe547651dd8c8c28cff15377ec8dd (patch)
treebfd05d6caaeb3a124947fcee4ce15bf757741ca8
parent4fbead675f057e7cbb006b8d0d29edcc776c8375 (diff)
parent9755eb0c25b7f90c409818c2af4ef806a12cc003 (diff)
downloadenchant-297999e05a0fe547651dd8c8c28cff15377ec8dd.tar.gz
Merge pull request #82 from rrthomas/master
Issue #72: remove Windows registry support
-rw-r--r--.gitignore5
-rw-r--r--bootstrap.conf2
-rw-r--r--configure.ac2
-rw-r--r--m4/.gitignore19
-rw-r--r--m4/ssize_t.m421
-rw-r--r--src/enchant-provider.h3
-rw-r--r--src/enchant.c164
-rw-r--r--src/ispell/ispell_checker.cpp5
-rw-r--r--src/myspell/myspell_checker.cpp55
-rw-r--r--tests/enchant-ispell.c2
-rw-r--r--tests/enchant-lsmod.c2
-rw-r--r--unittests/EnchantBrokerTestFixture.h3
-rw-r--r--unittests/EnchantDictionaryTestFixture.h2
-rw-r--r--unittests/EnchantTestFixture.h211
-rw-r--r--unittests/Makefile.am4
-rw-r--r--unittests/broker/enchant_broker_describe_tests.cpp7
-rw-r--r--unittests/broker/enchant_broker_set_ordering_tests.cpp36
-rw-r--r--unittests/provider/enchant_provider_get_prefix_dir_tests.cpp20
-rw-r--r--unittests/provider/enchant_provider_get_registry_value_tests.cpp180
-rw-r--r--unittests/provider/enchant_provider_get_user_config_dirs_tests.cpp70
-rw-r--r--unittests/provider/enchant_provider_get_user_language_tests.cpp1
21 files changed, 69 insertions, 745 deletions
diff --git a/.gitignore b/.gitignore
index 8b5cc1e..4bcf773 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,8 @@ enchant-*.tar.gz
.libs
.deps
.dirstamp
+Makefile
+Makefile.in
/aclocal.m4
/autom4te.cache
/build-aux
@@ -23,5 +25,4 @@ enchant-*.tar.gz
/missing
/INSTALL
/test-driver
-Makefile
-Makefile.in
+/stamp-h1
diff --git a/bootstrap.conf b/bootstrap.conf
index afbea23..3b9b799 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -1,4 +1,4 @@
-# bootstrap.conf (GNU zile) version 2017-02-03
+# bootstrap.conf (GNU zile) version 2017-02-10
# Written by Gary V. Vaughan, 2010
# Copyright (C) 2010 Free Software Foundation, Inc.
diff --git a/configure.ac b/configure.ac
index 85ffc74..daa51d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,7 +49,6 @@ LT_INIT([win32-dll])
gl_INIT
ENCHANT_LT_OBJDIR=$lt_cv_objdir
AC_SUBST(ENCHANT_LT_OBJDIR)
-gt_TYPE_SSIZE_T
PKG_PROG_PKG_CONFIG
@@ -523,6 +522,7 @@ AM_CONDITIONAL(WITH_APPLESPELL, test "x$build_applespell" = "xyes")
dnl =======================================================================================
+AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
enchant.pc
diff --git a/m4/.gitignore b/m4/.gitignore
index 307e3e0..90a122e 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -16,3 +16,22 @@
/onceonly.m4
/sys_file_h.m4
/warn-on-use.m4
+/alloca.m4
+/eealloc.m4
+/environ.m4
+/extensions.m4
+/extern-inline.m4
+/limits-h.m4
+/longlong.m4
+/malloca.m4
+/multiarch.m4
+/off_t.m4
+/setenv.m4
+/stddef_h.m4
+/stdint.m4
+/stdlib_h.m4
+/sys_types_h.m4
+/unistd_h.m4
+/wchar_t.m4
+/wint_t.m4
+/ssize_t.m4
diff --git a/m4/ssize_t.m4 b/m4/ssize_t.m4
deleted file mode 100644
index 4eaef93..0000000
--- a/m4/ssize_t.m4
+++ /dev/null
@@ -1,21 +0,0 @@
-# ssize_t.m4 serial 4 (gettext-0.15)
-dnl Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-dnl Test whether ssize_t is defined.
-
-AC_DEFUN([gt_TYPE_SSIZE_T],
-[
- AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t],
- [AC_TRY_COMPILE([#include <sys/types.h>],
- [int x = sizeof (ssize_t *) + sizeof (ssize_t);
- return !x;],
- [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])])
- if test $gt_cv_ssize_t = no; then
- AC_DEFINE([ssize_t], [int],
- [Define as a signed type of the same size as size_t.])
- fi
-])
diff --git a/src/enchant-provider.h b/src/enchant-provider.h
index 7dc658f..3673c1e 100644
--- a/src/enchant-provider.h
+++ b/src/enchant-provider.h
@@ -59,9 +59,6 @@ typedef struct str_enchant_provider EnchantProvider;
ENCHANT_MODULE_EXPORT (GSList *)
enchant_get_user_config_dirs (void);
-ENCHANT_MODULE_EXPORT (char *)
- enchant_get_registry_value (const char * const prefix, const char * const key);
-
ENCHANT_MODULE_EXPORT(char *)
enchant_get_prefix_dir(void);
diff --git a/src/enchant.c b/src/enchant.c
index c9ae58c..1d3c622 100644
--- a/src/enchant.c
+++ b/src/enchant.c
@@ -56,9 +56,6 @@
ENCHANT_PLUGIN_DECLARE("Enchant")
-static char *
-enchant_get_registry_value_ex (int current_user, const char * const prefix, const char * const key);
-
/********************************************************************************/
/********************************************************************************/
@@ -102,25 +99,13 @@ typedef void (*EnchantPreConfigureFunc) (EnchantProvider * provider,
/********************************************************************************/
/********************************************************************************/
+/* Compare paths case-insensitively on Windows */
#ifdef _WIN32
#define path_cmp g_utf8_collate
#else
#define path_cmp strcmp
#endif
-static GSList* enchant_slist_prepend_unique_path (GSList *slist, gchar* data)
-{
- if (NULL == g_slist_find_custom (slist, data, (GCompareFunc)path_cmp))
- {
- return g_slist_prepend (slist, data);
- }
- else
- {
- g_free (data);
- return slist;
- }
-}
-
static GSList* enchant_slist_append_unique_path (GSList *slist, gchar* data)
{
if (NULL == g_slist_find_custom (slist, data, (GCompareFunc)path_cmp))
@@ -139,11 +124,6 @@ _enchant_get_user_home_dirs (void)
{
GSList *dirs = NULL;
const char* home_dir;
- char *tmp;
-
- tmp = enchant_get_registry_value_ex (1, "Config", "Home_Dir");
- if (tmp)
- dirs = enchant_slist_append_unique_path (dirs, tmp);
home_dir = g_get_home_dir ();
if (home_dir)
@@ -187,8 +167,8 @@ _enchant_get_dirs_from_string (const char * string)
return dirs;
}
-static GSList *
-enchant_get_user_dirs (void)
+ENCHANT_MODULE_EXPORT (GSList *)
+enchant_get_user_config_dirs (void)
{
GSList *user_dirs = NULL;
@@ -231,14 +211,6 @@ enchant_get_module_dirs (void)
char * module_dir = NULL;
char * prefix = NULL;
- {
- char* user_module_dir;
-
- user_module_dir = enchant_get_registry_value_ex (1, "Config", "Module_Dir");
- if (user_module_dir)
- module_dirs = enchant_slist_append_unique_path (module_dirs, user_module_dir);
- }
-
#ifdef XP_TARGET_COCOA
module_dirs = enchant_slist_append_unique_path (module_dirs, g_strdup ([[EnchantResourceProvider instance] moduleFolder]));
#endif
@@ -246,7 +218,7 @@ enchant_get_module_dirs (void)
{
GSList *user_dirs, *iter;
- user_dirs = enchant_get_user_dirs();
+ user_dirs = enchant_get_user_config_dirs();
for (iter = user_dirs; iter; iter = iter->next)
module_dirs = enchant_slist_append_unique_path (module_dirs, iter->data);
@@ -254,11 +226,6 @@ enchant_get_module_dirs (void)
g_slist_free (user_dirs);
}
- /* Look for explicitly set registry values */
- module_dir = enchant_get_registry_value_ex (0, "Config", "Module_Dir");
- if (module_dir)
- module_dirs = enchant_slist_append_unique_path (module_dirs, module_dir);
-
#if defined(ENCHANT_GLOBAL_MODULE_DIR)
module_dirs = enchant_slist_append_unique_path (module_dirs, g_strdup (ENCHANT_GLOBAL_MODULE_DIR));
#endif
@@ -309,11 +276,6 @@ enchant_get_conf_dirs (void)
conf_dirs = enchant_slist_append_unique_path (conf_dirs, g_strdup ([[EnchantResourceProvider instance] configFolder]));
#endif
- /* Look for explicitly set registry values */
- ordering_dir = enchant_get_registry_value_ex (0, "Config", "Data_Dir");
- if (ordering_dir)
- conf_dirs = enchant_slist_append_unique_path (conf_dirs, ordering_dir);
-
/* Dynamically locate library and search for files relative to it. */
prefix = enchant_get_prefix_dir();
if(prefix)
@@ -330,108 +292,6 @@ enchant_get_conf_dirs (void)
return conf_dirs;
}
-/**
- * enchant_get_user_config_dirs
- *
- * Returns: the user's enchant directory, or %null. Returned value
- * must be free'd.
- *
- * The enchant directory is the place where enchant finds user
- * dictionaries and settings related to enchant
- *
- * This API is private to the providers.
- */
-ENCHANT_MODULE_EXPORT (GSList *)
-enchant_get_user_config_dirs (void)
-{
- GSList *dirs;
- char* user_config;
-
- dirs = enchant_get_user_dirs();
-
- user_config = enchant_get_registry_value_ex (1, "Config", "Data_Dir");
- if (user_config)
- dirs = enchant_slist_prepend_unique_path (dirs, user_config);
-
- return dirs;
-}
-
-/*
- * Returns: the value if it exists and is not an empty string ("") or %null otherwise. Must be free'd.
- */
-static char *
-enchant_get_registry_value_ex (int current_user, const char * const prefix, const char * const key)
-{
-#ifndef _WIN32
- /* TODO: GConf? KConfig? */
- return NULL;
-#else
- HKEY hKey;
- HKEY baseKey;
- unsigned long lType;
- DWORD dwSize;
- char* keyName;
- WCHAR* wszValue = NULL;
- char* szValue = NULL;
- gunichar2 * uKeyName;
- gunichar2 * uKey;
-
- if (current_user)
- baseKey = HKEY_CURRENT_USER;
- else
- baseKey = HKEY_LOCAL_MACHINE;
-
- keyName = g_strdup_printf("Software\\Enchant\\%s", prefix);
- uKeyName = g_utf8_to_utf16 (keyName, -1, NULL, NULL, NULL);
- uKey = g_utf8_to_utf16 (key, -1, NULL, NULL, NULL);
-
- if(RegOpenKeyExW(baseKey, uKeyName, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
- {
- /* Determine size of string */
- if(RegQueryValueExW( hKey, uKey, NULL, &lType, NULL, &dwSize) == ERROR_SUCCESS)
- {
- wszValue = g_new0(WCHAR, dwSize + 1);
- RegQueryValueExW(hKey, uKey, NULL, &lType, (LPBYTE) wszValue, &dwSize);
- }
- RegCloseKey(hKey);
- }
-
- if(wszValue && *wszValue)
- szValue = g_utf16_to_utf8 (wszValue, -1, NULL, NULL, NULL);
-
- g_free(keyName);
- g_free(uKeyName);
- g_free(uKey);
- g_free(wszValue);
-
- return szValue;
-#endif
-}
-
-/**
- * enchant_get_registry_value
- * @prefix: Your category, such as "Ispell" or "Myspell"
- * @key: The tag within your category that you're interested in
- *
- * Returns: the value if it exists and is not an empty string ("") or %null otherwise. Must be free'd.
- *
- * This API is private to the providers.
- */
-ENCHANT_MODULE_EXPORT (char *)
-enchant_get_registry_value (const char * const prefix, const char * const key)
-{
- char *val;
-
- g_return_val_if_fail (prefix, NULL);
- g_return_val_if_fail (key, NULL);
-
- val = enchant_get_registry_value_ex(1, prefix, key);
- if(val == NULL) {
- val = enchant_get_registry_value_ex (0, prefix, key);
- }
- return val;
-}
-
/********************************************************************************/
/********************************************************************************/
@@ -2196,6 +2056,14 @@ enchant_get_prefix_dir(void)
{
char * prefix = NULL;
+ {
+ /* Use ENCHANT_PREFIX_DIR env var */
+ const gchar* env = g_getenv("ENCHANT_PREFIX_DIR");
+ if (env) {
+ prefix = g_filename_to_utf8(env, -1, NULL, NULL, NULL);
+ }
+ }
+
#ifdef _WIN32
if (!prefix) {
/* Dynamically locate library and return containing directory */
@@ -2215,14 +2083,6 @@ enchant_get_prefix_dir(void)
}
#endif
- if (!prefix) {
- /* Use ENCHANT_PREFIX_DIR env var */
- const gchar* env = g_getenv("ENCHANT_PREFIX_DIR");
- if (env) {
- prefix = g_filename_to_utf8(env, -1, NULL, NULL, NULL);
- }
- }
-
#if defined(ENCHANT_PREFIX_DIR)
if (!prefix) {
prefix = g_strdup (ENCHANT_PREFIX_DIR);
diff --git a/src/ispell/ispell_checker.cpp b/src/ispell/ispell_checker.cpp
index 62c967d..6b86537 100644
--- a/src/ispell/ispell_checker.cpp
+++ b/src/ispell/ispell_checker.cpp
@@ -309,11 +309,6 @@ ispell_checker_get_dictionary_dirs (EnchantBroker * broker)
#ifndef XP_TARGET_COCOA
char * ispell_prefix = NULL;
- /* Look for explicitly set registry values */
- ispell_prefix = enchant_get_registry_value ("Ispell", "Data_Dir");
- if (ispell_prefix)
- dirs = g_slist_append (dirs, ispell_prefix);
-
/* Dynamically locate library and search for modules relative to it. */
char * enchant_prefix = enchant_get_prefix_dir();
if(enchant_prefix)
diff --git a/src/myspell/myspell_checker.cpp b/src/myspell/myspell_checker.cpp
index ac1e78d..f105341 100644
--- a/src/myspell/myspell_checker.cpp
+++ b/src/myspell/myspell_checker.cpp
@@ -74,56 +74,6 @@ private:
/***************************************************************************/
-#if defined(_WIN32)
-static WCHAR* GetRegistryValue(HKEY baseKey, const WCHAR * uKeyName, const WCHAR * uKey)
-{
- HKEY hKey;
- unsigned long lType;
- DWORD dwSize;
- WCHAR* wszValue = NULL;
-
- if(RegOpenKeyExW(baseKey, uKeyName, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
- {
- /* Determine size of string */
- if(RegQueryValueExW( hKey, uKey, NULL, &lType, NULL, &dwSize) == ERROR_SUCCESS)
- {
- wszValue = g_new0(WCHAR, dwSize + 1);
- RegQueryValueExW(hKey, uKey, NULL, &lType, (LPBYTE) wszValue, &dwSize);
- }
- }
-
- return wszValue;
-}
-
-static char *
-myspell_checker_get_open_office_dicts_dir(void)
-{
- WCHAR* wszDirectory;
- char* open_office_dir, * open_office_dicts_dir;
-
- /*start by trying current user*/
- wszDirectory = GetRegistryValue (HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\soffice.exe", L"Path");
- if(wszDirectory == NULL)
- {
- /*next try local machine*/
- wszDirectory = GetRegistryValue (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\soffice.exe", L"Path");
- }
-
- if(wszDirectory == NULL)
- {
- return NULL;
- }
-
- else {
- open_office_dir = g_utf16_to_utf8 ((gunichar2*)wszDirectory, -1, NULL, NULL, NULL);
- open_office_dicts_dir = g_build_filename(open_office_dir, "share", "dict", "ooo", NULL);
- g_free(wszDirectory);
- g_free(open_office_dir);
- return open_office_dicts_dir;
- }
-}
-#endif
-
static bool
g_iconv_is_valid(GIConv i)
{
@@ -253,11 +203,6 @@ myspell_checker_get_dictionary_dirs (EnchantBroker * broker)
#ifndef XP_TARGET_COCOA
char * myspell_prefix = NULL;
- /* Look for explicitly set registry values */
- myspell_prefix = enchant_get_registry_value ("Myspell", "Data_Dir");
- if (myspell_prefix)
- dirs = g_slist_append (dirs, myspell_prefix);
-
/* Dynamically locate library and search for modules relative to it. */
char * enchant_prefix = enchant_get_prefix_dir();
if(enchant_prefix)
diff --git a/tests/enchant-ispell.c b/tests/enchant-ispell.c
index 934e253..e3ff922 100644
--- a/tests/enchant-ispell.c
+++ b/tests/enchant-ispell.c
@@ -42,6 +42,8 @@
* Modified in 2016 to implement most ispell prefix commands.
*/
+#include "config.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tests/enchant-lsmod.c b/tests/enchant-lsmod.c
index 7176c50..bca3c41 100644
--- a/tests/enchant-lsmod.c
+++ b/tests/enchant-lsmod.c
@@ -28,6 +28,8 @@
* do so, delete this exception statement from your version.
*/
+#include "config.h"
+
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/unittests/EnchantBrokerTestFixture.h b/unittests/EnchantBrokerTestFixture.h
index 01b176e..015b7f6 100644
--- a/unittests/EnchantBrokerTestFixture.h
+++ b/unittests/EnchantBrokerTestFixture.h
@@ -151,9 +151,6 @@ struct EnchantBrokerTestFixture : EnchantTestFixture
CopyProvider("enchant", "enchant"); //not a provider
}
-#if _WIN32
- SetUserRegistryConfigDir(GetTempUserEnchantDir());
-#endif
InitializeBroker();
}
diff --git a/unittests/EnchantDictionaryTestFixture.h b/unittests/EnchantDictionaryTestFixture.h
index a85355f..ac735b9 100644
--- a/unittests/EnchantDictionaryTestFixture.h
+++ b/unittests/EnchantDictionaryTestFixture.h
@@ -116,7 +116,7 @@ struct EnchantDictionaryTestFixture : EnchantBrokerTestFixture
_pwl = RequestPersonalDictionary();
_pwlFileName = GetLastPersonalDictionaryFileName();
- bool hasLangEnv = (g_getenv("LANG") != NULL);
+ hasLangEnv = (g_getenv("LANG") != NULL);
if(hasLangEnv)
{
origLangEnv = std::string(g_getenv("LANG"));
diff --git a/unittests/EnchantTestFixture.h b/unittests/EnchantTestFixture.h
index be76efa..38e8a13 100644
--- a/unittests/EnchantTestFixture.h
+++ b/unittests/EnchantTestFixture.h
@@ -47,77 +47,15 @@
struct EnchantTestFixture
{
- std::string savedRegistryHomeDir;
- std::string savedUserRegistryModuleDir;
- std::string savedMachineRegistryModuleDir;
- std::string savedUserRegistryConfigDir;
- std::string savedMachineRegistryConfigDir;
-
//Setup
EnchantTestFixture()
{
CleanUpFiles(); //just in case we stopped the process in the middle.
MoveEnchantUserFilesOutOfTheWay();
-
-#ifdef _WIN32
- savedRegistryHomeDir = GetRegistryHomeDir();
- ClearRegistryHomeDir();
-
- savedUserRegistryModuleDir = GetUserRegistryModuleDir();
- ClearUserRegistryModuleDir();
-
- savedMachineRegistryModuleDir = GetMachineRegistryModuleDir();
- ClearMachineRegistryModuleDir();
-
- savedUserRegistryConfigDir = GetUserRegistryConfigDir();
- ClearUserRegistryConfigDir();
-
- savedMachineRegistryConfigDir = GetMachineRegistryConfigDir();
- ClearMachineRegistryConfigDir();
-#endif
}
//Teardown
~EnchantTestFixture(){
-#ifdef _WIN32
- if(savedRegistryHomeDir.empty()) {
- ClearRegistryHomeDir();
- }
- else {
- SetRegistryHomeDir(savedRegistryHomeDir);
- }
-
- if(savedUserRegistryModuleDir.empty()) {
- ClearUserRegistryModuleDir();
- }
- else{
- SetUserRegistryModuleDir(savedUserRegistryModuleDir);
- }
-
- if(savedMachineRegistryModuleDir.empty())
- {
- ClearMachineRegistryModuleDir();
- }
- else{
- SetMachineRegistryModuleDir(savedMachineRegistryModuleDir);
- }
-
- if(savedUserRegistryConfigDir.empty())
- {
- ClearUserRegistryConfigDir();
- }
- else{
- SetUserRegistryConfigDir(savedUserRegistryConfigDir);
- }
-
- if(savedMachineRegistryConfigDir.empty()) {
- ClearMachineRegistryConfigDir();
- }
- else {
- SetMachineRegistryConfigDir(savedMachineRegistryConfigDir);
- }
-
-#endif
RestoreEnchantUserFiles();
CleanUpFiles();
}
@@ -276,155 +214,6 @@ struct EnchantTestFixture
return result;
}
-#if defined(_WIN32)
- std::string GetRegistryHomeDir()
- {
- return Convert(GetRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Config", L"Home_Dir"));
- }
-
- void SetRegistryHomeDir(const std::string & dir)
- {
- SetRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Config", L"Home_Dir", dir);
- }
-
- void ClearRegistryHomeDir()
- {
- ClearRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Config", L"Home_Dir");
- }
-
- std::string GetUserRegistryModuleDir()
- {
- return Convert(GetRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Config", L"Module_Dir"));
-
- }
-
- void SetUserRegistryModuleDir(const std::string & dir)
- {
- SetRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Config", L"Module_Dir", dir);
- }
-
- void ClearUserRegistryModuleDir()
- {
- ClearRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Config", L"Module_Dir");
- }
-
- std::string GetMachineRegistryModuleDir()
- {
- return Convert(GetRegistryValue(HKEY_LOCAL_MACHINE, L"Software\\Enchant\\Config", L"Module_Dir"));
-
- }
-
- void SetMachineRegistryModuleDir(const std::string & dir)
- {
- SetRegistryValue(HKEY_LOCAL_MACHINE, L"Software\\Enchant\\Config", L"Module_Dir", dir);
- }
-
- void ClearMachineRegistryModuleDir()
- {
- ClearRegistryValue(HKEY_LOCAL_MACHINE, L"Software\\Enchant\\Config", L"Module_Dir");
- }
-
- std::string GetUserRegistryConfigDir()
- {
- return Convert(GetRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Config", L"Data_Dir"));
- }
-
- void SetUserRegistryConfigDir(const std::string & dir)
- {
- SetRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Config", L"Data_Dir", dir);
- }
-
- void ClearUserRegistryConfigDir()
- {
- ClearRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Config", L"Data_Dir");
- }
-
- std::string GetMachineRegistryConfigDir()
- {
- return Convert(GetRegistryValue(HKEY_LOCAL_MACHINE, L"Software\\Enchant\\Config", L"Data_Dir"));
- }
-
- void SetMachineRegistryConfigDir(const std::string & dir)
- {
- SetRegistryValue(HKEY_LOCAL_MACHINE, L"Software\\Enchant\\Config", L"Data_Dir", dir);
- }
-
- void ClearMachineRegistryConfigDir()
- {
- ClearRegistryValue(HKEY_LOCAL_MACHINE, L"Software\\Enchant\\Config", L"Data_Dir");
- }
-
- std::wstring GetRegistryValue(HKEY baseKey, const std::wstring& key, const std::wstring& valueName)
- {
- std::wstring result;
-
- WCHAR data[2048];
- DWORD dwSize = sizeof(data) * sizeof(WCHAR);
- HKEY hkey;
-
- if(RegOpenKeyEx(baseKey,
- key.c_str(),
- 0, KEY_WRITE, &hkey) == ERROR_SUCCESS)
- {
- if(RegQueryValueEx(hkey,
- valueName.c_str(),
- 0,
- NULL,
- (LPBYTE)&data, &dwSize)
- == ERROR_SUCCESS){
- result = std::wstring(data,dwSize);
- }
- }
- return result;
- }
-
- void SetRegistryValue(HKEY baseKey,
- const std::wstring& key,
- const std::wstring& valueName,
- const std::string& value)
- {
- SetRegistryValue(baseKey, key, valueName, Convert(value));
- }
- void SetRegistryValue(HKEY baseKey,
- const std::wstring& key,
- const std::wstring& valueName,
- const std::wstring& value)
- {
- HKEY hkey;
- if(RegCreateKeyEx(baseKey,
- key.c_str(),
- 0, NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL, &hkey,
- NULL) == ERROR_SUCCESS)
- {
- RegSetValueEx(hkey,
- valueName.c_str(),
- 0,
- REG_SZ,
- (LPBYTE)value.c_str(),
- (DWORD)((value.length()+1)*sizeof(wchar_t)) );
-
- RegCloseKey(hkey);
- }
- }
-
- void ClearRegistryValue(HKEY baseKey,
- const std::wstring& key,
- const std::wstring& valueName)
- {
- HKEY hkey;
- if(RegOpenKeyEx(baseKey,
- key.c_str(),
- 0, KEY_WRITE, &hkey) == ERROR_SUCCESS)
- {
- RegDeleteValue(hkey, valueName.c_str());
- RegCloseKey(hkey);
- }
- }
-#endif
-
static std::string AddToPath(const std::string & path, const std::string & fileOrDirName)
{
std::string result;
diff --git a/unittests/Makefile.am b/unittests/Makefile.am
index 7948641..9eb660e 100644
--- a/unittests/Makefile.am
+++ b/unittests/Makefile.am
@@ -4,8 +4,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(UNITTESTPP_CFLAGS)
# FIXME: .so extension will not work on Windows
AM_TESTS_ENVIRONMENT = \
- ENCHANT_MODULE_PATH=$(top_builddir)/unittests/lib/enchant; \
- export ENCHANT_MODULE_PATH; \
+ ENCHANT_PREFIX_DIR=""; \
+ export ENCHANT_PREFIX_DIR; \
cp $(builddir)/mock_provider/*.so $(builddir)/mock_provider/.libs/*.so $(builddir)/mock_provider/*.dll $(builddir)/mock_provider/.libs/*.dll . || :;
DEPS = $(top_builddir)/src/libenchant.la
diff --git a/unittests/broker/enchant_broker_describe_tests.cpp b/unittests/broker/enchant_broker_describe_tests.cpp
index 8040f42..d9e95ca 100644
--- a/unittests/broker/enchant_broker_describe_tests.cpp
+++ b/unittests/broker/enchant_broker_describe_tests.cpp
@@ -206,14 +206,7 @@ struct EnchantBrokerDescribe_ProviderHasInvalidUtf8Describe_TestFixture : Enchan
* [on windows in the enchant directory in the user's Application Data
* directory]
*
- * The user's provider directory on windows can be overridden using the registry
- * setting HKEY_CURRENT_USER\Software\Enchant\Config\Data_Dir
- *
* Then from the module directory (that libenchant is in).
- *
- * The module directory can be overridden using the registry setting
- * HKEY_CURRENT_USER\Software\Enchant\Config\Module_Dir
- * or HKEY_LOCAL_MACHINE\Software\Enchant\Config\Module_Dir
*/
/////////////////////////////////////////////////////////////////////////////
diff --git a/unittests/broker/enchant_broker_set_ordering_tests.cpp b/unittests/broker/enchant_broker_set_ordering_tests.cpp
index b8cfeff..6e1d8ea 100644
--- a/unittests/broker/enchant_broker_set_ordering_tests.cpp
+++ b/unittests/broker/enchant_broker_set_ordering_tests.cpp
@@ -339,8 +339,6 @@ TEST_FIXTURE(EnchantBrokerSetOrdering_TestFixture,
}
-// Windows only test.
-#ifdef _WIN32
/*
* Ordering can also be set in enchant.ordering file:
* Language_Tag : Provider1, Provider2, ProviderN
@@ -349,17 +347,7 @@ TEST_FIXTURE(EnchantBrokerSetOrdering_TestFixture,
* config directory, then in the .enchant directory in the user's home directory.
*
* The user's config directory is located at share/enchant
- * in the module directory (that libenchant is in)
- * but it can be overridden using the registry setting
- * HKEY_CURRENT_USER\Software\Enchant\Config\Data_Dir
- * or HKEY_LOCAL_MACHINE\Software\Enchant\Config\Data_Dir
- *
- * The user's home directory on windows can be overridden using the registry
- * setting HKEY_CURRENT_USER\Software\Enchant\Config\Home_Dir
- *
- * The module directory can be overridden using the registry setting
- * HKEY_CURRENT_USER\Software\Enchant\Config\Module_Dir
- * or HKEY_LOCAL_MACHINE\Software\Enchant\Config\Module_Dir
+ * in the module directory (that libenchant is in).
*/
/////////////////////////////////////////////////////////////////////////////
@@ -369,20 +357,22 @@ TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
EnchantBrokerFileOrderingMock1ThenMock2_DefaultConfigDirectory)
{
WriteStringToOrderingFile(GetEnchantConfigDir(),"en_GB:mock1,mock2");
- InitializeBroker();
+ InitializeBroker();
- CHECK_EQUAL(Mock1ThenMock2, GetProviderOrder("en_GB"));
+ CHECK_EQUAL(Mock1ThenMock2, GetProviderOrder("en_GB"));
}
TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
EnchantBrokerFileOrderingMock2ThenMock1_DefaultConfigDirectory)
{
WriteStringToOrderingFile(GetEnchantConfigDir(),"en_GB:mock2,mock1");
- InitializeBroker();
+ InitializeBroker();
- CHECK_EQUAL(Mock2ThenMock1, GetProviderOrder("en_GB"));
+ CHECK_EQUAL(Mock2ThenMock1, GetProviderOrder("en_GB"));
}
+// FIXME: Resurrect these once we have a way to reconfigure user config directory
+#if 0
TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
EnchantBrokerFileOrderingMock1ThenMock2_UserOverriddenConfigDirectory)
{
@@ -443,6 +433,7 @@ TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
CHECK_EQUAL(Mock2ThenMock1, GetProviderOrder("en_GB"));
}
+#endif
TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
EnchantBrokerFileOrdering_ExtraSpacesAndTabs_Mock1Then2)
@@ -481,6 +472,8 @@ TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
}
+// FIXME: Resurrect these once we have a way to reconfigure user config directory
+#if 0
TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
EnchantBrokerFileOrdering_HomeAndGlobal_HomeMergedWithGlobal_HomeTakesPrecedence_Mock1Then2)
{
@@ -506,6 +499,7 @@ TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
CHECK_EQUAL(Mock2ThenMock1, GetProviderOrder("en_GB"));
CHECK_EQUAL(Mock2ThenMock1, GetProviderOrder("qaa"));
}
+#endif
/////////////////////////////////////////////////////////////////////////////
// Test Error Conditions
@@ -533,6 +527,8 @@ TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
InitializeBroker();
}
+// FIXME: Resurrect these once we have a way to reconfigure user config directory
+#if 0
TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
EnchantBrokerFileOrdering_NoProviders_DoesNotOverridePreviousOrdering_Mock1Then2)
{
@@ -555,14 +551,15 @@ TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
InitializeBroker();
CHECK_EQUAL(Mock2ThenMock1, GetProviderOrder("en_GB"));
}
+#endif
TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
EnchantBrokerFileOrdering_ListedTwice_LastTakesPrecedence_Mock1ThenMock2)
{
WriteStringToOrderingFile(GetEnchantConfigDir(),"en_GB:mock2,mock1\nen_GB:mock1,mock2");
- InitializeBroker();
+ InitializeBroker();
- CHECK_EQUAL(Mock1ThenMock2, GetProviderOrder("en_GB"));
+ CHECK_EQUAL(Mock1ThenMock2, GetProviderOrder("en_GB"));
}
TEST_FIXTURE(EnchantBrokerFileSetOrdering_TestFixture,
@@ -573,4 +570,3 @@ EnchantBrokerFileOrdering_ListedTwice_LastTakesPrecedence_Mock2ThenMock1)
CHECK_EQUAL(Mock2ThenMock1, GetProviderOrder("en_GB"));
}
-#endif
diff --git a/unittests/provider/enchant_provider_get_prefix_dir_tests.cpp b/unittests/provider/enchant_provider_get_prefix_dir_tests.cpp
index d7b2bfa..7dd67c1 100644
--- a/unittests/provider/enchant_provider_get_prefix_dir_tests.cpp
+++ b/unittests/provider/enchant_provider_get_prefix_dir_tests.cpp
@@ -28,20 +28,23 @@ struct EnchantGetPrefixDirTestFixture : EnchantTestFixture{
//Setup
EnchantGetPrefixDirTestFixture()
{
+ /* Use ENCHANT_PREFIX_DIR env var */
+ const gchar* env = g_getenv("ENCHANT_PREFIX_DIR");
+ if (env) {
+ expectedPrefixDir = std::string(g_filename_to_utf8(env, -1, NULL, NULL, NULL));
+ } else {
expectedPrefixDir = GetDirectoryOfThisModule();
+
#if defined(ENCHANT_PREFIX_DIR)
if (expectedPrefixDir.empty()) {
expectedPrefixDir = std::string(ENCHANT_PREFIX_DIR);
}
#endif
+ }
}
const char* ExpectedPrefixDir()
{
- if(expectedPrefixDir.empty()){
- return NULL;
- }
-
return expectedPrefixDir.c_str();
}
@@ -53,15 +56,9 @@ struct EnchantGetPrefixDirTestFixture : EnchantTestFixture{
* enchant_get_prefix_dir
*
* Returns a string giving the location of the base directory
- * of the enchant installation. This corresponds roughly to
- * the --prefix option given to ./configure when enchant is
- * compiled, except it is determined at runtime based on the location
- * of the enchant library.
+ * of the enchant installation.
*
* This API is private to the providers.
- *
- * returns NULL if it cannot dynamically determine the location of
- * the enchant library
*/
TEST_FIXTURE(EnchantGetPrefixDirTestFixture,
@@ -69,6 +66,7 @@ TEST_FIXTURE(EnchantGetPrefixDirTestFixture,
{
char* prefixDir = enchant_get_prefix_dir();
const char* expectedPrefixDir = ExpectedPrefixDir();
+ fprintf(stderr, "prefixDir: %s, expectedPrefixDir: %s\n", prefixDir, expectedPrefixDir);
CHECK((expectedPrefixDir == NULL && prefixDir == NULL) ||
strcmp(expectedPrefixDir, prefixDir) == 0);
g_free(prefixDir);
diff --git a/unittests/provider/enchant_provider_get_registry_value_tests.cpp b/unittests/provider/enchant_provider_get_registry_value_tests.cpp
deleted file mode 100644
index e978c42..0000000
--- a/unittests/provider/enchant_provider_get_registry_value_tests.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/* Copyright (c) 2007 Eric Scott Albright
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include <UnitTest++.h>
-#include <enchant-provider.h>
-#include "../EnchantTestFixture.h"
-
-struct EnchantGetRegistryValue_TestFixture : EnchantTestFixture{
- //Teardown
- ~EnchantGetRegistryValue_TestFixture(){
- ClearRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Test", L"Value");
- ClearRegistryValue(HKEY_LOCAL_MACHINE, L"Software\\Enchant\\Test", L"Value");
- }
-
- void SetUserRegistryValue(const std::string& value)
- {
- SetRegistryValue(HKEY_CURRENT_USER, L"Software\\Enchant\\Test", L"Value", value);
- }
-
- void SetMachineRegistryValue(const std::string& value)
- {
- SetRegistryValue(HKEY_LOCAL_MACHINE, L"Software\\Enchant\\Test", L"Value", value);
- }
-};
-
-
-/**
- * enchant_get_registry_value
- * @prefix: Your category, such as "Ispell" or "Myspell"
- * @key: The tag within your category that you're interested in
- *
- * Returns: the value if it exists and is not an empty string ("") or %null otherwise. Must be free'd.
- *
- * Choices: User Machine Result
- * "hello" "world" "hello"
- * "hello" NULL "hello"
- * "hello" "" "hello"
- * "" "world" "world"
- * "" NULL ""
- * "" "" ""
- * NULL "world" "world"
- * NULL NULL NULL
- * NULL "" ""
- *
- * This API is private to the providers.
- */
-
-/////////////////////////////////////////////////////////////////////////////
-// Test Normal Operation
-#ifdef _WIN32
-TEST_FIXTURE(EnchantGetRegistryValue_TestFixture,
- GetRegistryValue_UserAndMachine_ValueFromUser)
-{
- SetUserRegistryValue("hello");
- SetMachineRegistryValue("world");
-
- char * value = enchant_get_registry_value("Test", "Value");
-
- CHECK(value);
- CHECK_EQUAL("hello", value);
-
- g_free(value);
-}
-
-TEST_FIXTURE(EnchantGetRegistryValue_TestFixture,
- GetRegistryValue_UserOnly_ValueFromUser)
-{
- SetUserRegistryValue("hello");
- char * value = enchant_get_registry_value("Test", "Value");
-
- CHECK(value);
- CHECK_EQUAL("hello", value);
-
- g_free(value);
-}
-
-TEST_FIXTURE(EnchantGetRegistryValue_TestFixture,
- GetRegistryValue_MachineOnly_ValueFromMachine)
-{
- SetMachineRegistryValue("world");
- char * value = enchant_get_registry_value("Test", "Value");
-
- CHECK(value);
- CHECK_EQUAL("world", value);
-
- g_free(value);
-}
-
-TEST_FIXTURE(EnchantGetRegistryValue_TestFixture,
- GetRegistryValue_UserEmptyAndMachineSet_ValueFromMachine)
-{
- SetUserRegistryValue("");
- SetMachineRegistryValue("world");
-
- char * value = enchant_get_registry_value("Test", "Value");
-
- CHECK(value);
- CHECK_EQUAL("world", value);
-
- g_free(value);
-}
-
-TEST_FIXTURE(EnchantGetRegistryValue_TestFixture,
- GetRegistryValue_UserEmptyAndMachineNotSet_Null)
-{
- SetUserRegistryValue("");
-
- char * value = enchant_get_registry_value("Test", "Value");
-
- CHECK(!value);
-
- g_free(value);
-}
-#endif
-
-
-TEST(GetRegistryValue_None_NULL)
-{
- char * value = enchant_get_registry_value("Test", "Value");
-
- CHECK(value == NULL);
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-// Test Error Conditions
-TEST(GetRegistryValue_NullPrefix_NULL)
-{
- char * value = enchant_get_registry_value(NULL, "Value");
-
- CHECK(value == NULL);
-}
-
-TEST(GetRegistryValue_NullKey_NULL)
-{
- char * value = enchant_get_registry_value("Test", NULL);
-
- CHECK(value == NULL);
-}
-
-#ifdef _WIN32
-TEST_FIXTURE(EnchantGetRegistryValue_TestFixture,
- GetRegistryValue_NullPrefix_Null)
-{
- SetUserRegistryValue("hello");
-
- char * value = enchant_get_registry_value(NULL, "Value");
-
- CHECK(value == NULL);
-}
-
-TEST_FIXTURE(EnchantGetRegistryValue_TestFixture,
- GetRegistryValue_NullKey_Null)
-{
- SetUserRegistryValue("hello");
-
- char * value = enchant_get_registry_value("Test", NULL);
-
- CHECK(value == NULL);
-}
-
-#endif \ No newline at end of file
diff --git a/unittests/provider/enchant_provider_get_user_config_dirs_tests.cpp b/unittests/provider/enchant_provider_get_user_config_dirs_tests.cpp
index f638579..7b4e314 100644
--- a/unittests/provider/enchant_provider_get_user_config_dirs_tests.cpp
+++ b/unittests/provider/enchant_provider_get_user_config_dirs_tests.cpp
@@ -35,76 +35,6 @@
* This API is private to the providers.
*/
-/*
- * The user's config directory on windows can be overridden using the registry
- * setting HKEY_CURRENT_USER\Software\Enchant\Config\Data_Dir
- */
-#ifdef _WIN32
-TEST_FIXTURE(EnchantTestFixture,
- GetUserConfigDir_FromRegistryConfigDataDir)
-{
- std::string configDir("here I am");
- SetUserRegistryConfigDir(configDir);
-
- GSList * enchantUserConfigDirs = enchant_get_user_config_dirs();
-
- CHECK(enchantUserConfigDirs);
- CHECK_EQUAL(configDir, (gchar*) enchantUserConfigDirs->data);
-
- g_slist_free(enchantUserConfigDirs);
-}
-
-TEST_FIXTURE(EnchantTestFixture,
- GetUserConfigDir_BlankFromRegistryConfigDataDir_RegistryEntryIgnored)
-{
- std::string configDir("");
- SetUserRegistryConfigDir(configDir);
-
- GSList * enchantUserConfigDirs = enchant_get_user_config_dirs();
-
- CHECK(enchantUserConfigDirs);
-
- CHECK_EQUAL(GetEnchantHomeDirFromBase(g_get_user_config_dir()), (gchar*) enchantUserConfigDirs->data);
-
- g_slist_free(enchantUserConfigDirs);
-}
-
-TEST_FIXTURE(EnchantTestFixture,
- GetUserConfigDir_FromRegistryConfigHomeDir)
-{
- std::string homeDir("here I am");
- SetRegistryHomeDir(homeDir);
-
- GSList * enchantUserConfigDirs = enchant_get_user_config_dirs();
-
- CHECK(enchantUserConfigDirs);
- GSList* iter = enchantUserConfigDirs->next;
- CHECK(iter);
-
- CHECK_EQUAL(GetEnchantHomeDirFromBase(homeDir), (gchar*) iter->data);
-
- g_slist_free(enchantUserConfigDirs);
-}
-
-TEST_FIXTURE(EnchantTestFixture,
- GetUserConfigDir_BlankFromRegistryConfigHomeDir_RegistryEntryIgnored)
-{
- std::string homeDir("");
- SetRegistryHomeDir(homeDir);
-
- GSList * enchantUserConfigDirs = enchant_get_user_config_dirs();
-
- CHECK(enchantUserConfigDirs);
- GSList* iter = enchantUserConfigDirs->next;
- CHECK(iter);
-
- CHECK_EQUAL(GetEnchantHomeDirFromBase(g_get_home_dir()), (gchar*) iter->data);
-
- g_slist_free(enchantUserConfigDirs);
-}
-
-#endif
-
TEST_FIXTURE(EnchantTestFixture,
GetUserConfigDir)
{
diff --git a/unittests/provider/enchant_provider_get_user_language_tests.cpp b/unittests/provider/enchant_provider_get_user_language_tests.cpp
index b98f046..aba1433 100644
--- a/unittests/provider/enchant_provider_get_user_language_tests.cpp
+++ b/unittests/provider/enchant_provider_get_user_language_tests.cpp
@@ -66,6 +66,7 @@ static void SetLocaleAndCheckLanguage(const char *locale, const char *language)
char* userLanguage = enchant_get_user_language();
CHECK(userLanguage);
// Language may be followed by country code and encoding
+ fprintf(stderr, "language %s, userLanguage %s\n", language, userLanguage);
CHECK(strncmp(language, userLanguage, strlen(language)) == 0);
if (strlen(userLanguage) > 2)
{