aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dired.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/dired.c b/src/dired.c
index d012eaaa140..39c64d28393 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -113,7 +113,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\
113 Lisp_Object dirname, full, match, nosort; 113 Lisp_Object dirname, full, match, nosort;
114{ 114{
115 DIR *d; 115 DIR *d;
116 int length; 116 int dirnamelen;
117 Lisp_Object list, name, dirfilename; 117 Lisp_Object list, name, dirfilename;
118 Lisp_Object handler; 118 Lisp_Object handler;
119 struct re_pattern_buffer *bufp; 119 struct re_pattern_buffer *bufp;
@@ -174,7 +174,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\
174 report_file_error ("Opening directory", Fcons (dirname, Qnil)); 174 report_file_error ("Opening directory", Fcons (dirname, Qnil));
175 175
176 list = Qnil; 176 list = Qnil;
177 length = XSTRING (dirname)->size; 177 dirnamelen = XSTRING (dirname)->size;
178 178
179 /* Loop reading blocks */ 179 /* Loop reading blocks */
180 while (1) 180 while (1)
@@ -191,23 +191,24 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\
191 { 191 {
192 if (!NILP (full)) 192 if (!NILP (full))
193 { 193 {
194 int index = XSTRING (dirname)->size; 194 int afterdirindex = dirnamelen;
195 int total = len + index; 195 int total = len + dirnamelen;
196 int needsep = 0;
197
198 /* Decide whether we need to add a directory separator. */
196#ifndef VMS 199#ifndef VMS
197 if (length == 0 200 if (dirnamelen == 0
198 || !IS_ANY_SEP (XSTRING (dirname)->data[length - 1])) 201 || !IS_ANY_SEP (XSTRING (dirname)->data[dirnamelen - 1]))
199 total++; 202 needsep = 1;
200#endif /* VMS */ 203#endif /* VMS */
201 204
202 name = make_uninit_string (total); 205 name = make_uninit_string (total + needsep);
203 bcopy (XSTRING (dirname)->data, XSTRING (name)->data, 206 bcopy (XSTRING (dirname)->data, XSTRING (name)->data,
204 index); 207 dirnamelen);
205#ifndef VMS 208 if (needsep)
206 if (length == 0 209 XSTRING (name)->data[afterdirindex++] = DIRECTORY_SEP;
207 || IS_ANY_SEP (XSTRING (dirname)->data[length - 1])) 210 bcopy (dp->d_name,
208 XSTRING (name)->data[index++] = DIRECTORY_SEP; 211 XSTRING (name)->data + afterdirindex, len);
209#endif /* VMS */
210 bcopy (dp->d_name, XSTRING (name)->data + index, len);
211 } 212 }
212 else 213 else
213 name = make_string (dp->d_name, len); 214 name = make_string (dp->d_name, len);