simplify print_columns func argument: no need to return the first arg any more
This commit is contained in:
21
misc.c
21
misc.c
@@ -30,7 +30,7 @@
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.233 2015/07/05 14:33:21 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.234 2015/07/05 14:43:07 tg Exp $");
|
||||
|
||||
#define KSH_CHVT_FLAG
|
||||
#ifdef MKSH_SMALL
|
||||
@@ -173,11 +173,11 @@ struct options_info {
|
||||
int opts[NELEM(options)];
|
||||
};
|
||||
|
||||
static char *options_fmt_entry(char *, size_t, unsigned int, const void *);
|
||||
static void options_fmt_entry(char *, size_t, unsigned int, const void *);
|
||||
static void printoptions(bool);
|
||||
|
||||
/* format a single select menu item */
|
||||
static char *
|
||||
static void
|
||||
options_fmt_entry(char *buf, size_t buflen, unsigned int i, const void *arg)
|
||||
{
|
||||
const struct options_info *oi = (const struct options_info *)arg;
|
||||
@@ -185,7 +185,6 @@ options_fmt_entry(char *buf, size_t buflen, unsigned int i, const void *arg)
|
||||
shf_snprintf(buf, buflen, "%-*s %s",
|
||||
oi->opt_width, OFN(oi->opts[i]),
|
||||
Flag(oi->opts[i]) ? "on" : "off");
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1227,7 +1226,7 @@ print_value_quoted(struct shf *shf, const char *s)
|
||||
*/
|
||||
void
|
||||
print_columns(struct shf *shf, unsigned int n,
|
||||
char *(*func)(char *, size_t, unsigned int, const void *),
|
||||
void (*func)(char *, size_t, unsigned int, const void *),
|
||||
const void *arg, size_t max_oct, size_t max_colz, bool prefcol)
|
||||
{
|
||||
unsigned int i, r, c, rows, cols, nspace, max_col;
|
||||
@@ -1264,9 +1263,11 @@ print_columns(struct shf *shf, unsigned int n,
|
||||
|
||||
/* 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)(str, max_oct, i, arg));
|
||||
for (i = 0; i < n; ++i) {
|
||||
(*func)(str, max_oct, i, arg);
|
||||
shf_puts(str, shf);
|
||||
shf_putc('\n', shf);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1284,8 +1285,8 @@ print_columns(struct shf *shf, unsigned int n,
|
||||
for (c = 0; c < cols; c++) {
|
||||
i = c * rows + r;
|
||||
if (i < n) {
|
||||
shf_fprintf(shf, "%*s", max_col,
|
||||
(*func)(str, max_oct, i, arg));
|
||||
(*func)(str, max_oct, i, arg);
|
||||
shf_fprintf(shf, "%*s", max_col, str);
|
||||
if (i + rows < n)
|
||||
shf_fprintf(shf, "%*s", nspace, null);
|
||||
}
|
||||
|
Reference in New Issue
Block a user