1 diff -riwBu -Xex aspell-setter-sep06/common/config.cpp aspell-setter-sep06-modified/common/config.cpp
\r
2 --- aspell-setter-sep06/common/config.cpp 2005-12-12 17:41:06.000000000 +0100
\r
3 +++ aspell-setter-sep06-modified/common/config.cpp 2007-02-16 22:40:26.947401600 +0100
\r
9 + String GetWindowsDir(String registry_name, String default_directory);
\r
12 const char * const keyinfo_type_name[4] = {
\r
13 N_("string"), N_("integer"), N_("boolean"), N_("list")
\r
15 @@ -642,20 +646,19 @@
\r
17 } else if (strcmp(i, "home-dir") == 0) {
\r
19 - //get the personal folder (e.g. "c:\My Documents")
\r
20 - char * dir = new char[MAX_PATH];
\r
21 - LPITEMIDLIST items = 0;
\r
22 - HRESULT hand = SHGetSpecialFolderLocation(0, CSIDL_PERSONAL, &items);
\r
23 - if ((NOERROR == hand) && items) {
\r
24 - if (SHGetPathFromIDList(items, dir)) {
\r
25 - for (char *ptr = dir; *ptr; ++ptr)
\r
30 - CoTaskMemFree(items);
\r
33 + final_str = GetWindowsDir("Base Path", "");
\r
35 + } else if (strcmp(i, "dict-dir") == 0) {
\r
37 + final_str = GetWindowsDir("Dictionary Path", "Dictionaries");
\r
39 + } else if (strcmp(i, "data-dir") == 0) {
\r
41 + final_str = GetWindowsDir("Data Path", "Data");
\r
43 + } else if (strcmp(i, "personal-dir") == 0) {
\r
45 + final_str = GetWindowsDir("Personal Path", "Personal");
\r
49 @@ -1394,20 +1397,6 @@
\r
53 -#if defined(WIN32_USE_PERSONAL_DIR)
\r
54 -# define HOME_DIR "!home-dir"
\r
55 -# define PERSONAL "<lang>.pws"
\r
56 -# define REPL "<lang>.prepl"
\r
57 -#elif defined(ENABLE_WIN32_RELOCATABLE)
\r
58 -# define HOME_DIR "<prefix>"
\r
59 -# define PERSONAL "<lang>.pws"
\r
60 -# define REPL "<lang>.prepl"
\r
62 -# define HOME_DIR "<$HOME|./>"
\r
63 -# define PERSONAL ".aspell.<lang>.pws"
\r
64 -# define REPL ".aspell.<lang>.prepl"
\r
67 static const KeyInfo config_keys[] = {
\r
68 // the description should be under 50 chars
\r
69 {"actual-dict-dir", KeyInfoString, "<dict-dir^master>", 0}
\r
70 @@ -1484,12 +1473,12 @@
\r
71 , {"per-conf-path", KeyInfoString, "<home-dir/per-conf>", 0}
\r
72 , {"personal", KeyInfoString, PERSONAL,
\r
73 N_("personal dictionary file name")}
\r
74 - , {"personal-path", KeyInfoString, "<home-dir/personal>", 0}
\r
75 + , {"personal-path", KeyInfoString, "<personal-dir/personal>", 0}
\r
76 , {"prefix", KeyInfoString, PREFIX,
\r
77 N_("prefix directory")}
\r
78 , {"repl", KeyInfoString, REPL,
\r
79 N_("replacements list file name") }
\r
80 - , {"repl-path", KeyInfoString, "<home-dir/repl>", 0}
\r
81 + , {"repl-path", KeyInfoString, "<personal-dir/repl>", 0}
\r
82 , {"run-together", KeyInfoBool, "false",
\r
83 N_("consider run-together words legal"), KEYINFO_MAY_CHANGE}
\r
84 , {"run-together-limit", KeyInfoInt, "2",
\r
85 @@ -1524,12 +1513,6 @@
\r
86 N_("search path for word list information files"), KEYINFO_HIDDEN}
\r
87 , {"warn", KeyInfoBool, "true",
\r
88 N_("enable warnings")}
\r
90 - , {"dict-subdir", KeyInfoString, "dicts",
\r
91 - N_("sub directory for dictionaries")}
\r
92 - , {"data-subdir", KeyInfoString, "data",
\r
93 - N_("sub directory for other data")}
\r
97 // These options are generally used when creating dictionaries
\r
98 @@ -1574,7 +1557,10 @@
\r
99 N_("suggest possible replacements"), KEYINFO_MAY_CHANGE}
\r
100 , {"time" , KeyInfoBool, "false",
\r
101 N_("time load time and suggest time in pipe mode"), KEYINFO_MAY_CHANGE}
\r
104 + , {"personal-dir", KeyInfoString, PERSONAL_DIR,
\r
105 + N_("directory for personal dictionaries")}
\r
109 const KeyInfo * config_impl_keys_begin = config_keys;
\r
110 @@ -1588,4 +1574,87 @@
\r
111 config_impl_keys_end);
\r
116 + String ReadRegString(HKEY hive, String key, String name)
\r
119 + // Reads a string from the Windows registry (used to get paths)
\r
122 + unsigned long lType;
\r
124 + unsigned char* szValue = NULL;
\r
126 + if (::RegOpenKeyEx(hive, key.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
\r
128 + if(::RegQueryValueEx(hKey, name.c_str(), NULL, &lType, NULL, &dwSize) == ERROR_SUCCESS)
\r
130 + szValue = new unsigned char[dwSize + 1];
\r
131 + ::RegQueryValueEx(hKey, name.c_str(), NULL, &lType, szValue, &dwSize);
\r
132 + String RegistryReturn((char*)szValue);
\r
133 + delete[] szValue;
\r
134 + return RegistryReturn;
\r
144 + HKEY GetRegHive()
\r
147 + // Check whether Aspell is installed for the current user or for all users
\r
151 + if (ReadRegString(HKEY_CURRENT_USER, "Software\\Aspell", "Base Path").empty())
\r
153 + return HKEY_LOCAL_MACHINE;
\r
155 + return HKEY_CURRENT_USER;
\r
160 + String GetWindowsDir(String registry_name, String default_dir)
\r
163 + String final_dir;
\r
165 + // Get directory from registry
\r
167 + hive = GetRegHive();
\r
168 + final_dir = ReadRegString(hive, "Software\\Aspell", registry_name);
\r
170 + // Default location in "Documents and Settings"
\r
171 + if (final_dir.empty()) {
\r
173 + char * dir = new char[MAX_PATH];
\r
174 + LPITEMIDLIST items = 0;
\r
175 + HRESULT hand = SHGetSpecialFolderLocation(0, CSIDL_APPDATA, &items);
\r
177 + if ((NOERROR == hand) && items) {
\r
178 + if (SHGetPathFromIDList(items, dir)) {
\r
179 + for (char *ptr = dir; *ptr; ++ptr)
\r
180 + if ('\\' == *ptr)
\r
183 + final_dir.append("/Aspell/");
\r
184 + final_dir.append(default_dir.c_str());
\r
186 + CoTaskMemFree(items);
\r
191 + return final_dir;
\r
198 diff -riwBu -Xex aspell-setter-sep06/common/vector.hpp aspell-setter-sep06-modified/common/vector.hpp
\r
199 --- aspell-setter-sep06/common/vector.hpp 2005-10-13 09:42:54.000000000 +0200
\r
200 +++ aspell-setter-sep06-modified/common/vector.hpp 2006-09-17 19:50:45.730606400 +0200
\r
201 @@ -50,10 +50,10 @@
\r
202 T * data_end() {return &*this->end();}
\r
204 T * pbegin() {return &*this->begin();}
\r
205 - T * pend() {return &*this->end();}
\r
206 + T * pend() {return &this->back()+1;}
\r
208 const T * pbegin() const {return &*this->begin();}
\r
209 - const T * pend() const {return &*this->end();}
\r
210 + const T * pend() const {return &this->back()+1;}
\r
212 template <typename U>
\r
214 diff -riwBu -Xex aspell-setter-sep06/win32/dirs.h aspell-setter-sep06-modified/win32/dirs.h
\r
215 --- aspell-setter-sep06/win32/dirs.h 2005-10-13 13:29:34.000000000 +0200
\r
216 +++ aspell-setter-sep06-modified/win32/dirs.h 2007-02-16 22:52:43.486492800 +0100
\r
221 -#ifdef WIN32_USE_EXECUTABLE_DIR
\r
222 -# define DATA_DIR "<prefix/data-subdir>"
\r
223 -# define CONF_DIR "<prefix>"
\r
224 -# define DICT_DIR "<prefix/dict-subdir>"
\r
225 +# define DATA_DIR "!data-dir"
\r
226 +# define DICT_DIR "!dict-dir"
\r
227 +# define PERSONAL_DIR "!personal-dir"
\r
228 +# define CONF_DIR "<home-dir>"
\r
230 +#if defined(WIN32_USE_EXECUTABLE_DIR)
\r
231 +# define HOME_DIR "<prefix>"
\r
232 +# define PERSONAL "<lang>.pws"
\r
233 +# define REPL "<lang>.prepl"
\r
234 # define PREFIX "!prefix"
\r
235 +#elif defined(WIN32_USE_PERSONAL_DIR)
\r
236 +# define HOME_DIR "!home-dir"
\r
237 +# define PERSONAL "<lang>.pws"
\r
238 +# define REPL "<lang>.prepl"
\r
239 +# define PREFIX "<home-dir>"
\r
241 -# define DATA_DIR "aspell-win32/data"
\r
242 -# define CONF_DIR "aspell-win32"
\r
243 -# define DICT_DIR "dicts"
\r
244 -# define PREFIX "aspell-win32"
\r
245 +# define HOME_DIR "<$HOME|./>"
\r
246 +# define PERSONAL ".aspell.<lang>.pws"
\r
247 +# define REPL ".aspell.<lang>.prepl"
\r
248 +# define PREFIX "<home-dir>"
\r
252 diff -riwBu -Xex aspell-setter-sep06/win32/settings.h aspell-setter-sep06-modified/win32/settings.h
\r
253 --- aspell-setter-sep06/win32/settings.h 2006-09-06 10:51:16.000000000 +0200
\r
254 +++ aspell-setter-sep06-modified/win32/settings.h 2006-09-17 18:55:23.112916800 +0200
\r
256 /* Defined if curses like POSIX Functions should be used */
\r
259 -/* Defined if win32 relocation should be used */
\r
260 -#define ENABLE_WIN32_RELOCATABLE 1
\r
262 /* Define to 1 if you have the <dlfcn.h> header file. */
\r
263 #undef HAVE_DLFCN_H
\r