1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 07:16:23 -05:00

Align implementation of overwrite-string with insert-string.

This commit is contained in:
Renaud 2015-09-28 13:37:22 +08:00
parent cbbd860bdc
commit 3ffa8967ef

View File

@ -1184,19 +1184,12 @@ int fmatch(int ch)
return TRUE; return TRUE;
} }
/* static int iovstring( int f, int n, const char *prompt, int (*fun)( char *)) {
* ask for and insert a string into the current
* buffer at the current point
*
* int f, n; ignored arguments
*/
int istring(int f, int n)
{
int status ; /* status return code */ int status ; /* status return code */
char *tstring ; /* string to add */ char *tstring ; /* string to add */
/* ask for string to insert */ /* ask for string to insert */
tstring = newmlreplyt( "String to insert<META>: ") ; tstring = newmlreplyt( prompt) ;
if( tstring == NULL) if( tstring == NULL)
return FALSE ; return FALSE ;
@ -1208,36 +1201,30 @@ int istring(int f, int n)
/* insert it */ /* insert it */
status = TRUE ; status = TRUE ;
while( n-- && status) while( n-- && status)
status = linstr( tstring) ; status = fun( tstring) ;
free( tstring) ; free( tstring) ;
return status ; return status ;
} }
/*
* ask for and insert a string into the current
* buffer at the current point
*
* int f, n; ignored arguments
*/
int istring( int f, int n) {
return iovstring( f, n, "String to insert<META>: ", linstr) ;
}
/* /*
* ask for and overwite a string into the current * ask for and overwite a string into the current
* buffer at the current point * buffer at the current point
* *
* int f, n; ignored arguments * int f, n; ignored arguments
*/ */
int ovstring(int f, int n) int ovstring( int f, int n) {
{ return iovstring( f, n, "String to overwrite<META>: ", lover) ;
int status; /* status return code */
char tstring[ NSTRING + 1] ; /* string to add */
/* ask for string to insert */
status =
mlreplyt( "String to overwrite<META>: ", tstring, NSTRING) ;
if (status != TRUE)
return status;
if (f == FALSE)
n = 1;
if (n < 0)
n = -n;
/* insert it */
while (n-- && (status = lover(tstring)));
return status;
} }
/* end of random.c */