mirror of
https://github.com/rfivet/uemacs.git
synced 2024-11-17 18:16:22 -05:00
Avoid unnecessary sprintf & buffers when updating message or status line.
This commit is contained in:
parent
c10c550bdd
commit
2b8992350d
16
display.c
16
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;
|
||||
}
|
||||
}
|
||||
|
16
eval.c
16
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 */
|
||||
|
23
file.c
23
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,20 +702,19 @@ 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, ");
|
||||
errmsg = "I/O ERROR, " ;
|
||||
curbp->b_flag |= BFTRUNC ;
|
||||
}
|
||||
if (s == FIOMEM) {
|
||||
strcat(mesg, "OUT OF MEMORY, ");
|
||||
} else if( s == FIOMEM) {
|
||||
errmsg = "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:
|
||||
/* advance to the next line and mark the window for changes */
|
||||
|
Loading…
Reference in New Issue
Block a user