From owner-svn-src-head@FreeBSD.ORG Sat Nov 21 14:28:32 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9BC6106566C; Sat, 21 Nov 2009 14:28:32 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CECCF8FC14; Sat, 21 Nov 2009 14:28:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nALESWOM082010; Sat, 21 Nov 2009 14:28:32 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nALESWpF082002; Sat, 21 Nov 2009 14:28:32 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <200911211428.nALESWpF082002@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 21 Nov 2009 14:28:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199629 - head/bin/sh X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2009 14:28:33 -0000 Author: jilles Date: Sat Nov 21 14:28:32 2009 New Revision: 199629 URL: http://svn.freebsd.org/changeset/base/199629 Log: 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 Modified: head/bin/sh/histedit.c head/bin/sh/input.c head/bin/sh/jobs.c head/bin/sh/main.c head/bin/sh/output.c head/bin/sh/output.h head/bin/sh/parser.c Modified: head/bin/sh/histedit.c ============================================================================== --- head/bin/sh/histedit.c Sat Nov 21 14:12:51 2009 (r199628) +++ head/bin/sh/histedit.c Sat Nov 21 14:28:32 2009 (r199629) @@ -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) { Modified: head/bin/sh/input.c ============================================================================== --- head/bin/sh/input.c Sat Nov 21 14:12:51 2009 (r199628) +++ head/bin/sh/input.c Sat Nov 21 14:28:32 2009 (r199629) @@ -215,7 +215,7 @@ retry: 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; Modified: head/bin/sh/jobs.c ============================================================================== --- head/bin/sh/jobs.c Sat Nov 21 14:12:51 2009 (r199628) +++ head/bin/sh/jobs.c Sat Nov 21 14:28:32 2009 (r199629) @@ -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); } Modified: head/bin/sh/main.c ============================================================================== --- head/bin/sh/main.c Sat Nov 21 14:12:51 2009 (r199628) +++ head/bin/sh/main.c Sat Nov 21 14:28:32 2009 (r199629) @@ -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) { Modified: head/bin/sh/output.c ============================================================================== --- head/bin/sh/output.c Sat Nov 21 14:12:51 2009 (r199628) +++ head/bin/sh/output.c Sat Nov 21 14:28:32 2009 (r199629) @@ -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 *fil { 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; Modified: head/bin/sh/output.h ============================================================================== --- head/bin/sh/output.h Sat Nov 21 14:12:51 2009 (r199628) +++ head/bin/sh/output.h Sat Nov 21 14:28:32 2009 (r199629) @@ -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); Modified: head/bin/sh/parser.c ============================================================================== --- head/bin/sh/parser.c Sat Nov 21 14:12:51 2009 (r199628) +++ head/bin/sh/parser.c Sat Nov 21 14:28:32 2009 (r199629) @@ -1563,7 +1563,10 @@ setprompt(int which) #ifndef NO_HISTORY if (!el) #endif + { out2str(getprompt(NULL)); + flushout(out2); + } } /*