mirror of
https://github.com/rfivet/uemacs.git
synced 2024-06-29 04:55:31 +00: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) {
|
if (!msg) {
|
||||||
struct line *lp;
|
struct line *lp;
|
||||||
int numlines, predlines, ratio;
|
int numlines, predlines ;
|
||||||
|
|
||||||
lp = lforw(bp->b_linep);
|
lp = lforw(bp->b_linep);
|
||||||
numlines = 0;
|
numlines = 0;
|
||||||
|
@ -1261,13 +1261,23 @@ static void modeline(struct window *wp)
|
||||||
if (wp->w_dotp == bp->b_linep) {
|
if (wp->w_dotp == bp->b_linep) {
|
||||||
msg = " Bot ";
|
msg = " Bot ";
|
||||||
} else {
|
} else {
|
||||||
ratio = 0;
|
int ratio = 0 ;
|
||||||
|
|
||||||
if (numlines != 0)
|
if (numlines != 0)
|
||||||
ratio =
|
ratio =
|
||||||
(100L * predlines) / numlines;
|
(100L * predlines) / numlines;
|
||||||
if (ratio > 99)
|
if (ratio > 99)
|
||||||
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;
|
msg = tline;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
16
eval.c
16
eval.c
|
@ -816,19 +816,15 @@ static void mlforce( char *s) ;
|
||||||
|
|
||||||
#if DEBUGM
|
#if DEBUGM
|
||||||
int mdbugout( char *fmt, char *s1, char *s2, char *s3) {
|
int mdbugout( char *fmt, char *s1, char *s2, char *s3) {
|
||||||
char outline[ NSTRING] ; /* global string to hold debug line text */
|
int c ; /* input from kbd, output to terminal */
|
||||||
int c, size ; /* input from kbd, output to terminal */
|
int savediscmd ;
|
||||||
|
|
||||||
/* insure debug info fits in terminal and buffer width */
|
|
||||||
size = term.t_ncol + 1 ;
|
|
||||||
if( size > sizeof outline)
|
|
||||||
size = sizeof outline ;
|
|
||||||
|
|
||||||
/* assignment status ; variable name ; value we tried to assign */
|
/* assignment status ; variable name ; value we tried to assign */
|
||||||
snprintf( outline, size, fmt, s1, s2, s3) ;
|
|
||||||
|
|
||||||
/* write out the debug line */
|
/* write out the debug line */
|
||||||
mlforce( outline) ;
|
savediscmd = discmd ;
|
||||||
|
discmd = TRUE ;
|
||||||
|
mlwrite( fmt, s1, s2, s3) ;
|
||||||
|
discmd = savediscmd ;
|
||||||
update( TRUE) ;
|
update( TRUE) ;
|
||||||
|
|
||||||
/* and get the keystroke to hold the output */
|
/* 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 s;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
int nline;
|
int nline;
|
||||||
char mesg[NSTRING];
|
char *errmsg ;
|
||||||
|
|
||||||
bp = curbp; /* Cheap. */
|
bp = curbp; /* Cheap. */
|
||||||
bp->b_flag |= BFCHG; /* we have changed */
|
bp->b_flag |= BFCHG; /* we have changed */
|
||||||
|
@ -702,20 +702,19 @@ int ifile( const char *fname)
|
||||||
}
|
}
|
||||||
ffclose(); /* Ignore errors. */
|
ffclose(); /* Ignore errors. */
|
||||||
curwp->w_markp = lforw(curwp->w_markp);
|
curwp->w_markp = lforw(curwp->w_markp);
|
||||||
strcpy(mesg, "(");
|
|
||||||
if( s == FIOERR) {
|
if( s == FIOERR) {
|
||||||
strcat(mesg, "I/O ERROR, ");
|
errmsg = "I/O ERROR, " ;
|
||||||
curbp->b_flag |= BFTRUNC ;
|
curbp->b_flag |= BFTRUNC ;
|
||||||
}
|
} else if( s == FIOMEM) {
|
||||||
if (s == FIOMEM) {
|
errmsg = "OUT OF MEMORY, " ;
|
||||||
strcat(mesg, "OUT OF MEMORY, ");
|
|
||||||
curbp->b_flag |= BFTRUNC;
|
curbp->b_flag |= BFTRUNC;
|
||||||
}
|
} else
|
||||||
sprintf(&mesg[strlen(mesg)], "Inserted %d line", nline);
|
errmsg = "" ;
|
||||||
if (nline > 1)
|
|
||||||
strcat(mesg, "s");
|
mloutfmt( "(%sInserted %d line%s)",
|
||||||
strcat(mesg, ")");
|
errmsg,
|
||||||
mloutstr( mesg);
|
nline,
|
||||||
|
(nline > 1) ? "s" : "") ;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
/* advance to the next line and mark the window for changes */
|
/* advance to the next line and mark the window for changes */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user