Fix TCGETWINSZ compat.

This commit is contained in:
Todd C. Miller
2010-10-07 14:11:10 -04:00
parent 1a4990f571
commit e2f253e51d
3 changed files with 9 additions and 9 deletions

View File

@@ -74,7 +74,6 @@
# define TIOCGWINSZ TIOCGSIZE # define TIOCGWINSZ TIOCGSIZE
# define TIOCSWINSZ TIOCSSIZE # define TIOCSWINSZ TIOCSSIZE
# define winsize ttysize # define winsize ttysize
# define ws_cols ts_col
#endif #endif
struct io_buffer { struct io_buffer {

View File

@@ -189,7 +189,7 @@ extern int tgetpass_flags;
int get_pty(int *master, int *slave, char *name, size_t namesz, uid_t uid); int get_pty(int *master, int *slave, char *name, size_t namesz, uid_t uid);
/* ttysize.c */ /* ttysize.c */
void get_ttysize(int *linep, int *colp); void get_ttysize(int *rowp, int *colp);
/* sudo.c */ /* sudo.c */
int exec_setup(struct command_details *details, const char *ptyname, int ptyfd); int exec_setup(struct command_details *details, const char *ptyname, int ptyfd);

View File

@@ -40,27 +40,28 @@
#if !defined(TIOCGWINSZ) && defined(TIOCGSIZE) #if !defined(TIOCGWINSZ) && defined(TIOCGSIZE)
# define TIOCGWINSZ TIOCGSIZE # define TIOCGWINSZ TIOCGSIZE
# define winsize ttysize # define winsize ttysize
# define ws_cols ts_col # define ws_col ts_cols
# define ws_row ts_lines
#endif #endif
void void
get_ttysize(int *linep, int *colp) get_ttysize(int *rowp, int *colp)
{ {
char *p; char *p;
#ifdef TIOCGWINSZ #ifdef TIOCGWINSZ
struct winsize wsize; struct winsize wsize;
if (ioctl(STDERR_FILENO, TIOCGWINSZ, &wsize) == 0 && if (ioctl(STDERR_FILENO, TIOCGWINSZ, &wsize) == 0 &&
wsize.ws_lines != 0 && wsize.ws_cols != 0) { wsize.ws_row != 0 && wsize.ws_col != 0) {
*linep = wsize.ws_lines; *rowp = wsize.ws_row;
*colp = wsize.ws_cols; *colp = wsize.ws_col;
return; return;
} }
#endif #endif
/* Fall back on $LINES and $COLUMNS. */ /* Fall back on $LINES and $COLUMNS. */
if ((p = getenv("LINES")) == NULL || (*linep = atoi(p)) <= 0) if ((p = getenv("LINES")) == NULL || (*rowp = atoi(p)) <= 0)
*linep = 24; *rowp = 24;
if ((p = getenv("COLUMNS")) == NULL || (*colp = atoi(p)) <= 0) if ((p = getenv("COLUMNS")) == NULL || (*colp = atoi(p)) <= 0)
*colp = 80; *colp = 80;
} }