diff options
| author | Andreas Schwab | 1998-04-06 09:11:05 +0000 |
|---|---|---|
| committer | Andreas Schwab | 1998-04-06 09:11:05 +0000 |
| commit | 96d6400464cb2c73925e723c256089bb572f706c (patch) | |
| tree | 9b2a4a31a92b39fcae00eac5d7d4e8f24c9a9d6d /src | |
| parent | 6feef451539bfd40ee1aea706290d734bdda6ff7 (diff) | |
| download | emacs-96d6400464cb2c73925e723c256089bb572f706c.tar.gz emacs-96d6400464cb2c73925e723c256089bb572f706c.zip | |
(Fdirectory_files): GCPRO encoded_directory and list.
Compute needsep only once. Pass correct arg to chars_in_text.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dired.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/dired.c b/src/dired.c index 090f58b7252..12406b8041b 100644 --- a/src/dired.c +++ b/src/dired.c | |||
| @@ -122,6 +122,8 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\ | |||
| 122 | Lisp_Object encoded_directory; | 122 | Lisp_Object encoded_directory; |
| 123 | Lisp_Object handler; | 123 | Lisp_Object handler; |
| 124 | struct re_pattern_buffer *bufp; | 124 | struct re_pattern_buffer *bufp; |
| 125 | int needsep = 0; | ||
| 126 | struct gcpro gcpro1, gcpro2; | ||
| 125 | 127 | ||
| 126 | /* If the file name has special constructs in it, | 128 | /* If the file name has special constructs in it, |
| 127 | call the corresponding file handler. */ | 129 | call the corresponding file handler. */ |
| @@ -139,18 +141,14 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\ | |||
| 139 | return Ffuncall (6, args); | 141 | return Ffuncall (6, args); |
| 140 | } | 142 | } |
| 141 | 143 | ||
| 142 | { | 144 | /* Because of file name handlers, these functions might call |
| 143 | struct gcpro gcpro1, gcpro2; | ||
| 144 | |||
| 145 | /* Because of file name handlers, these functions might call | ||
| 146 | Ffuncall, and cause a GC. */ | 145 | Ffuncall, and cause a GC. */ |
| 147 | GCPRO1 (match); | 146 | GCPRO1 (match); |
| 148 | directory = Fexpand_file_name (directory, Qnil); | 147 | directory = Fexpand_file_name (directory, Qnil); |
| 149 | UNGCPRO; | 148 | UNGCPRO; |
| 150 | GCPRO2 (match, directory); | 149 | GCPRO2 (match, directory); |
| 151 | dirfilename = Fdirectory_file_name (directory); | 150 | dirfilename = Fdirectory_file_name (directory); |
| 152 | UNGCPRO; | 151 | UNGCPRO; |
| 153 | } | ||
| 154 | 152 | ||
| 155 | if (!NILP (match)) | 153 | if (!NILP (match)) |
| 156 | { | 154 | { |
| @@ -188,6 +186,15 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\ | |||
| 188 | dirnamelen = XSTRING (encoded_directory)->size; | 186 | dirnamelen = XSTRING (encoded_directory)->size; |
| 189 | re_match_object = Qt; | 187 | re_match_object = Qt; |
| 190 | 188 | ||
| 189 | /* Decide whether we need to add a directory separator. */ | ||
| 190 | #ifndef VMS | ||
| 191 | if (dirnamelen == 0 | ||
| 192 | || !IS_ANY_SEP (XSTRING (encoded_directory)->data[dirnamelen - 1])) | ||
| 193 | needsep = 1; | ||
| 194 | #endif /* VMS */ | ||
| 195 | |||
| 196 | GCPRO2 (encoded_directory, list); | ||
| 197 | |||
| 191 | /* Loop reading blocks */ | 198 | /* Loop reading blocks */ |
| 192 | while (1) | 199 | while (1) |
| 193 | { | 200 | { |
| @@ -205,16 +212,8 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\ | |||
| 205 | { | 212 | { |
| 206 | int afterdirindex = dirnamelen; | 213 | int afterdirindex = dirnamelen; |
| 207 | int total = len + dirnamelen; | 214 | int total = len + dirnamelen; |
| 208 | int needsep = 0; | ||
| 209 | int nchars; | 215 | int nchars; |
| 210 | 216 | ||
| 211 | /* Decide whether we need to add a directory separator. */ | ||
| 212 | #ifndef VMS | ||
| 213 | if (dirnamelen == 0 | ||
| 214 | || !IS_ANY_SEP (XSTRING (encoded_directory)->data[dirnamelen - 1])) | ||
| 215 | needsep = 1; | ||
| 216 | #endif /* VMS */ | ||
| 217 | |||
| 218 | name = make_uninit_string (total + needsep); | 217 | name = make_uninit_string (total + needsep); |
| 219 | bcopy (XSTRING (encoded_directory)->data, XSTRING (name)->data, | 218 | bcopy (XSTRING (encoded_directory)->data, XSTRING (name)->data, |
| 220 | dirnamelen); | 219 | dirnamelen); |
| @@ -222,7 +221,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\ | |||
| 222 | XSTRING (name)->data[afterdirindex++] = DIRECTORY_SEP; | 221 | XSTRING (name)->data[afterdirindex++] = DIRECTORY_SEP; |
| 223 | bcopy (dp->d_name, | 222 | bcopy (dp->d_name, |
| 224 | XSTRING (name)->data + afterdirindex, len); | 223 | XSTRING (name)->data + afterdirindex, len); |
| 225 | nchars = chars_in_text (dp->d_name, | 224 | nchars = chars_in_text (XSTRING (name)->data, |
| 226 | afterdirindex + len); | 225 | afterdirindex + len); |
| 227 | XSTRING (name)->size = nchars; | 226 | XSTRING (name)->size = nchars; |
| 228 | if (nchars == STRING_BYTES (XSTRING (name))) | 227 | if (nchars == STRING_BYTES (XSTRING (name))) |
| @@ -236,6 +235,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\ | |||
| 236 | } | 235 | } |
| 237 | } | 236 | } |
| 238 | closedir (d); | 237 | closedir (d); |
| 238 | UNGCPRO; | ||
| 239 | if (!NILP (nosort)) | 239 | if (!NILP (nosort)) |
| 240 | return list; | 240 | return list; |
| 241 | return Fsort (Fnreverse (list), Qstring_lessp); | 241 | return Fsort (Fnreverse (list), Qstring_lessp); |