[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: texinfo-4.13.90 pretest available
From: |
Eli Zaretskii |
Subject: |
Re: texinfo-4.13.90 pretest available |
Date: |
Sat, 17 Nov 2012 16:12:03 +0200 |
> Date: Sat, 17 Nov 2012 13:54:31 +0200
> From: Sergey Poznyakoff <address@hidden>
> Fcc: +sent-messages,
>
> Patrice Dumas <address@hidden> ha escrit:
>
> > I guess Sergey missed it.
>
> Yes, I missed it indeed. Thanks for reminding, I'll get back to it
> after fixing the "image" stuff.
Thanks. To facilitate, I attach below an updated patch, relative to
4.13.90 sources.
Here's an explanation of a few additional changes I needed to build
this pretest with MinGW:
1. I got compilation warning in install-info.c:
gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../gnulib/lib -I../gnulib/lib
-DLOCALEDIR=\"d:/usr/share/locale\" -Id:/usr/include -g -O2 -MT install-info.o
-MD -MP -MF .deps/install-info.Tpo -c -o install-info.o install-info.c
install-info.c: In function `vdiag':
install-info.c:212: warning: passing arg 2 of `libintl_vfprintf' discards
qualifiers from pointer target type
This happens because system.h does this:
/* For gettext (NLS). */
#define const
#include "gettext.h"
#undef const
My solution: comment out the #define and #undef lines. Do we
really need such kludges in the year 2012? What platform needs
that?
2. Link in install-info fails:
gcc -g -O2 -o ginstall-info.exe install-info.o ../gnulib/lib/libgnu.a
d:/usr/lib/libintl.dll.a d:/usr/lib/libiconv.dll.a -Ld:/usr/lib
install-info.o(.text+0x2613): In function `main':
d:/gnu/texinfo-4.13.90/install-info/install-info.c:2197: undefined
reference to `_imp__regexec'
install-info.o(.text+0x27c0):d:/gnu/texinfo-4.13.90/install-info/install-info.c:2107:
undefined reference to `_imp__regcomp'
install-info.o(.text+0x27e8):d:/gnu/texinfo-4.13.90/install-info/install-info.c:2110:
undefined reference to `_imp__regerror'
install-info.o(.text+0x280e):d:/gnu/texinfo-4.13.90/install-info/install-info.c:2112:
undefined reference to `_imp__regerror'
collect2: ld returned 1 exit status
make[3]: *** [ginstall-info.exe] Error 1
This happens because configure does not probe for regex functions,
assuming they are in libc. My solution was to reconfigure using
LIBS=-lregex ./configure --build=i686-pc-mingw32 --prefix=d:/usr
However, I think the configure script should not make such
assumptions.
3. Compilation of info/session.c fails:
gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../gnulib/lib -I../gnulib/lib
-DLOCALEDIR=\"d:/usr/share/locale\" -DINFODIR=\"d:/usr/share/info\"
-DINFODIR2=\"d:/usr/share/info\" -Id:/usr/include -g -O2 -MT session.o -MD -MP
-MF .deps/session.Tpo -c -o session.o session.c
session.c: In function `info_gather_typeahead':
session.c:5410: error: `F_GETFL' undeclared (first use in this function)
session.c:5410: error: (Each undeclared identifier is reported only once
session.c:5410: error: for each function it appears in.)
session.c:5412: error: `F_SETFL' undeclared (first use in this function)
make[3]: *** [session.o] Error 1
This happens because gnulib/lib/fcntl.h defines O_NDELAY, but
F_GETFL is (of course) not supported by MinGW. Solution: change
# if defined (O_NDELAY)
into
# if defined (O_NDELAY) && defined (F_GETFL) && defined (F_SETFL)
4. I decided to modify definitions of tputs, tgoto, and tgetent on
pcterm.c and at the beginning of terminal.c to match what the
ncurses and other termcap headers say. This should avoid compiler
warnings and even errors when those headers are included.
5. Link of info/ginfo.exe fails:
terminal.o(.text+0x2bd): In function `gettextinfo':
d:/gnu/texinfo-4.13.90/info/pcterm.c:181: undefined reference to `xexit'
This is because xexit.c was removed from gnulib/lib since 4.13a.
Solution: use 'exit' instead.
Here's a cumulative patch:
diff -up -r texinfo-4.13.90.orig/info/dir.c texinfo-4.13.90/info/dir.c
--- texinfo-4.13.90.orig/info/dir.c 2009-01-24 10:27:56.000000000 +0200
+++ texinfo-4.13.90/info/dir.c 2012-11-17 13:39:18.828125000 +0200
@@ -40,7 +40,7 @@ static char *dirs_to_add[] = {
/* Return zero if the file represented in the stat structure TEST has
- already been seen, nonzero else. */
+ already been seen, nonzero otherwise. */
typedef struct
{
@@ -59,7 +59,10 @@ new_dir_file_p (struct stat *test)
{
dir_file_list_entry_type entry;
entry = dir_file_list[i];
- if (entry.device == test->st_dev && entry.inode == test->st_ino)
+ if (entry.device == test->st_dev && entry.inode == test->st_ino
+ /* On MS-Windows, `stat' returns zero as the inode, so we
+ effectively disable this optimization for that OS. */
+ && entry.inode != 0)
return 0;
}
diff -up -r texinfo-4.13.90.orig/info/info.c texinfo-4.13.90/info/info.c
--- texinfo-4.13.90.orig/info/info.c 2012-06-11 20:54:26.000000000 +0300
+++ texinfo-4.13.90/info/info.c 2012-11-17 13:39:18.875000000 +0200
@@ -86,7 +86,7 @@ static int print_where_p = 0;
/* Non-zero means don't try to be smart when searching for nodes. */
int strict_node_location_p = 0;
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
/* Non-zero indicates that screen output should be made 'speech-friendly'.
Since on MSDOS the usual behavior is to write directly to the video
memory, speech synthesizer software cannot grab the output. Therefore,
@@ -123,14 +123,14 @@ static struct option long_options[] = {
{ "version", 0, &print_version_p, 1 },
{ "vi-keys", 0, &vi_keys_p, 1 },
{ "where", 0, &print_where_p, 1 },
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
{ "speech-friendly", 0, &speech_friendly, 1 },
#endif
{NULL, 0, NULL, 0}
};
/* String describing the shorthand versions of the long options found above. */
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
static char *short_options = "k:d:n:f:ho:ORswb";
#else
static char *short_options = "k:d:n:f:ho:ORws";
@@ -244,12 +244,12 @@ main (int argc, char *argv[])
print_where_p = 1;
break;
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
/* User wants speech-friendly output. */
case 'b':
speech_friendly = 1;
break;
-#endif /* __MSDOS__ */
+#endif /* __MSDOS__ || _WIN32 */
/* User has specified a string to search all indices for. */
case 'k':
@@ -648,7 +648,7 @@ Options:\n\
--restore=FILENAME read initial keystrokes from FILENAME.\n\
-O, --show-options, --usage go to command-line options node."));
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
puts (_("\
-b, --speech-friendly be friendly to speech synthesizers."));
#endif
diff -up -r texinfo-4.13.90.orig/info/infokey.c texinfo-4.13.90/info/infokey.c
--- texinfo-4.13.90.orig/info/infokey.c 2012-07-07 02:55:32.000000000 +0300
+++ texinfo-4.13.90/info/infokey.c 2012-11-17 13:39:18.875000000 +0200
@@ -177,7 +177,7 @@ There is NO WARRANTY, to the extent perm
char *homedir;
homedir = getenv ("HOME");
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
if (!homedir)
homedir = ".";
#endif
diff -up -r texinfo-4.13.90.orig/info/infomap.c texinfo-4.13.90/info/infomap.c
--- texinfo-4.13.90.orig/info/infomap.c 2012-04-21 03:38:04.000000000 +0300
+++ texinfo-4.13.90/info/infomap.c 2012-11-17 13:39:18.890625000 +0200
@@ -930,7 +930,7 @@ fetch_user_maps (void)
strcat(filename, "/");
strcat(filename, INFOKEY_FILE);
}
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
/* Poor baby, she doesn't have a HOME... */
else
filename = xstrdup(INFOKEY_FILE); /* try current directory */
diff -up -r texinfo-4.13.90.orig/info/man.c texinfo-4.13.90/info/man.c
--- texinfo-4.13.90.orig/info/man.c 2012-06-11 20:54:26.000000000 +0300
+++ texinfo-4.13.90/info/man.c 2012-11-17 13:39:18.890625000 +0200
@@ -20,7 +20,9 @@
Originally written by Brian Fox Thu May 4 09:17:52 1995. */
#include "info.h"
+#ifndef __MINGW32__
#include <sys/ioctl.h>
+#endif
#include "signals.h"
#if defined (HAVE_SYS_TIME_H)
#include <sys/time.h>
diff -up -r texinfo-4.13.90.orig/info/pcterm.c texinfo-4.13.90/info/pcterm.c
--- texinfo-4.13.90.orig/info/pcterm.c 2012-06-11 20:54:26.000000000 +0300
+++ texinfo-4.13.90/info/pcterm.c 2012-11-17 15:06:36.812500000 +0200
@@ -18,10 +18,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/* WARNING WARNING WARNING!!!
- This probably won't work as is with anything but DJGPP! However, Borland
- should come close, and other PC compilers will need minor modifications. */
+/* WARNING WARNING WARNING!!! This probably won't work as is with
+ anything but DJGPP and MinGW! However, Borland should come close,
+ and other PC compilers will need minor modifications. */
+#ifdef __MSDOS__
/* intl/libintl.h defines a macro `gettext' which
conflicts with conio.h header. */
#ifdef gettext
@@ -32,6 +33,42 @@
#include <pc.h>
#include <keys.h>
#include <conio.h>
+#endif
+
+#ifdef _WIN32
+#include <io.h>
+#include <conio.h>
+#include <process.h>
+#include <windows.h>
+
+struct text_info {
+ WORD normattr;
+ WORD attribute;
+ SHORT winleft;
+ SHORT wintop;
+ SHORT winright;
+ SHORT winbottom;
+ SHORT screenheight;
+ SHORT screenwidth;
+ SHORT curx;
+ SHORT cury;
+ COORD bufsize;
+ unsigned char currmode; /* unused and unsupported for Windows */
+};
+
+struct termios {
+ int dummy;
+};
+
+enum text_modes { LASTMODE=-1 };
+
+#define cprintf _cprintf
+#define cputs _cputs
+
+#undef read
+#undef _read
+
+#endif
#include "variables.h"
@@ -44,10 +81,515 @@ extern int speech_friendly; /* defined i
/* **************************************************************** */
static struct text_info outside_info; /* holds screen params outside Info */
+#ifdef _WIN32
+static SHORT norm_attr, inv_attr;
+static SHORT current_attr;
+static HANDLE hstdin = INVALID_HANDLE_VALUE;
+static HANDLE hstdout = INVALID_HANDLE_VALUE;
+static HANDLE hinfo = INVALID_HANDLE_VALUE;
+static HANDLE hscreen = INVALID_HANDLE_VALUE;
+static DWORD old_inpmode;
+#else
static unsigned char norm_attr, inv_attr;
+#endif
static unsigned const char * find_sequence (int);
+#ifdef _WIN32
+
+/* Windows-specific initialization and de-initialization. */
+void
+w32_info_prep (void)
+{
+ SetConsoleActiveScreenBuffer (hinfo);
+ current_attr = norm_attr;
+ hscreen = hinfo;
+ SetConsoleMode (hstdin, ENABLE_WINDOW_INPUT);
+}
+
+void
+w32_info_unprep (void)
+{
+ SetConsoleActiveScreenBuffer (hstdout);
+ current_attr = outside_info.normattr;
+ hscreen = hstdout;
+ SetConsoleMode (hstdin, old_inpmode);
+}
+
+void
+w32_cleanup (void)
+{
+ CloseHandle (hinfo);
+}
+
+static void w32_info_init (void) __attribute__((constructor));
+
+static void
+w32_info_init (void)
+{
+ static void pc_initialize_terminal (char *);
+
+ /* We need to set this single hook here; the rest
+ will be set by pc_initialize_terminal when it is called. */
+ terminal_initialize_terminal_hook = pc_initialize_terminal;
+}
+
+/* Emulate DJGPP conio functions for Windows. */
+static void
+gettextinfo (struct text_info *ti)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ static TCHAR errbuf[500];
+
+ hstdin = GetStdHandle (STD_INPUT_HANDLE);
+ hstdout = GetStdHandle (STD_OUTPUT_HANDLE);
+ hinfo = CreateConsoleScreenBuffer (GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
+
+ if (hstdin != INVALID_HANDLE_VALUE
+ && hstdout != INVALID_HANDLE_VALUE
+ && hinfo != INVALID_HANDLE_VALUE
+ && GetConsoleMode (hstdin, &old_inpmode)
+ && GetConsoleScreenBufferInfo (hstdout, &csbi))
+ {
+ ti->normattr = csbi.wAttributes;
+ ti->winleft = 1;
+ ti->wintop = 1;
+ ti->winright = csbi.srWindow.Right + 1;
+ ti->winbottom = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+ ti->attribute = csbi.wAttributes;
+ ti->screenheight = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+ ti->screenwidth = csbi.srWindow.Right - csbi.srWindow.Left + 1;
+ ti->curx = csbi.dwCursorPosition.X;
+ ti->cury = csbi.dwCursorPosition.Y;
+ ti->bufsize = csbi.dwSize;
+
+ atexit (w32_cleanup);
+ }
+ else
+ {
+ DWORD error_no = GetLastError ();
+
+ if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL,
+ error_no,
+ 0, /* choose most suitable language */
+ errbuf, sizeof (errbuf), NULL))
+ sprintf (errbuf, "w32 error %u", error_no);
+ CloseHandle (hinfo);
+ info_error (_("Terminal cannot be initialized: %s\n"), errbuf, NULL);
+ exit (1);
+ }
+}
+
+void
+textattr (int attr)
+{
+ SetConsoleTextAttribute (hscreen, attr);
+}
+
+void
+textmode (int mode)
+{
+ /* Nothing. */
+}
+
+void
+ScreenGetCursor (int *row, int *col)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ GetConsoleScreenBufferInfo (hscreen, &csbi);
+ *row = csbi.dwCursorPosition.Y;
+ *col = csbi.dwCursorPosition.X;
+}
+
+void
+ScreenSetCursor (int row, int col)
+{
+ COORD cursor_pos;
+
+ cursor_pos.X = col;
+ cursor_pos.Y = row;
+
+ SetConsoleCursorPosition (hscreen, cursor_pos);
+}
+
+void
+ScreenClear (void)
+{
+ DWORD nchars = screenwidth * screenheight;
+ COORD start_pos;
+ DWORD written;
+
+ start_pos.X = start_pos.Y = 0;
+ FillConsoleOutputAttribute (hscreen, norm_attr, nchars, start_pos, &written);
+ FillConsoleOutputCharacter (hscreen, ' ', nchars, start_pos, &written);
+}
+
+void
+clreol (void)
+{
+ DWORD nchars;
+ COORD start_pos;
+ DWORD written;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ GetConsoleScreenBufferInfo (hscreen, &csbi);
+ start_pos = csbi.dwCursorPosition;
+ nchars = csbi.dwSize.X - start_pos.X;
+
+ FillConsoleOutputAttribute (hscreen, current_attr, nchars, start_pos,
+ &written);
+ FillConsoleOutputCharacter (hscreen, ' ', nchars, start_pos, &written);
+}
+
+void
+ScreenVisualBell (void)
+{
+ DWORD nchars = screenwidth * screenheight;
+ COORD start_pos;
+ DWORD written;
+
+ start_pos.X = start_pos.Y = 0;
+ FillConsoleOutputAttribute (hscreen, inv_attr, nchars, start_pos, &written);
+ Sleep (20);
+ FillConsoleOutputAttribute (hscreen, norm_attr, nchars, start_pos, &written);
+}
+
+int
+movetext(int left, int top, int right, int bottom, int destleft, int desttop)
+{
+ SMALL_RECT src;
+ COORD dest;
+ CHAR_INFO fill;
+
+ src.Left = left - 1;
+ src.Top = top - 1;
+ src.Right = right - 1;
+ src.Bottom = bottom - 1;
+
+ dest.X = destleft - 1;
+ dest.Y = desttop - 1;
+
+ fill.Attributes = norm_attr;
+ fill.Char.AsciiChar = (CHAR)' ';
+
+ return ScrollConsoleScreenBuffer (hscreen, &src , NULL, dest, &fill) != 0;
+}
+
+int
+ScreenRows (void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ GetConsoleScreenBufferInfo (hscreen, &csbi);
+ return csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+}
+
+int
+ScreenCols (void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ GetConsoleScreenBufferInfo (hscreen, &csbi);
+ return csbi.srWindow.Right - csbi.srWindow.Left + 1;
+}
+
+void
+_set_screen_lines (int lines)
+{
+ SMALL_RECT window_rectangle;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD scrbufsize;
+
+ GetConsoleScreenBufferInfo (hscreen, &csbi);
+
+ window_rectangle = csbi.srWindow;
+ window_rectangle.Bottom = window_rectangle.Top + lines - 1;
+ SetConsoleWindowInfo (hscreen, TRUE, &window_rectangle);
+
+ /* Set the screen buffer size to the same dimensions as the window,
+ so that the dysfunctional scroll bar disappears. */
+ scrbufsize.X = window_rectangle.Right - window_rectangle.Left + 1;
+ scrbufsize.Y = window_rectangle.Bottom - window_rectangle.Top + 1;
+ SetConsoleScreenBufferSize (hscreen, scrbufsize);
+}
+
+void
+w32_set_screen_dimensions (int cols, int rows)
+{
+ SMALL_RECT window_rectangle;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ GetConsoleScreenBufferInfo (hscreen, &csbi);
+
+ window_rectangle = csbi.srWindow;
+ window_rectangle.Bottom = window_rectangle.Top + rows - 1;
+ window_rectangle.Right = window_rectangle.Left + cols - 1;
+ SetConsoleWindowInfo (hscreen, TRUE, &window_rectangle);
+}
+
+/* Emulate `sleep'. */
+unsigned
+sleep (unsigned sec)
+{
+ Sleep (sec*1000);
+ return 0;
+}
+
+/* Keyboard input support. */
+
+static int
+w32_our_tty (int fd)
+{
+ return
+ isatty (fd)
+ /* Windows `isatty' actually tests for character devices, so the
+ null device gets reported as a tty. Fix that by calling
+ `lseek'. */
+ && lseek (fd, SEEK_CUR, 0) == -1
+ /* Is this our tty? */
+ && hstdin != INVALID_HANDLE_VALUE
+ && hstdin == (HANDLE)_get_osfhandle (fd);
+}
+
+/* Translate a Windows key event into the equivalent sequence of bytes
+ to be submitted to Info dispatcher. */
+#define define_seq(p,s1,s2) \
+ do { \
+ if ((ctl & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0) \
+ memcpy (p, s1, sizeof (s1)), p += sizeof (s1) - 1; \
+ else \
+ memcpy (p, s2, sizeof (s2)), p += sizeof (s2) - 1; \
+ } while (0)
+
+static int
+w32keyseq (unsigned char ascii_ch, WORD vkey, DWORD ctl, unsigned char *seq)
+{
+ unsigned char *p = seq;
+
+ switch (ascii_ch)
+ {
+ case '\0':
+ /* Keys with no ASCII code are extended keys, like arrows. */
+ switch (vkey)
+ {
+ case VK_PRIOR:
+ define_seq (p, "\033\061p", "\033v");
+ break;
+ case VK_NEXT:
+ define_seq (p, "\033\061n", "\026");
+ break;
+ case VK_END:
+ define_seq (p, "\033>", "\033>");
+ break;
+ case VK_HOME:
+ define_seq (p, "\033<", "\033<");
+ break;
+ case VK_LEFT:
+ define_seq (p, "\033b", "\033[D");
+ break;
+ case VK_UP:
+ define_seq (p, "\033\061u", "\033[A");
+ break;
+ case VK_RIGHT:
+ define_seq (p, "\033f", "\033[C");
+ break;
+ case VK_DOWN:
+ define_seq (p, "\033\061m", "\033[B");
+ break;
+ case VK_INSERT:
+ define_seq (p, "\033[L", "\033[L");
+ break;
+ case VK_DELETE: /* Delete => Ctrl-d, Alt-Delete => ESC d */
+ if ((ctl & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) != 0)
+ define_seq (p, "\033d", "\033d");
+ else
+ define_seq (p, "\033d", "\004");
+ break;
+ case VK_HELP: /* F1 => Ctrl-h */
+ case VK_F1:
+ *p++ = '\010';
+ break;
+ case 50: /* Ctrl-@ => '\0' */
+ if ((ctl & SHIFT_PRESSED) != 0)
+ *p++ = '\0';
+ break;
+ default:
+ if (0x41 <= vkey && vkey <= 0x5a)
+ {
+ /* Alt-Ctrl-a, Alt-Ctrl-b, etc. */
+ *p++ = '\033';
+ *p++ = '\001' + vkey - 0x41;
+ }
+ }
+ break;
+ case ' ': /* Ctrl-SPC => '\0' */
+ if ((ctl & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0)
+ ascii_ch = '\0';
+ *p++ = ascii_ch;
+ break;
+ case '\t': /* Shift-TAB/Alt-TAB => Esc-TAB */
+ if ((ctl & (SHIFT_PRESSED | LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) != 0)
+ {
+ memcpy (p, "\033\011", sizeof ("\033\011"));
+ p += sizeof ("\033\011") - 1;
+ }
+ else
+ *p++ = '\t';
+ break;
+ case '\b':
+ /* Backspace => DEL. */
+ ascii_ch = '\177';
+ /* FALLTHROUGH */
+ default:
+ if ((ctl & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) != 0)
+ *p++ = '\033';
+ *p++ = ascii_ch;
+ break;
+ }
+ return p - seq;
+}
+
+static unsigned char buffered_chars[512];
+static size_t buf_head;
+static size_t buf_tail;
+
+static ssize_t
+w32_kbd_read (unsigned char *inbuf, size_t n)
+{
+ DWORD nevents, nread;
+ INPUT_RECORD inrec;
+ ssize_t nret = 0;
+
+ do {
+
+ /* Stuff any unread buffered characters. */
+ while (buf_head < buf_tail && n > 0)
+ {
+ *inbuf++ = buffered_chars[buf_head++];
+ nret++;
+ n--;
+ }
+ if (n <= 0)
+ break;
+
+ /* Wait for input. */
+ while (GetNumberOfConsoleInputEvents (hstdin, &nevents)
+ && nevents < 1)
+ Sleep (20);
+
+ while (nevents-- && n > 0)
+ {
+ if (!ReadConsoleInput (hstdin, &inrec, 1, &nread))
+ return -1;
+
+ if (nread > 0)
+ {
+ switch (inrec.EventType)
+ {
+ case KEY_EVENT:
+ if (inrec.Event.KeyEvent.bKeyDown == TRUE
+ && !(inrec.Event.KeyEvent.wVirtualScanCode == 0
+ || inrec.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT
+ || inrec.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL
+ || inrec.Event.KeyEvent.wVirtualKeyCode == VK_MENU))
+ {
+ unsigned char keyseq[10];
+ int count = inrec.Event.KeyEvent.wRepeatCount;
+ unsigned char ch = inrec.Event.KeyEvent.uChar.AsciiChar;
+ WORD vkey = inrec.Event.KeyEvent.wVirtualKeyCode;
+ DWORD ctl_state = inrec.Event.KeyEvent.dwControlKeyState;
+ int nbytes = w32keyseq (ch, vkey, ctl_state, keyseq);
+
+ /* Supply up to N characters to the caller. */
+ while (count && n >= nbytes)
+ {
+ if (nbytes == 1 && keyseq[0] == '\032')
+ {
+ terminal_goto_xy (0, screenheight - 1);
+ terminal_clear_to_eol ();
+ fflush (stdout);
+ terminal_unprep_terminal ();
+ kill (getpid (), 0);
+ terminal_prep_terminal ();
+ reset_info_window_sizes ();
+ }
+ else
+ {
+ memcpy (&inbuf[nret], keyseq, nbytes);
+ nret += nbytes;
+ n -= nbytes;
+ }
+ count--;
+ }
+ /* Buffer the rest. */
+ if (count > 0)
+ {
+ buf_head = buf_tail = 0;
+ while (count--
+ && buf_tail < sizeof(buffered_chars) - nbytes)
+ {
+ memcpy (&buffered_chars[buf_tail], keyseq,
nbytes);
+ buf_tail += nbytes;
+ }
+ }
+ }
+ break;
+ case WINDOW_BUFFER_SIZE_EVENT:
+ {
+ int rows, cols;
+
+ /* Note: this event is only sent when the console
+ window's _screen_buffer_ size is changed via
+ the Properties->Layout dialog. */
+ cols = inrec.Event.WindowBufferSizeEvent.dwSize.X;
+ rows = inrec.Event.WindowBufferSizeEvent.dwSize.Y;
+ screenwidth = cols;
+ screenheight = rows;
+ w32_set_screen_dimensions (cols, rows);
+ display_initialize_display (screenwidth, screenheight);
+ window_new_screen_size (screenwidth, screenheight);
+ redisplay_after_signal ();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ } while (n > 0);
+ return nret;
+}
+
+long
+w32_chars_avail (int fd)
+{
+ if (w32_our_tty (fd))
+ return buf_tail - buf_head;
+ else
+ {
+ struct stat st;
+
+ if (fstat (fd, &st) < 0)
+ return 1;
+ else
+ return st.st_size;
+ }
+}
+
+ssize_t
+w32_read (int fd, void *buf, size_t n)
+{
+ if (w32_our_tty (fd))
+ return w32_kbd_read (buf, n);
+ else
+ return _read (fd, buf, n);
+}
+
+#endif /* _WIN32 */
+
/* Turn on reverse video. */
static void
pc_begin_inverse (void)
@@ -192,6 +734,10 @@ pc_prep_terminal (void)
{
int tty;
+#ifdef _WIN32
+ w32_info_prep ();
+#endif
+
/* Do not set screen height if we already have it, because
doing so erases the screen. */
if (screenheight != ScreenRows ())
@@ -221,6 +767,10 @@ pc_unprep_terminal (void)
{
int tty;
+#ifdef _WIN32
+ w32_info_unprep ();
+#endif
+
textattr (outside_info.normattr);
/* Do not set screen height if we already have it, because
@@ -230,8 +780,13 @@ pc_unprep_terminal (void)
_set_screen_lines (outside_info.screenheight);
textmode (LASTMODE);
}
+#ifdef __MSDOS__
else
pc_clear_to_eol (); /* for text attributes to really take effect */
+#endif
+#ifdef _WIN32
+ SetConsoleScreenBufferSize (hstdout, outside_info.bufsize);
+#endif
/* Switch back to text mode on stdin. */
tty = fileno (stdin);
@@ -256,7 +811,12 @@ pc_initialize_terminal (term_name)
{
term_name = getenv ("TERM");
if (!term_name)
+#ifdef __MSDOS__
term_name = "pc-dos"; /* ``what's in a name?'' */
+#endif
+#ifdef _WIN32
+ term_name = "w32console";
+#endif
}
/* Get current video information, to be restored later. */
@@ -311,6 +871,7 @@ pc_initialize_terminal (term_name)
pc_get_screen_size ();
+#ifdef __MSDOS__
/* Store the arrow keys. */
term_ku = (char *)find_sequence (K_Up);
term_kd = (char *)find_sequence (K_Down);
@@ -326,6 +887,7 @@ pc_initialize_terminal (term_name)
term_ki = (char *)find_sequence (K_Insert);
term_kx = (char *)find_sequence (K_Delete);
#endif
+#endif /* __MSDOS__ */
/* Set all the hooks to our PC-specific functions. */
terminal_begin_inverse_hook = pc_begin_inverse;
@@ -687,9 +1249,11 @@ kill (pid_t pid, int sig)
exit (EXIT_FAILURE);
case SIGUSR1:
/* Simulate SIGTSTP by invoking a subsidiary shell. */
+#ifndef _WIN32
pc_goto_xy (0, outside_info.screenheight - 1);
pc_clear_to_eol ();
pc_write_chars (stopped_msg, sizeof (stopped_msg) - 1);
+#endif
/* The child shell can change the working directory, so
we need to save and restore it, since it is global. */
@@ -699,7 +1263,26 @@ kill (pid_t pid, int sig)
/* We don't want to get fatal signals while the subshell runs. */
old_INT = signal (SIGINT, SIG_IGN);
old_QUIT = signal (SIGQUIT, SIG_IGN);
+#ifdef _WIN32
+ {
+ const char *argv[2];
+ const char *shell = NULL;
+
+ argv[0] = NULL;
+ shell = getenv ("SHELL");
+ if (!shell)
+ {
+ shell = getenv ("COMSPEC");
+ if (!shell)
+ return -1;
+ argv[0] = " /k";
+ }
+ argv[1] = NULL;
+ _spawnvp (_P_WAIT, shell, argv);
+ }
+#else
system ("");
+#endif
if (*cwd)
chdir (cwd);
signal (SIGINT, old_INT);
@@ -718,14 +1301,14 @@ kill (pid_t pid, int sig)
/* These should never be called, but they make the linker happy. */
-void tputs (char *a, int b, int (*c)())
+int tputs (const char *a, int b, int (*c)(int))
{
- perror ("tputs");
+ perror ("tputs"); return 0; /* here and below, added dummy retvals */
}
-char* tgoto (char*a, int b, int c)
+char* tgoto (const char *a, int b, int c)
{
- perror ("tgoto"); return 0; /* here and below, added dummy retvals */
+ perror ("tgoto"); return 0;
}
int tgetnum (char*a)
@@ -743,7 +1326,7 @@ char* tgetstr (char *a, char **b)
perror ("tgetstr"); return 0;
}
-int tgetent (char*a, char*b)
+int tgetent (char *a, const char *b)
{
perror ("tgetent"); return 0;
}
diff -up -r texinfo-4.13.90.orig/info/session.c texinfo-4.13.90/info/session.c
--- texinfo-4.13.90.orig/info/session.c 2012-06-11 20:54:26.000000000 +0300
+++ texinfo-4.13.90/info/session.c 2012-11-17 14:54:36.015625000 +0200
@@ -21,7 +21,13 @@
#include "info.h"
#include "search.h"
+#ifndef __MINGW32__
#include <sys/ioctl.h>
+#endif
+#ifdef _WIN32
+# define read(f,b,s) w32_read(f,b,s)
+# define _read(f,b,s) w32_read(f,b,s)
+#endif
#if defined (HAVE_SYS_TIME_H)
# include <sys/time.h>
@@ -5397,7 +5403,7 @@ info_gather_typeahead (void)
chars_avail = read (tty, &input[0], chars_avail);
}
#else /* !FIONREAD */
-# if defined (O_NDELAY)
+# if defined (O_NDELAY) && defined (F_GETFL) && defined (F_SETFL)
{
int flags;
@@ -5434,6 +5440,19 @@ info_gather_typeahead (void)
if (chars_avail)
chars_avail = read (tty, &input[0], chars_avail);
}
+# else
+# ifdef _WIN32
+ {
+ extern long w32_chars_avail (int);
+
+ chars_avail = w32_chars_avail (tty);
+
+ if (chars_avail > space_avail)
+ chars_avail = space_avail;
+ if (chars_avail)
+ chars_avail = read (tty, &input[0], chars_avail);
+ }
+# endif /* _WIN32 */
# endif/* __DJGPP__ */
# endif /* O_NDELAY */
#endif /* !FIONREAD */
diff -up -r texinfo-4.13.90.orig/info/signals.c texinfo-4.13.90/info/signals.c
--- texinfo-4.13.90.orig/info/signals.c 2007-12-03 03:19:27.000000000 +0200
+++ texinfo-4.13.90/info/signals.c 2012-11-17 13:39:18.921875000 +0200
@@ -151,7 +151,7 @@ initialize_info_signal_handler (void)
#endif
}
-static void
+void
redisplay_after_signal (void)
{
terminal_clear_screen ();
@@ -162,7 +162,7 @@ redisplay_after_signal (void)
fflush (stdout);
}
-static void
+void
reset_info_window_sizes (void)
{
terminal_goto_xy (0, 0);
diff -up -r texinfo-4.13.90.orig/info/termdep.h texinfo-4.13.90/info/termdep.h
--- texinfo-4.13.90.orig/info/termdep.h 2007-07-02 00:20:31.000000000 +0300
+++ texinfo-4.13.90/info/termdep.h 2012-11-17 13:39:18.937500000 +0200
@@ -43,7 +43,9 @@
# endif /* M_XENIX */
# endif /* HAVE_SYS_PTEM_H */
# else /* !HAVE_TERMIO_H */
+# ifndef __MINGW32__
# include <sgtty.h>
+# endif
# endif /* !HAVE_TERMIO_H */
#endif /* !HAVE_TERMIOS_H */
@@ -55,4 +57,8 @@
# include <sys/ttold.h>
#endif /* HAVE_SYS_TTOLD_H */
+#ifdef _WIN32
+extern unsigned sleep (unsigned);
+#endif
+
#endif /* not INFO_TERMDEP_H */
diff -up -r texinfo-4.13.90.orig/info/terminal.c texinfo-4.13.90/info/terminal.c
--- texinfo-4.13.90.orig/info/terminal.c 2008-06-12 10:49:55.000000000
+0300
+++ texinfo-4.13.90/info/terminal.c 2012-11-17 15:36:39.390625000 +0200
@@ -43,7 +43,7 @@ char PC; /* Pad character */
short ospeed; /* Terminal output baud rate */
extern int tgetnum (), tgetflag (), tgetent ();
extern char *tgetstr (), *tgoto ();
-extern void tputs ();
+extern int tputs ();
#endif /* not HAVE_TERMCAP_H */
#endif /* not HAVE_NCURSES_TERMCAP_H */
@@ -572,7 +572,9 @@ terminal_initialize_terminal (char *term
ospeed = B9600;
}
# else
+#ifndef __MINGW32__
ospeed = B9600;
+#endif
# endif /* !TIOCGETP */
#endif
@@ -663,7 +665,9 @@ struct termio original_termio, ttybuff;
/* Buffers containing the terminal mode flags upon entry to info. */
int original_tty_flags = 0;
int original_lmode;
+#ifndef __MINGW32__
struct sgttyb ttybuff;
+#endif
# if defined(TIOCGETC) && defined(M_XENIX)
/* SCO 3.2v5.0.2 defines but does not support TIOCGETC. Gak. Maybe
@@ -758,7 +762,7 @@ terminal_prep_terminal (void)
# endif
#endif
-#if !defined (HAVE_TERMIOS_H) && !defined (HAVE_TERMIO_H)
+#if !defined (HAVE_TERMIOS_H) && !defined (HAVE_TERMIO_H) &&
!defined(__MINGW32__)
ioctl (tty, TIOCGETP, &ttybuff);
if (!original_tty_flags)
@@ -819,9 +823,11 @@ terminal_prep_terminal (void)
}
# endif /* TIOCGLTC */
+# ifndef __MINGW32__
ttybuff.sg_flags &= ~ECHO;
ttybuff.sg_flags |= CBREAK;
ioctl (tty, TIOCSETN, &ttybuff);
+# endif
#endif /* !HAVE_TERMIOS_H && !HAVE_TERMIO_H */
}
@@ -846,9 +852,11 @@ terminal_unprep_terminal (void)
# if defined (HAVE_TERMIO_H)
ioctl (tty, TCSETA, &original_termio);
# else /* !HAVE_TERMIO_H */
+# ifndef __MINGW32__
ioctl (tty, TIOCGETP, &ttybuff);
ttybuff.sg_flags = original_tty_flags;
ioctl (tty, TIOCSETN, &ttybuff);
+# endif
# if defined (TIOCGETC)
ioctl (tty, TIOCSETC, &original_tchars);
@@ -867,6 +875,6 @@ terminal_unprep_terminal (void)
terminal_end_using_terminal ();
}
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
# include "pcterm.c"
#endif
diff -up -r texinfo-4.13.90.orig/info/tilde.c texinfo-4.13.90/info/tilde.c
--- texinfo-4.13.90.orig/info/tilde.c 2012-06-11 20:54:27.000000000 +0300
+++ texinfo-4.13.90/info/tilde.c 2012-11-17 13:39:18.953125000 +0200
@@ -190,11 +190,15 @@ tilde_expand_word (char *filename)
the password database. */
if (!temp_home)
{
+#ifndef _WIN32
struct passwd *entry;
entry = (struct passwd *) getpwuid (getuid ());
if (entry)
temp_home = entry->pw_dir;
+#else
+ temp_home = ".";
+#endif
}
temp_name = xmalloc (1 + strlen (&dirname[1])
@@ -210,7 +214,9 @@ tilde_expand_word (char *filename)
}
else
{
+#ifndef _WIN32
struct passwd *user_entry;
+#endif
char *username = xmalloc (257);
int i, c;
@@ -223,6 +229,7 @@ tilde_expand_word (char *filename)
}
username[i - 1] = 0;
+#ifndef _WIN32
if (!(user_entry = (struct passwd *) getpwnam (username)))
{
/* If the calling program has a special syntax for
@@ -259,6 +266,24 @@ tilde_expand_word (char *filename)
endpwent ();
free (username);
+#else
+ if (tilde_expansion_failure_hook)
+ {
+ char *expansion = (*tilde_expansion_failure_hook) (username);
+
+ if (expansion)
+ {
+ temp_name = xmalloc (1 + strlen (expansion)
+ + strlen (&dirname[i]));
+ strcpy (temp_name, expansion);
+ strcat (temp_name, &dirname[i]);
+ free (expansion);
+ }
+ }
+ free (dirname);
+ dirname = xstrdup (temp_name);
+ free (temp_name);
+#endif
}
}
return dirname;
diff -up -r texinfo-4.13.90.orig/system.h texinfo-4.13.90/system.h
--- texinfo-4.13.90.orig/system.h 2011-10-18 20:37:31.000000000 +0200
+++ texinfo-4.13.90/system.h 2012-11-17 14:40:40.531250000 +0200
@@ -45,9 +45,9 @@
#include <unistd.h>
/* For gettext (NLS). */
-#define const
+/* #define const */
#include "gettext.h"
-#undef const
+/* #undef const */
#define _(String) gettext (String)
#define N_(String) (String)
@@ -162,6 +162,9 @@ extern int strcoll ();
# define NULL_DEVICE "/dev/null"
# define PIPE_USE_FORK 1
# else /* O_BINARY && !__CYGWIN__ */
+# ifdef _WIN32
+# define SET_SCREEN_SIZE_HELPER terminal_prep_terminal()
+# endif /* _WIN32 */
# define DEFAULT_TMPDIR "c:/"
# define PATH_SEP ";"
# define STRIP_DOT_EXE 1
- texinfo-4.13.90 pretest available, Karl Berry, 2012/11/16
- Re: texinfo-4.13.90 pretest available, Eli Zaretskii, 2012/11/16
- Re: texinfo-4.13.90 pretest available, Patrice Dumas, 2012/11/16
- Re: texinfo-4.13.90 pretest available, Sergey Poznyakoff, 2012/11/17
- Re: texinfo-4.13.90 pretest available,
Eli Zaretskii <=
- Re: texinfo-4.13.90 pretest available, Karl Berry, 2012/11/17
- Re: texinfo-4.13.90 pretest available, Eli Zaretskii, 2012/11/17
- Re: texinfo-4.13.90 pretest available, Eli Zaretskii, 2012/11/24
- Re: texinfo-4.13.90 pretest available, Patrice Dumas, 2012/11/24
- Re: texinfo-4.13.90 pretest available, Eli Zaretskii, 2012/11/24
Re: texinfo-4.13.90 pretest available, Karl Berry, 2012/11/16
Re: texinfo-4.13.90 pretest available, Stefano Lattarini, 2012/11/17