diff --git a/input.c b/input.c index d86397b..5731ccd 100644 --- a/input.c +++ b/input.c @@ -102,6 +102,26 @@ static int nextarg( const char *prompt, char *buf, int size, int terminator) { return gettokval( buf, size) ; } +static char *newnextarg( const char *prompt, int terminator) { + /* if we are interactive, go get it! */ + if( clexec == FALSE) { + char *buf ; + int size ; + + size = term.t_ncol + 1 ; + buf = malloc( size) ; + if( buf != NULL) { + if( TRUE != getstring( prompt, buf, size, terminator)) { + free( buf) ; + buf = NULL ; + } + } + + return buf ; + } else + return getnewtokval() ; +} + /* * Write a prompt into the message line, then read back a response. Keep * track of the physical position of the cursor. If we are in a keyboard @@ -118,6 +138,10 @@ int mlreplyt( const char *prompt, char *buf, int nbuf) { return nextarg( prompt, buf, nbuf, metac) ; } +char *newmlreplyt( const char *prompt) { + return newnextarg( prompt, metac) ; +} + /* * ectoc: * expanded character to character diff --git a/input.h b/input.h index fffd38c..f163c8d 100644 --- a/input.h +++ b/input.h @@ -25,6 +25,7 @@ extern const int nlc ; /* end of input char */ int mlyesno( const char *prompt) ; int mlreply( const char *prompt, char *buf, int nbuf) ; int mlreplyt( const char *prompt, char *buf, int nbuf) ; +char *newmlreplyt( const char *prompt) ; int ectoc( int c) ; fn_t getname( void) ; int tgetc( void) ; diff --git a/random.c b/random.c index b791898..934b9c3 100644 --- a/random.c +++ b/random.c @@ -12,6 +12,7 @@ */ #include +#include #include #include "basic.h" @@ -1191,24 +1192,26 @@ int fmatch(int ch) */ int istring(int f, int n) { - int status; /* status return code */ - char tstring[ 512] ; /* string to add */ + int status ; /* status return code */ + char *tstring ; /* string to add */ /* ask for string to insert */ - status = - mlreplyt( "String to insert: ", tstring, sizeof tstring - 1) ; - if (status != TRUE) - return status; + tstring = newmlreplyt( "String to insert: ") ; + if( tstring == NULL) + return FALSE ; - if (f == FALSE) - n = 1; - - if (n < 0) - n = -n; + if( f == FALSE) + n = 1 ; + else if( n < 0) + n = -n ; /* insert it */ - while (n-- && (status = linstr(tstring))); - return status; + status = TRUE ; + while( n-- && status) + status = linstr( tstring) ; + + free( tstring) ; + return status ; } /*