# HG changeset patch # User Richard M. Stallman # Date 759109837 0 # Node ID 7bd40f51b9e945a6e16a9ea3a71545c0fba57fdf # Parent 9e5b5196aae963961e9fbea840eb93e7d40a1015 (double_dollars): New function. (Fread_file_name_internal): Use double_dollars. (Fread_file_name): Likewise. diff -r 9e5b5196aae9 -r 7bd40f51b9e9 src/fileio.c --- 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;