summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0918
blob: e7e36712d45e328087014dd66b441a4d543408d9 (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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0918
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0918
Problem:    MS-Windows: startup messages are not converted.
Solution:   Convert messages when the current codepage differs from
            'encoding'. (Yasuhiro Matsumoto, closes #3914)
Files:	    src/message.c, src/os_mswin.c, src/vim.h


*** ../vim-8.1.0917/src/message.c	2019-01-24 17:59:35.135217476 +0100
--- src/message.c	2019-02-14 14:04:44.531851174 +0100
***************
*** 2570,2626 ****
  msg_puts_printf(char_u *str, int maxlen)
  {
      char_u	*s = str;
!     char_u	buf[4];
!     char_u	*p;
! #ifdef WIN3264
! # if !defined(FEAT_GUI_MSWIN)
!     char_u	*ccp = NULL;
  
! # endif
      if (!(silent_mode && p_verbose == 0))
! 	mch_settmode(TMODE_COOK);	/* handle '\r' and '\n' correctly */
! 
! # if !defined(FEAT_GUI_MSWIN)
!     if (enc_codepage >= 0 && (int)GetConsoleCP() != enc_codepage)
!     {
! 	int	inlen = (int)STRLEN(str);
! 	int	outlen;
! 	WCHAR	*widestr = (WCHAR *)enc_to_utf16(str, &inlen);
! 
! 	if (widestr != NULL)
! 	{
! 	    WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, inlen,
! 						 (LPSTR *)&ccp, &outlen, 0, 0);
! 	    vim_free(widestr);
! 	    s = str = ccp;
! 	}
!     }
! # endif
  #endif
      while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)
      {
  	if (!(silent_mode && p_verbose == 0))
  	{
! 	    /* NL --> CR NL translation (for Unix, not for "--version") */
! 	    p = &buf[0];
! 	    if (*s == '\n' && !info_message)
! 		*p++ = '\r';
! #if defined(USE_CR)
! 	    else
  #endif
! 		*p++ = *s;
! 	    *p = '\0';
! 	    if (info_message)	/* informative message, not an error */
! 		mch_msg((char *)buf);
! 	    else
! 		mch_errmsg((char *)buf);
  	}
  
! 	/* primitive way to compute the current column */
  #ifdef FEAT_RIGHTLEFT
  	if (cmdmsg_rl)
  	{
! 	    if (*s == '\r' || *s == '\n')
  		msg_col = Columns - 1;
  	    else
  		--msg_col;
--- 2570,2614 ----
  msg_puts_printf(char_u *str, int maxlen)
  {
      char_u	*s = str;
!     char_u	*buf = NULL;
!     char_u	*p = s;
  
! #ifdef WIN3264
      if (!(silent_mode && p_verbose == 0))
! 	mch_settmode(TMODE_COOK);	/* handle CR and NL correctly */
  #endif
      while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)
      {
  	if (!(silent_mode && p_verbose == 0))
  	{
! 	    // NL --> CR NL translation (for Unix, not for "--version")
! 	    if (*s == NL)
! 	    {
! 		int n = (int)(s - p);
! 
! 		buf = alloc(n + 3);
! 		memcpy(buf, p, n);
! 		if (!info_message)
! 		    buf[n++] = CAR;
! #ifdef USE_CR
! 		else
  #endif
! 		    buf[n++] = NL;
! 		buf[n++] = NUL;
! 		if (info_message)   // informative message, not an error
! 		    mch_msg((char *)buf);
! 		else
! 		    mch_errmsg((char *)buf);
! 		vim_free(buf);
! 		p = s + 1;
! 	    }
  	}
  
! 	// primitive way to compute the current column
  #ifdef FEAT_RIGHTLEFT
  	if (cmdmsg_rl)
  	{
! 	    if (*s == CAR || *s == NL)
  		msg_col = Columns - 1;
  	    else
  		--msg_col;
***************
*** 2628,2646 ****
  	else
  #endif
  	{
! 	    if (*s == '\r' || *s == '\n')
  		msg_col = 0;
  	    else
  		++msg_col;
  	}
  	++s;
      }
!     msg_didout = TRUE;	    /* assume that line is not empty */
  
  #ifdef WIN3264
- # if !defined(FEAT_GUI_MSWIN)
-     vim_free(ccp);
- # endif
      if (!(silent_mode && p_verbose == 0))
  	mch_settmode(TMODE_RAW);
  #endif
--- 2616,2642 ----
  	else
  #endif
  	{
! 	    if (*s == CAR || *s == NL)
  		msg_col = 0;
  	    else
  		++msg_col;
  	}
  	++s;
      }
! 
!     if (*p != NUL && !(silent_mode && p_verbose == 0))
!     {
! 	if (maxlen > 0 && STRLEN(p) > (size_t)maxlen)
! 	    p[maxlen] = 0;
! 	if (info_message)
! 	    mch_msg((char *)p);
! 	else
! 	    mch_errmsg((char *)p);
!     }
! 
!     msg_didout = TRUE;	    // assume that line is not empty
  
  #ifdef WIN3264
      if (!(silent_mode && p_verbose == 0))
  	mch_settmode(TMODE_RAW);
  #endif
***************
*** 2941,2972 ****
      void
  mch_errmsg(char *str)
  {
      int		len;
  
! #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
      /* On Unix use stderr if it's a tty.
       * When not going to start the GUI also use stderr.
       * On Mac, when started from Finder, stderr is the console. */
      if (
! # ifdef UNIX
! #  ifdef MACOS_X
  	    (isatty(2) && strcmp("/dev/console", ttyname(2)) != 0)
! #  else
  	    isatty(2)
! #  endif
! #  ifdef FEAT_GUI
  	    ||
  #  endif
! # endif
! # ifdef FEAT_GUI
  	    !(gui.in_use || gui.starting)
! # endif
  	    )
      {
  	fprintf(stderr, "%s", str);
  	return;
      }
! #endif
  
      /* avoid a delay for a message that isn't there */
      emsg_on_display = FALSE;
--- 2937,2987 ----
      void
  mch_errmsg(char *str)
  {
+ #if defined(WIN3264) && !defined(FEAT_GUI_MSWIN)
+     int	    len = STRLEN(str);
+     DWORD   nwrite = 0;
+     DWORD   mode = 0;
+     HANDLE  h = GetStdHandle(STD_ERROR_HANDLE);
+ 
+     if (GetConsoleMode(h, &mode) && enc_codepage >= 0
+ 	    && (int)GetConsoleCP() != enc_codepage)
+     {
+ 	WCHAR	*w = enc_to_utf16((char_u *)str, &len);
+ 
+ 	WriteConsoleW(h, w, len, &nwrite, NULL);
+ 	vim_free(w);
+     }
+     else
+     {
+ 	fprintf(stderr, "%s", str);
+     }
+ #else
      int		len;
  
! # if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
      /* On Unix use stderr if it's a tty.
       * When not going to start the GUI also use stderr.
       * On Mac, when started from Finder, stderr is the console. */
      if (
! #  ifdef UNIX
! #   ifdef MACOS_X
  	    (isatty(2) && strcmp("/dev/console", ttyname(2)) != 0)
! #   else
  	    isatty(2)
! #   endif
! #   ifdef FEAT_GUI
  	    ||
+ #   endif
  #  endif
! #  ifdef FEAT_GUI
  	    !(gui.in_use || gui.starting)
! #  endif
  	    )
      {
  	fprintf(stderr, "%s", str);
  	return;
      }
! # endif
  
      /* avoid a delay for a message that isn't there */
      emsg_on_display = FALSE;
***************
*** 2981,2987 ****
      {
  	mch_memmove((char_u *)error_ga.ga_data + error_ga.ga_len,
  							  (char_u *)str, len);
! #ifdef UNIX
  	/* remove CR characters, they are displayed */
  	{
  	    char_u	*p;
--- 2996,3002 ----
      {
  	mch_memmove((char_u *)error_ga.ga_data + error_ga.ga_len,
  							  (char_u *)str, len);
! # ifdef UNIX
  	/* remove CR characters, they are displayed */
  	{
  	    char_u	*p;
***************
*** 2995,3004 ****
  		*p = ' ';
  	    }
  	}
! #endif
  	--len;		/* don't count the NUL at the end */
  	error_ga.ga_len += len;
      }
  }
  
  /*
--- 3010,3020 ----
  		*p = ' ';
  	    }
  	}
! # endif
  	--len;		/* don't count the NUL at the end */
  	error_ga.ga_len += len;
      }
+ #endif
  }
  
  /*
***************
*** 3009,3015 ****
      void
  mch_msg(char *str)
  {
! #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
      /* On Unix use stdout if we have a tty.  This allows "vim -h | more" and
       * uses mch_errmsg() when started from the desktop.
       * When not going to start the GUI also use stdout.
--- 3025,3051 ----
      void
  mch_msg(char *str)
  {
! #if defined(WIN3264) && !defined(FEAT_GUI_MSWIN)
!     int	    len = STRLEN(str);
!     DWORD   nwrite = 0;
!     DWORD   mode;
!     HANDLE  h = GetStdHandle(STD_OUTPUT_HANDLE);
! 
! 
!     if (GetConsoleMode(h, &mode) && enc_codepage >= 0
! 	    && (int)GetConsoleCP() != enc_codepage)
!     {
! 	WCHAR	*w = enc_to_utf16((char_u *)str, &len);
! 
! 	WriteConsoleW(h, w, len, &nwrite, NULL);
! 	vim_free(w);
!     }
!     else
!     {
! 	printf("%s", str);
!     }
! #else
! # if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
      /* On Unix use stdout if we have a tty.  This allows "vim -h | more" and
       * uses mch_errmsg() when started from the desktop.
       * When not going to start the GUI also use stdout.
***************
*** 3035,3040 ****
--- 3071,3077 ----
      }
  # endif
      mch_errmsg(str);
+ #endif
  }
  #endif /* USE_MCH_ERRMSG */
  
*** ../vim-8.1.0917/src/os_mswin.c	2019-02-12 23:12:33.600730918 +0100
--- src/os_mswin.c	2019-02-14 13:48:22.873645483 +0100
***************
*** 675,680 ****
--- 675,681 ----
  # undef display_errors
  #endif
  
+ #ifdef FEAT_GUI
  /*
   * Display the saved error message(s).
   */
***************
*** 690,702 ****
  	    if (!isspace(*p))
  	    {
  		(void)gui_mch_dialog(
- #ifdef FEAT_GUI
  				     gui.starting ? VIM_INFO :
- #endif
  					     VIM_ERROR,
- #ifdef FEAT_GUI
  				     gui.starting ? (char_u *)_("Message") :
- #endif
  					     (char_u *)_("Error"),
  				     (char_u *)p, (char_u *)_("&Ok"),
  					1, NULL, FALSE);
--- 691,699 ----
***************
*** 705,710 ****
--- 702,714 ----
  	ga_clear(&error_ga);
      }
  }
+ #else
+     void
+ display_errors(void)
+ {
+     FlushFileBuffers(GetStdHandle(STD_ERROR_HANDLE));
+ }
+ #endif
  #endif
  
  
*** ../vim-8.1.0917/src/vim.h	2019-02-01 20:42:18.718884011 +0100
--- src/vim.h	2019-02-14 13:48:22.873645483 +0100
***************
*** 2093,2099 ****
   * functions of these names. The declarations would break if the defines had
   * been seen at that stage.  But it must be before globals.h, where error_ga
   * is declared. */
! #if !defined(FEAT_GUI_W32) && !defined(FEAT_GUI_X11) \
  	&& !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MAC) && !defined(PROTO)
  # define mch_errmsg(str)	fprintf(stderr, "%s", (str))
  # define display_errors()	fflush(stderr)
--- 2093,2099 ----
   * functions of these names. The declarations would break if the defines had
   * been seen at that stage.  But it must be before globals.h, where error_ga
   * is declared. */
! #if !defined(MSWIN) && !defined(FEAT_GUI_X11) \
  	&& !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MAC) && !defined(PROTO)
  # define mch_errmsg(str)	fprintf(stderr, "%s", (str))
  # define display_errors()	fflush(stderr)
*** ../vim-8.1.0917/src/version.c	2019-02-14 13:43:33.779220100 +0100
--- src/version.c	2019-02-14 13:49:48.741169891 +0100
***************
*** 785,786 ****
--- 785,788 ----
  {   /* Add new patch number below this line */
+ /**/
+     918,
  /**/

-- 
BODY:        I'm not dead!
CART DRIVER: 'Ere.  He says he's not dead.
LARGE MAN:   Yes he is.
BODY:        I'm not!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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    ///