o Don't dump core with ~m in term mode.

o Always put a '\r' before a '\n' at the end of a line
  in prompt_vPrintf() in term mode, and make prompt_Printf()
  use prompt_vPrintf().
o Fix ~? message.
This commit is contained in:
Brian Somers 1998-06-16 07:15:11 +00:00
parent d93d3a9c32
commit f7704be7d3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37011
2 changed files with 40 additions and 16 deletions

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: mbuf.c,v 1.14 1998/05/21 21:46:46 brian Exp $
* $Id: mbuf.c,v 1.15 1998/06/15 19:06:17 brian Exp $
*
*/
#include <sys/types.h>
@ -151,7 +151,6 @@ mbuf_Write(struct mbuf * bp, u_char * ptr, int cnt)
int
mbuf_Show(struct cmdargs const *arg)
{
/* Watch it - ~m calls us with arg == NULL */
int i;
static const char *mbuftype[] = {
"async", "fsm", "hdlcout", "ipin", "echo", "lqr", "link", "vjcomp",

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: prompt.c,v 1.4 1998/05/27 22:43:37 brian Exp $
* $Id: prompt.c,v 1.5 1998/06/15 19:06:53 brian Exp $
*/
#include <sys/param.h>
@ -155,14 +155,12 @@ prompt_IsSet(struct descriptor *d, const fd_set *fdset)
static void
prompt_ShowHelp(struct prompt *p)
{
prompt_Printf(p, "The following commands are available:\r\n");
prompt_Printf(p, " ~p\tEnter Packet mode\r\n");
prompt_Printf(p, " ~-\tDecrease log level\r\n");
prompt_Printf(p, " ~+\tIncrease log level\r\n");
prompt_Printf(p, " ~t\tShow timers\r\n");
prompt_Printf(p, " ~m\tShow memory map\r\n");
prompt_Printf(p, " ~.\tTerminate program\r\n");
prompt_Printf(p, " ~?\tThis help\r\n");
prompt_Printf(p, "The following commands are available:\n");
prompt_Printf(p, " ~p\tEnter Packet mode\n");
prompt_Printf(p, " ~t\tShow timers\n");
prompt_Printf(p, " ~m\tShow memory map\n");
prompt_Printf(p, " ~.\tTerminate program\n");
prompt_Printf(p, " ~?\tThis help\n");
}
static void
@ -250,7 +248,20 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
timer_Show(0, p);
break;
case 'm':
mbuf_Show(NULL);
{
struct cmdargs arg;
arg.cmdtab = NULL;
arg.cmd = NULL;
arg.argc = 0;
arg.argn = 0;
arg.argv = NULL;
arg.bundle = bundle;
arg.cx = p->TermMode;
arg.prompt = p;
mbuf_Show(&arg);
}
break;
default:
if (physical_Write(p->TermMode->physical, &ch, n) < 0) {
@ -343,11 +354,10 @@ prompt_Printf(struct prompt *p, const char *fmt,...)
{
if (p && p->active) {
va_list ap;
va_start(ap, fmt);
vfprintf(p->Term, fmt, ap);
fflush(p->Term);
prompt_vPrintf(p, fmt, ap);
va_end(ap);
p->nonewline = 1;
}
}
@ -355,7 +365,22 @@ void
prompt_vPrintf(struct prompt *p, const char *fmt, va_list ap)
{
if (p && p->active) {
vfprintf(p->Term, fmt, ap);
char nfmt[LINE_LEN];
const char *pfmt;
if (p->TermMode) {
/* Stuff '\r' in front of '\n' 'cos we're in raw mode */
int len = strlen(fmt);
if (len && len < sizeof nfmt - 1 && fmt[len-1] == '\n') {
strcpy(nfmt, fmt);
strcpy(nfmt + len - 1, "\r\n");
pfmt = nfmt;
} else
pfmt = fmt;
} else
pfmt = fmt;
vfprintf(p->Term, pfmt, ap);
fflush(p->Term);
p->nonewline = 1;
}