From bb44fc57ad2b62b3495a41c609af568c687abf1c Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 13 Feb 2015 17:46:42 +0800 Subject: [PATCH] Limit the scope of mlforce to eval. --- display.c | 16 ---------------- display.h | 1 - eval.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ eval.h | 3 +++ random.c | 30 ------------------------------ random.h | 2 -- 6 files changed, 53 insertions(+), 49 deletions(-) diff --git a/display.c b/display.c index 18bc062..96c71d1 100644 --- a/display.c +++ b/display.c @@ -1420,22 +1420,6 @@ void mlwrite(const char *fmt, ...) TTflush(); } -/* - * Force a string out to the message line regardless of the - * current $discmd setting. This is needed when $debug is TRUE - * and for the write-message and clear-message-line commands - * - * char *s; string to force out - */ -void mlforce( char *s) { - int oldcmd; /* original command display flag */ - - oldcmd = discmd; /* save the discmd value */ - discmd = TRUE; /* and turn display on */ - mlwrite( (*s) ? "%s" : "", s) ; /* write the string out or erase line */ - discmd = oldcmd; /* and restore the original setting */ -} - /* * Write out a string. Update the physical cursor position. This assumes that * the characters in the string all have width "1"; if this is not the case diff --git a/display.h b/display.h index 26ba4fc..82d4adb 100644 --- a/display.h +++ b/display.h @@ -23,7 +23,6 @@ void upmode( void) ; void movecursor( int row, int col) ; void mlerase( void) ; void mlwrite( const char *fmt, ...) ; -void mlforce( char *s) ; void getscreensize( int *widthp, int *heightp) ; #if UNIX diff --git a/eval.c b/eval.c index c50c88a..2a5bd33 100644 --- a/eval.c +++ b/eval.c @@ -808,6 +808,8 @@ int setvar(int f, int n) return status; } +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 */ @@ -1393,3 +1395,51 @@ static char *xlat( char *source, char *lookup, char *trans) { *rp = 0; return result; } + +/* + * Force a string out to the message line regardless of the + * current $discmd setting. This is needed when $debug is TRUE + * and for the write-message and clear-message-line commands + * + * char *s; string to force out + */ +static void mlforce( char *s) { + int oldcmd; /* original command display flag */ + + oldcmd = discmd; /* save the discmd value */ + discmd = TRUE; /* and turn display on */ + mlwrite( (*s) ? "%s" : "", s) ; /* write the string out or erase line */ + discmd = oldcmd; /* and restore the original setting */ +} + +/* + * This function simply clears the message line, + * mainly for macro usage + * + * int f, n; arguments ignored + */ +int clrmes( int f, int n) { + mlforce( "") ; + return TRUE ; +} + +/* + * This function writes a string on the message line + * mainly for macro usage + * + * int f, n; arguments ignored + */ +int writemsg( int f, int n) { + int status; + char buf[ NSTRING] ; /* buffer to recieve message into */ + + status = mlreply( "Message to write: ", buf, sizeof buf - 1) ; + if( status != TRUE) + return status ; + + /* write the message out */ + mlforce( buf) ; + return TRUE ; +} + + diff --git a/eval.h b/eval.h index 1778061..dea3397 100644 --- a/eval.h +++ b/eval.h @@ -26,4 +26,7 @@ int stol( char *val) ; char *mklower( char *str) ; int abs( int x) ; +int clrmes( int f, int n) ; +int writemsg( int f, int n) ; + #endif diff --git a/random.c b/random.c index 384f471..f13bc1a 100644 --- a/random.c +++ b/random.c @@ -1014,36 +1014,6 @@ int adjustmode(int kind, int global) return FALSE; } -/* - * This function simply clears the message line, - * mainly for macro usage - * - * int f, n; arguments ignored - */ -int clrmes( int f, int n) { - mlforce( "") ; - return TRUE ; -} - -/* - * This function writes a string on the message line - * mainly for macro usage - * - * int f, n; arguments ignored - */ -int writemsg( int f, int n) { - int status; - char buf[ NSTRING] ; /* buffer to recieve message into */ - - status = mlreply( "Message to write: ", buf, sizeof buf - 1) ; - if( status != TRUE) - return status ; - - /* write the message out */ - mlforce( buf) ; - return TRUE ; -} - #if CFENCE /* * the cursor is moved to a matching fence diff --git a/random.h b/random.h index 749a62c..e3136cd 100644 --- a/random.h +++ b/random.h @@ -42,8 +42,6 @@ int delmode( int f, int n) ; int setgmode( int f, int n) ; int delgmode( int f, int n) ; int adjustmode( int kind, int global) ; -int clrmes( int f, int n) ; -int writemsg( int f, int n) ; int getfence( int f, int n) ; int fmatch( int ch) ; int istring( int f, int n) ;