Fix TCGETWINSZ compat.
This commit is contained in:
@@ -74,7 +74,6 @@
|
||||
# define TIOCGWINSZ TIOCGSIZE
|
||||
# define TIOCSWINSZ TIOCSSIZE
|
||||
# define winsize ttysize
|
||||
# define ws_cols ts_col
|
||||
#endif
|
||||
|
||||
struct io_buffer {
|
||||
|
@@ -189,7 +189,7 @@ extern int tgetpass_flags;
|
||||
int get_pty(int *master, int *slave, char *name, size_t namesz, uid_t uid);
|
||||
|
||||
/* ttysize.c */
|
||||
void get_ttysize(int *linep, int *colp);
|
||||
void get_ttysize(int *rowp, int *colp);
|
||||
|
||||
/* sudo.c */
|
||||
int exec_setup(struct command_details *details, const char *ptyname, int ptyfd);
|
||||
|
@@ -40,27 +40,28 @@
|
||||
#if !defined(TIOCGWINSZ) && defined(TIOCGSIZE)
|
||||
# define TIOCGWINSZ TIOCGSIZE
|
||||
# define winsize ttysize
|
||||
# define ws_cols ts_col
|
||||
# define ws_col ts_cols
|
||||
# define ws_row ts_lines
|
||||
#endif
|
||||
|
||||
void
|
||||
get_ttysize(int *linep, int *colp)
|
||||
get_ttysize(int *rowp, int *colp)
|
||||
{
|
||||
char *p;
|
||||
#ifdef TIOCGWINSZ
|
||||
struct winsize wsize;
|
||||
|
||||
if (ioctl(STDERR_FILENO, TIOCGWINSZ, &wsize) == 0 &&
|
||||
wsize.ws_lines != 0 && wsize.ws_cols != 0) {
|
||||
*linep = wsize.ws_lines;
|
||||
*colp = wsize.ws_cols;
|
||||
wsize.ws_row != 0 && wsize.ws_col != 0) {
|
||||
*rowp = wsize.ws_row;
|
||||
*colp = wsize.ws_col;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Fall back on $LINES and $COLUMNS. */
|
||||
if ((p = getenv("LINES")) == NULL || (*linep = atoi(p)) <= 0)
|
||||
*linep = 24;
|
||||
if ((p = getenv("LINES")) == NULL || (*rowp = atoi(p)) <= 0)
|
||||
*rowp = 24;
|
||||
if ((p = getenv("COLUMNS")) == NULL || (*colp = atoi(p)) <= 0)
|
||||
*colp = 80;
|
||||
}
|
||||
|
Reference in New Issue
Block a user