diff --git a/display.c b/display.c index 96c71d1..ba15667 100644 --- a/display.c +++ b/display.c @@ -1246,7 +1246,7 @@ static void modeline(struct window *wp) } if (!msg) { struct line *lp; - int numlines, predlines, ratio; + int numlines, predlines ; lp = lforw(bp->b_linep); numlines = 0; @@ -1261,13 +1261,23 @@ static void modeline(struct window *wp) if (wp->w_dotp == bp->b_linep) { msg = " Bot "; } else { - ratio = 0; + int ratio = 0 ; + if (numlines != 0) ratio = (100L * predlines) / numlines; if (ratio > 99) ratio = 99; - sprintf(tline, " %2d%% ", ratio); + + tline[ 0] = ' ' ; + tline[ 1] = ratio / 10 + '0' ; + tline[ 2] = ratio % 10 + '0' ; + tline[ 3] = '%' ; + tline[ 4] = ' ' ; + tline[ 5] = 0 ; + if( tline[ 1] == '0') + tline[ 1] = ' ' ; + msg = tline; } } diff --git a/eval.c b/eval.c index 32bc7d3..ebba735 100644 --- a/eval.c +++ b/eval.c @@ -816,19 +816,15 @@ static void mlforce( char *s) ; #if DEBUGM int mdbugout( char *fmt, char *s1, char *s2, char *s3) { - char outline[ NSTRING] ; /* global string to hold debug line text */ - int c, size ; /* input from kbd, output to terminal */ - - /* insure debug info fits in terminal and buffer width */ - size = term.t_ncol + 1 ; - if( size > sizeof outline) - size = sizeof outline ; + int c ; /* input from kbd, output to terminal */ + int savediscmd ; /* assignment status ; variable name ; value we tried to assign */ - snprintf( outline, size, fmt, s1, s2, s3) ; - /* write out the debug line */ - mlforce( outline) ; + savediscmd = discmd ; + discmd = TRUE ; + mlwrite( fmt, s1, s2, s3) ; + discmd = savediscmd ; update( TRUE) ; /* and get the keystroke to hold the output */ diff --git a/file.c b/file.c index 8f43b8d..7e5571e 100644 --- a/file.c +++ b/file.c @@ -655,7 +655,7 @@ int ifile( const char *fname) int s; int nbytes; int nline; - char mesg[NSTRING]; + char *errmsg ; bp = curbp; /* Cheap. */ bp->b_flag |= BFCHG; /* we have changed */ @@ -702,22 +702,21 @@ int ifile( const char *fname) } ffclose(); /* Ignore errors. */ curwp->w_markp = lforw(curwp->w_markp); - strcpy(mesg, "("); - if (s == FIOERR) { - strcat(mesg, "I/O ERROR, "); + if( s == FIOERR) { + errmsg = "I/O ERROR, " ; + curbp->b_flag |= BFTRUNC ; + } else if( s == FIOMEM) { + errmsg = "OUT OF MEMORY, " ; curbp->b_flag |= BFTRUNC; - } - if (s == FIOMEM) { - strcat(mesg, "OUT OF MEMORY, "); - curbp->b_flag |= BFTRUNC; - } - sprintf(&mesg[strlen(mesg)], "Inserted %d line", nline); - if (nline > 1) - strcat(mesg, "s"); - strcat(mesg, ")"); - mloutstr( mesg); + } else + errmsg = "" ; + + mloutfmt( "(%sInserted %d line%s)", + errmsg, + nline, + (nline > 1) ? "s" : "") ; - out: +out: /* advance to the next line and mark the window for changes */ curwp->w_dotp = lforw(curwp->w_dotp); curwp->w_flag |= WFHARD | WFMODE;