when outputting in a row x column formatted way, but the available space
on the screen is not enough for two columns, just output the text line by line, instead of trying to format it; gets rid of superfluous empty lines if we did not even have space for one column on the screen (x_cols) noticed by Gábor Gergely in irc, thanks!
This commit is contained in:
parent
5e22cb486f
commit
1b3e4a3a2e
4
check.t
4
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.255 2009/02/20 13:25:08 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.256 2009/02/22 18:02:30 tg Exp $
|
||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||
@ -7,7 +7,7 @@
|
||||
# http://www.research.att.com/~gsf/public/ifs.sh
|
||||
|
||||
expected-stdout:
|
||||
@(#)MIRBSD KSH R36 2009/02/20
|
||||
@(#)MIRBSD KSH R36 2009/02/22
|
||||
description:
|
||||
Check version of shell.
|
||||
stdin:
|
||||
|
16
misc.c
16
misc.c
@ -6,7 +6,7 @@
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.94 2008/12/17 19:37:08 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.95 2009/02/22 18:02:31 tg Exp $");
|
||||
|
||||
#undef USE_CHVT
|
||||
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
||||
@ -936,13 +936,22 @@ print_columns(struct shf *shf, int n,
|
||||
char *str = alloc(max_width + 1, ATEMP);
|
||||
int i, r, c, rows, cols, nspace;
|
||||
|
||||
/* ensure x_cols is valid first */
|
||||
if (x_cols < MIN_COLS)
|
||||
change_winsz();
|
||||
|
||||
/* max_width + 1 for the space. Note that no space
|
||||
* is printed after the last column to avoid problems
|
||||
* with terminals that have auto-wrap.
|
||||
*/
|
||||
cols = x_cols / (max_width + 1);
|
||||
if (!cols)
|
||||
cols = 1;
|
||||
/* if we can only print one column anyway, skip the goo */
|
||||
if (cols < 2) {
|
||||
for (i = 0; i < n; ++i)
|
||||
shf_fprintf(shf, "%s \n",
|
||||
(*func)(arg, i, str, max_width + 1));
|
||||
goto out;
|
||||
}
|
||||
rows = (n + cols - 1) / cols;
|
||||
if (prefcol && n && cols > rows) {
|
||||
int tmp = rows;
|
||||
@ -969,6 +978,7 @@ print_columns(struct shf *shf, int n,
|
||||
}
|
||||
shf_putchar('\n', shf);
|
||||
}
|
||||
out:
|
||||
afree(str, ATEMP);
|
||||
}
|
||||
|
||||
|
4
sh.h
4
sh.h
@ -102,9 +102,9 @@
|
||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.273 2009/02/20 13:25:10 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.274 2009/02/22 18:02:31 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R36 2009/02/20"
|
||||
#define MKSH_VERSION "R36 2009/02/22"
|
||||
|
||||
#ifndef MKSH_INCLUDES_ONLY
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user