aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1993-03-15 03:04:52 +0000
committerJim Blandy1993-03-15 03:04:52 +0000
commit6155fae1c87411ff6269131a1342fa0633429f48 (patch)
treec49232e3d5081b73c9cdf8afb432916027344086 /src
parent4095411173aff1b64aecb03bb737408e1b744120 (diff)
downloademacs-6155fae1c87411ff6269131a1342fa0633429f48.tar.gz
emacs-6155fae1c87411ff6269131a1342fa0633429f48.zip
* dired.c (Fdirectory_files): Compile the MATCH regexp after
calling everything else which might compile a regexp. * dired.c (Fdirectory_files): Properly GCPRO the strings while calling Fexpand_file_name and Fdirectory_file_name.
Diffstat (limited to 'src')
-rw-r--r--src/dired.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/dired.c b/src/dired.c
index 23bb41e7496..35de7515d72 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -100,7 +100,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\
100{ 100{
101 DIR *d; 101 DIR *d;
102 int length; 102 int length;
103 Lisp_Object list, name; 103 Lisp_Object list, name, dirfilename;
104 Lisp_Object handler; 104 Lisp_Object handler;
105 105
106 /* If the file name has special constructs in it, 106 /* If the file name has special constructs in it,
@@ -119,6 +119,18 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\
119 return Ffuncall (6, args); 119 return Ffuncall (6, args);
120 } 120 }
121 121
122 {
123 struct gcpro gcpro1, gcpro2;
124
125 /* Because of file name handlers, these functions might call
126 Ffuncall, and cause a GC. */
127 GCPRO1 (match);
128 dirname = Fexpand_file_name (dirname, Qnil);
129 GCPRO2 (match, dirname);
130 dirfilename = Fdirectory_file_name (dirname);
131 UNGCPRO;
132 }
133
122 if (!NILP (match)) 134 if (!NILP (match))
123 { 135 {
124 CHECK_STRING (match, 3); 136 CHECK_STRING (match, 3);
@@ -134,8 +146,15 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\
134#endif 146#endif
135 } 147 }
136 148
137 dirname = Fexpand_file_name (dirname, Qnil); 149 /* Now searchbuf is the compiled form of MATCH; don't call anything
138 if (!(d = opendir (XSTRING (Fdirectory_file_name (dirname))->data))) 150 which might compile a new regexp until we're done with the loop! */
151
152 /* Do this opendir after anything which might signal an error; if
153 an error is signalled while the directory stream is open, we
154 have to make sure it gets closed, and setting up an
155 unwind_protect to do so would be a pain. */
156 d = opendir (XSTRING (dirfilename)->data);
157 if (! d)
139 report_file_error ("Opening directory", Fcons (dirname, Qnil)); 158 report_file_error ("Opening directory", Fcons (dirname, Qnil));
140 159
141 list = Qnil; 160 list = Qnil;