summaryrefslogtreecommitdiff
path: root/source/ap/vim/patches/7.3.198
blob: 5ef4a8aad31b53c0669d4b42a30fcbbd046bda2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
To: vim_dev@googlegroups.com
Subject: Patch 7.3.198
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.198
Problem:    No completion for ":lang".
Solution:   Get locales to complete from. (Dominique Pelle)
Files:	    src/eval.c, src/ex_cmds2.c, src/ex_getln.c,
	    src/proto/ex_cmds2.pro, src/proto/ex_getln.pro, src/vim.h


*** ../mercurial/vim73/src/eval.c	2011-05-19 17:25:36.000000000 +0200
--- src/eval.c	2011-05-19 17:52:02.000000000 +0200
***************
*** 911,916 ****
--- 911,917 ----
      hash_clear(&compat_hashtab);
  
      free_scriptnames();
+     free_locales();
  
      /* global variables */
      vars_clear(&globvarht);
*** ../mercurial/vim73/src/ex_cmds2.c	2011-05-10 16:41:13.000000000 +0200
--- src/ex_cmds2.c	2011-05-19 18:16:54.000000000 +0200
***************
*** 1476,1482 ****
  #endif
  
  /*
!  * Ask the user what to do when abondoning a changed buffer.
   * Must check 'write' option first!
   */
      void
--- 1476,1482 ----
  #endif
  
  /*
!  * Ask the user what to do when abandoning a changed buffer.
   * Must check 'write' option first!
   */
      void
***************
*** 4153,4158 ****
--- 4153,4234 ----
  }
  
  # if defined(FEAT_CMDL_COMPL) || defined(PROTO)
+ 
+ static char_u	**locales = NULL;	/* Array of all available locales */
+ static int	did_init_locales = FALSE;
+ 
+ static void init_locales __ARGS((void));
+ static char_u **find_locales __ARGS((void));
+ 
+ /*
+  * Lazy initialization of all available locales.
+  */
+     static void
+ init_locales()
+ {
+     if (!did_init_locales)
+     {
+ 	did_init_locales = TRUE;
+ 	locales = find_locales();
+     }
+ }
+ 
+ /* Return an array of strings for all available locales + NULL for the
+  * last element.  Return NULL in case of error. */
+     static char_u **
+ find_locales()
+ {
+     garray_T	locales_ga;
+     char_u	*loc;
+ 
+     /* Find all available locales by running command "locale -a".  If this
+      * doesn't work we won't have completion. */
+     char_u *locale_a = get_cmd_output((char_u *)"locale -a",
+ 							NULL, SHELL_SILENT);
+     if (locale_a == NULL)
+ 	return NULL;
+     ga_init2(&locales_ga, sizeof(char_u *), 20);
+ 
+     /* Transform locale_a string where each locale is separated by "\n"
+      * into an array of locale strings. */
+     loc = (char_u *)strtok((char *)locale_a, "\n");
+ 
+     while (loc != NULL)
+     {
+ 	if (ga_grow(&locales_ga, 1) == FAIL)
+ 	    break;
+ 	loc = vim_strsave(loc);
+ 	if (loc == NULL)
+ 	    break;
+ 
+ 	((char_u **)locales_ga.ga_data)[locales_ga.ga_len++] = loc;
+ 	loc = (char_u *)strtok(NULL, "\n");
+     }
+     vim_free(locale_a);
+     if (ga_grow(&locales_ga, 1) == FAIL)
+     {
+ 	ga_clear(&locales_ga);
+ 	return NULL;
+     }
+     ((char_u **)locales_ga.ga_data)[locales_ga.ga_len] = NULL;
+     return (char_u **)locales_ga.ga_data;
+ }
+ 
+ #  if defined(EXITFREE) || defined(PROTO)
+     void
+ free_locales()
+ {
+     int			i;
+     if (locales != NULL)
+     {
+ 	for (i = 0; locales[i] != NULL; i++)
+ 	    vim_free(locales[i]);
+ 	vim_free(locales);
+ 	locales = NULL;
+     }
+ }
+ #  endif
+ 
  /*
   * Function given to ExpandGeneric() to obtain the possible arguments of the
   * ":language" command.
***************
*** 4168,4174 ****
  	return (char_u *)"ctype";
      if (idx == 2)
  	return (char_u *)"time";
!     return NULL;
  }
  # endif
  
--- 4244,4268 ----
  	return (char_u *)"ctype";
      if (idx == 2)
  	return (char_u *)"time";
! 
!     init_locales();
!     if (locales == NULL)
! 	return NULL;
!     return locales[idx - 3];
! }
! 
! /*
!  * Function given to ExpandGeneric() to obtain the available locales.
!  */
!     char_u *
! get_locales(xp, idx)
!     expand_T	*xp UNUSED;
!     int		idx;
! {
!     init_locales();
!     if (locales == NULL)
! 	return NULL;
!     return locales[idx];
  }
  # endif
  
*** ../mercurial/vim73/src/ex_getln.c	2011-05-19 14:50:49.000000000 +0200
--- src/ex_getln.c	2011-05-19 18:18:49.000000000 +0200
***************
*** 4571,4618 ****
  	    int		context;
  	    char_u	*((*func)__ARGS((expand_T *, int)));
  	    int		ic;
  	} tab[] =
  	{
! 	    {EXPAND_COMMANDS, get_command_name, FALSE},
! 	    {EXPAND_BEHAVE, get_behave_arg, TRUE},
  #ifdef FEAT_USR_CMDS
! 	    {EXPAND_USER_COMMANDS, get_user_commands, FALSE},
! 	    {EXPAND_USER_CMD_FLAGS, get_user_cmd_flags, FALSE},
! 	    {EXPAND_USER_NARGS, get_user_cmd_nargs, FALSE},
! 	    {EXPAND_USER_COMPLETE, get_user_cmd_complete, FALSE},
  #endif
  #ifdef FEAT_EVAL
! 	    {EXPAND_USER_VARS, get_user_var_name, FALSE},
! 	    {EXPAND_FUNCTIONS, get_function_name, FALSE},
! 	    {EXPAND_USER_FUNC, get_user_func_name, FALSE},
! 	    {EXPAND_EXPRESSION, get_expr_name, FALSE},
  #endif
  #ifdef FEAT_MENU
! 	    {EXPAND_MENUS, get_menu_name, FALSE},
! 	    {EXPAND_MENUNAMES, get_menu_names, FALSE},
  #endif
  #ifdef FEAT_SYN_HL
! 	    {EXPAND_SYNTAX, get_syntax_name, TRUE},
  #endif
! 	    {EXPAND_HIGHLIGHT, get_highlight_name, TRUE},
  #ifdef FEAT_AUTOCMD
! 	    {EXPAND_EVENTS, get_event_name, TRUE},
! 	    {EXPAND_AUGROUP, get_augroup_name, TRUE},
  #endif
  #ifdef FEAT_CSCOPE
! 	    {EXPAND_CSCOPE, get_cscope_name, TRUE},
  #endif
  #ifdef FEAT_SIGNS
! 	    {EXPAND_SIGN, get_sign_name, TRUE},
  #endif
  #ifdef FEAT_PROFILE
! 	    {EXPAND_PROFILE, get_profile_name, TRUE},
  #endif
  #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
  	&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
! 	    {EXPAND_LANGUAGE, get_lang_arg, TRUE},
  #endif
! 	    {EXPAND_ENV_VARS, get_env_name, TRUE},
  	};
  	int	i;
  
--- 4571,4620 ----
  	    int		context;
  	    char_u	*((*func)__ARGS((expand_T *, int)));
  	    int		ic;
+ 	    int		escaped;
  	} tab[] =
  	{
! 	    {EXPAND_COMMANDS, get_command_name, FALSE, TRUE},
! 	    {EXPAND_BEHAVE, get_behave_arg, TRUE, TRUE},
  #ifdef FEAT_USR_CMDS
! 	    {EXPAND_USER_COMMANDS, get_user_commands, FALSE, TRUE},
! 	    {EXPAND_USER_CMD_FLAGS, get_user_cmd_flags, FALSE, TRUE},
! 	    {EXPAND_USER_NARGS, get_user_cmd_nargs, FALSE, TRUE},
! 	    {EXPAND_USER_COMPLETE, get_user_cmd_complete, FALSE, TRUE},
  #endif
  #ifdef FEAT_EVAL
! 	    {EXPAND_USER_VARS, get_user_var_name, FALSE, TRUE},
! 	    {EXPAND_FUNCTIONS, get_function_name, FALSE, TRUE},
! 	    {EXPAND_USER_FUNC, get_user_func_name, FALSE, TRUE},
! 	    {EXPAND_EXPRESSION, get_expr_name, FALSE, TRUE},
  #endif
  #ifdef FEAT_MENU
! 	    {EXPAND_MENUS, get_menu_name, FALSE, TRUE},
! 	    {EXPAND_MENUNAMES, get_menu_names, FALSE, TRUE},
  #endif
  #ifdef FEAT_SYN_HL
! 	    {EXPAND_SYNTAX, get_syntax_name, TRUE, TRUE},
  #endif
! 	    {EXPAND_HIGHLIGHT, get_highlight_name, TRUE, TRUE},
  #ifdef FEAT_AUTOCMD
! 	    {EXPAND_EVENTS, get_event_name, TRUE, TRUE},
! 	    {EXPAND_AUGROUP, get_augroup_name, TRUE, TRUE},
  #endif
  #ifdef FEAT_CSCOPE
! 	    {EXPAND_CSCOPE, get_cscope_name, TRUE, TRUE},
  #endif
  #ifdef FEAT_SIGNS
! 	    {EXPAND_SIGN, get_sign_name, TRUE, TRUE},
  #endif
  #ifdef FEAT_PROFILE
! 	    {EXPAND_PROFILE, get_profile_name, TRUE, TRUE},
  #endif
  #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
  	&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
! 	    {EXPAND_LANGUAGE, get_lang_arg, TRUE, FALSE},
! 	    {EXPAND_LOCALES, get_locales, TRUE, FALSE},
  #endif
! 	    {EXPAND_ENV_VARS, get_env_name, TRUE, TRUE},
  	};
  	int	i;
  
***************
*** 4626,4632 ****
  	    {
  		if (tab[i].ic)
  		    regmatch.rm_ic = TRUE;
! 		ret = ExpandGeneric(xp, &regmatch, num_file, file, tab[i].func);
  		break;
  	    }
      }
--- 4628,4635 ----
  	    {
  		if (tab[i].ic)
  		    regmatch.rm_ic = TRUE;
! 		ret = ExpandGeneric(xp, &regmatch, num_file, file,
!                                                 tab[i].func, tab[i].escaped);
  		break;
  	    }
      }
***************
*** 4648,4660 ****
   * Returns OK when no problems encountered, FAIL for error (out of memory).
   */
      int
! ExpandGeneric(xp, regmatch, num_file, file, func)
      expand_T	*xp;
      regmatch_T	*regmatch;
      int		*num_file;
      char_u	***file;
      char_u	*((*func)__ARGS((expand_T *, int)));
  					  /* returns a string from the list */
  {
      int		i;
      int		count = 0;
--- 4651,4664 ----
   * Returns OK when no problems encountered, FAIL for error (out of memory).
   */
      int
! ExpandGeneric(xp, regmatch, num_file, file, func, escaped)
      expand_T	*xp;
      regmatch_T	*regmatch;
      int		*num_file;
      char_u	***file;
      char_u	*((*func)__ARGS((expand_T *, int)));
  					  /* returns a string from the list */
+     int		escaped;
  {
      int		i;
      int		count = 0;
***************
*** 4679,4685 ****
  	    {
  		if (round)
  		{
! 		    str = vim_strsave_escaped(str, (char_u *)" \t\\.");
  		    (*file)[count] = str;
  #ifdef FEAT_MENU
  		    if (func == get_menu_names && str != NULL)
--- 4683,4692 ----
  	    {
  		if (round)
  		{
! 		    if (escaped)
! 			str = vim_strsave_escaped(str, (char_u *)" \t\\.");
! 		    else
! 			str = vim_strsave(str);
  		    (*file)[count] = str;
  #ifdef FEAT_MENU
  		    if (func == get_menu_names && str != NULL)
*** ../mercurial/vim73/src/proto/ex_cmds2.pro	2010-05-15 21:22:11.000000000 +0200
--- src/proto/ex_cmds2.pro	2011-05-19 17:53:52.000000000 +0200
***************
*** 83,87 ****
--- 83,89 ----
  char_u *get_mess_lang __ARGS((void));
  void set_lang_var __ARGS((void));
  void ex_language __ARGS((exarg_T *eap));
+ void free_locales __ARGS((void));
  char_u *get_lang_arg __ARGS((expand_T *xp, int idx));
+ char_u *get_locales __ARGS((expand_T *xp, int idx));
  /* vim: set ft=c : */
*** ../mercurial/vim73/src/proto/ex_getln.pro	2010-08-16 21:23:30.000000000 +0200
--- src/proto/ex_getln.pro	2011-05-19 17:54:00.000000000 +0200
***************
*** 31,37 ****
  char_u *addstar __ARGS((char_u *fname, int len, int context));
  void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col));
  int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches));
! int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int))));
  char_u *globpath __ARGS((char_u *path, char_u *file, int expand_options));
  void init_history __ARGS((void));
  int get_histtype __ARGS((char_u *name));
--- 31,37 ----
  char_u *addstar __ARGS((char_u *fname, int len, int context));
  void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col));
  int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches));
! int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int)), int escaped));
  char_u *globpath __ARGS((char_u *path, char_u *file, int expand_options));
  void init_history __ARGS((void));
  int get_histtype __ARGS((char_u *name));
*** ../mercurial/vim73/src/vim.h	2011-05-19 17:25:36.000000000 +0200
--- src/vim.h	2011-05-19 17:52:02.000000000 +0200
***************
*** 779,784 ****
--- 779,785 ----
  #define EXPAND_FILETYPE		37
  #define EXPAND_FILES_IN_PATH	38
  #define EXPAND_OWNSYNTAX	39
+ #define EXPAND_LOCALES		40
  
  /* Values for exmode_active (0 is no exmode) */
  #define EXMODE_NORMAL		1
*** ../vim-7.3.197/src/version.c	2011-05-19 17:42:54.000000000 +0200
--- src/version.c	2011-05-19 18:24:58.000000000 +0200
***************
*** 711,712 ****
--- 711,714 ----
  {   /* Add new patch number below this line */
+ /**/
+     198,
  /**/

-- 
The primary purpose of the DATA statement is to give names to constants;
instead of referring to pi as 3.141592653589793 at every appearance, the
variable PI can be given that value with a DATA statement and used instead
of the longer form of the constant.  This also simplifies modifying the
program, should the value of pi change.
	-- FORTRAN manual for Xerox Computers

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///