screen.c.diff2   [plain text]


--- screen.c.orig	2005-01-11 16:36:33.000000000 -0800
+++ screen.c	2005-02-18 14:52:13.000000000 -0800
@@ -239,6 +239,8 @@
 extern char *tgetstr();
 extern char *tgoto();
 
+extern int unix2003_compat;
+extern int dashn_numline_count;
 
 /*
  * Change terminal to "raw mode", or restore to "normal" mode.
@@ -770,27 +772,56 @@
 #endif
 #endif
 
-	if (sys_height > 0)
-		sc_height = sys_height;
-	else if ((s = lgetenv("LINES")) != NULL)
-		sc_height = atoi(s);
+	if (unix2003_compat) {
+		if (dashn_numline_count) /* Overrides all other sources */
+			sc_height = dashn_numline_count;
+		else {
+			if (sys_height > 0)
+				sc_height = sys_height;
+			/* don't override LINES/COLUMNS if conforming to UNIX 03 */
+			if ((s = lgetenv("LINES")) != NULL)
+				sc_height = atoi(s);
 #if !MSDOS_COMPILER
-	else if ((n = ltgetnum("li")) > 0)
- 		sc_height = n;
+			else if ((n = ltgetnum("li")) > 0)
+ 				sc_height = n;
 #endif
-	else
-		sc_height = DEF_SC_HEIGHT;
+			else
+				sc_height = DEF_SC_HEIGHT;
+		}
 
-	if (sys_width > 0)
-		sc_width = sys_width;
-	else if ((s = lgetenv("COLUMNS")) != NULL)
-		sc_width = atoi(s);
+		if (sys_width > 0)
+			sc_width = sys_width;
+		if ((s = lgetenv("COLUMNS")) != NULL)
+			sc_width = atoi(s);
+#if !MSDOS_COMPILER
+		else if ((n = ltgetnum("co")) > 0)
+ 			sc_width = n;
+#endif
+		else
+			sc_width = DEF_SC_WIDTH;
+	} else {
+		if (sys_height > 0)
+			sc_height = sys_height;
+		else if ((s = lgetenv("LINES")) != NULL)
+			sc_height = atoi(s);
+#if !MSDOS_COMPILER
+		else if ((n = ltgetnum("li")) > 0)
+ 			sc_height = n;
+#endif
+		else
+			sc_height = DEF_SC_HEIGHT;
+
+		if (sys_width > 0)
+			sc_width = sys_width;
+		else if ((s = lgetenv("COLUMNS")) != NULL)
+			sc_width = atoi(s);
 #if !MSDOS_COMPILER
-	else if ((n = ltgetnum("co")) > 0)
- 		sc_width = n;
+		else if ((n = ltgetnum("co")) > 0)
+ 			sc_width = n;
 #endif
-	else
-		sc_width = DEF_SC_WIDTH;
+		else
+			sc_width = DEF_SC_WIDTH;
+	}
 }
 
 #if MSDOS_COMPILER==MSOFTC