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 Mon Dec 12 17:41:06 2005
\r
3 +++ aspell-setter-sep06-modified\common\config.cpp Sun Oct 22 13:03:46 2006
\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,7 +1473,7 @@
\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, 0}
\r
76 , {"prefix", KeyInfoString, PREFIX,
\r
77 N_("prefix directory")}
\r
78 , {"repl", KeyInfoString, REPL,
\r
79 @@ -1525,10 +1514,8 @@
\r
80 , {"warn", KeyInfoBool, "true",
\r
81 N_("enable warnings")}
\r
83 - , {"dict-subdir", KeyInfoString, "dicts",
\r
84 - N_("sub directory for dictionaries")}
\r
85 - , {"data-subdir", KeyInfoString, "data",
\r
86 - N_("sub directory for other data")}
\r
87 + , {"personal-dir", KeyInfoString, PERSONAL_DIR,
\r
88 + N_("directory for personal dictionaries")}
\r
92 @@ -1587,5 +1574,88 @@
\r
93 config_impl_keys_begin,
\r
94 config_impl_keys_end);
\r
99 + String ReadRegString(HKEY hive, String key, String name)
\r
102 + // Reads a string from the Windows registry (used to get paths)
\r
105 + unsigned long lType;
\r
107 + unsigned char* szValue = NULL;
\r
109 + if (::RegOpenKeyEx(hive, key.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
\r
111 + if(::RegQueryValueEx(hKey, name.c_str(), NULL, &lType, NULL, &dwSize) == ERROR_SUCCESS)
\r
113 + szValue = new unsigned char[dwSize + 1];
\r
114 + ::RegQueryValueEx(hKey, name.c_str(), NULL, &lType, szValue, &dwSize);
\r
115 + String RegistryReturn((char*)szValue);
\r
116 + delete[] szValue;
\r
117 + return RegistryReturn;
\r
127 + HKEY GetRegHive()
\r
130 + // Check whether Aspell is installed for the current user or for all users
\r
134 + if (ReadRegString(HKEY_CURRENT_USER, "Software\\Aspell", "Base Path").empty())
\r
136 + return HKEY_LOCAL_MACHINE;
\r
138 + return HKEY_CURRENT_USER;
\r
143 + String GetWindowsDir(String registry_name, String default_dir)
\r
146 + String final_dir;
\r
148 + // Get directory from registry
\r
150 + hive = GetRegHive();
\r
151 + final_dir = ReadRegString(hive, "Software\\Aspell", registry_name);
\r
153 + // Default location in "Documents and Settings"
\r
154 + if (final_dir.empty()) {
\r
156 + char * dir = new char[MAX_PATH];
\r
157 + LPITEMIDLIST items = 0;
\r
158 + HRESULT hand = SHGetSpecialFolderLocation(0, CSIDL_APPDATA, &items);
\r
160 + if ((NOERROR == hand) && items) {
\r
161 + if (SHGetPathFromIDList(items, dir)) {
\r
162 + for (char *ptr = dir; *ptr; ++ptr)
\r
163 + if ('\\' == *ptr)
\r
166 + final_dir.append("/Aspell/");
\r
167 + final_dir.append(default_dir.c_str());
\r
169 + CoTaskMemFree(items);
\r
174 + return final_dir;
\r
181 diff -riwBu -Xex aspell-setter-sep06\common\vector.hpp aspell-setter-sep06-modified\common\vector.hpp
\r
182 --- aspell-setter-sep06\common\vector.hpp Thu Oct 13 08:42:54 2005
\r
183 +++ aspell-setter-sep06-modified\common\vector.hpp Sun Sep 17 18:50:45 2006
\r
184 @@ -50,10 +50,10 @@
\r
185 T * data_end() {return &*this->end();}
\r
187 T * pbegin() {return &*this->begin();}
\r
188 - T * pend() {return &*this->end();}
\r
189 + T * pend() {return &this->back()+1;}
\r
191 const T * pbegin() const {return &*this->begin();}
\r
192 - const T * pend() const {return &*this->end();}
\r
193 + const T * pend() const {return &this->back()+1;}
\r
195 template <typename U>
\r
197 diff -riwBu -Xex aspell-setter-sep06\win32\dirs.h aspell-setter-sep06-modified\win32\dirs.h
\r
198 --- aspell-setter-sep06\win32\dirs.h Thu Oct 13 12:29:34 2005
\r
199 +++ aspell-setter-sep06-modified\win32\dirs.h Sun Oct 22 12:55:10 2006
\r
204 -#ifdef WIN32_USE_EXECUTABLE_DIR
\r
205 -# define DATA_DIR "<prefix/data-subdir>"
\r
206 -# define CONF_DIR "<prefix>"
\r
207 -# define DICT_DIR "<prefix/dict-subdir>"
\r
208 +# define DATA_DIR "!data-dir"
\r
209 +# define DICT_DIR "!dict-dir"
\r
210 +# define PERSONAL_DIR "!personal-dir"
\r
212 +#if defined(WIN32_USE_EXECUTABLE_DIR)
\r
213 +# define HOME_DIR "<prefix>"
\r
214 +# define PERSONAL "<personal-dir>/<lang>.pws"
\r
215 +# define REPL "<personal-dir>/<lang>.prepl"
\r
216 # define PREFIX "!prefix"
\r
217 +#elif defined(WIN32_USE_PERSONAL_DIR)
\r
218 +# define HOME_DIR "!home-dir"
\r
219 +# define PERSONAL "<personal-dir>/<lang>.pws"
\r
220 +# define REPL "<personal-dir>/<lang>.prepl"
\r
221 +# define PREFIX "<home-dir>"
\r
223 -# define DATA_DIR "aspell-win32/data"
\r
224 -# define CONF_DIR "aspell-win32"
\r
225 -# define DICT_DIR "dicts"
\r
226 -# define PREFIX "aspell-win32"
\r
227 +# define HOME_DIR "<$HOME|./>"
\r
228 +# define PERSONAL "<personal-dir>/.aspell.<lang>.pws"
\r
229 +# define REPL "<personal-dir>/.aspell.<lang>.prepl"
\r
230 +# define PREFIX "<home-dir>"
\r
233 +#define CONF_DIR HOME_DIR
\r
236 diff -riwBu -Xex aspell-setter-sep06\win32\settings.h aspell-setter-sep06-modified\win32\settings.h
\r
237 --- aspell-setter-sep06\win32\settings.h Wed Sep 06 09:51:16 2006
\r
238 +++ aspell-setter-sep06-modified\win32\settings.h Sun Sep 17 17:55:23 2006
\r
240 /* Defined if curses like POSIX Functions should be used */
\r
243 -/* Defined if win32 relocation should be used */
\r
244 -#define ENABLE_WIN32_RELOCATABLE 1
\r
246 /* Define to 1 if you have the <dlfcn.h> header file. */
\r
247 #undef HAVE_DLFCN_H
\r