diff options
| author | Joakim Verona | 2012-09-03 17:30:17 +0200 |
|---|---|---|
| committer | Joakim Verona | 2012-09-03 17:30:17 +0200 |
| commit | 4a37733c693d59a9b83a3fb2d0c7f9461d149f60 (patch) | |
| tree | a33402e09342f748baebf0e4f5a1e40538e620f4 /src/dired.c | |
| parent | 5436d1df5e2ba0b4d4f72b03a1cd09b20403654b (diff) | |
| parent | dcde497f27945c3ca4ce8c21f655ef6f627acdd2 (diff) | |
| download | emacs-4a37733c693d59a9b83a3fb2d0c7f9461d149f60.tar.gz emacs-4a37733c693d59a9b83a3fb2d0c7f9461d149f60.zip | |
upstream
Diffstat (limited to 'src/dired.c')
| -rw-r--r-- | src/dired.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/dired.c b/src/dired.c index 771230717e3..fa293258107 100644 --- a/src/dired.c +++ b/src/dired.c | |||
| @@ -109,18 +109,20 @@ directory_files_internal_unwind (Lisp_Object dh) | |||
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | /* Function shared by Fdirectory_files and Fdirectory_files_and_attributes. | 111 | /* Function shared by Fdirectory_files and Fdirectory_files_and_attributes. |
| 112 | When ATTRS is zero, return a list of directory filenames; when | 112 | If not ATTRS, return a list of directory filenames; |
| 113 | non-zero, return a list of directory filenames and their attributes. | 113 | if ATTRS, return a list of directory filenames and their attributes. |
| 114 | In the latter case, ID_FORMAT is passed to Ffile_attributes. */ | 114 | In the latter case, ID_FORMAT is passed to Ffile_attributes. */ |
| 115 | 115 | ||
| 116 | Lisp_Object | 116 | Lisp_Object |
| 117 | directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object match, Lisp_Object nosort, int attrs, Lisp_Object id_format) | 117 | directory_files_internal (Lisp_Object directory, Lisp_Object full, |
| 118 | Lisp_Object match, Lisp_Object nosort, bool attrs, | ||
| 119 | Lisp_Object id_format) | ||
| 118 | { | 120 | { |
| 119 | DIR *d; | 121 | DIR *d; |
| 120 | ptrdiff_t directory_nbytes; | 122 | ptrdiff_t directory_nbytes; |
| 121 | Lisp_Object list, dirfilename, encoded_directory; | 123 | Lisp_Object list, dirfilename, encoded_directory; |
| 122 | struct re_pattern_buffer *bufp = NULL; | 124 | struct re_pattern_buffer *bufp = NULL; |
| 123 | int needsep = 0; | 125 | bool needsep = 0; |
| 124 | ptrdiff_t count = SPECPDL_INDEX (); | 126 | ptrdiff_t count = SPECPDL_INDEX (); |
| 125 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 127 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 126 | DIRENTRY *dp; | 128 | DIRENTRY *dp; |
| @@ -227,7 +229,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object m | |||
| 227 | if (DIRENTRY_NONEMPTY (dp)) | 229 | if (DIRENTRY_NONEMPTY (dp)) |
| 228 | { | 230 | { |
| 229 | ptrdiff_t len; | 231 | ptrdiff_t len; |
| 230 | int wanted = 0; | 232 | bool wanted = 0; |
| 231 | Lisp_Object name, finalname; | 233 | Lisp_Object name, finalname; |
| 232 | struct gcpro gcpro1, gcpro2; | 234 | struct gcpro gcpro1, gcpro2; |
| 233 | 235 | ||
| @@ -381,9 +383,8 @@ which see. */) | |||
| 381 | } | 383 | } |
| 382 | 384 | ||
| 383 | 385 | ||
| 384 | static Lisp_Object file_name_completion | 386 | static Lisp_Object file_name_completion (Lisp_Object, Lisp_Object, bool, |
| 385 | (Lisp_Object file, Lisp_Object dirname, int all_flag, int ver_flag, | 387 | Lisp_Object); |
| 386 | Lisp_Object predicate); | ||
| 387 | 388 | ||
| 388 | DEFUN ("file-name-completion", Ffile_name_completion, Sfile_name_completion, | 389 | DEFUN ("file-name-completion", Ffile_name_completion, Sfile_name_completion, |
| 389 | 2, 3, 0, | 390 | 2, 3, 0, |
| @@ -415,7 +416,7 @@ determined by the variable `completion-ignored-extensions', which see. */) | |||
| 415 | if (!NILP (handler)) | 416 | if (!NILP (handler)) |
| 416 | return call4 (handler, Qfile_name_completion, file, directory, predicate); | 417 | return call4 (handler, Qfile_name_completion, file, directory, predicate); |
| 417 | 418 | ||
| 418 | return file_name_completion (file, directory, 0, 0, predicate); | 419 | return file_name_completion (file, directory, 0, predicate); |
| 419 | } | 420 | } |
| 420 | 421 | ||
| 421 | DEFUN ("file-name-all-completions", Ffile_name_all_completions, | 422 | DEFUN ("file-name-all-completions", Ffile_name_all_completions, |
| @@ -439,14 +440,15 @@ These are all file names in directory DIRECTORY which begin with FILE. */) | |||
| 439 | if (!NILP (handler)) | 440 | if (!NILP (handler)) |
| 440 | return call3 (handler, Qfile_name_all_completions, file, directory); | 441 | return call3 (handler, Qfile_name_all_completions, file, directory); |
| 441 | 442 | ||
| 442 | return file_name_completion (file, directory, 1, 0, Qnil); | 443 | return file_name_completion (file, directory, 1, Qnil); |
| 443 | } | 444 | } |
| 444 | 445 | ||
| 445 | static int file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_addr); | 446 | static int file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_addr); |
| 446 | static Lisp_Object Qdefault_directory; | 447 | static Lisp_Object Qdefault_directory; |
| 447 | 448 | ||
| 448 | static Lisp_Object | 449 | static Lisp_Object |
| 449 | file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int ver_flag, Lisp_Object predicate) | 450 | file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag, |
| 451 | Lisp_Object predicate) | ||
| 450 | { | 452 | { |
| 451 | DIR *d; | 453 | DIR *d; |
| 452 | ptrdiff_t bestmatchsize = 0; | 454 | ptrdiff_t bestmatchsize = 0; |
| @@ -458,11 +460,11 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v | |||
| 458 | Lisp_Object encoded_file; | 460 | Lisp_Object encoded_file; |
| 459 | Lisp_Object encoded_dir; | 461 | Lisp_Object encoded_dir; |
| 460 | struct stat st; | 462 | struct stat st; |
| 461 | int directoryp; | 463 | bool directoryp; |
| 462 | /* If includeall is zero, exclude files in completion-ignored-extensions as | 464 | /* If not INCLUDEALL, exclude files in completion-ignored-extensions as |
| 463 | well as "." and "..". Until shown otherwise, assume we can't exclude | 465 | well as "." and "..". Until shown otherwise, assume we can't exclude |
| 464 | anything. */ | 466 | anything. */ |
| 465 | int includeall = 1; | 467 | bool includeall = 1; |
| 466 | ptrdiff_t count = SPECPDL_INDEX (); | 468 | ptrdiff_t count = SPECPDL_INDEX (); |
| 467 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 469 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 468 | 470 | ||
| @@ -500,7 +502,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v | |||
| 500 | { | 502 | { |
| 501 | DIRENTRY *dp; | 503 | DIRENTRY *dp; |
| 502 | ptrdiff_t len; | 504 | ptrdiff_t len; |
| 503 | int canexclude = 0; | 505 | bool canexclude = 0; |
| 504 | 506 | ||
| 505 | errno = 0; | 507 | errno = 0; |
| 506 | dp = readdir (d); | 508 | dp = readdir (d); |
| @@ -528,7 +530,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v | |||
| 528 | if (file_name_completion_stat (encoded_dir, dp, &st) < 0) | 530 | if (file_name_completion_stat (encoded_dir, dp, &st) < 0) |
| 529 | continue; | 531 | continue; |
| 530 | 532 | ||
| 531 | directoryp = S_ISDIR (st.st_mode); | 533 | directoryp = S_ISDIR (st.st_mode) != 0; |
| 532 | tem = Qnil; | 534 | tem = Qnil; |
| 533 | /* If all_flag is set, always include all. | 535 | /* If all_flag is set, always include all. |
| 534 | It would not actually be helpful to the user to ignore any possible | 536 | It would not actually be helpful to the user to ignore any possible |
| @@ -716,7 +718,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v | |||
| 716 | /* This tests that the current file is an exact match | 718 | /* This tests that the current file is an exact match |
| 717 | but BESTMATCH is not (it is too long). */ | 719 | but BESTMATCH is not (it is too long). */ |
| 718 | if ((matchsize == SCHARS (name) | 720 | if ((matchsize == SCHARS (name) |
| 719 | && matchsize + !!directoryp < SCHARS (bestmatch)) | 721 | && matchsize + directoryp < SCHARS (bestmatch)) |
| 720 | || | 722 | || |
| 721 | /* If there is no exact match ignoring case, | 723 | /* If there is no exact match ignoring case, |
| 722 | prefer a match that does not change the case | 724 | prefer a match that does not change the case |
| @@ -728,7 +730,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v | |||
| 728 | either both or neither are exact. */ | 730 | either both or neither are exact. */ |
| 729 | (((matchsize == SCHARS (name)) | 731 | (((matchsize == SCHARS (name)) |
| 730 | == | 732 | == |
| 731 | (matchsize + !!directoryp == SCHARS (bestmatch))) | 733 | (matchsize + directoryp == SCHARS (bestmatch))) |
| 732 | && (cmp = Fcompare_strings (name, zero, | 734 | && (cmp = Fcompare_strings (name, zero, |
| 733 | make_number (SCHARS (file)), | 735 | make_number (SCHARS (file)), |
| 734 | file, zero, | 736 | file, zero, |