From f83ab0860941d314cb480821d1a9ba1c250518ca Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 5 Apr 2016 11:33:38 +0800 Subject: [PATCH] Review formatted string printing when '%' is at end of string. Clean up unused IO return code. --- display.c | 15 ++++++++------- fileio.h | 3 +-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/display.c b/display.c index 13c913c..f57f6b1 100644 --- a/display.c +++ b/display.c @@ -1333,12 +1333,14 @@ void vmlwrite( const char *fmt, va_list ap) { movecursor( term.t_nrow, 0) ; mpresf = *fmt ? TRUE : FALSE ; /* flag if line has content or not */ - while ((c = *fmt++) != 0) { - if (c != '%') + while( ( c = *fmt++) != 0) + if( c != '%') mlputc( c) ; - else { - c = *fmt++; - switch (c) { + else if( ( c = *fmt++) == 0) { + mlputc( '%') ; + break ; + } else + switch( c) { case 'd': mlputi(va_arg(ap, int), 10); break; @@ -1369,11 +1371,10 @@ void vmlwrite( const char *fmt, va_list ap) { default: mlputc( '%') ; + /* fallthrough */ case '%': mlputc( c) ; } - } - } /* if we can, erase to the end of screen */ if( eolexist == TRUE && ttcol < term.t_ncol) diff --git a/fileio.h b/fileio.h index 0de0888..7f14184 100644 --- a/fileio.h +++ b/fileio.h @@ -6,8 +6,7 @@ typedef enum { FIOFNF, /* File I/O, file not found. */ FIOEOF, /* File I/O, end of file. */ FIOERR, /* File I/O, error. */ - FIOMEM, /* File I/O, out of memory */ - FIOFUN /* File I/O, eod of file/bad line */ + FIOMEM /* File I/O, out of memory */ } fio_code ; #define FTYPE_NONE 0