]> git.lyx.org Git - lyx.git/blob - development/Win32/patches/msvc/aspell-setter-sep06.patch
tiny encoding fix for LyXWinInstaller
[lyx.git] / development / Win32 / patches / msvc / aspell-setter-sep06.patch
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
4 @@ -78,6 +78,10 @@\r
5  \r
6  namespace aspell {\r
7  \r
8 +#ifdef WIN32PORT\r
9 +       String GetWindowsDir(String registry_name, String default_directory);\r
10 +#endif\r
11 +\r
12    const char * const keyinfo_type_name[4] = {\r
13      N_("string"), N_("integer"), N_("boolean"), N_("list")\r
14    };\r
15 @@ -642,20 +646,19 @@\r
16  \r
17        } else if (strcmp(i, "home-dir") == 0) { \r
18  \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
26 -              if ('\\' == *ptr)\r
27 -                *ptr = '/';\r
28 -            final_str = dir;\r
29 -          }\r
30 -          CoTaskMemFree(items);\r
31 -        }\r
32 -        delete [] dir;\r
33 +                 final_str = GetWindowsDir("Base Path", "");\r
34 +\r
35 +      } else if (strcmp(i, "dict-dir") == 0) { \r
36 +\r
37 +                 final_str = GetWindowsDir("Dictionary Path", "Dictionaries");\r
38 +\r
39 +      } else if (strcmp(i, "data-dir") == 0) { \r
40 +\r
41 +                 final_str = GetWindowsDir("Data Path", "Data");\r
42 +\r
43 +      } else if (strcmp(i, "personal-dir") == 0) { \r
44 +\r
45 +                 final_str = GetWindowsDir("Personal Path", "Personal");\r
46  \r
47        }\r
48  #endif\r
49 @@ -1394,20 +1397,6 @@\r
50      return no_err;\r
51    }\r
52  \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
61 -#else\r
62 -#  define HOME_DIR "<$HOME|./>"\r
63 -#  define PERSONAL ".aspell.<lang>.pws"\r
64 -#  define REPL     ".aspell.<lang>.prepl"\r
65 -#endif\r
66 -\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
89 -#ifdef WIN32PORT\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
94 -#endif\r
95      \r
96      //\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
102 -\r
103 + #ifdef WIN32PORT\r
104 +    , {"personal-dir", KeyInfoString, PERSONAL_DIR,\r
105 +       N_("directory for personal dictionaries")}\r
106 + #endif\r
107      };\r
108  \r
109    const KeyInfo * config_impl_keys_begin = config_keys;\r
110 @@ -1588,4 +1574,87 @@\r
111                        config_impl_keys_end);\r
112    }\r
113    \r
114 +#ifdef WIN32PORT\r
115 +\r
116 +  String ReadRegString(HKEY hive, String key, String name)\r
117 +  {\r
118 +  \r
119 +    // Reads a string from the Windows registry (used to get paths)  \r
120 +       \r
121 +    HKEY hKey;\r
122 +    unsigned long lType;\r
123 +    DWORD dwSize;\r
124 +    unsigned char* szValue = NULL;\r
125 +       \r
126 +    if (::RegOpenKeyEx(hive, key.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS)\r
127 +    {\r
128 +      if(::RegQueryValueEx(hKey, name.c_str(), NULL, &lType, NULL, &dwSize) == ERROR_SUCCESS)\r
129 +      {\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
135 +         } else {\r
136 +           return "";\r
137 +      }\r
138 +    } else {\r
139 +         return "";\r
140 +       }\r
141 +  \r
142 +  }\r
143 +  \r
144 +  HKEY GetRegHive()\r
145 +  {\r
146 +    \r
147 +    // Check whether Aspell is installed for the current user or for all users\r
148 +       \r
149 +    String value;\r
150 +       \r
151 +    if (ReadRegString(HKEY_CURRENT_USER, "Software\\Aspell", "Base Path").empty())\r
152 +    {\r
153 +      return HKEY_LOCAL_MACHINE;\r
154 +    } else {\r
155 +      return HKEY_CURRENT_USER;\r
156 +    }\r
157 +       \r
158 +  }\r
159 +\r
160 +  String GetWindowsDir(String registry_name, String default_dir)\r
161 +  {\r
162 +\r
163 +    String final_dir;\r
164 +\r
165 +    // Get directory from registry\r
166 +       HKEY hive;\r
167 +       hive = GetRegHive();\r
168 +       final_dir = ReadRegString(hive, "Software\\Aspell", registry_name);\r
169 +\r
170 +       // Default location in "Documents and Settings"\r
171 +       if (final_dir.empty()) {\r
172 +\r
173 +         char * dir = new char[MAX_PATH];\r
174 +      LPITEMIDLIST items = 0;\r
175 +      HRESULT hand = SHGetSpecialFolderLocation(0, CSIDL_APPDATA, &items);\r
176 +\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
181 +              *ptr = '/';\r
182 +          final_dir = dir;\r
183 +          final_dir.append("/Aspell/");\r
184 +          final_dir.append(default_dir.c_str());\r
185 +        }\r
186 +        CoTaskMemFree(items);\r
187 +      }\r
188 +\r
189 +    }\r
190 +\r
191 +       return final_dir;\r
192 +\r
193 +  }\r
194 +\r
195 +#endif\r
196 +  \r
197  }\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
203  \r
204      T * pbegin() {return &*this->begin();}\r
205 -    T * pend()   {return &*this->end();}\r
206 +    T * pend()   {return &this->back()+1;}\r
207  \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
211  \r
212      template <typename U>\r
213      U * datap() { \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
217 @@ -1,16 +1,26 @@\r
218  #ifndef dirs_h\r
219  #define dirs_h\r
220  \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
229 +\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
240  #else\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
249  #endif\r
250  \r
251  #endif\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
255 @@ -9,9 +9,6 @@\r
256  /* Defined if curses like POSIX Functions should be used */\r
257  #undef CURSES_ONLY\r
258  \r
259 -/* Defined if win32 relocation should be used */\r
260 -#define ENABLE_WIN32_RELOCATABLE 1\r
261 -\r
262  /* Define to 1 if you have the <dlfcn.h> header file. */\r
263  #undef HAVE_DLFCN_H\r
264  \r