make print -c honour line separator
This commit is contained in:
parent
26689a7c81
commit
6c04e4a665
4
edit.c
4
edit.c
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.309 2016/11/11 20:14:16 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.310 2016/11/11 21:13:21 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in later versions we might use libtermcap for this, but since external
|
* in later versions we might use libtermcap for this, but since external
|
||||||
@ -273,6 +273,8 @@ x_print_expansions(int nwords, char * const *words, bool is_command)
|
|||||||
x_putc('\r');
|
x_putc('\r');
|
||||||
x_putc('\n');
|
x_putc('\n');
|
||||||
co.shf = shl_out;
|
co.shf = shl_out;
|
||||||
|
co.linesep = '\n';
|
||||||
|
co.do_last = true;
|
||||||
co.prefcol = false;
|
co.prefcol = false;
|
||||||
pr_list(&co, use_copy ? (char **)XPptrv(l) : words);
|
pr_list(&co, use_copy ? (char **)XPptrv(l) : words);
|
||||||
|
|
||||||
|
5
exec.c
5
exec.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.184 2016/11/11 20:14:17 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.185 2016/11/11 21:13:23 tg Exp $");
|
||||||
|
|
||||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||||
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"
|
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"
|
||||||
@ -1686,7 +1686,8 @@ pr_menu(const char * const *ap)
|
|||||||
|
|
||||||
smi.args = ap;
|
smi.args = ap;
|
||||||
co.shf = shl_out;
|
co.shf = shl_out;
|
||||||
co.prefcol = true;
|
co.linesep = '\n';
|
||||||
|
co.prefcol = co.do_last = true;
|
||||||
print_columns(&co, n, select_fmt_entry, (void *)&smi,
|
print_columns(&co, n, select_fmt_entry, (void *)&smi,
|
||||||
smi.num_width + 2 + aocts, smi.num_width + 2 + acols);
|
smi.num_width + 2 + aocts, smi.num_width + 2 + acols);
|
||||||
}
|
}
|
||||||
|
19
funcs.c
19
funcs.c
@ -38,7 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.315 2016/11/11 20:53:15 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.316 2016/11/11 21:13:23 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -525,25 +525,21 @@ c_print(const char **wp)
|
|||||||
}
|
}
|
||||||
if (po.col) {
|
if (po.col) {
|
||||||
size_t w = XPsize(words);
|
size_t w = XPsize(words);
|
||||||
char *cp;
|
|
||||||
struct columnise_opts co;
|
struct columnise_opts co;
|
||||||
|
|
||||||
XPput(words, NULL);
|
XPput(words, NULL);
|
||||||
co.shf = shf_sopen(NULL, 128, SHF_WR | SHF_DYNAMIC, NULL);
|
co.shf = shf_sopen(NULL, 128, SHF_WR | SHF_DYNAMIC, NULL);
|
||||||
co.prefcol = false;
|
co.linesep = po.nl;
|
||||||
|
co.prefcol = co.do_last = false;
|
||||||
pr_list(&co, (char **)XPptrv(words));
|
pr_list(&co, (char **)XPptrv(words));
|
||||||
while (w--)
|
while (w--)
|
||||||
afree(XPptrv(words)[w], ATEMP);
|
afree(XPptrv(words)[w], ATEMP);
|
||||||
XPfree(words);
|
XPfree(words);
|
||||||
cp = shf_sclose(co.shf);
|
w = co.shf->wp - co.shf->buf;
|
||||||
w = strlen(cp);
|
|
||||||
|
|
||||||
XcheckN(xs, xp, w);
|
XcheckN(xs, xp, w);
|
||||||
memcpy(xp, cp, w);
|
memcpy(xp, co.shf->buf, w);
|
||||||
xp += w;
|
xp += w;
|
||||||
afree(cp, ATEMP);
|
shf_sclose(co.shf);
|
||||||
|
|
||||||
po.nl = '!'; /* for now */
|
|
||||||
}
|
}
|
||||||
print_no_arg:
|
print_no_arg:
|
||||||
if (po.nl != '!')
|
if (po.nl != '!')
|
||||||
@ -1520,7 +1516,8 @@ c_kill(const char **wp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
co.shf = shl_stdout;
|
co.shf = shl_stdout;
|
||||||
co.prefcol = true;
|
co.linesep = '\n';
|
||||||
|
co.prefcol = co.do_last = true;
|
||||||
|
|
||||||
print_columns(&co, (unsigned int)(ksh_NSIG - 1),
|
print_columns(&co, (unsigned int)(ksh_NSIG - 1),
|
||||||
kill_fmt_entry, (void *)&ki,
|
kill_fmt_entry, (void *)&ki,
|
||||||
|
12
misc.c
12
misc.c
@ -30,7 +30,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.247 2016/11/11 20:22:52 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.248 2016/11/11 21:13:25 tg Exp $");
|
||||||
|
|
||||||
#define KSH_CHVT_FLAG
|
#define KSH_CHVT_FLAG
|
||||||
#ifdef MKSH_SMALL
|
#ifdef MKSH_SMALL
|
||||||
@ -213,7 +213,8 @@ printoptions(bool verbose)
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
co.shf = shl_stdout;
|
co.shf = shl_stdout;
|
||||||
co.prefcol = true;
|
co.linesep = '\n';
|
||||||
|
co.prefcol = co.do_last = true;
|
||||||
print_columns(&co, n, options_fmt_entry, &oi,
|
print_columns(&co, n, options_fmt_entry, &oi,
|
||||||
octs + 4, oi.opt_width + 4);
|
octs + 4, oi.opt_width + 4);
|
||||||
} else {
|
} else {
|
||||||
@ -1270,7 +1271,7 @@ print_columns(struct columnise_opts *opts, unsigned int n,
|
|||||||
if (cols < 2) {
|
if (cols < 2) {
|
||||||
goto prcols_easy;
|
goto prcols_easy;
|
||||||
while (r < n) {
|
while (r < n) {
|
||||||
shf_putc('\n', opts->shf);
|
shf_putc(opts->linesep, opts->shf);
|
||||||
prcols_easy:
|
prcols_easy:
|
||||||
(*func)(str, max_oct, r++, arg);
|
(*func)(str, max_oct, r++, arg);
|
||||||
shf_puts(str, opts->shf);
|
shf_puts(str, opts->shf);
|
||||||
@ -1290,7 +1291,7 @@ print_columns(struct columnise_opts *opts, unsigned int n,
|
|||||||
max_col = -max_col;
|
max_col = -max_col;
|
||||||
goto prcols_hard;
|
goto prcols_hard;
|
||||||
while (r < rows) {
|
while (r < rows) {
|
||||||
shf_putchar('\n', opts->shf);
|
shf_putchar(opts->linesep, opts->shf);
|
||||||
prcols_hard:
|
prcols_hard:
|
||||||
for (c = 0; c < cols; c++) {
|
for (c = 0; c < cols; c++) {
|
||||||
if ((i = c * rows + r) >= n)
|
if ((i = c * rows + r) >= n)
|
||||||
@ -1305,7 +1306,8 @@ print_columns(struct columnise_opts *opts, unsigned int n,
|
|||||||
++r;
|
++r;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
shf_putchar('\n', opts->shf);
|
if (opts->do_last)
|
||||||
|
shf_putchar(opts->linesep, opts->shf);
|
||||||
afree(str, ATEMP);
|
afree(str, ATEMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user