diff options
| author | Paul Eggert | 2015-01-29 13:54:51 -0800 |
|---|---|---|
| committer | Paul Eggert | 2015-01-29 13:54:51 -0800 |
| commit | eadf313c72edcc3a11b9d03032699416efebfe1a (patch) | |
| tree | 81469c8442f140d2fdc6896e17b15cf3761e1663 /src | |
| parent | 7c8b0b3644ada886dfde4032fdf38687a5968089 (diff) | |
| parent | ad588afdaa166bcdacbf9f746bd4d39b2c649768 (diff) | |
| download | emacs-eadf313c72edcc3a11b9d03032699416efebfe1a.tar.gz emacs-eadf313c72edcc3a11b9d03032699416efebfe1a.zip | |
Merge from origin/emacs-24
ad588af Improve the fix for bug #19701
Conflicts:
src/ChangeLog
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 12 | ||||
| -rw-r--r-- | src/dired.c | 15 | ||||
| -rw-r--r-- | src/w32.c | 41 |
3 files changed, 51 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 36a3e8d64d2..96e6aa25d5e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,17 @@ | |||
| 1 | 2015-01-29 Eli Zaretskii <eliz@gnu.org> | 1 | 2015-01-29 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | * dired.c (directory_files_internal, file_name_completion) | ||
| 4 | [WINDOWSNT]: Signal an error when errno is set non-zero by | ||
| 5 | 'readdir', regardless of its value. | ||
| 6 | |||
| 7 | * w32.c (sys_readdir): Set errno to ENOENT when the directory | ||
| 8 | doesn't exist and to EACCES when it's not accessible to the | ||
| 9 | current user. Set errno to zero when FindNextFile exhausts the | ||
| 10 | directory, so that callers don't interpret that as an error and | ||
| 11 | don't signal a file-error. | ||
| 12 | (open_unc_volume): Set errno to ENOENT if WNetOpenEnum fails. | ||
| 13 | 2015-01-29 Eli Zaretskii <eliz@gnu.org> | ||
| 14 | |||
| 3 | Use bool for boolean in w32menu.c, w32font.c, w32uniscribe.c. | 15 | Use bool for boolean in w32menu.c, w32font.c, w32uniscribe.c. |
| 4 | * w32uniscribe.c (uniscribe_list, uniscribe_match): Use bool where | 16 | * w32uniscribe.c (uniscribe_list, uniscribe_match): Use bool where |
| 5 | appropriate. | 17 | appropriate. |
diff --git a/src/dired.c b/src/dired.c index 757eb6d30cd..f0e81b61278 100644 --- a/src/dired.c +++ b/src/dired.c | |||
| @@ -242,14 +242,9 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, | |||
| 242 | /* The MS-Windows implementation of 'opendir' doesn't | 242 | /* The MS-Windows implementation of 'opendir' doesn't |
| 243 | actually open a directory until the first call to | 243 | actually open a directory until the first call to |
| 244 | 'readdir'. If 'readdir' fails to open the directory, it | 244 | 'readdir'. If 'readdir' fails to open the directory, it |
| 245 | sets errno to ENOTDIR; we convert it here to ENOENT so | 245 | sets errno to ENOENT or EACCES, see w32.c. */ |
| 246 | that the error message is similar to what happens on | 246 | if (errno) |
| 247 | Posix hosts in such cases. */ | 247 | report_file_error ("Opening directory", directory); |
| 248 | if (errno == ENOTDIR) | ||
| 249 | { | ||
| 250 | errno = ENOENT; | ||
| 251 | report_file_error ("Opening directory", directory); | ||
| 252 | } | ||
| 253 | #endif | 248 | #endif |
| 254 | break; | 249 | break; |
| 255 | } | 250 | } |
| @@ -520,6 +515,10 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag, | |||
| 520 | QUIT; | 515 | QUIT; |
| 521 | continue; | 516 | continue; |
| 522 | } | 517 | } |
| 518 | #ifdef WINDOWSNT | ||
| 519 | if (errno) | ||
| 520 | report_file_error ("Opening directory", dirname); | ||
| 521 | #endif | ||
| 523 | break; | 522 | break; |
| 524 | } | 523 | } |
| 525 | 524 | ||
| @@ -3434,17 +3434,30 @@ sys_readdir (DIR *dirp) | |||
| 3434 | 3434 | ||
| 3435 | if (dir_find_handle == INVALID_HANDLE_VALUE) | 3435 | if (dir_find_handle == INVALID_HANDLE_VALUE) |
| 3436 | { | 3436 | { |
| 3437 | /* Any changes in the value of errno here should be in sync | ||
| 3438 | with what directory_files_internal does when it calls | ||
| 3439 | readdir. */ | ||
| 3437 | switch (GetLastError ()) | 3440 | switch (GetLastError ()) |
| 3438 | { | 3441 | { |
| 3439 | case ERROR_PATH_NOT_FOUND: | 3442 | /* Windows uses this value when FindFirstFile finds no |
| 3443 | files that match the wildcard. This is not supposed | ||
| 3444 | to happen, since our wildcard is "*", but just in | ||
| 3445 | case, if there's some weird empty directory with not | ||
| 3446 | even "." and ".." entries... */ | ||
| 3447 | case ERROR_FILE_NOT_FOUND: | ||
| 3448 | errno = 0; | ||
| 3449 | /* FALLTHRU */ | ||
| 3450 | default: | ||
| 3451 | break; | ||
| 3440 | case ERROR_ACCESS_DENIED: | 3452 | case ERROR_ACCESS_DENIED: |
| 3453 | case ERROR_NETWORK_ACCESS_DENIED: | ||
| 3454 | errno = EACCES; | ||
| 3455 | break; | ||
| 3456 | case ERROR_PATH_NOT_FOUND: | ||
| 3441 | case ERROR_INVALID_DRIVE: | 3457 | case ERROR_INVALID_DRIVE: |
| 3442 | case ERROR_BAD_NETPATH: | 3458 | case ERROR_BAD_NETPATH: |
| 3443 | /* This special value will be noticed by | 3459 | case ERROR_BAD_NET_NAME: |
| 3444 | directory_files_internal, which see. */ | 3460 | errno = ENOENT; |
| 3445 | errno = ENOTDIR; | ||
| 3446 | break; | ||
| 3447 | default: | ||
| 3448 | break; | 3461 | break; |
| 3449 | } | 3462 | } |
| 3450 | return NULL; | 3463 | return NULL; |
| @@ -3453,12 +3466,18 @@ sys_readdir (DIR *dirp) | |||
| 3453 | else if (w32_unicode_filenames) | 3466 | else if (w32_unicode_filenames) |
| 3454 | { | 3467 | { |
| 3455 | if (!FindNextFileW (dir_find_handle, &dir_find_data_w)) | 3468 | if (!FindNextFileW (dir_find_handle, &dir_find_data_w)) |
| 3456 | return NULL; | 3469 | { |
| 3470 | errno = 0; | ||
| 3471 | return NULL; | ||
| 3472 | } | ||
| 3457 | } | 3473 | } |
| 3458 | else | 3474 | else |
| 3459 | { | 3475 | { |
| 3460 | if (!FindNextFileA (dir_find_handle, &dir_find_data_a)) | 3476 | if (!FindNextFileA (dir_find_handle, &dir_find_data_a)) |
| 3461 | return NULL; | 3477 | { |
| 3478 | errno = 0; | ||
| 3479 | return NULL; | ||
| 3480 | } | ||
| 3462 | } | 3481 | } |
| 3463 | 3482 | ||
| 3464 | /* Emacs never uses this value, so don't bother making it match | 3483 | /* Emacs never uses this value, so don't bother making it match |
| @@ -3560,7 +3579,11 @@ open_unc_volume (const char *path) | |||
| 3560 | if (result == NO_ERROR) | 3579 | if (result == NO_ERROR) |
| 3561 | return henum; | 3580 | return henum; |
| 3562 | else | 3581 | else |
| 3563 | return INVALID_HANDLE_VALUE; | 3582 | { |
| 3583 | /* Make sure directory_files_internal reports a sensible error. */ | ||
| 3584 | errno = ENOENT; | ||
| 3585 | return INVALID_HANDLE_VALUE; | ||
| 3586 | } | ||
| 3564 | } | 3587 | } |
| 3565 | 3588 | ||
| 3566 | static void * | 3589 | static void * |