sh: Some changes to stderr flushing:
* increase buffer size from 100 to 256 bytes * remove implied flush from out2str(), in particular this avoids unnecessary flushing in the middle of a -x tracing line * rename dprintf() to out2fmt_flush(), make it flush out2 and use this function in various places where flushing is desired after an error message
This commit is contained in:
parent
ee47d334ef
commit
c6204d4a81
@ -92,7 +92,7 @@ histedit(void)
|
||||
if (hist != NULL)
|
||||
sethistsize(histsizeval());
|
||||
else
|
||||
out2str("sh: can't initialize history\n");
|
||||
out2fmt_flush("sh: can't initialize history\n");
|
||||
}
|
||||
if (editing && !el && isatty(0)) { /* && isatty(2) ??? */
|
||||
/*
|
||||
@ -114,7 +114,7 @@ histedit(void)
|
||||
el_set(el, EL_PROMPT, getprompt);
|
||||
} else {
|
||||
bad:
|
||||
out2str("sh: can't initialize editing\n");
|
||||
out2fmt_flush("sh: can't initialize editing\n");
|
||||
}
|
||||
INTON;
|
||||
} else if (!editing && el) {
|
||||
@ -336,6 +336,7 @@ histcmd(int argc, char **argv)
|
||||
if (sflg) {
|
||||
if (displayhist) {
|
||||
out2str(s);
|
||||
flushout(out2);
|
||||
}
|
||||
evalstring(s, 0);
|
||||
if (displayhist && hist) {
|
||||
|
@ -215,7 +215,7 @@ preadfd(void)
|
||||
if (flags >= 0 && flags & O_NONBLOCK) {
|
||||
flags &=~ O_NONBLOCK;
|
||||
if (fcntl(0, F_SETFL, flags) >= 0) {
|
||||
out2str("sh: turning off NDELAY mode\n");
|
||||
out2fmt_flush("sh: turning off NDELAY mode\n");
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
@ -359,7 +359,7 @@ pushstring(char *s, int len, void *ap)
|
||||
struct strpush *sp;
|
||||
|
||||
INTOFF;
|
||||
/*dprintf("*** calling pushstring: %s, %d\n", s, len);*/
|
||||
/*out2fmt_flush("*** calling pushstring: %s, %d\n", s, len);*/
|
||||
if (parsefile->strpush) {
|
||||
sp = ckmalloc(sizeof (struct strpush));
|
||||
sp->prev = parsefile->strpush;
|
||||
@ -386,7 +386,7 @@ popstring(void)
|
||||
parsenextc = sp->prevstring;
|
||||
parsenleft = sp->prevnleft;
|
||||
parselleft = sp->prevlleft;
|
||||
/*dprintf("*** calling popstring: restoring to '%s'\n", parsenextc);*/
|
||||
/*out2fmt_flush("*** calling popstring: restoring to '%s'\n", parsenextc);*/
|
||||
if (sp->ap)
|
||||
sp->ap->flag &= ~ALIASINUSE;
|
||||
parsefile->strpush = sp->prev;
|
||||
|
@ -146,7 +146,7 @@ setjobctl(int on)
|
||||
do { /* while we are in the background */
|
||||
initialpgrp = tcgetpgrp(ttyfd);
|
||||
if (initialpgrp < 0) {
|
||||
out: out2str("sh: can't access tty; job control turned off\n");
|
||||
out: out2fmt_flush("sh: can't access tty; job control turned off\n");
|
||||
mflag = 0;
|
||||
return;
|
||||
}
|
||||
@ -1046,7 +1046,7 @@ stoppedjobs(void)
|
||||
if (jp->used == 0)
|
||||
continue;
|
||||
if (jp->state == JOBSTOPPED) {
|
||||
out2str("You have stopped jobs.\n");
|
||||
out2fmt_flush("You have stopped jobs.\n");
|
||||
job_warning = 2;
|
||||
return (1);
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ main(int argc, char *argv[])
|
||||
setstackmark(&smark);
|
||||
procargs(argc, argv);
|
||||
if (getpwd() == NULL && iflag)
|
||||
out2str("sh: cannot determine working directory\n");
|
||||
out2fmt_flush("sh: cannot determine working directory\n");
|
||||
if (getpwd() != NULL)
|
||||
setvar ("PWD", getpwd(), VEXPORT);
|
||||
if (argv[0] && argv[0][0] == '-') {
|
||||
@ -223,7 +223,7 @@ cmdloop(int top)
|
||||
if (!stoppedjobs()) {
|
||||
if (!Iflag)
|
||||
break;
|
||||
out2str("\nUse \"exit\" to leave shell.\n");
|
||||
out2fmt_flush("\nUse \"exit\" to leave shell.\n");
|
||||
}
|
||||
numeof++;
|
||||
} else if (n != NULL && nflag == 0) {
|
||||
|
@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
|
||||
static int doformat_wr(void *, const char *, int);
|
||||
|
||||
struct output output = {NULL, 0, NULL, OUTBUFSIZ, 1, 0};
|
||||
struct output errout = {NULL, 0, NULL, 100, 2, 0};
|
||||
struct output errout = {NULL, 0, NULL, 256, 2, 0};
|
||||
struct output memout = {NULL, 0, NULL, 0, MEM_OUT, 0};
|
||||
struct output *out1 = &output;
|
||||
struct output *out2 = &errout;
|
||||
@ -124,8 +124,6 @@ outstr(const char *p, struct output *file)
|
||||
{
|
||||
while (*p)
|
||||
outc(*p++, file);
|
||||
if (file == out2)
|
||||
flushout(file);
|
||||
}
|
||||
|
||||
/* Like outstr(), but quote for re-input into the shell. */
|
||||
@ -255,7 +253,7 @@ out1fmt(const char *fmt, ...)
|
||||
}
|
||||
|
||||
void
|
||||
dprintf(const char *fmt, ...)
|
||||
out2fmt_flush(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
@ -65,7 +65,7 @@ void flushout(struct output *);
|
||||
void freestdout(void);
|
||||
void outfmt(struct output *, const char *, ...) __printflike(2, 3);
|
||||
void out1fmt(const char *, ...) __printflike(1, 2);
|
||||
void dprintf(const char *, ...) __printflike(1, 2);
|
||||
void out2fmt_flush(const char *, ...) __printflike(1, 2);
|
||||
void fmtstr(char *, int, const char *, ...) __printflike(3, 4);
|
||||
void doformat(struct output *, const char *, va_list) __printflike(2, 0);
|
||||
int xwrite(int, char *, int);
|
||||
|
@ -1563,7 +1563,10 @@ setprompt(int which)
|
||||
#ifndef NO_HISTORY
|
||||
if (!el)
|
||||
#endif
|
||||
{
|
||||
out2str(getprompt(NULL));
|
||||
flushout(out2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user