All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>
Subject: mconf.c: Honor $LINES and $COLUMNS if TIOCGWINSZ failed
Date: Wed, 14 Jul 2004 17:35:25 +0200	[thread overview]
Message-ID: <20040714153525.GU2019@lug-owl.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 1779 bytes --]

Hi!

While reading code, I found this buglet. If the TIOCGWINSZ fails,
mconf.c assumes 24/80 as screen size, without honoring the LINES and
COLUMNS environment variables. This is the shorter and IMHO more correct
version:

Signed-off-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>


--- linux-2.6.7-tar-pkg/scripts/kconfig/mconf.c~	Wed Jul 14 15:38:48 2004
+++ linux-2.6.7-tar-pkg/scripts/kconfig/mconf.c	Wed Jul 14 15:47:52 2004
@@ -87,7 +87,7 @@
 static char *args[1024], **argptr = args;
 static int indent;
 static struct termios ios_org;
-static int rows, cols;
+static int rows = 0, cols = 0;
 static struct menu *current_menu;
 static int child_count;
 static int do_resize;
@@ -113,26 +113,24 @@
 	struct winsize ws;
 	char *env;
 
-	if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
-		rows = 24;
-		cols = 80;
-	} else {
+	if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) {
 		rows = ws.ws_row;
 		cols = ws.ws_col;
-		if (!rows) {
-			env = getenv("LINES");
-			if (env)
-				rows = atoi(env);
-			if (!rows)
-				rows = 24;
-		}
-		if (!cols) {
-			env = getenv("COLUMNS");
-			if (env)
-				cols = atoi(env);
-			if (!cols)
-				cols = 80;
-		}
+	}
+
+	if (!rows) {
+		env = getenv("LINES");
+		if (env)
+			rows = atoi(env);
+		if (!rows)
+			rows = 24;
+	}
+	if (!cols) {
+		env = getenv("COLUMNS");
+		if (env)
+			cols = atoi(env);
+		if (!cols)
+			cols = 80;
 	}
 
 	if (rows < 19 || cols < 80) {

MfG, JBG

-- 
   Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481
   "Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg
    fuer einen Freien Staat voll Freier Bürger" | im Internet! |   im Irak!
   ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

                 reply	other threads:[~2004-07-14 15:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040714153525.GU2019@lug-owl.de \
    --to=jbglaw@lug-owl.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.