Abdelrazak Younes wrote:
>
setterg@... wrote:
>>
>> -------------- Original message ---------------------- <snip>
>> > the LyX project has long solved the Windows packaging problem by
>> > forking Aspell.
>> <snip>
>>
>> -------------- Reply ---------------------------------- It may not be
>> my place to ask, but why didn't the LyX people submit patches so that
>> we could have one aspell that works for Unix and Windows? Gary Setter
>
> We of course did that (More exactly Peter Kuemmel did), a long time ago:
>
>
http://sourceforge.net/tracker/index.php?func=detail&aid=1507425&group_id=245&atid=300245
You can by the way find the patches for MSVC and Mingw in our svn repo:
svn://svn.lyx.org/lyx/lyx-devel/trunk/development/Win32/patches/mingw/aspell-0.60.4.patch
svn://svn.lyx.org/lyx/lyx-devel/trunk/development/Win32/patches/msvc/aspell-setter-sep06.patch
Joost, are they the latest ones? And by the way, do you still use the
original CMake files by Peter? Or something else?
I attach these two patches as they are not too big.
OK, I tried to trigger (again) a discussion about this issue in the hope
that the Aspell project would integrate our modification.
Abdel.
diff -riwbBuN -Xex aspell-0.60.4/Makefile.am aspell-0.60.4-modified/Makefile.am
--- aspell-0.60.4/Makefile.am Wed Oct 19 11:12:02 2005
+++ aspell-0.60.4-modified/Makefile.am Thu Jun 15 14:45:47 2006
@@ -32,6 +32,7 @@
endif
libaspell_la_SOURCES =\
+ common/aspell_win.cpp\
common/cache.cpp\
common/string.cpp\
common/getdata.cpp\
diff -riwbBuN -Xex aspell-0.60.4/common/aspell_win.cpp aspell-0.60.4-modified/common/aspell_win.cpp
--- aspell-0.60.4/common/aspell_win.cpp Thu Jan 1 01:00:00 1970
+++ aspell-0.60.4-modified/common/aspell_win.cpp Fri Jun 16 01:19:04 2006
@@ -0,0 +1,54 @@
+#ifdef _WIN32
+
+#include <windows.h>
+#include "string.hpp"
+
+namespace acommon {
+
+ String ReadRegString(HKEY hive, String key, String name)
+ {
+
+ // Reads a string from the Windows registry (used to get paths)
+
+ HKEY hKey;
+ unsigned long lType;
+ DWORD dwSize;
+ unsigned char* szValue = NULL;
+
+ if (::RegOpenKeyEx(hive, key.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+ {
+ if(::RegQueryValueEx(hKey, name.c_str(), NULL, &lType, NULL, &dwSize) == ERROR_SUCCESS)
+ {
+ szValue = new unsigned char[dwSize + 1];
+ ::RegQueryValueEx(hKey, name.c_str(), NULL, &lType, szValue, &dwSize);
+ String RegistryReturn((char*)szValue);
+ delete[] szValue;
+ return RegistryReturn;
+ } else {
+ return "";
+ }
+ } else {
+ return "";
+ }
+
+ }
+
+ HKEY GetRegHive()
+ {
+
+ // Check whether Aspell is installed for the current user or for all users
+
+ String value;
+
+ if (ReadRegString(HKEY_LOCAL_MACHINE, "Software\\Aspell", "Dictionary Path") == "")
+ {
+ return HKEY_CURRENT_USER;
+ } else {
+ return HKEY_LOCAL_MACHINE;
+ }
+
+ }
+
+}
+
+#endif
diff -riwbBuN -Xex aspell-0.60.4/common/aspell_win.hpp aspell-0.60.4-modified/common/aspell_win.hpp
--- aspell-0.60.4/common/aspell_win.hpp Thu Jan 1 01:00:00 1970
+++ aspell-0.60.4-modified/common/aspell_win.hpp Thu Jun 15 15:33:58 2006
@@ -0,0 +1,18 @@
+#ifdef _WIN32
+
+#ifndef ASPELL_WIN__HPP
+#define ASPELL_WIN__HPP
+
+#include "string.hpp"
+#include <windows.h>
+
+namespace acommon {
+
+ extern HKEY GetRegHive();
+ extern String ReadRegString(HKEY type, String key, String name);
+
+}
+
+#endif
+
+#endif
diff -riwbBuN -Xex aspell-0.60.4/common/config.cpp aspell-0.60.4-modified/common/config.cpp
--- aspell-0.60.4/common/config.cpp Wed Jun 22 07:32:30 2005
+++ aspell-0.60.4-modified/common/config.cpp Wed Jun 14 20:44:29 2006
@@ -39,6 +39,7 @@
#include "string_list.hpp"
#include "gettext.h"
+#undef printf
#include "iostream.hpp"
diff -riwbBuN -Xex aspell-0.60.4/common/convert.cpp aspell-0.60.4-modified/common/convert.cpp
--- aspell-0.60.4/common/convert.cpp Thu Sep 29 05:20:04 2005
+++ aspell-0.60.4-modified/common/convert.cpp Sat May 27 12:08:02 2006
@@ -23,6 +23,7 @@
#include "iostream.hpp"
#include "gettext.h"
+#undef printf
namespace acommon {
diff -riwbBuN -Xex aspell-0.60.4/common/file_util.cpp aspell-0.60.4-modified/common/file_util.cpp
--- aspell-0.60.4/common/file_util.cpp Mon Nov 15 13:29:54 2004
+++ aspell-0.60.4-modified/common/file_util.cpp Sat May 27 12:08:02 2006
@@ -26,6 +26,7 @@
#ifdef WIN32
+# include "asc_ctype.hpp"
# include <io.h>
# define ACCESS _access
# include <windows.h>
diff -riwbBuN -Xex aspell-0.60.4/common/gettext_init.cpp aspell-0.60.4-modified/common/gettext_init.cpp
--- aspell-0.60.4/common/gettext_init.cpp Tue Nov 9 09:20:24 2004
+++ aspell-0.60.4-modified/common/gettext_init.cpp Thu Jun 15 15:31:02 2006
@@ -1,5 +1,13 @@
+#include "settings.h"
+#include "string.hpp"
+
+#ifdef _WIN32
+ #include <windows.h>
+ #include "aspell_win.hpp"
+#endif
#include "gettext.h"
+#undef printf
#if ENABLE_NLS
@@ -11,12 +19,24 @@
extern "C" void aspell_gettext_init()
{
- {
acommon::Lock l(&lock);
if (did_init) return;
did_init = true;
- }
+
+#ifdef _WIN32
+ // Registry key for Locale Path
+
+ acommon::String value;
+ HKEY hive;
+
+ hive = acommon::GetRegHive();
+ value = acommon::ReadRegString(hive, "Software\\Aspell", "Locale Path");
+ if (value == "") value = LOCALEDIR;
+
+ bindtextdomain("aspell", value.c_str());
+#else
bindtextdomain("aspell", LOCALEDIR);
+#endif
}
#else
diff -riwbBuN -Xex aspell-0.60.4/common/info.cpp aspell-0.60.4-modified/common/info.cpp
--- aspell-0.60.4/common/info.cpp Wed Nov 10 07:18:46 2004
+++ aspell-0.60.4-modified/common/info.cpp Fri Jun 16 01:20:52 2006
@@ -15,9 +15,11 @@
/* BSDi defines u_intXX_t types in machine/types.h */
#include <machine/types.h>
#endif
+
#ifdef WIN32
# include <windows.h>
# include <winbase.h>
+#include "aspell_win.hpp"
#endif
#include "iostream.hpp"
@@ -38,6 +40,7 @@
#include "string_map.hpp"
#include "gettext.h"
+#undef printf
namespace acommon {
@@ -492,8 +495,22 @@
void get_data_dirs (Config * config,
StringList & lst)
{
+ String dictpath;
+ HKEY hive;
+
lst.clear();
- lst.add(config->retrieve("data-dir"));
+
+ hive = GetRegHive();
+
+#ifdef _WIN32
+ // Registry key for dictionary path
+ dictpath = ReadRegString(hive, "Software\\Aspell", "Dictionary Path");;
+ if (dictpath == "") dictpath = config->retrieve("data-dir");
+#else
+ dictpath = config->retrieve("data-dir");
+#endif
+
+ lst.add(dictpath);
lst.add(config->retrieve("dict-dir"));
}
diff -riwbBuN -Xex aspell-0.60.4/common/posib_err.cpp aspell-0.60.4-modified/common/posib_err.cpp
--- aspell-0.60.4/common/posib_err.cpp Sun Nov 21 03:52:22 2004
+++ aspell-0.60.4-modified/common/posib_err.cpp Sat May 27 12:08:02 2006
@@ -13,6 +13,7 @@
#include "posib_err.hpp"
#include "gettext.h"
+#undef printf
namespace acommon {
diff -riwbBuN -Xex aspell-0.60.4/modules/speller/default/language.cpp aspell-0.60.4-modified/modules/speller/default/language.cpp
--- aspell-0.60.4/modules/speller/default/language.cpp Sun Feb 20 22:47:08 2005
+++ aspell-0.60.4-modified/modules/speller/default/language.cpp Wed Jun 14 19:55:47 2006
@@ -21,10 +21,11 @@
#include "file_util.hpp"
#ifdef ENABLE_NLS
-# include <langinfo.h>
+//#include <langinfo.h>
#endif
#include "gettext.h"
+#undef printf
namespace aspeller {
diff -riwbBuN -Xex aspell-0.60.4/prog/aspell.cpp aspell-0.60.4-modified/prog/aspell.cpp
--- aspell-0.60.4/prog/aspell.cpp Sun Jun 19 14:00:46 2005
+++ aspell-0.60.4-modified/prog/aspell.cpp Wed Jun 14 20:46:09 2006
@@ -60,6 +60,7 @@
#include "hash_fun.hpp"
#include "gettext.h"
+#undef printf
using namespace acommon;
diff -riwBu -Xex aspell-setter-sep06/common/config.cpp aspell-setter-sep06-modified/common/config.cpp
--- aspell-setter-sep06/common/config.cpp 2005-12-12 17:41:06.000000000 +0100
+++ aspell-setter-sep06-modified/common/config.cpp 2007-02-16 22:40:26.947401600 +0100
@@ -78,6 +78,10 @@
namespace aspell {
+#ifdef WIN32PORT
+ String GetWindowsDir(String registry_name, String default_directory);
+#endif
+
const char * const keyinfo_type_name[4] = {
N_("string"), N_("integer"), N_("boolean"), N_("list")
};
@@ -642,20 +646,19 @@
} else if (strcmp(i, "home-dir") == 0) {
- //get the personal folder (e.g. "c:\My Documents")
- char * dir = new char[MAX_PATH];
- LPITEMIDLIST items = 0;
- HRESULT hand = SHGetSpecialFolderLocation(0, CSIDL_PERSONAL, &items);
- if ((NOERROR == hand) && items) {
- if (SHGetPathFromIDList(items, dir)) {
- for (char *ptr = dir; *ptr; ++ptr)
- if ('\\' == *ptr)
- *ptr = '/';
- final_str = dir;
- }
- CoTaskMemFree(items);
- }
- delete [] dir;
+ final_str = GetWindowsDir("Base Path", "");
+
+ } else if (strcmp(i, "dict-dir") == 0) {
+
+ final_str = GetWindowsDir("Dictionary Path", "Dictionaries");
+
+ } else if (strcmp(i, "data-dir") == 0) {
+
+ final_str = GetWindowsDir("Data Path", "Data");
+
+ } else if (strcmp(i, "personal-dir") == 0) {
+
+ final_str = GetWindowsDir("Personal Path", "Personal");
}
#endif
@@ -1394,20 +1397,6 @@
return no_err;
}
-#if defined(WIN32_USE_PERSONAL_DIR)
-# define HOME_DIR "!home-dir"
-# define PERSONAL "<lang>.pws"
-# define REPL "<lang>.prepl"
-#elif defined(ENABLE_WIN32_RELOCATABLE)
-# define HOME_DIR "<prefix>"
-# define PERSONAL "<lang>.pws"
-# define REPL "<lang>.prepl"
-#else
-# define HOME_DIR "<$HOME|./>"
-# define PERSONAL ".aspell.<lang>.pws"
-# define REPL ".aspell.<lang>.prepl"
-#endif
-
static const KeyInfo config_keys[] = {
// the description should be under 50 chars
{"actual-dict-dir", KeyInfoString, "<dict-dir^master>", 0}
@@ -1484,12 +1473,12 @@
, {"per-conf-path", KeyInfoString, "<home-dir/per-conf>", 0}
, {"personal", KeyInfoString, PERSONAL,
N_("personal dictionary file name")}
- , {"personal-path", KeyInfoString, "<home-dir/personal>", 0}
+ , {"personal-path", KeyInfoString, "<personal-dir/personal>", 0}
, {"prefix", KeyInfoString, PREFIX,
N_("prefix directory")}
, {"repl", KeyInfoString, REPL,
N_("replacements list file name") }
- , {"repl-path", KeyInfoString, "<home-dir/repl>", 0}
+ , {"repl-path", KeyInfoString, "<personal-dir/repl>", 0}
, {"run-together", KeyInfoBool, "false",
N_("consider run-together words legal"), KEYINFO_MAY_CHANGE}
, {"run-together-limit", KeyInfoInt, "2",
@@ -1524,12 +1513,6 @@
N_("search path for word list information files"), KEYINFO_HIDDEN}
, {"warn", KeyInfoBool, "true",
N_("enable warnings")}
-#ifdef WIN32PORT
- , {"dict-subdir", KeyInfoString, "dicts",
- N_("sub directory for dictionaries")}
- , {"data-subdir", KeyInfoString, "data",
- N_("sub directory for other data")}
-#endif
//
// These options are generally used when creating dictionaries
@@ -1574,7 +1557,10 @@
N_("suggest possible replacements"), KEYINFO_MAY_CHANGE}
, {"time" , KeyInfoBool, "false",
N_("time load time and suggest time in pipe mode"), KEYINFO_MAY_CHANGE}
-
+ #ifdef WIN32PORT
+ , {"personal-dir", KeyInfoString, PERSONAL_DIR,
+ N_("directory for personal dictionaries")}
+ #endif
};
const KeyInfo * config_impl_keys_begin = config_keys;
@@ -1588,4 +1574,87 @@
config_impl_keys_end);
}
+#ifdef WIN32PORT
+
+ String ReadRegString(HKEY hive, String key, String name)
+ {
+
+ // Reads a string from the Windows registry (used to get paths)
+
+ HKEY hKey;
+ unsigned long lType;
+ DWORD dwSize;
+ unsigned char* szValue = NULL;
+
+ if (::RegOpenKeyEx(hive, key.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+ {
+ if(::RegQueryValueEx(hKey, name.c_str(), NULL, &lType, NULL, &dwSize) == ERROR_SUCCESS)
+ {
+ szValue = new unsigned char[dwSize + 1];
+ ::RegQueryValueEx(hKey, name.c_str(), NULL, &lType, szValue, &dwSize);
+ String RegistryReturn((char*)szValue);
+ delete[] szValue;
+ return RegistryReturn;
+ } else {
+ return "";
+ }
+ } else {
+ return "";
+ }
+
+ }
+
+ HKEY GetRegHive()
+ {
+
+ // Check whether Aspell is installed for the current user or for all users
+
+ String value;
+
+ if (ReadRegString(HKEY_CURRENT_USER, "Software\\Aspell", "Base Path").empty())
+ {
+ return HKEY_LOCAL_MACHINE;
+ } else {
+ return HKEY_CURRENT_USER;
+ }
+
+ }
+
+ String GetWindowsDir(String registry_name, String default_dir)
+ {
+
+ String final_dir;
+
+ // Get directory from registry
+ HKEY hive;
+ hive = GetRegHive();
+ final_dir = ReadRegString(hive, "Software\\Aspell", registry_name);
+
+ // Default location in "Documents and Settings"
+ if (final_dir.empty()) {
+
+ char * dir = new char[MAX_PATH];
+ LPITEMIDLIST items = 0;
+ HRESULT hand = SHGetSpecialFolderLocation(0, CSIDL_APPDATA, &items);
+
+ if ((NOERROR == hand) && items) {
+ if (SHGetPathFromIDList(items, dir)) {
+ for (char *ptr = dir; *ptr; ++ptr)
+ if ('\\' == *ptr)
+ *ptr = '/';
+ final_dir = dir;
+ final_dir.append("/Aspell/");
+ final_dir.append(default_dir.c_str());
+ }
+ CoTaskMemFree(items);
+ }
+
+ }
+
+ return final_dir;
+
+ }
+
+#endif
+
}
diff -riwBu -Xex aspell-setter-sep06/common/vector.hpp aspell-setter-sep06-modified/common/vector.hpp
--- aspell-setter-sep06/common/vector.hpp 2005-10-13 09:42:54.000000000 +0200
+++ aspell-setter-sep06-modified/common/vector.hpp 2006-09-17 19:50:45.730606400 +0200
@@ -50,10 +50,10 @@
T * data_end() {return &*this->end();}
T * pbegin() {return &*this->begin();}
- T * pend() {return &*this->end();}
+ T * pend() {return &this->back()+1;}
const T * pbegin() const {return &*this->begin();}
- const T * pend() const {return &*this->end();}
+ const T * pend() const {return &this->back()+1;}
template <typename U>
U * datap() {
diff -riwBu -Xex aspell-setter-sep06/win32/dirs.h aspell-setter-sep06-modified/win32/dirs.h
--- aspell-setter-sep06/win32/dirs.h 2005-10-13 13:29:34.000000000 +0200
+++ aspell-setter-sep06-modified/win32/dirs.h 2007-02-16 22:52:43.486492800 +0100
@@ -1,16 +1,26 @@
#ifndef dirs_h
#define dirs_h
-#ifdef WIN32_USE_EXECUTABLE_DIR
-# define DATA_DIR "<prefix/data-subdir>"
-# define CONF_DIR "<prefix>"
-# define DICT_DIR "<prefix/dict-subdir>"
+# define DATA_DIR "!data-dir"
+# define DICT_DIR "!dict-dir"
+# define PERSONAL_DIR "!personal-dir"
+# define CONF_DIR "<home-dir>"
+
+#if defined(WIN32_USE_EXECUTABLE_DIR)
+# define HOME_DIR "<prefix>"
+# define PERSONAL "<lang>.pws"
+# define REPL "<lang>.prepl"
# define PREFIX "!prefix"
+#elif defined(WIN32_USE_PERSONAL_DIR)
+# define HOME_DIR "!home-dir"
+# define PERSONAL "<lang>.pws"
+# define REPL "<lang>.prepl"
+# define PREFIX "<home-dir>"
#else
-# define DATA_DIR "aspell-win32/data"
-# define CONF_DIR "aspell-win32"
-# define DICT_DIR "dicts"
-# define PREFIX "aspell-win32"
+# define HOME_DIR "<$HOME|./>"
+# define PERSONAL ".aspell.<lang>.pws"
+# define REPL ".aspell.<lang>.prepl"
+# define PREFIX "<home-dir>"
#endif
#endif
diff -riwBu -Xex aspell-setter-sep06/win32/settings.h aspell-setter-sep06-modified/win32/settings.h
--- aspell-setter-sep06/win32/settings.h 2006-09-06 10:51:16.000000000 +0200
+++ aspell-setter-sep06-modified/win32/settings.h 2006-09-17 18:55:23.112916800 +0200
@@ -9,9 +9,6 @@
/* Defined if curses like POSIX Functions should be used */
#undef CURSES_ONLY
-/* Defined if win32 relocation should be used */
-#define ENABLE_WIN32_RELOCATABLE 1
-
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
_______________________________________________
Aspell-devel mailing list
Aspell-devel@...
http://lists.gnu.org/mailman/listinfo/aspell-devel