changeset 5647:7bd40f51b9e9

(double_dollars): New function. (Fread_file_name_internal): Use double_dollars. (Fread_file_name): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Thu, 20 Jan 1994 23:50:37 +0000
parents 9e5b5196aae9
children bd8a172bf8a0
files src/fileio.c
diffstat 1 files changed, 38 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Thu Jan 20 19:58:44 1994 +0000
+++ b/src/fileio.c	Thu Jan 20 23:50:37 1994 +0000
@@ -3457,6 +3457,38 @@
 /* Reading and completing file names */
 extern Lisp_Object Ffile_name_completion (), Ffile_name_all_completions ();
 
+/* In the string VAL, change each $ to $$ and return the result.  */
+
+static Lisp_Object
+double_dollars (val)
+     Lisp_Object val;
+{
+  register unsigned char *old, *new;
+  register int n;
+  int osize, count;
+
+  osize = XSTRING (val)->size;
+  /* Quote "$" as "$$" to get it past substitute-in-file-name */
+  for (n = osize, count = 0, old = XSTRING (val)->data; n > 0; n--)
+    if (*old++ == '$') count++;
+  if (count > 0)
+    {
+      old = XSTRING (val)->data;
+      val = Fmake_string (make_number (osize + count), make_number (0));
+      new = XSTRING (val)->data;
+      for (n = osize; n > 0; n--)
+	if (*old != '$')
+	  *new++ = *old++;
+	else
+	  {
+	    *new++ = '$';
+	    *new++ = '$';
+	    old++;
+	  }
+    }
+  return val;
+}
+
 DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_internal,
   3, 3, 0,
   "Internal subroutine for read-file-name.  Do not call this.")
@@ -3511,33 +3543,10 @@
       if (!NILP (specdir))
 	val = concat2 (specdir, val);
 #ifndef VMS
-      {
-	register unsigned char *old, *new;
-	register int n;
-	int osize, count;
-
-	osize = XSTRING (val)->size;
-	/* Quote "$" as "$$" to get it past substitute-in-file-name */
-	for (n = osize, count = 0, old = XSTRING (val)->data; n > 0; n--)
-	  if (*old++ == '$') count++;
-	if (count > 0)
-	  {
-	    old = XSTRING (val)->data;
-	    val = Fmake_string (make_number (osize + count), make_number (0));
-	    new = XSTRING (val)->data;
-	    for (n = osize; n > 0; n--)
-	      if (*old != '$')
-		*new++ = *old++;
-	      else
-		{
-		  *new++ = '$';
-		  *new++ = '$';
-		  old++;
-		}
-	  }
-      }
-#endif /* Not VMS */
+      return double_dollars (val);
+#else /* not VMS */
       return val;
+#endif /* not VMS */
     }
   UNGCPRO;
 
@@ -3599,8 +3608,10 @@
 	  args[1] = initial;
 	  insdef = Fconcat (2, args);
 	  pos = make_number (XSTRING (dir)->size);
-	  insdef1 = Fcons (insdef, pos);
+	  insdef1 = Fcons (double_dollars (insdef), pos);
 	}
+      else
+	insdef1 = double_dollars (insdef);
     }
   else
     insdef = Qnil, insdef1 = Qnil;