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