Subject: bug#8596: 24.0.50; crash when use C-x 5 2 with emacs -nw -Q

From: Juanma Barranquero <[email-masked]>
Date: Sat, 30 Apr 2011 23:30:57 +0200

On Sat, Apr 30, 2011 at 22:32, Eli Zaretskii <[email-masked]> wrote:

> I think this happens because w32 lacks a proper implementation of
> get_tty_size.

That's not hard to fix, is it?

But, I cannot find the oldest Windows release supporting
GetConsoleScreenBufferInfo. Most online references do not go farther
than the oldest supported release, Windows 2K.

    Juanma

=== modified file 'src/sysdep.c'
--- src/sysdep.c	2011-04-26 06:17:52 +0000
+++ src/sysdep.c	2011-04-30 21:23:28 +0000
@@ -1138,6 +1138,16 @@
     }

 #else
+#ifdef WINDOWSNT
+  CONSOLE_SCREEN_BUFFER_INFO info;
+  if (GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info))
+    {
+      *widthp = info.srWindow.Right - info.srWindow.Left + 1;
+      *heightp = info.srWindow.Bottom - info.srWindow.Top + 1;
+    }
+  else
+    * widthp = *heightp = 0;
+#else
 #ifdef MSDOS
   *widthp = ScreenCols ();
   *heightp = ScreenRows ();
@@ -1145,6 +1155,7 @@
   *widthp = 0;
   *heightp = 0;
 #endif
+#endif /* not WINDOWSNT */
 #endif /* not SunOS-style */
 #endif /* not BSD-style */
 }