Mercurial > mxe-octave
annotate src/mingw-texinfo-1-fixes.patch @ 3609:360eff7d9c06
texinfo: compile native info when native target.
* src/mingw-texinfo-1-fixes.patch: define sleep in mingw.
* src/texinfo.mk: only build tools libs for cross build ginfo when doing cross build.
author | John Donoghue |
---|---|
date | Mon, 09 Jun 2014 08:11:22 -0400 |
parents | 4e90544559a3 |
children | 28a83a566666 |
rev | line source |
---|---|
3587 | 1 diff -ur texinfo-4.13.orig/info/man.c texinfo-4.13/info/man.c |
2 --- texinfo-4.13.orig/info/man.c 2014-04-24 13:39:35.918682762 -0400 | |
3 +++ texinfo-4.13/info/man.c 2014-04-24 13:40:33.385768723 -0400 | |
4 @@ -20,7 +20,9 @@ | |
5 Originally written by Brian Fox Thu May 4 09:17:52 1995. */ | |
6 | |
7 #include "info.h" | |
8 +#if defined (HAVE_SYS_IOCTL_H) | |
9 #include <sys/ioctl.h> | |
10 +#endif | |
11 #include "signals.h" | |
12 #if defined (HAVE_SYS_TIME_H) | |
13 #include <sys/time.h> | |
14 diff -ur texinfo-4.13.orig/info/pcterm.c texinfo-4.13/info/pcterm.c | |
15 --- texinfo-4.13.orig/info/pcterm.c 2014-04-24 13:39:35.917682743 -0400 | |
16 +++ texinfo-4.13/info/pcterm.c 2014-04-24 13:44:02.643696094 -0400 | |
17 @@ -717,7 +717,7 @@ | |
18 } | |
19 | |
20 /* These should never be called, but they make the linker happy. */ | |
21 - | |
22 +#ifndef __MINGW32__ | |
23 void tputs (char *a, int b, int (*c)()) | |
24 { | |
25 perror ("tputs"); | |
26 @@ -757,3 +757,4 @@ | |
27 { | |
28 perror ("tcsetattr"); return 0; | |
29 } | |
30 +#endif | |
31 diff -ur texinfo-4.13.orig/info/session.c texinfo-4.13/info/session.c | |
32 --- texinfo-4.13.orig/info/session.c 2014-04-24 13:39:35.917682743 -0400 | |
33 +++ texinfo-4.13/info/session.c 2014-04-24 13:41:43.144087140 -0400 | |
34 @@ -21,7 +21,9 @@ | |
35 | |
36 #include "info.h" | |
37 #include "search.h" | |
38 +#if defined (HAVE_SYS_IOCTL_H) | |
39 #include <sys/ioctl.h> | |
40 +#endif | |
41 | |
42 #if defined (HAVE_SYS_TIME_H) | |
43 # include <sys/time.h> | |
44 diff -ur texinfo-4.13.orig/info/search.c texinfo-4.13/info/search.c | |
45 --- texinfo-4.13.orig/info/search.c 2014-04-24 13:51:21.592277409 -0400 | |
46 +++ texinfo-4.13/info/search.c 2014-04-24 13:52:53.217898167 -0400 | |
47 @@ -20,7 +20,14 @@ | |
48 Originally written by Brian Fox (bfox@ai.mit.edu). */ | |
49 | |
50 #include "info.h" | |
51 -#include <regex.h> | |
52 + | |
53 +#ifndef __MINGW32__ | |
54 + #include <regex.h> | |
55 +#else | |
56 + // using pcre | |
57 + #include <pcre.h> | |
58 + #include <pcreposix.h> | |
59 +#endif | |
60 | |
61 #include "search.h" | |
62 #include "nodes.h" | |
63 diff -ur texinfo-4.13.orig/info/termdep.h texinfo-4.13/info/termdep.h | |
64 --- texinfo-4.13.orig/info/termdep.h 2014-04-24 13:55:42.343917317 -0400 | |
65 +++ texinfo-4.13/info/termdep.h 2014-04-24 13:56:31.331797804 -0400 | |
66 @@ -43,7 +43,9 @@ | |
67 # endif /* M_XENIX */ | |
68 # endif /* HAVE_SYS_PTEM_H */ | |
69 # else /* !HAVE_TERMIO_H */ | |
70 +#ifndef __MINGW32__ | |
71 # include <sgtty.h> | |
72 +#endif | |
73 # endif /* !HAVE_TERMIO_H */ | |
74 #endif /* !HAVE_TERMIOS_H */ | |
75 | |
76 diff -ur texinfo-4.13.orig/info/terminal.c texinfo-4.13/info/terminal.c | |
77 --- texinfo-4.13.orig/info/terminal.c 2014-04-24 13:55:42.344917335 -0400 | |
78 +++ texinfo-4.13/info/terminal.c 2014-04-24 14:17:33.962456844 -0400 | |
79 @@ -572,7 +572,9 @@ | |
80 ospeed = B9600; | |
81 } | |
82 # else | |
83 +#ifndef __MINGW32__ | |
84 ospeed = B9600; | |
85 +#endif | |
86 # endif /* !TIOCGETP */ | |
87 #endif | |
88 | |
89 @@ -663,7 +665,9 @@ | |
90 /* Buffers containing the terminal mode flags upon entry to info. */ | |
91 int original_tty_flags = 0; | |
92 int original_lmode; | |
93 +#ifndef __MINGW32__ | |
94 struct sgttyb ttybuff; | |
95 +#endif | |
96 | |
97 # if defined(TIOCGETC) && defined(M_XENIX) | |
98 /* SCO 3.2v5.0.2 defines but does not support TIOCGETC. Gak. Maybe | |
99 @@ -758,7 +762,7 @@ | |
100 # endif | |
101 #endif | |
102 | |
103 -#if !defined (HAVE_TERMIOS_H) && !defined (HAVE_TERMIO_H) | |
104 +#if !defined (HAVE_TERMIOS_H) && !defined (HAVE_TERMIO_H) && !defined(__MINGW32__) | |
105 ioctl (tty, TIOCGETP, &ttybuff); | |
106 | |
107 if (!original_tty_flags) | |
108 @@ -818,10 +822,11 @@ | |
109 ioctl (tty, TIOCSLTC, &temp); | |
110 } | |
111 # endif /* TIOCGLTC */ | |
112 - | |
113 +#ifndef __MINGW32__ | |
114 ttybuff.sg_flags &= ~ECHO; | |
115 ttybuff.sg_flags |= CBREAK; | |
116 ioctl (tty, TIOCSETN, &ttybuff); | |
117 +#endif | |
118 #endif /* !HAVE_TERMIOS_H && !HAVE_TERMIO_H */ | |
119 } | |
120 | |
121 @@ -846,9 +851,11 @@ | |
122 # if defined (HAVE_TERMIO_H) | |
123 ioctl (tty, TCSETA, &original_termio); | |
124 # else /* !HAVE_TERMIO_H */ | |
125 +#ifndef __MINGW32__ | |
126 ioctl (tty, TIOCGETP, &ttybuff); | |
127 ttybuff.sg_flags = original_tty_flags; | |
128 ioctl (tty, TIOCSETN, &ttybuff); | |
129 +#endif | |
130 | |
131 # if defined (TIOCGETC) | |
132 ioctl (tty, TIOCSETC, &original_tchars); | |
133 @@ -867,6 +874,6 @@ | |
134 terminal_end_using_terminal (); | |
135 } | |
136 | |
137 -#ifdef __MSDOS__ | |
138 +#if defined(__MSDOS__) || defined(__MINGW32__) | |
139 # include "pcterm.c" | |
140 #endif | |
141 diff -ur texinfo-4.13.orig/info/pcterm.c texinfo-4.13/info/pcterm.c | |
142 --- texinfo-4.13.orig/info/pcterm.c 2014-04-24 14:19:51.514087212 -0400 | |
143 +++ texinfo-4.13/info/pcterm.c 2014-04-24 14:42:21.295014635 -0400 | |
144 @@ -24,6 +24,7 @@ | |
145 | |
146 /* intl/libintl.h defines a macro `gettext' which | |
147 conflicts with conio.h header. */ | |
148 +#ifdef __MSDOS__ | |
149 #ifdef gettext | |
150 # undef gettext | |
151 # define gettext _gettext | |
152 @@ -32,6 +33,42 @@ | |
153 #include <pc.h> | |
154 #include <keys.h> | |
155 #include <conio.h> | |
156 +#endif | |
157 + | |
158 +#ifdef _WIN32 | |
159 +#include <io.h> | |
160 +#include <conio.h> | |
161 +#include <process.h> | |
162 +#include <windows.h> | |
163 + | |
164 +struct text_info { | |
165 + WORD normattr; | |
166 + WORD attribute; | |
167 + SHORT winleft; | |
168 + SHORT wintop; | |
169 + SHORT winright; | |
170 + SHORT winbottom; | |
171 + SHORT screenheight; | |
172 + SHORT screenwidth; | |
173 + SHORT curx; | |
174 + SHORT cury; | |
175 + COORD bufsize; | |
176 + unsigned char currmode; /* unused and unsupported for Windows */ | |
177 +}; | |
178 + | |
179 +struct termios { | |
180 + int dummy; | |
181 +}; | |
182 + | |
183 +enum text_modes { LASTMODE=-1 }; | |
184 + | |
185 +#define cprintf _cprintf | |
186 +#define cputs _cputs | |
187 + | |
188 +#undef read | |
189 +#undef _read | |
190 + | |
191 +#endif | |
192 | |
193 #include "variables.h" | |
194 | |
195 @@ -44,10 +81,511 @@ | |
196 /* **************************************************************** */ | |
197 | |
198 static struct text_info outside_info; /* holds screen params outside Info */ | |
199 +#ifdef _WIN32 | |
200 +static SHORT norm_attr, inv_attr; | |
201 +static SHORT current_attr; | |
202 +static HANDLE hstdin = INVALID_HANDLE_VALUE; | |
203 +static HANDLE hstdout = INVALID_HANDLE_VALUE; | |
204 +static HANDLE hinfo = INVALID_HANDLE_VALUE; | |
205 +static HANDLE hscreen = INVALID_HANDLE_VALUE; | |
206 +static DWORD old_inpmode; | |
207 +#else | |
208 static unsigned char norm_attr, inv_attr; | |
209 - | |
210 +#endif | |
211 static unsigned const char * find_sequence (int); | |
212 | |
213 +#ifdef _WIN32 | |
214 + | |
215 +/* Windows-specific initialization and de-initialization. */ | |
216 +void | |
217 +w32_info_prep (void) | |
218 +{ | |
219 + SetConsoleActiveScreenBuffer (hinfo); | |
220 + current_attr = norm_attr; | |
221 + hscreen = hinfo; | |
222 + SetConsoleMode (hstdin, ENABLE_WINDOW_INPUT); | |
223 +} | |
224 + | |
225 +void | |
226 +w32_info_unprep (void) | |
227 +{ | |
228 + SetConsoleActiveScreenBuffer (hstdout); | |
229 + current_attr = outside_info.normattr; | |
230 + hscreen = hstdout; | |
231 + SetConsoleMode (hstdin, old_inpmode); | |
232 +} | |
233 + | |
234 +void | |
235 +w32_cleanup (void) | |
236 +{ | |
237 + CloseHandle (hinfo); | |
238 +} | |
239 + | |
240 +static void w32_info_init (void) __attribute__((constructor)); | |
241 +static void pc_initialize_terminal (char *); | |
242 + | |
243 +static void | |
244 +w32_info_init (void) | |
245 +{ | |
246 + /* We need to set this single hook here; the rest | |
247 + * will be set by pc_initialize_terminal when it is called. */ | |
248 + terminal_initialize_terminal_hook = pc_initialize_terminal; | |
249 +} | |
250 + | |
251 +/* Emulate DJGPP conio functions for Windows. */ | |
252 +static void | |
253 +gettextinfo (struct text_info *ti) | |
254 +{ | |
255 + CONSOLE_SCREEN_BUFFER_INFO csbi; | |
256 + static TCHAR errbuf[500]; | |
257 + | |
258 + hstdin = GetStdHandle (STD_INPUT_HANDLE); | |
259 + hstdout = GetStdHandle (STD_OUTPUT_HANDLE); | |
260 + hinfo = CreateConsoleScreenBuffer (GENERIC_READ | GENERIC_WRITE, | |
261 + FILE_SHARE_READ | FILE_SHARE_WRITE, | |
262 + NULL, CONSOLE_TEXTMODE_BUFFER, NULL); | |
263 + | |
264 + if (hstdin != INVALID_HANDLE_VALUE | |
265 + && hstdout != INVALID_HANDLE_VALUE | |
266 + && hinfo != INVALID_HANDLE_VALUE | |
267 + && GetConsoleMode (hstdin, &old_inpmode) | |
268 + && GetConsoleScreenBufferInfo (hstdout, &csbi)) | |
269 + { | |
270 + ti->normattr = csbi.wAttributes; | |
271 + ti->winleft = 1; | |
272 + ti->wintop = 1; | |
273 + ti->winright = csbi.srWindow.Right + 1; | |
274 + ti->winbottom = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; | |
275 + ti->attribute = csbi.wAttributes; | |
276 + ti->screenheight = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; | |
277 + ti->screenwidth = csbi.srWindow.Right - csbi.srWindow.Left + 1; | |
278 + ti->curx = csbi.dwCursorPosition.X; | |
279 + ti->cury = csbi.dwCursorPosition.Y; | |
280 + ti->bufsize = csbi.dwSize; | |
281 + | |
282 + | |
283 + atexit (w32_cleanup); | |
284 + } | |
285 + else | |
286 + { | |
287 + DWORD error_no = GetLastError (); | |
288 + | |
289 + if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, | |
290 + error_no, | |
291 + 0, /* choose most suitable language */ | |
292 + errbuf, sizeof (errbuf), NULL)) | |
293 + sprintf (errbuf, "w32 error %u", error_no); | |
294 + CloseHandle (hinfo); | |
295 + info_error (_("Terminal cannot be initialized: %s\n"), errbuf, NULL); | |
296 + exit (1); | |
297 + } | |
298 +} | |
299 + | |
300 +void | |
301 +textattr (int attr) | |
302 +{ | |
303 + SetConsoleTextAttribute (hscreen, attr); | |
304 +} | |
305 + | |
306 +void | |
307 +textmode (int mode) | |
308 +{ | |
309 + /* Nothing. */ | |
310 +} | |
311 + | |
312 +void | |
313 +ScreenGetCursor (int *row, int *col) | |
314 +{ | |
315 + CONSOLE_SCREEN_BUFFER_INFO csbi; | |
316 + | |
317 + GetConsoleScreenBufferInfo (hscreen, &csbi); | |
318 + *row = csbi.dwCursorPosition.Y; | |
319 + *col = csbi.dwCursorPosition.X; | |
320 +} | |
321 + | |
322 +void | |
323 +ScreenSetCursor (int row, int col) | |
324 +{ | |
325 + COORD cursor_pos; | |
326 + | |
327 + cursor_pos.X = col; | |
328 + cursor_pos.Y = row; | |
329 + | |
330 + SetConsoleCursorPosition (hscreen, cursor_pos); | |
331 +} | |
332 + | |
333 +void | |
334 +ScreenClear (void) | |
335 +{ | |
336 + DWORD nchars = screenwidth * screenheight; | |
337 + COORD start_pos; | |
338 + DWORD written; | |
339 + | |
340 + start_pos.X = start_pos.Y = 0; | |
341 + FillConsoleOutputAttribute (hscreen, norm_attr, nchars, start_pos, &written); | |
342 + FillConsoleOutputCharacter (hscreen, ' ', nchars, start_pos, &written); | |
343 +} | |
344 +void | |
345 +clreol (void) | |
346 +{ | |
347 + DWORD nchars; | |
348 + COORD start_pos; | |
349 + DWORD written; | |
350 + CONSOLE_SCREEN_BUFFER_INFO csbi; | |
351 + | |
352 + GetConsoleScreenBufferInfo (hscreen, &csbi); | |
353 + start_pos = csbi.dwCursorPosition; | |
354 + nchars = csbi.dwSize.X - start_pos.X; | |
355 + | |
356 + FillConsoleOutputAttribute (hscreen, current_attr, nchars, start_pos, | |
357 + &written); | |
358 + FillConsoleOutputCharacter (hscreen, ' ', nchars, start_pos, &written); | |
359 +} | |
360 + | |
361 +void | |
362 +ScreenVisualBell (void) | |
363 +{ | |
364 + DWORD nchars = screenwidth * screenheight; | |
365 + COORD start_pos; | |
366 + DWORD written; | |
367 + | |
368 + start_pos.X = start_pos.Y = 0; | |
369 + FillConsoleOutputAttribute (hscreen, inv_attr, nchars, start_pos, &written); | |
370 + Sleep (20); | |
371 + FillConsoleOutputAttribute (hscreen, norm_attr, nchars, start_pos, &written); | |
372 +} | |
373 + | |
374 +int | |
375 +movetext(int left, int top, int right, int bottom, int destleft, int desttop) | |
376 +{ | |
377 + SMALL_RECT src; | |
378 + COORD dest; | |
379 + CHAR_INFO fill; | |
380 + | |
381 + src.Left = left - 1; | |
382 + src.Top = top - 1; | |
383 + src.Right = right - 1; | |
384 + src.Bottom = bottom - 1; | |
385 + | |
386 + dest.X = destleft - 1; | |
387 + dest.Y = desttop - 1; | |
388 + | |
389 + fill.Attributes = norm_attr; | |
390 + fill.Char.AsciiChar = (CHAR)' '; | |
391 + | |
392 + return ScrollConsoleScreenBuffer (hscreen, &src , NULL, dest, &fill) != 0; | |
393 +} | |
394 + | |
395 +int | |
396 +ScreenRows (void) | |
397 +{ | |
398 + CONSOLE_SCREEN_BUFFER_INFO csbi; | |
399 + | |
400 + GetConsoleScreenBufferInfo (hscreen, &csbi); | |
401 + return csbi.srWindow.Bottom - csbi.srWindow.Top + 1; | |
402 +} | |
403 +int | |
404 +ScreenCols (void) | |
405 +{ | |
406 + CONSOLE_SCREEN_BUFFER_INFO csbi; | |
407 + | |
408 + GetConsoleScreenBufferInfo (hscreen, &csbi); | |
409 + return csbi.srWindow.Right - csbi.srWindow.Left + 1; | |
410 +} | |
411 + | |
412 +void | |
413 +_set_screen_lines (int lines) | |
414 +{ | |
415 + SMALL_RECT window_rectangle; | |
416 + CONSOLE_SCREEN_BUFFER_INFO csbi; | |
417 + COORD scrbufsize; | |
418 + | |
419 + GetConsoleScreenBufferInfo (hscreen, &csbi); | |
420 + | |
421 + window_rectangle = csbi.srWindow; | |
422 + window_rectangle.Bottom = window_rectangle.Top + lines - 1; | |
423 + SetConsoleWindowInfo (hscreen, TRUE, &window_rectangle); | |
424 + | |
425 + /* Set the screen buffer size to the same dimensions as the window, | |
426 + * so that the dysfunctional scroll bar disappears. */ | |
427 + scrbufsize.X = window_rectangle.Right - window_rectangle.Left + 1; | |
428 + scrbufsize.Y = window_rectangle.Bottom - window_rectangle.Top + 1; | |
429 + SetConsoleScreenBufferSize (hscreen, scrbufsize); | |
430 +} | |
431 + | |
432 +void | |
433 +w32_set_screen_dimensions (int cols, int rows) | |
434 +{ | |
435 + SMALL_RECT window_rectangle; | |
436 + CONSOLE_SCREEN_BUFFER_INFO csbi; | |
437 + | |
438 + GetConsoleScreenBufferInfo (hscreen, &csbi); | |
439 + | |
440 + window_rectangle = csbi.srWindow; | |
441 + window_rectangle.Bottom = window_rectangle.Top + rows - 1; | |
442 + window_rectangle.Right = window_rectangle.Left + cols - 1; | |
443 + SetConsoleWindowInfo (hscreen, TRUE, &window_rectangle); | |
444 +} | |
445 + | |
446 +/* Emulate `sleep'. */ | |
447 +unsigned | |
448 +sleep (unsigned sec) | |
449 +{ | |
450 + Sleep (sec*1000); | |
451 + return 0; | |
452 +} | |
453 + | |
454 +/* Keyboard input support. */ | |
455 + | |
456 +static int | |
457 +w32_our_tty (int fd) | |
458 +{ | |
459 + return | |
460 + isatty (fd) | |
461 + /* Windows `isatty' actually tests for character devices, so the | |
462 + null device gets reported as a tty. Fix that by calling | |
463 + `lseek'. */ | |
464 + && lseek (fd, SEEK_CUR, 0) == -1 | |
465 + /* Is this our tty? */ | |
466 + && hstdin != INVALID_HANDLE_VALUE | |
467 + && hstdin == (HANDLE)_get_osfhandle (fd); | |
468 +} | |
469 + | |
470 +/* Translate a Windows key event into the equivalent sequence of bytes | |
471 + to be submitted to Info dispatcher. */ | |
472 +#define define_seq(p,s1,s2) \ | |
473 + do { \ | |
474 + if ((ctl & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0) \ | |
475 + memcpy (p, s1, sizeof (s1)), p += sizeof (s1) - 1; \ | |
476 + else \ | |
477 + memcpy (p, s2, sizeof (s2)), p += sizeof (s2) - 1; \ | |
478 + } while (0) | |
479 + | |
480 +static int | |
481 +w32keyseq (unsigned char ascii_ch, WORD vkey, DWORD ctl, unsigned char *seq) | |
482 +{ | |
483 + unsigned char *p = seq; | |
484 + | |
485 + switch (ascii_ch) | |
486 + { | |
487 + case '\0': | |
488 + /* Keys with no ASCII code are extended keys, like arrows. */ | |
489 + switch (vkey) | |
490 + { | |
491 + case VK_PRIOR: | |
492 + define_seq (p, "\033\061p", "\033v"); | |
493 + break; | |
494 + case VK_NEXT: | |
495 + define_seq (p, "\033\061n", "\026"); | |
496 + break; | |
497 + case VK_END: | |
498 + define_seq (p, "\033>", "\033>"); | |
499 + break; | |
500 + case VK_HOME: | |
501 + define_seq (p, "\033<", "\033<"); | |
502 + break; | |
503 + case VK_LEFT: | |
504 + define_seq (p, "\033b", "\033[D"); | |
505 + break; | |
506 + case VK_UP: | |
507 + define_seq (p, "\033\061u", "\033[A"); | |
508 + break; | |
509 + case VK_RIGHT: | |
510 + define_seq (p, "\033f", "\033[C"); | |
511 + break; | |
512 + case VK_DOWN: | |
513 + define_seq (p, "\033\061m", "\033[B"); | |
514 + break; | |
515 + case VK_INSERT: | |
516 + define_seq (p, "\033[L", "\033[L"); | |
517 + break; | |
518 + case VK_DELETE: /* Delete => Ctrl-d, Alt-Delete => ESC d */ | |
519 + if ((ctl & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) != 0) | |
520 + define_seq (p, "\033d", "\033d"); | |
521 + else | |
522 + define_seq (p, "\033d", "\004"); | |
523 + break; | |
524 + case VK_F1: | |
525 + *p++ = '\010'; | |
526 + break; | |
527 + case 50: /* Ctrl-@ => '\0' */ | |
528 + if ((ctl & SHIFT_PRESSED) != 0) | |
529 + *p++ = '\0'; | |
530 + break; | |
531 + default: | |
532 + if (0x41 <= vkey && vkey <= 0x5a) | |
533 + { | |
534 + /* Alt-Ctrl-a, Alt-Ctrl-b, etc. */ | |
535 + *p++ = '\033'; | |
536 + *p++ = '\001' + vkey - 0x41; | |
537 + } | |
538 + } | |
539 + break; | |
540 + case ' ': /* Ctrl-SPC => '\0' */ | |
541 + if ((ctl & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0) | |
542 + ascii_ch = '\0'; | |
543 + *p++ = ascii_ch; | |
544 + break; | |
545 + case '\t': /* Shift-TAB/Alt-TAB => Esc-TAB */ | |
546 + if ((ctl & (SHIFT_PRESSED | LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) != 0) | |
547 + { | |
548 + memcpy (p, "\033\011", sizeof ("\033\011")); | |
549 + p += sizeof ("\033\011") - 1; | |
550 + } | |
551 + else | |
552 + *p++ = '\t'; | |
553 + break; | |
554 + case '\b': | |
555 + /* Backspace => DEL. */ | |
556 + ascii_ch = '\177'; | |
557 + /* FALLTHROUGH */ | |
558 + default: | |
559 + if ((ctl & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) != 0) | |
560 + *p++ = '\033'; | |
561 + *p++ = ascii_ch; | |
562 + break; | |
563 + } | |
564 + return p - seq; | |
565 +} | |
566 + | |
567 +static unsigned char buffered_chars[512]; | |
568 +static size_t buf_head; | |
569 +static size_t buf_tail; | |
570 + | |
571 +static ssize_t | |
572 +w32_kbd_read (unsigned char *inbuf, size_t n) | |
573 +{ | |
574 + DWORD nevents, nread; | |
575 + INPUT_RECORD inrec; | |
576 + ssize_t nret = 0; | |
577 + | |
578 + do { | |
579 + | |
580 + /* Stuff any unread buffered characters. */ | |
581 + while (buf_head < buf_tail && n > 0) | |
582 + { | |
583 + *inbuf++ = buffered_chars[buf_head++]; | |
584 + nret++; | |
585 + n--; | |
586 + } | |
587 + if (n <= 0) | |
588 + break; | |
589 + | |
590 + /* Wait for input. */ | |
591 + while (GetNumberOfConsoleInputEvents (hstdin, &nevents) | |
592 + && nevents < 1) | |
593 + Sleep (20); | |
594 + | |
595 + while (nevents-- && n > 0) | |
596 + { | |
597 + if (!ReadConsoleInput (hstdin, &inrec, 1, &nread)) | |
598 + return -1; | |
599 + | |
600 + if (nread > 0) | |
601 + { | |
602 + switch (inrec.EventType) | |
603 + { | |
604 + case KEY_EVENT: | |
605 + if (inrec.Event.KeyEvent.bKeyDown == TRUE | |
606 + && !(inrec.Event.KeyEvent.wVirtualScanCode == 0 | |
607 + || inrec.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT | |
608 + || inrec.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL | |
609 + || inrec.Event.KeyEvent.wVirtualKeyCode == VK_MENU)) | |
610 + { | |
611 + unsigned char keyseq[10]; | |
612 + int count = inrec.Event.KeyEvent.wRepeatCount; | |
613 + unsigned char ch = inrec.Event.KeyEvent.uChar.AsciiChar; | |
614 + WORD vkey = inrec.Event.KeyEvent.wVirtualKeyCode; | |
615 + DWORD ctl_state = inrec.Event.KeyEvent.dwControlKeyState; | |
616 + int nbytes = w32keyseq (ch, vkey, ctl_state, keyseq); | |
617 + | |
618 + /* Supply up to N characters to the caller. */ | |
619 + while (count && n >= nbytes) | |
620 + { | |
621 + if (nbytes == 1 && keyseq[0] == '\032') | |
622 + { | |
623 + terminal_goto_xy (0, screenheight - 1); | |
624 + terminal_clear_to_eol (); | |
625 + fflush (stdout); | |
626 + terminal_unprep_terminal (); | |
627 + kill (getpid (), 0); | |
628 + terminal_prep_terminal (); | |
629 + reset_info_window_sizes (); | |
630 + } | |
631 + else | |
632 + { | |
633 + memcpy (&inbuf[nret], keyseq, nbytes); | |
634 + nret += nbytes; | |
635 + n -= nbytes; | |
636 + } | |
637 + count--; | |
638 + } | |
639 + /* Buffer the rest. */ | |
640 + if (count > 0) | |
641 + { | |
642 + buf_head = buf_tail = 0; | |
643 + while (count-- | |
644 + && buf_tail < sizeof(buffered_chars) - nbytes) | |
645 + { | |
646 + memcpy (&buffered_chars[buf_tail], keyseq, nbytes); | |
647 + buf_tail += nbytes; | |
648 + } | |
649 + } | |
650 + } | |
651 + break; | |
652 + case WINDOW_BUFFER_SIZE_EVENT: | |
653 + { | |
654 + int rows, cols; | |
655 + | |
656 + /* Note: this event is only sent when the console | |
657 + window's _screen_buffer_ size is changed via | |
658 + the Properties->Layout dialog. */ | |
659 + cols = inrec.Event.WindowBufferSizeEvent.dwSize.X; | |
660 + rows = inrec.Event.WindowBufferSizeEvent.dwSize.Y; | |
661 + screenwidth = cols; | |
662 + screenheight = rows; | |
663 + w32_set_screen_dimensions (cols, rows); | |
664 + display_initialize_display (screenwidth, screenheight); | |
665 + window_new_screen_size (screenwidth, screenheight); | |
666 + redisplay_after_signal (); | |
667 + } | |
668 + break; | |
669 + default: | |
670 + break; | |
671 + } | |
672 + } | |
673 + } | |
674 + } while (n > 0); | |
675 + return nret; | |
676 +} | |
677 +long | |
678 +w32_chars_avail (int fd) | |
679 +{ | |
680 + if (w32_our_tty (fd)) | |
681 + return buf_tail - buf_head; | |
682 + else | |
683 + { | |
684 + struct stat st; | |
685 + | |
686 + if (fstat (fd, &st) < 0) | |
687 + return 1; | |
688 + else | |
689 + return st.st_size; | |
690 + } | |
691 +} | |
692 + | |
693 +ssize_t | |
694 +w32_read (int fd, void *buf, size_t n) | |
695 +{ | |
696 + if (w32_our_tty (fd)) | |
697 + return w32_kbd_read (buf, n); | |
698 + else | |
699 + return _read (fd, buf, n); | |
700 +} | |
701 + | |
702 +#endif /* _WIN32 */ | |
703 + | |
704 + | |
705 /* Turn on reverse video. */ | |
706 static void | |
707 pc_begin_inverse (void) | |
708 @@ -192,6 +730,11 @@ | |
709 { | |
710 int tty; | |
711 | |
712 +#ifdef _WIN32 | |
713 + w32_info_prep (); | |
714 +#endif | |
715 + | |
716 + | |
717 /* Do not set screen height if we already have it, because | |
718 doing so erases the screen. */ | |
719 if (screenheight != ScreenRows ()) | |
720 @@ -221,6 +764,11 @@ | |
721 { | |
722 int tty; | |
723 | |
724 +#ifdef _WIN32 | |
725 + w32_info_unprep (); | |
726 +#endif | |
727 + | |
728 + | |
729 textattr (outside_info.normattr); | |
730 | |
731 /* Do not set screen height if we already have it, because | |
732 @@ -230,8 +778,14 @@ | |
733 _set_screen_lines (outside_info.screenheight); | |
734 textmode (LASTMODE); | |
735 } | |
736 +#ifdef __MSDOS__ | |
737 else | |
738 pc_clear_to_eol (); /* for text attributes to really take effect */ | |
739 +#endif | |
740 +#ifdef _WIN32 | |
741 + SetConsoleScreenBufferSize (hstdout, outside_info.bufsize); | |
742 +#endif | |
743 + | |
744 | |
745 /* Switch back to text mode on stdin. */ | |
746 tty = fileno (stdin); | |
747 @@ -256,7 +810,12 @@ | |
748 { | |
749 term_name = getenv ("TERM"); | |
750 if (!term_name) | |
751 +#ifdef __MSDOS__ | |
752 term_name = "pc-dos"; /* ``what's in a name?'' */ | |
753 +#endif | |
754 +#ifdef _WIN32 | |
755 + term_name = "w32console"; | |
756 +#endif | |
757 } | |
758 | |
759 /* Get current video information, to be restored later. */ | |
760 @@ -310,7 +869,7 @@ | |
761 terminal_is_dumb_p = 0; | |
762 | |
763 pc_get_screen_size (); | |
764 - | |
765 +#ifdef __MSDOS__ | |
766 /* Store the arrow keys. */ | |
767 term_ku = (char *)find_sequence (K_Up); | |
768 term_kd = (char *)find_sequence (K_Down); | |
769 @@ -326,6 +885,7 @@ | |
770 term_ki = (char *)find_sequence (K_Insert); | |
771 term_kx = (char *)find_sequence (K_Delete); | |
772 #endif | |
773 +#endif | |
774 | |
775 /* Set all the hooks to our PC-specific functions. */ | |
776 terminal_begin_inverse_hook = pc_begin_inverse; | |
777 @@ -687,10 +1247,11 @@ | |
778 xexit (1); | |
779 case SIGUSR1: | |
780 /* Simulate SIGTSTP by invoking a subsidiary shell. */ | |
781 +#ifndef _WIN32 | |
782 pc_goto_xy (0, outside_info.screenheight - 1); | |
783 pc_clear_to_eol (); | |
784 pc_write_chars (stopped_msg, sizeof (stopped_msg) - 1); | |
785 - | |
786 +#endif | |
787 /* The child shell can change the working directory, so | |
788 we need to save and restore it, since it is global. */ | |
789 if (!getcwd (cwd, PATH_MAX)) /* should never happen */ | |
790 @@ -699,7 +1260,26 @@ | |
791 /* We don't want to get fatal signals while the subshell runs. */ | |
792 old_INT = signal (SIGINT, SIG_IGN); | |
793 old_QUIT = signal (SIGQUIT, SIG_IGN); | |
794 +#ifdef _WIN32 | |
795 + { | |
796 + const char *argv[2]; | |
797 + const char *shell = NULL; | |
798 + | |
799 + argv[0] = NULL; | |
800 + shell = getenv ("SHELL"); | |
801 + if (!shell) | |
802 + { | |
803 + shell = getenv ("COMSPEC"); | |
804 + if (!shell) | |
805 + return -1; | |
806 + argv[0] = " /k"; | |
807 + } | |
808 + argv[1] = NULL; | |
809 + _spawnvp (_P_WAIT, shell, argv); | |
810 + } | |
811 +#else | |
812 system (""); | |
813 +#endif | |
814 if (*cwd) | |
815 chdir (cwd); | |
816 signal (SIGINT, old_INT); | |
817 @@ -758,3 +1338,4 @@ | |
818 perror ("tcsetattr"); return 0; | |
819 } | |
820 #endif | |
821 + | |
822 diff -ur texinfo-4.13.orig/info/tilde.c texinfo-4.13/info/tilde.c | |
823 --- texinfo-4.13.orig/info/tilde.c 2014-04-24 14:52:47.757094645 -0400 | |
824 +++ texinfo-4.13/info/tilde.c 2014-04-24 14:58:38.949450825 -0400 | |
825 @@ -190,11 +190,15 @@ | |
826 the password database. */ | |
827 if (!temp_home) | |
828 { | |
829 +#ifndef __MINGW32__ | |
830 struct passwd *entry; | |
831 | |
832 entry = (struct passwd *) getpwuid (getuid ()); | |
833 if (entry) | |
834 temp_home = entry->pw_dir; | |
835 +#else | |
836 + temp_home = "."; | |
837 +#endif | |
838 } | |
839 | |
840 temp_name = xmalloc (1 + strlen (&dirname[1]) | |
841 @@ -210,7 +214,9 @@ | |
842 } | |
843 else | |
844 { | |
845 +#ifndef __MINGW32__ | |
846 struct passwd *user_entry; | |
847 +#endif | |
848 char *username = xmalloc (257); | |
849 int i, c; | |
850 | |
851 @@ -222,7 +228,7 @@ | |
852 username[i - 1] = c; | |
853 } | |
854 username[i - 1] = 0; | |
855 - | |
856 +#ifndef __MINGW32__ | |
857 if (!(user_entry = (struct passwd *) getpwnam (username))) | |
858 { | |
859 /* If the calling program has a special syntax for | |
860 @@ -259,6 +265,24 @@ | |
861 | |
862 endpwent (); | |
863 free (username); | |
864 +#else | |
865 + if (tilde_expansion_failure_hook) | |
866 + { | |
867 + char *expansion = (*tilde_expansion_failure_hook) (username); | |
868 + | |
869 + if (expansion) | |
870 + { | |
871 + temp_name = xmalloc (1 + strlen (expansion) | |
872 + + strlen (&dirname[i])); | |
873 + strcpy (temp_name, expansion); | |
874 + strcat (temp_name, &dirname[i]); | |
875 + free (expansion); | |
876 + } | |
877 + } | |
878 + free (dirname); | |
879 + dirname = xstrdup (temp_name); | |
880 + free (temp_name); | |
881 +#endif | |
882 } | |
883 } | |
884 return dirname; | |
885 diff -ur texinfo-4.13.orig/info/info.c texinfo-4.13/info/info.c | |
886 --- texinfo-4.13.orig/info/info.c 2014-04-24 15:00:00.165123612 -0400 | |
887 +++ texinfo-4.13/info/info.c 2014-04-24 15:07:10.262443440 -0400 | |
888 @@ -82,7 +82,7 @@ | |
889 /* Non-zero means print the absolute location of the file to be loaded. */ | |
890 static int print_where_p = 0; | |
891 | |
892 -#ifdef __MSDOS__ | |
893 +#if defined(__MSDOS__) || defined(__MINGW32__) | |
894 /* Non-zero indicates that screen output should be made 'speech-friendly'. | |
895 Since on MSDOS the usual behavior is to write directly to the video | |
896 memory, speech synthesizer software cannot grab the output. Therefore, | |
897 @@ -118,14 +118,14 @@ | |
898 { "version", 0, &print_version_p, 1 }, | |
899 { "vi-keys", 0, &vi_keys_p, 1 }, | |
900 { "where", 0, &print_where_p, 1 }, | |
901 -#ifdef __MSDOS__ | |
902 +#if defined(__MSDOS__) || defined(__MINGW32__) | |
903 { "speech-friendly", 0, &speech_friendly, 1 }, | |
904 #endif | |
905 {NULL, 0, NULL, 0} | |
906 }; | |
907 | |
908 /* String describing the shorthand versions of the long options found above. */ | |
909 -#ifdef __MSDOS__ | |
910 +#if defined(__MSDOS__) || defined(__MINGW32__) | |
911 static char *short_options = "k:d:n:f:ho:ORswb"; | |
912 #else | |
913 static char *short_options = "k:d:n:f:ho:ORws"; | |
914 @@ -239,7 +239,7 @@ | |
915 print_where_p = 1; | |
916 break; | |
917 | |
918 -#ifdef __MSDOS__ | |
919 +#if defined(__MSDOS__) || defined(__MINGW32__) | |
920 /* User wants speech-friendly output. */ | |
921 case 'b': | |
922 speech_friendly = 1; | |
923 @@ -621,8 +621,7 @@ | |
924 --no-raw-escapes output escapes as literal text.\n\ | |
925 --restore=FILENAME read initial keystrokes from FILENAME.\n\ | |
926 -O, --show-options, --usage go to command-line options node.")); | |
927 - | |
928 -#ifdef __MSDOS__ | |
929 +#if defined(__MSDOS__) || defined(__MINGW32__) | |
930 puts (_("\ | |
931 -b, --speech-friendly be friendly to speech synthesizers.")); | |
932 #endif | |
933 diff -ur texinfo-4.13.orig/info/signals.c texinfo-4.13/info/signals.c | |
934 --- texinfo-4.13.orig/info/signals.c 2014-04-24 15:00:00.164123591 -0400 | |
935 +++ texinfo-4.13/info/signals.c 2014-04-24 15:13:26.706132612 -0400 | |
936 @@ -151,7 +151,7 @@ | |
937 #endif | |
938 } | |
939 | |
940 -static void | |
941 +void | |
942 redisplay_after_signal (void) | |
943 { | |
944 terminal_clear_screen (); | |
945 @@ -162,7 +162,7 @@ | |
946 fflush (stdout); | |
947 } | |
948 | |
949 -static void | |
950 +void | |
951 reset_info_window_sizes (void) | |
952 { | |
953 terminal_goto_xy (0, 0); | |
3609
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
954 diff -ur texinfo-4.13.orig/info/terminal.c texinfo-4.13/info/terminal.c |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
955 --- texinfo-4.13.orig/info/terminal.c 2014-06-09 00:27:32 -0400 |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
956 +++ texinfo-4.13/info/terminal.c 2014-06-09 00:33:37 -0400 |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
957 @@ -47,6 +47,10 @@ |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
958 #endif /* not HAVE_TERMCAP_H */ |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
959 #endif /* not HAVE_NCURSES_TERMCAP_H */ |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
960 |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
961 +#if defined(__MSDOS__) || defined(__MINGW32__) |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
962 + unsigned int sleep(unsigned int); |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
963 +#endif |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
964 + |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
965 /* Function "hooks". If you make one of these point to a function, that |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
966 function is called when appropriate instead of its namesake. Your |
360eff7d9c06
texinfo: compile native info when native target.
John Donoghue
parents:
3587
diff
changeset
|
967 function is called with exactly the same arguments that were passed |