Fix get_windows_size() on Windows
The committed implementation of get_windows_size() failed to compile on the Windows platform. 'int ret' declaration is moved to avoid unused variable warning. Change-Id: I0f6ea4524db736d539b10c6bd7836a770a5e7058
This commit is contained in:

committed by
Jeffrey Altman

parent
d051ecedb2
commit
e8aea380be
@@ -60,12 +60,12 @@
|
|||||||
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||||
get_window_size(int fd, int *lines, int *columns)
|
get_window_size(int fd, int *lines, int *columns)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
#if defined(TIOCGWINSZ)
|
#if defined(TIOCGWINSZ)
|
||||||
{
|
{
|
||||||
struct winsize ws;
|
struct winsize ws;
|
||||||
|
int ret;
|
||||||
ret = ioctl(fd, TIOCGWINSZ, &ws);
|
ret = ioctl(fd, TIOCGWINSZ, &ws);
|
||||||
if (ret != -1) {
|
if (ret != -1) {
|
||||||
if (lines)
|
if (lines)
|
||||||
@@ -78,7 +78,7 @@ get_window_size(int fd, int *lines, int *columns)
|
|||||||
#elif defined(TIOCGSIZE)
|
#elif defined(TIOCGSIZE)
|
||||||
{
|
{
|
||||||
struct ttysize ts;
|
struct ttysize ts;
|
||||||
|
int ret;
|
||||||
ret = ioctl(fd, TIOCGSIZE, &ts);
|
ret = ioctl(fd, TIOCGSIZE, &ts);
|
||||||
if (ret != -1) {
|
if (ret != -1) {
|
||||||
if (lines)
|
if (lines)
|
||||||
@@ -107,10 +107,12 @@ get_window_size(int fd, int *lines, int *columns)
|
|||||||
fh = _get_osfhandle(fd);
|
fh = _get_osfhandle(fd);
|
||||||
if (fh != (intptr_t) INVALID_HANDLE_VALUE &&
|
if (fh != (intptr_t) INVALID_HANDLE_VALUE &&
|
||||||
GetConsoleScreenBufferInfo((HANDLE) fh, &sb_info)) {
|
GetConsoleScreenBufferInfo((HANDLE) fh, &sb_info)) {
|
||||||
wp->ws_row = 1 + sb_info.srWindow.Bottom - sb_info.srWindow.Top;
|
if (lines)
|
||||||
wp->ws_col = 1 + sb_info.srWindow.Right - sb_info.srWindow.Left;
|
*lines = 1 + sb_info.srWindow.Bottom - sb_info.srWindow.Top;
|
||||||
|
if (columns)
|
||||||
|
*columns = 1 + sb_info.srWindow.Right - sb_info.srWindow.Left;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user