Article View: comp.sources.bugs
Article #411top v2.1 fix for RISC Ultrix 3.1/4.0
From: jim brown
Date: Sat, 25 Aug 1990 04:28
Date: Sat, 25 Aug 1990 04:28
84 lines
2697 bytes
2697 bytes
The following patch to top v2.1 was found to be necessary for both
RISC Ultrix 3.1 and 4.0. Top was treating a normal ASCII tube
(say a vt200 or vt100) as 'dumb' because ws.ws_row was coming back 0.
If the ioctl works and ws.ws_row is 0 then use "li" and "co" to size
the 'dumb'er (but not stupid) terminal.
*** screen.c.orig Mon Sep 5 22:35:05 1988
--- screen.c Sat Aug 25 00:19:39 1990
***************
*** 8,13 ****
--- 8,14 ----
#include <stdio.h>
#include <sgtty.h>
+ #include <errno.h>
#include "screen.h"
#include "boolean.h"
***************
*** 89,102 ****
#if defined(TIOCGWINSZ)
{
struct winsize ws;
! ioctl(0, TIOCGWINSZ, &ws);
! if (!(screen_length = ws.ws_row)) { /* yes I mean "=" */
screen_length = smart_terminal = 0;
return;
! }
! if (!(screen_width = ws.ws_col - 1)) { /* uh huh */
screen_width = 79;
}
}
#else
--- 90,132 ----
#if defined(TIOCGWINSZ)
{
struct winsize ws;
+ int stat;
! stat = ioctl(0, TIOCGWINSZ, &ws);
! if (stat != -1 && ws.ws_row == 0) {
! stat = -1; errno = ENOTTY; /* values no good */
! }
! if (stat != -1) {
! if (!(screen_length = ws.ws_row)) { /* yes I mean "=" */
! screen_length = smart_terminal = 0;
! return;
! }
! if (!(screen_width = ws.ws_col - 1)) { /* uh huh */
! screen_width = 79;
! }
! }
! else if (errno == ENOTTY) {
! /* set up common terminal capabilities */
! if ((screen_length = tgetnum("li")) <= 0)
! {
screen_length = smart_terminal = 0;
return;
! }
!
! /* screen_width is a little different */
! if ((screen_width = tgetnum("co")) == -1)
! {
screen_width = 79;
+ }
+ else
+ {
+ screen_width -= 1;
+ }
+ }
+ else {
+ fprintf("Can't ioctl TTY: %d\n", errno);
+ screen_length = smart_terminal = 0;
+ return;
}
}
#else
=========== end of patch for screen.c ============
--
Jim Brown, University of Miami, RSMAS/MPO
[send mail to jim@umigw.miami.edu]
Technical Details
Message-ID:
<1990Aug25.042839.15222@umigw.miami.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!sdd.hp.com!elroy.jpl.nasa.gov!ncar!umigw!mango.miami.edu!jimShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!sdd.hp.com!elroy.jpl.nasa.gov!ncar!umigw!mango.miami.edu!jim From: jim@mango.miami.edu (jim brown) Newsgroups: comp.sources.bugs Subject: top v2.1 fix for RISC Ultrix 3.1/4.0 Keywords: smart terminals can be dumb too Message-ID: <1990Aug25.042839.15222@umigw.miami.edu> Date: 25 Aug 90 04:28:39 GMT Sender: news@umigw.miami.edu (USENET News System) Reply-To: jim@mango.miami.edu (jim brown) Distribution: na Organization: University of Miami Lines: 84