diff options
| author | Joakim Verona | 2012-12-17 20:26:49 +0100 |
|---|---|---|
| committer | Joakim Verona | 2012-12-17 20:26:49 +0100 |
| commit | 50f3874cc956355007e2fefc9d7663ea6dea1794 (patch) | |
| tree | c6e1067f3c7296481dae8048d321f19cc7536279 /src | |
| parent | bf7be49be8c23196dce8110d8d7b40351ee7f85d (diff) | |
| parent | 1e101a4be420878653f42a9f5e105adfb6690229 (diff) | |
| download | emacs-50f3874cc956355007e2fefc9d7663ea6dea1794.tar.gz emacs-50f3874cc956355007e2fefc9d7663ea6dea1794.zip | |
auto upstream
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 56 | ||||
| -rw-r--r-- | src/fileio.c | 19 | ||||
| -rw-r--r-- | src/w32.c | 415 | ||||
| -rw-r--r-- | src/window.c | 22 | ||||
| -rw-r--r-- | src/window.h | 9 | ||||
| -rw-r--r-- | src/xdisp.c | 24 |
6 files changed, 510 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d5071c541b4..2eb301bd934 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,37 @@ | |||
| 1 | 2012-12-17 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * xdisp.c (select_frame_for_redisplay): Use select_window_1 to | ||
| 4 | propagate redisplay's scrolling (if any) to the right window. | ||
| 5 | (redisplay_internal): Use ensure_selected_frame. | ||
| 6 | (display_mode_lines): Complete last fix. | ||
| 7 | * window.c (select_window_1): New func, extracted from select_window. | ||
| 8 | (select_window): Use it. | ||
| 9 | * window.h (select_window_1): Declare. | ||
| 10 | |||
| 11 | 2012-12-17 Eli Zaretskii <eliz@gnu.org> | ||
| 12 | |||
| 13 | Emulate Posix ACL APIs on MS-Windows. | ||
| 14 | * w32.c: Include sddl.h and sys/acl.h. | ||
| 15 | (SDDL_REVISION_1): Define if not already defined. | ||
| 16 | (g_b_init_get_security_descriptor_dacl) | ||
| 17 | (g_b_init_convert_sd_to_sddl, g_b_init_convert_sddl_to_sd) | ||
| 18 | (g_b_init_is_valid_security_descriptor) | ||
| 19 | (g_b_init_set_file_security): New static flags. | ||
| 20 | (globals_of_w32): Initialize them to zero. | ||
| 21 | (SetFileSecurity_Name): New string constant. | ||
| 22 | (SetFileSecurity_Proc, GetSecurityDescriptorDacl_Proc) | ||
| 23 | (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc) | ||
| 24 | (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc) | ||
| 25 | (IsValidSecurityDescriptor_Proc): New typedefs. | ||
| 26 | (get_file_security, get_security_descriptor_owner) | ||
| 27 | (get_security_descriptor_group): Set errno to ENOTSUP. | ||
| 28 | (set_file_security, get_security_descriptor_dacl) | ||
| 29 | (is_valid_security_descriptor, convert_sd_to_sddl) | ||
| 30 | (convert_sddl_to_sd, acl_valid, acl_to_text, acl_from_text) | ||
| 31 | (acl_free, acl_get_file, acl_set_file): New functions. | ||
| 32 | |||
| 33 | * fileio.c (Fcopy_file) [WINDOWSNT]: Support copying ACLs. | ||
| 34 | |||
| 1 | 2012-12-17 Paul Eggert <eggert@cs.ucla.edu> | 35 | 2012-12-17 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 36 | ||
| 3 | Don't reraise SIGCHLD, as that can now lose (Bug#13192). | 37 | Don't reraise SIGCHLD, as that can now lose (Bug#13192). |
| @@ -18,8 +52,7 @@ | |||
| 18 | 52 | ||
| 19 | * fileio.c (Ffile_acl, Fset_file_acl): New functions. | 53 | * fileio.c (Ffile_acl, Fset_file_acl): New functions. |
| 20 | (Fcopy_file): Change last arg to `preserve_extended_attributes' | 54 | (Fcopy_file): Change last arg to `preserve_extended_attributes' |
| 21 | and copy ACL entries of file in addition to SELinux context if | 55 | and copy ACL entries of file in addition to SELinux context if set. |
| 22 | set. | ||
| 23 | (syms_of_fileio): Add `file-acl' and `set-file-acl'. | 56 | (syms_of_fileio): Add `file-acl' and `set-file-acl'. |
| 24 | 57 | ||
| 25 | * Makefile.in (LIBACL_LIBS): New macro. | 58 | * Makefile.in (LIBACL_LIBS): New macro. |
| @@ -142,7 +175,7 @@ | |||
| 142 | 175 | ||
| 143 | 2012-12-12 Daniel Colascione <dancol@dancol.org> | 176 | 2012-12-12 Daniel Colascione <dancol@dancol.org> |
| 144 | 177 | ||
| 145 | * unexcw.c (fixup_executable): use posix_fallocate to ensure that | 178 | * unexcw.c (fixup_executable): Use posix_fallocate to ensure that |
| 146 | the dumped Emacs is not a sparse file, greatly improving Cygwin | 179 | the dumped Emacs is not a sparse file, greatly improving Cygwin |
| 147 | "make bootstrap" performance. | 180 | "make bootstrap" performance. |
| 148 | 181 | ||
| @@ -211,8 +244,7 @@ | |||
| 211 | * w32fns.c (cache_system_info): Initialize the global hinst | 244 | * w32fns.c (cache_system_info): Initialize the global hinst |
| 212 | variable here so various initialization calls DTRT. | 245 | variable here so various initialization calls DTRT. |
| 213 | 246 | ||
| 214 | * unexw32.c (hprevinst, lpCmdLine, nCmdShow): Remove unused | 247 | * unexw32.c (hprevinst, lpCmdLine, nCmdShow): Remove unused variables. |
| 215 | variables. | ||
| 216 | (hinst): Remove unneeded extern declaration. | 248 | (hinst): Remove unneeded extern declaration. |
| 217 | (_start): Remove initialization of above variables; remove | 249 | (_start): Remove initialization of above variables; remove |
| 218 | initialization of hinst, as cache_system_info now does that. | 250 | initialization of hinst, as cache_system_info now does that. |
| @@ -284,8 +316,7 @@ | |||
| 284 | * w32fns.c (w32_wnd_proc): Handle the WM_EMACS_FILENOTIFY message | 316 | * w32fns.c (w32_wnd_proc): Handle the WM_EMACS_FILENOTIFY message |
| 285 | by posting it to the w32_read_socket queue. | 317 | by posting it to the w32_read_socket queue. |
| 286 | 318 | ||
| 287 | * termhooks.h (enum event_kind) [HAVE_NTGUI]: Support | 319 | * termhooks.h (enum event_kind) [HAVE_NTGUI]: Support FILE_NOTIFY_EVENT. |
| 288 | FILE_NOTIFY_EVENT. | ||
| 289 | 320 | ||
| 290 | * makefile.w32-in (OBJ2): Add $(BLD)/w32notify.$(O). | 321 | * makefile.w32-in (OBJ2): Add $(BLD)/w32notify.$(O). |
| 291 | (GLOBAL_SOURCES): Add w32notify.c | 322 | (GLOBAL_SOURCES): Add w32notify.c |
| @@ -293,8 +324,8 @@ | |||
| 293 | 324 | ||
| 294 | * lisp.h (syms_of_w32notify) [WINDOWSNT]: Add prototype. | 325 | * lisp.h (syms_of_w32notify) [WINDOWSNT]: Add prototype. |
| 295 | 326 | ||
| 296 | * keyboard.c (kbd_buffer_get_event) [WINDOWSNT]: Handle | 327 | * keyboard.c (kbd_buffer_get_event) [WINDOWSNT]: |
| 297 | FILE_NOTIFY_EVENT. | 328 | Handle FILE_NOTIFY_EVENT. |
| 298 | (syms_of_keyboard) [HAVE_NTGUI] <Qfile_notify>: New symbol. | 329 | (syms_of_keyboard) [HAVE_NTGUI] <Qfile_notify>: New symbol. |
| 299 | (keys_of_keyboard) [WINDOWSNT]: Bind file-notify to | 330 | (keys_of_keyboard) [WINDOWSNT]: Bind file-notify to |
| 300 | w32notify-handle-event by default. | 331 | w32notify-handle-event by default. |
| @@ -305,8 +336,7 @@ | |||
| 305 | 2012-12-10 Rüdiger Sonderfeld <ruediger@c-plusplus.de> | 336 | 2012-12-10 Rüdiger Sonderfeld <ruediger@c-plusplus.de> |
| 306 | 337 | ||
| 307 | Support for filesystem notifications on GNU/Linux via inotify. | 338 | Support for filesystem notifications on GNU/Linux via inotify. |
| 308 | * termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add | 339 | * termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add FILE_NOTIFY_EVENT. |
| 309 | FILE_NOTIFY_EVENT. | ||
| 310 | 340 | ||
| 311 | * lisp.h (syms_of_inotify) [HAVE_INOTIFY]: Add prototype. | 341 | * lisp.h (syms_of_inotify) [HAVE_INOTIFY]: Add prototype. |
| 312 | 342 | ||
| @@ -623,9 +653,9 @@ | |||
| 623 | 2012-12-03 Fabrice Popineau <fabrice.popineau@gmail.com> | 653 | 2012-12-03 Fabrice Popineau <fabrice.popineau@gmail.com> |
| 624 | 654 | ||
| 625 | * w32fns.c: Remove prototype of atof. | 655 | * w32fns.c: Remove prototype of atof. |
| 626 | (syspage_mask): Declared DWORD_PTR, for compatibility with 64-bit | 656 | (syspage_mask): Make it DWORD_PTR, for compatibility with 64-bit |
| 627 | builds. | 657 | builds. |
| 628 | (file_dialog_callback): Declared UINT_PTR. | 658 | (file_dialog_callback): Make it UINT_PTR. |
| 629 | 659 | ||
| 630 | * w32common.h (syspage_mask): Declare DWORD_PTR, for compatibility | 660 | * w32common.h (syspage_mask): Declare DWORD_PTR, for compatibility |
| 631 | with 64-bit builds. | 661 | with 64-bit builds. |
diff --git a/src/fileio.c b/src/fileio.c index f1cfe0eb625..26150a7e55b 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -1956,6 +1956,14 @@ entries (depending on how Emacs was built). */) | |||
| 1956 | out_st.st_mode = 0; | 1956 | out_st.st_mode = 0; |
| 1957 | 1957 | ||
| 1958 | #ifdef WINDOWSNT | 1958 | #ifdef WINDOWSNT |
| 1959 | if (!NILP (preserve_extended_attributes)) | ||
| 1960 | { | ||
| 1961 | #ifdef HAVE_POSIX_ACL | ||
| 1962 | acl = acl_get_file (SDATA (encoded_file), ACL_TYPE_ACCESS); | ||
| 1963 | if (acl == NULL && errno != ENOTSUP) | ||
| 1964 | report_file_error ("Getting ACL", Fcons (file, Qnil)); | ||
| 1965 | #endif | ||
| 1966 | } | ||
| 1959 | if (!CopyFile (SDATA (encoded_file), | 1967 | if (!CopyFile (SDATA (encoded_file), |
| 1960 | SDATA (encoded_newname), | 1968 | SDATA (encoded_newname), |
| 1961 | FALSE)) | 1969 | FALSE)) |
| @@ -1983,6 +1991,17 @@ entries (depending on how Emacs was built). */) | |||
| 1983 | /* Restore original attributes. */ | 1991 | /* Restore original attributes. */ |
| 1984 | SetFileAttributes (filename, attributes); | 1992 | SetFileAttributes (filename, attributes); |
| 1985 | } | 1993 | } |
| 1994 | #ifdef HAVE_POSIX_ACL | ||
| 1995 | if (acl != NULL) | ||
| 1996 | { | ||
| 1997 | bool fail = | ||
| 1998 | acl_set_file (SDATA (encoded_newname), ACL_TYPE_ACCESS, acl) != 0; | ||
| 1999 | if (fail && errno != ENOTSUP) | ||
| 2000 | report_file_error ("Setting ACL", Fcons (newname, Qnil)); | ||
| 2001 | |||
| 2002 | acl_free (acl); | ||
| 2003 | } | ||
| 2004 | #endif | ||
| 1986 | #else /* not WINDOWSNT */ | 2005 | #else /* not WINDOWSNT */ |
| 1987 | immediate_quit = 1; | 2006 | immediate_quit = 1; |
| 1988 | ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); | 2007 | ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); |
| @@ -117,6 +117,15 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX { | |||
| 117 | 117 | ||
| 118 | #include <winioctl.h> | 118 | #include <winioctl.h> |
| 119 | #include <aclapi.h> | 119 | #include <aclapi.h> |
| 120 | #include <sddl.h> | ||
| 121 | |||
| 122 | #include <sys/acl.h> | ||
| 123 | |||
| 124 | /* This is not in MinGW's sddl.h (but they are in MSVC headers), so we | ||
| 125 | define them by hand if not already defined. */ | ||
| 126 | #ifndef SDDL_REVISION_1 | ||
| 127 | #define SDDL_REVISION_1 1 | ||
| 128 | #endif /* SDDL_REVISION_1 */ | ||
| 120 | 129 | ||
| 121 | #ifdef _MSC_VER | 130 | #ifdef _MSC_VER |
| 122 | /* MSVC doesn't provide the definition of REPARSE_DATA_BUFFER and the | 131 | /* MSVC doesn't provide the definition of REPARSE_DATA_BUFFER and the |
| @@ -257,6 +266,11 @@ static BOOL g_b_init_copy_sid; | |||
| 257 | static BOOL g_b_init_get_native_system_info; | 266 | static BOOL g_b_init_get_native_system_info; |
| 258 | static BOOL g_b_init_get_system_times; | 267 | static BOOL g_b_init_get_system_times; |
| 259 | static BOOL g_b_init_create_symbolic_link; | 268 | static BOOL g_b_init_create_symbolic_link; |
| 269 | static BOOL g_b_init_get_security_descriptor_dacl; | ||
| 270 | static BOOL g_b_init_convert_sd_to_sddl; | ||
| 271 | static BOOL g_b_init_convert_sddl_to_sd; | ||
| 272 | static BOOL g_b_init_is_valid_security_descriptor; | ||
| 273 | static BOOL g_b_init_set_file_security; | ||
| 260 | 274 | ||
| 261 | /* | 275 | /* |
| 262 | BEGIN: Wrapper functions around OpenProcessToken | 276 | BEGIN: Wrapper functions around OpenProcessToken |
| @@ -286,9 +300,11 @@ GetProcessTimes_Proc get_process_times_fn = NULL; | |||
| 286 | #ifdef _UNICODE | 300 | #ifdef _UNICODE |
| 287 | const char * const LookupAccountSid_Name = "LookupAccountSidW"; | 301 | const char * const LookupAccountSid_Name = "LookupAccountSidW"; |
| 288 | const char * const GetFileSecurity_Name = "GetFileSecurityW"; | 302 | const char * const GetFileSecurity_Name = "GetFileSecurityW"; |
| 303 | const char * const SetFileSecurity_Name = "SetFileSecurityW"; | ||
| 289 | #else | 304 | #else |
| 290 | const char * const LookupAccountSid_Name = "LookupAccountSidA"; | 305 | const char * const LookupAccountSid_Name = "LookupAccountSidA"; |
| 291 | const char * const GetFileSecurity_Name = "GetFileSecurityA"; | 306 | const char * const GetFileSecurity_Name = "GetFileSecurityA"; |
| 307 | const char * const SetFileSecurity_Name = "SetFileSecurityA"; | ||
| 292 | #endif | 308 | #endif |
| 293 | typedef BOOL (WINAPI * LookupAccountSid_Proc) ( | 309 | typedef BOOL (WINAPI * LookupAccountSid_Proc) ( |
| 294 | LPCTSTR lpSystemName, | 310 | LPCTSTR lpSystemName, |
| @@ -318,6 +334,10 @@ typedef BOOL (WINAPI * GetFileSecurity_Proc) ( | |||
| 318 | PSECURITY_DESCRIPTOR pSecurityDescriptor, | 334 | PSECURITY_DESCRIPTOR pSecurityDescriptor, |
| 319 | DWORD nLength, | 335 | DWORD nLength, |
| 320 | LPDWORD lpnLengthNeeded); | 336 | LPDWORD lpnLengthNeeded); |
| 337 | typedef BOOL (WINAPI *SetFileSecurity_Proc) ( | ||
| 338 | LPCTSTR lpFileName, | ||
| 339 | SECURITY_INFORMATION SecurityInformation, | ||
| 340 | PSECURITY_DESCRIPTOR pSecurityDescriptor); | ||
| 321 | typedef BOOL (WINAPI * GetSecurityDescriptorOwner_Proc) ( | 341 | typedef BOOL (WINAPI * GetSecurityDescriptorOwner_Proc) ( |
| 322 | PSECURITY_DESCRIPTOR pSecurityDescriptor, | 342 | PSECURITY_DESCRIPTOR pSecurityDescriptor, |
| 323 | PSID *pOwner, | 343 | PSID *pOwner, |
| @@ -326,6 +346,11 @@ typedef BOOL (WINAPI * GetSecurityDescriptorGroup_Proc) ( | |||
| 326 | PSECURITY_DESCRIPTOR pSecurityDescriptor, | 346 | PSECURITY_DESCRIPTOR pSecurityDescriptor, |
| 327 | PSID *pGroup, | 347 | PSID *pGroup, |
| 328 | LPBOOL lpbGroupDefaulted); | 348 | LPBOOL lpbGroupDefaulted); |
| 349 | typedef BOOL (WINAPI *GetSecurityDescriptorDacl_Proc) ( | ||
| 350 | PSECURITY_DESCRIPTOR pSecurityDescriptor, | ||
| 351 | LPBOOL lpbDaclPresent, | ||
| 352 | PACL *pDacl, | ||
| 353 | LPBOOL lpbDaclDefaulted); | ||
| 329 | typedef BOOL (WINAPI * IsValidSid_Proc) ( | 354 | typedef BOOL (WINAPI * IsValidSid_Proc) ( |
| 330 | PSID sid); | 355 | PSID sid); |
| 331 | typedef HANDLE (WINAPI * CreateToolhelp32Snapshot_Proc) ( | 356 | typedef HANDLE (WINAPI * CreateToolhelp32Snapshot_Proc) ( |
| @@ -376,6 +401,18 @@ typedef BOOLEAN (WINAPI *CreateSymbolicLink_Proc) ( | |||
| 376 | LPTSTR lpSymlinkFileName, | 401 | LPTSTR lpSymlinkFileName, |
| 377 | LPTSTR lpTargetFileName, | 402 | LPTSTR lpTargetFileName, |
| 378 | DWORD dwFlags); | 403 | DWORD dwFlags); |
| 404 | typedef BOOL (WINAPI *ConvertStringSecurityDescriptorToSecurityDescriptor_Proc) ( | ||
| 405 | LPCTSTR StringSecurityDescriptor, | ||
| 406 | DWORD StringSDRevision, | ||
| 407 | PSECURITY_DESCRIPTOR *SecurityDescriptor, | ||
| 408 | PULONG SecurityDescriptorSize); | ||
| 409 | typedef BOOL (WINAPI *ConvertSecurityDescriptorToStringSecurityDescriptor_Proc) ( | ||
| 410 | PSECURITY_DESCRIPTOR SecurityDescriptor, | ||
| 411 | DWORD RequestedStringSDRevision, | ||
| 412 | SECURITY_INFORMATION SecurityInformation, | ||
| 413 | LPTSTR *StringSecurityDescriptor, | ||
| 414 | PULONG StringSecurityDescriptorLen); | ||
| 415 | typedef BOOL (WINAPI *IsValidSecurityDescriptor_Proc) (PSECURITY_DESCRIPTOR); | ||
| 379 | 416 | ||
| 380 | /* ** A utility function ** */ | 417 | /* ** A utility function ** */ |
| 381 | static BOOL | 418 | static BOOL |
| @@ -621,6 +658,7 @@ get_file_security (LPCTSTR lpFileName, | |||
| 621 | HMODULE hm_advapi32 = NULL; | 658 | HMODULE hm_advapi32 = NULL; |
| 622 | if (is_windows_9x () == TRUE) | 659 | if (is_windows_9x () == TRUE) |
| 623 | { | 660 | { |
| 661 | errno = ENOTSUP; | ||
| 624 | return FALSE; | 662 | return FALSE; |
| 625 | } | 663 | } |
| 626 | if (g_b_init_get_file_security == 0) | 664 | if (g_b_init_get_file_security == 0) |
| @@ -633,6 +671,7 @@ get_file_security (LPCTSTR lpFileName, | |||
| 633 | } | 671 | } |
| 634 | if (s_pfn_Get_File_Security == NULL) | 672 | if (s_pfn_Get_File_Security == NULL) |
| 635 | { | 673 | { |
| 674 | errno = ENOTSUP; | ||
| 636 | return FALSE; | 675 | return FALSE; |
| 637 | } | 676 | } |
| 638 | return (s_pfn_Get_File_Security (lpFileName, RequestedInformation, | 677 | return (s_pfn_Get_File_Security (lpFileName, RequestedInformation, |
| @@ -641,6 +680,35 @@ get_file_security (LPCTSTR lpFileName, | |||
| 641 | } | 680 | } |
| 642 | 681 | ||
| 643 | static BOOL WINAPI | 682 | static BOOL WINAPI |
| 683 | set_file_security (LPCTSTR lpFileName, | ||
| 684 | SECURITY_INFORMATION SecurityInformation, | ||
| 685 | PSECURITY_DESCRIPTOR pSecurityDescriptor) | ||
| 686 | { | ||
| 687 | static SetFileSecurity_Proc s_pfn_Set_File_Security = NULL; | ||
| 688 | HMODULE hm_advapi32 = NULL; | ||
| 689 | if (is_windows_9x () == TRUE) | ||
| 690 | { | ||
| 691 | errno = ENOTSUP; | ||
| 692 | return FALSE; | ||
| 693 | } | ||
| 694 | if (g_b_init_set_file_security == 0) | ||
| 695 | { | ||
| 696 | g_b_init_set_file_security = 1; | ||
| 697 | hm_advapi32 = LoadLibrary ("Advapi32.dll"); | ||
| 698 | s_pfn_Set_File_Security = | ||
| 699 | (SetFileSecurity_Proc) GetProcAddress ( | ||
| 700 | hm_advapi32, SetFileSecurity_Name); | ||
| 701 | } | ||
| 702 | if (s_pfn_Set_File_Security == NULL) | ||
| 703 | { | ||
| 704 | errno = ENOTSUP; | ||
| 705 | return FALSE; | ||
| 706 | } | ||
| 707 | return (s_pfn_Set_File_Security (lpFileName, SecurityInformation, | ||
| 708 | pSecurityDescriptor)); | ||
| 709 | } | ||
| 710 | |||
| 711 | static BOOL WINAPI | ||
| 644 | get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor, | 712 | get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor, |
| 645 | PSID *pOwner, | 713 | PSID *pOwner, |
| 646 | LPBOOL lpbOwnerDefaulted) | 714 | LPBOOL lpbOwnerDefaulted) |
| @@ -649,6 +717,7 @@ get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor, | |||
| 649 | HMODULE hm_advapi32 = NULL; | 717 | HMODULE hm_advapi32 = NULL; |
| 650 | if (is_windows_9x () == TRUE) | 718 | if (is_windows_9x () == TRUE) |
| 651 | { | 719 | { |
| 720 | errno = ENOTSUP; | ||
| 652 | return FALSE; | 721 | return FALSE; |
| 653 | } | 722 | } |
| 654 | if (g_b_init_get_security_descriptor_owner == 0) | 723 | if (g_b_init_get_security_descriptor_owner == 0) |
| @@ -661,6 +730,7 @@ get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor, | |||
| 661 | } | 730 | } |
| 662 | if (s_pfn_Get_Security_Descriptor_Owner == NULL) | 731 | if (s_pfn_Get_Security_Descriptor_Owner == NULL) |
| 663 | { | 732 | { |
| 733 | errno = ENOTSUP; | ||
| 664 | return FALSE; | 734 | return FALSE; |
| 665 | } | 735 | } |
| 666 | return (s_pfn_Get_Security_Descriptor_Owner (pSecurityDescriptor, pOwner, | 736 | return (s_pfn_Get_Security_Descriptor_Owner (pSecurityDescriptor, pOwner, |
| @@ -676,6 +746,7 @@ get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor, | |||
| 676 | HMODULE hm_advapi32 = NULL; | 746 | HMODULE hm_advapi32 = NULL; |
| 677 | if (is_windows_9x () == TRUE) | 747 | if (is_windows_9x () == TRUE) |
| 678 | { | 748 | { |
| 749 | errno = ENOTSUP; | ||
| 679 | return FALSE; | 750 | return FALSE; |
| 680 | } | 751 | } |
| 681 | if (g_b_init_get_security_descriptor_group == 0) | 752 | if (g_b_init_get_security_descriptor_group == 0) |
| @@ -688,6 +759,7 @@ get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor, | |||
| 688 | } | 759 | } |
| 689 | if (s_pfn_Get_Security_Descriptor_Group == NULL) | 760 | if (s_pfn_Get_Security_Descriptor_Group == NULL) |
| 690 | { | 761 | { |
| 762 | errno = ENOTSUP; | ||
| 691 | return FALSE; | 763 | return FALSE; |
| 692 | } | 764 | } |
| 693 | return (s_pfn_Get_Security_Descriptor_Group (pSecurityDescriptor, pGroup, | 765 | return (s_pfn_Get_Security_Descriptor_Group (pSecurityDescriptor, pGroup, |
| @@ -695,6 +767,37 @@ get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor, | |||
| 695 | } | 767 | } |
| 696 | 768 | ||
| 697 | static BOOL WINAPI | 769 | static BOOL WINAPI |
| 770 | get_security_descriptor_dacl (PSECURITY_DESCRIPTOR pSecurityDescriptor, | ||
| 771 | LPBOOL lpbDaclPresent, | ||
| 772 | PACL *pDacl, | ||
| 773 | LPBOOL lpbDaclDefaulted) | ||
| 774 | { | ||
| 775 | static GetSecurityDescriptorDacl_Proc s_pfn_Get_Security_Descriptor_Dacl = NULL; | ||
| 776 | HMODULE hm_advapi32 = NULL; | ||
| 777 | if (is_windows_9x () == TRUE) | ||
| 778 | { | ||
| 779 | errno = ENOTSUP; | ||
| 780 | return FALSE; | ||
| 781 | } | ||
| 782 | if (g_b_init_get_security_descriptor_dacl == 0) | ||
| 783 | { | ||
| 784 | g_b_init_get_security_descriptor_dacl = 1; | ||
| 785 | hm_advapi32 = LoadLibrary ("Advapi32.dll"); | ||
| 786 | s_pfn_Get_Security_Descriptor_Dacl = | ||
| 787 | (GetSecurityDescriptorDacl_Proc) GetProcAddress ( | ||
| 788 | hm_advapi32, "GetSecurityDescriptorDacl"); | ||
| 789 | } | ||
| 790 | if (s_pfn_Get_Security_Descriptor_Dacl == NULL) | ||
| 791 | { | ||
| 792 | errno = ENOTSUP; | ||
| 793 | return FALSE; | ||
| 794 | } | ||
| 795 | return (s_pfn_Get_Security_Descriptor_Dacl (pSecurityDescriptor, | ||
| 796 | lpbDaclPresent, pDacl, | ||
| 797 | lpbDaclDefaulted)); | ||
| 798 | } | ||
| 799 | |||
| 800 | static BOOL WINAPI | ||
| 698 | is_valid_sid (PSID sid) | 801 | is_valid_sid (PSID sid) |
| 699 | { | 802 | { |
| 700 | static IsValidSid_Proc s_pfn_Is_Valid_Sid = NULL; | 803 | static IsValidSid_Proc s_pfn_Is_Valid_Sid = NULL; |
| @@ -888,6 +991,120 @@ create_symbolic_link (LPTSTR lpSymlinkFilename, | |||
| 888 | } | 991 | } |
| 889 | return retval; | 992 | return retval; |
| 890 | } | 993 | } |
| 994 | |||
| 995 | static BOOL WINAPI | ||
| 996 | is_valid_security_descriptor (PSECURITY_DESCRIPTOR pSecurityDescriptor) | ||
| 997 | { | ||
| 998 | static IsValidSecurityDescriptor_Proc s_pfn_Is_Valid_Security_Descriptor_Proc = NULL; | ||
| 999 | |||
| 1000 | if (is_windows_9x () == TRUE) | ||
| 1001 | { | ||
| 1002 | errno = ENOTSUP; | ||
| 1003 | return FALSE; | ||
| 1004 | } | ||
| 1005 | |||
| 1006 | if (g_b_init_is_valid_security_descriptor == 0) | ||
| 1007 | { | ||
| 1008 | g_b_init_is_valid_security_descriptor = 1; | ||
| 1009 | s_pfn_Is_Valid_Security_Descriptor_Proc = | ||
| 1010 | (IsValidSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"), | ||
| 1011 | "IsValidSecurityDescriptor"); | ||
| 1012 | } | ||
| 1013 | if (s_pfn_Is_Valid_Security_Descriptor_Proc == NULL) | ||
| 1014 | { | ||
| 1015 | errno = ENOTSUP; | ||
| 1016 | return FALSE; | ||
| 1017 | } | ||
| 1018 | |||
| 1019 | return s_pfn_Is_Valid_Security_Descriptor_Proc (pSecurityDescriptor); | ||
| 1020 | } | ||
| 1021 | |||
| 1022 | static BOOL WINAPI | ||
| 1023 | convert_sd_to_sddl (PSECURITY_DESCRIPTOR SecurityDescriptor, | ||
| 1024 | DWORD RequestedStringSDRevision, | ||
| 1025 | SECURITY_INFORMATION SecurityInformation, | ||
| 1026 | LPTSTR *StringSecurityDescriptor, | ||
| 1027 | PULONG StringSecurityDescriptorLen) | ||
| 1028 | { | ||
| 1029 | static ConvertSecurityDescriptorToStringSecurityDescriptor_Proc s_pfn_Convert_SD_To_SDDL = NULL; | ||
| 1030 | BOOL retval; | ||
| 1031 | |||
| 1032 | if (is_windows_9x () == TRUE) | ||
| 1033 | { | ||
| 1034 | errno = ENOTSUP; | ||
| 1035 | return FALSE; | ||
| 1036 | } | ||
| 1037 | |||
| 1038 | if (g_b_init_convert_sd_to_sddl == 0) | ||
| 1039 | { | ||
| 1040 | g_b_init_convert_sd_to_sddl = 1; | ||
| 1041 | #ifdef _UNICODE | ||
| 1042 | s_pfn_Convert_SD_To_SDDL = | ||
| 1043 | (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"), | ||
| 1044 | "ConvertSecurityDescriptorToStringSecurityDescriptorW"); | ||
| 1045 | #else | ||
| 1046 | s_pfn_Convert_SD_To_SDDL = | ||
| 1047 | (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"), | ||
| 1048 | "ConvertSecurityDescriptorToStringSecurityDescriptorA"); | ||
| 1049 | #endif | ||
| 1050 | } | ||
| 1051 | if (s_pfn_Convert_SD_To_SDDL == NULL) | ||
| 1052 | { | ||
| 1053 | errno = ENOTSUP; | ||
| 1054 | return FALSE; | ||
| 1055 | } | ||
| 1056 | |||
| 1057 | retval = s_pfn_Convert_SD_To_SDDL (SecurityDescriptor, | ||
| 1058 | RequestedStringSDRevision, | ||
| 1059 | SecurityInformation, | ||
| 1060 | StringSecurityDescriptor, | ||
| 1061 | StringSecurityDescriptorLen); | ||
| 1062 | |||
| 1063 | return retval; | ||
| 1064 | } | ||
| 1065 | |||
| 1066 | static BOOL WINAPI | ||
| 1067 | convert_sddl_to_sd (LPCTSTR StringSecurityDescriptor, | ||
| 1068 | DWORD StringSDRevision, | ||
| 1069 | PSECURITY_DESCRIPTOR *SecurityDescriptor, | ||
| 1070 | PULONG SecurityDescriptorSize) | ||
| 1071 | { | ||
| 1072 | static ConvertStringSecurityDescriptorToSecurityDescriptor_Proc s_pfn_Convert_SDDL_To_SD = NULL; | ||
| 1073 | BOOL retval; | ||
| 1074 | |||
| 1075 | if (is_windows_9x () == TRUE) | ||
| 1076 | { | ||
| 1077 | errno = ENOTSUP; | ||
| 1078 | return FALSE; | ||
| 1079 | } | ||
| 1080 | |||
| 1081 | if (g_b_init_convert_sddl_to_sd == 0) | ||
| 1082 | { | ||
| 1083 | g_b_init_convert_sddl_to_sd = 1; | ||
| 1084 | #ifdef _UNICODE | ||
| 1085 | s_pfn_Convert_SDDL_To_SD = | ||
| 1086 | (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"), | ||
| 1087 | "ConvertStringSecurityDescriptorToSecurityDescriptorW"); | ||
| 1088 | #else | ||
| 1089 | s_pfn_Convert_SDDL_To_SD = | ||
| 1090 | (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"), | ||
| 1091 | "ConvertStringSecurityDescriptorToSecurityDescriptorA"); | ||
| 1092 | #endif | ||
| 1093 | } | ||
| 1094 | if (s_pfn_Convert_SDDL_To_SD == NULL) | ||
| 1095 | { | ||
| 1096 | errno = ENOTSUP; | ||
| 1097 | return FALSE; | ||
| 1098 | } | ||
| 1099 | |||
| 1100 | retval = s_pfn_Convert_SDDL_To_SD (StringSecurityDescriptor, | ||
| 1101 | StringSDRevision, | ||
| 1102 | SecurityDescriptor, | ||
| 1103 | SecurityDescriptorSize); | ||
| 1104 | |||
| 1105 | return retval; | ||
| 1106 | } | ||
| 1107 | |||
| 891 | 1108 | ||
| 892 | 1109 | ||
| 893 | /* Return 1 if P is a valid pointer to an object of size SIZE. Return | 1110 | /* Return 1 if P is a valid pointer to an object of size SIZE. Return |
| @@ -4477,6 +4694,199 @@ chase_symlinks (const char *file) | |||
| 4477 | return target; | 4694 | return target; |
| 4478 | } | 4695 | } |
| 4479 | 4696 | ||
| 4697 | |||
| 4698 | /* Posix ACL emulation. */ | ||
| 4699 | |||
| 4700 | int | ||
| 4701 | acl_valid (acl_t acl) | ||
| 4702 | { | ||
| 4703 | return is_valid_security_descriptor ((PSECURITY_DESCRIPTOR)acl) ? 0 : -1; | ||
| 4704 | } | ||
| 4705 | |||
| 4706 | char * | ||
| 4707 | acl_to_text (acl_t acl, ssize_t *size) | ||
| 4708 | { | ||
| 4709 | LPTSTR str_acl; | ||
| 4710 | SECURITY_INFORMATION flags = | ||
| 4711 | OWNER_SECURITY_INFORMATION | | ||
| 4712 | GROUP_SECURITY_INFORMATION | | ||
| 4713 | DACL_SECURITY_INFORMATION; | ||
| 4714 | char *retval = NULL; | ||
| 4715 | ssize_t local_size; | ||
| 4716 | int e = errno; | ||
| 4717 | |||
| 4718 | errno = 0; | ||
| 4719 | |||
| 4720 | if (convert_sd_to_sddl ((PSECURITY_DESCRIPTOR)acl, SDDL_REVISION_1, flags, &str_acl, &local_size)) | ||
| 4721 | { | ||
| 4722 | errno = e; | ||
| 4723 | /* We don't want to mix heaps, so we duplicate the string in our | ||
| 4724 | heap and free the one allocated by the API. */ | ||
| 4725 | retval = xstrdup (str_acl); | ||
| 4726 | if (size) | ||
| 4727 | *size = local_size; | ||
| 4728 | LocalFree (str_acl); | ||
| 4729 | } | ||
| 4730 | else if (errno != ENOTSUP) | ||
| 4731 | errno = EINVAL; | ||
| 4732 | |||
| 4733 | return retval; | ||
| 4734 | } | ||
| 4735 | |||
| 4736 | acl_t | ||
| 4737 | acl_from_text (const char *acl_str) | ||
| 4738 | { | ||
| 4739 | PSECURITY_DESCRIPTOR psd, retval = NULL; | ||
| 4740 | ULONG sd_size; | ||
| 4741 | int e = errno; | ||
| 4742 | |||
| 4743 | errno = 0; | ||
| 4744 | |||
| 4745 | if (convert_sddl_to_sd (acl_str, SDDL_REVISION_1, &psd, &sd_size)) | ||
| 4746 | { | ||
| 4747 | errno = e; | ||
| 4748 | retval = xmalloc (sd_size); | ||
| 4749 | memcpy (retval, psd, sd_size); | ||
| 4750 | LocalFree (psd); | ||
| 4751 | } | ||
| 4752 | else if (errno != ENOTSUP) | ||
| 4753 | errno = EINVAL; | ||
| 4754 | |||
| 4755 | return retval; | ||
| 4756 | } | ||
| 4757 | |||
| 4758 | int | ||
| 4759 | acl_free (void *ptr) | ||
| 4760 | { | ||
| 4761 | xfree (ptr); | ||
| 4762 | return 0; | ||
| 4763 | } | ||
| 4764 | |||
| 4765 | acl_t | ||
| 4766 | acl_get_file (const char *fname, acl_type_t type) | ||
| 4767 | { | ||
| 4768 | PSECURITY_DESCRIPTOR psd = NULL; | ||
| 4769 | |||
| 4770 | if (type == ACL_TYPE_ACCESS) | ||
| 4771 | { | ||
| 4772 | DWORD sd_len, err; | ||
| 4773 | SECURITY_INFORMATION si = | ||
| 4774 | OWNER_SECURITY_INFORMATION | | ||
| 4775 | GROUP_SECURITY_INFORMATION | | ||
| 4776 | DACL_SECURITY_INFORMATION ; | ||
| 4777 | int e = errno; | ||
| 4778 | |||
| 4779 | errno = 0; | ||
| 4780 | if (!get_file_security (fname, si, psd, 0, &sd_len) | ||
| 4781 | && errno != ENOTSUP) | ||
| 4782 | { | ||
| 4783 | err = GetLastError (); | ||
| 4784 | if (err == ERROR_INSUFFICIENT_BUFFER) | ||
| 4785 | { | ||
| 4786 | psd = xmalloc (sd_len); | ||
| 4787 | if (!get_file_security (fname, si, psd, sd_len, &sd_len)) | ||
| 4788 | { | ||
| 4789 | xfree (psd); | ||
| 4790 | errno = EIO; | ||
| 4791 | psd = NULL; | ||
| 4792 | } | ||
| 4793 | } | ||
| 4794 | else if (err == ERROR_FILE_NOT_FOUND | ||
| 4795 | || err == ERROR_PATH_NOT_FOUND) | ||
| 4796 | errno = ENOENT; | ||
| 4797 | else | ||
| 4798 | errno = EIO; | ||
| 4799 | } | ||
| 4800 | else if (!errno) | ||
| 4801 | errno = e; | ||
| 4802 | } | ||
| 4803 | else if (type != ACL_TYPE_DEFAULT) | ||
| 4804 | errno = EINVAL; | ||
| 4805 | |||
| 4806 | return psd; | ||
| 4807 | } | ||
| 4808 | |||
| 4809 | int | ||
| 4810 | acl_set_file (const char *fname, acl_type_t type, acl_t acl) | ||
| 4811 | { | ||
| 4812 | TOKEN_PRIVILEGES old1, old2; | ||
| 4813 | DWORD err; | ||
| 4814 | BOOL res; | ||
| 4815 | int st = 0, retval = -1; | ||
| 4816 | SECURITY_INFORMATION flags = 0; | ||
| 4817 | PSID psid; | ||
| 4818 | PACL pacl; | ||
| 4819 | BOOL dflt; | ||
| 4820 | BOOL dacl_present; | ||
| 4821 | int e; | ||
| 4822 | |||
| 4823 | if (acl_valid (acl) != 0 | ||
| 4824 | || (type != ACL_TYPE_DEFAULT && type != ACL_TYPE_ACCESS)) | ||
| 4825 | { | ||
| 4826 | errno = EINVAL; | ||
| 4827 | return -1; | ||
| 4828 | } | ||
| 4829 | |||
| 4830 | if (type == ACL_TYPE_DEFAULT) | ||
| 4831 | { | ||
| 4832 | errno = ENOSYS; | ||
| 4833 | return -1; | ||
| 4834 | } | ||
| 4835 | |||
| 4836 | if (get_security_descriptor_owner ((PSECURITY_DESCRIPTOR)acl, &psid, &dflt) | ||
| 4837 | && psid) | ||
| 4838 | flags |= OWNER_SECURITY_INFORMATION; | ||
| 4839 | if (get_security_descriptor_group ((PSECURITY_DESCRIPTOR)acl, &psid, &dflt) | ||
| 4840 | && psid) | ||
| 4841 | flags |= GROUP_SECURITY_INFORMATION; | ||
| 4842 | if (get_security_descriptor_dacl ((PSECURITY_DESCRIPTOR)acl, &dacl_present, | ||
| 4843 | &pacl, &dflt) | ||
| 4844 | && dacl_present) | ||
| 4845 | flags |= DACL_SECURITY_INFORMATION; | ||
| 4846 | if (!flags) | ||
| 4847 | return 0; | ||
| 4848 | |||
| 4849 | /* According to KB-245153, setting the owner will succeed if either: | ||
| 4850 | (1) the caller is the user who will be the new owner, and has the | ||
| 4851 | SE_TAKE_OWNERSHIP privilege, or | ||
| 4852 | (2) the caller has the SE_RESTORE privilege, in which case she can | ||
| 4853 | set any valid user or group as the owner | ||
| 4854 | |||
| 4855 | We request below both SE_TAKE_OWNERSHIP and SE_RESTORE | ||
| 4856 | privileges, and disregard any failures in obtaining them. If | ||
| 4857 | these privileges cannot be obtained, and do not already exist in | ||
| 4858 | the calling thread's security token, this function could fail | ||
| 4859 | with EPERM. */ | ||
| 4860 | if (enable_privilege (SE_TAKE_OWNERSHIP_NAME, TRUE, &old1)) | ||
| 4861 | st++; | ||
| 4862 | if (enable_privilege (SE_RESTORE_NAME, TRUE, &old2)) | ||
| 4863 | st++; | ||
| 4864 | |||
| 4865 | e = errno; | ||
| 4866 | errno = 0; | ||
| 4867 | set_file_security ((char *)fname, flags, (PSECURITY_DESCRIPTOR)acl); | ||
| 4868 | err = GetLastError (); | ||
| 4869 | if (st >= 2) | ||
| 4870 | restore_privilege (&old2); | ||
| 4871 | if (st >= 1) | ||
| 4872 | restore_privilege (&old1); | ||
| 4873 | |||
| 4874 | if (errno == ENOTSUP) | ||
| 4875 | ; | ||
| 4876 | else if (err == ERROR_SUCCESS) | ||
| 4877 | { | ||
| 4878 | retval = 0; | ||
| 4879 | errno = e; | ||
| 4880 | } | ||
| 4881 | else if (err == ERROR_INVALID_OWNER) | ||
| 4882 | errno = EPERM; | ||
| 4883 | else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND) | ||
| 4884 | errno = ENOENT; | ||
| 4885 | |||
| 4886 | return retval; | ||
| 4887 | } | ||
| 4888 | |||
| 4889 | |||
| 4480 | /* MS-Windows version of careadlinkat (cf. ../lib/careadlinkat.c). We | 4890 | /* MS-Windows version of careadlinkat (cf. ../lib/careadlinkat.c). We |
| 4481 | have a fixed max size for file names, so we don't need the kind of | 4891 | have a fixed max size for file names, so we don't need the kind of |
| 4482 | alloc/malloc/realloc dance the gnulib version does. We also don't | 4892 | alloc/malloc/realloc dance the gnulib version does. We also don't |
| @@ -6848,6 +7258,11 @@ globals_of_w32 (void) | |||
| 6848 | g_b_init_get_native_system_info = 0; | 7258 | g_b_init_get_native_system_info = 0; |
| 6849 | g_b_init_get_system_times = 0; | 7259 | g_b_init_get_system_times = 0; |
| 6850 | g_b_init_create_symbolic_link = 0; | 7260 | g_b_init_create_symbolic_link = 0; |
| 7261 | g_b_init_get_security_descriptor_dacl = 0; | ||
| 7262 | g_b_init_convert_sd_to_sddl = 0; | ||
| 7263 | g_b_init_convert_sddl_to_sd = 0; | ||
| 7264 | g_b_init_is_valid_security_descriptor = 0; | ||
| 7265 | g_b_init_set_file_security = 0; | ||
| 6851 | num_of_processors = 0; | 7266 | num_of_processors = 0; |
| 6852 | /* The following sets a handler for shutdown notifications for | 7267 | /* The following sets a handler for shutdown notifications for |
| 6853 | console apps. This actually applies to Emacs in both console and | 7268 | console apps. This actually applies to Emacs in both console and |
diff --git a/src/window.c b/src/window.c index 3e3cd3a571c..56db79a57d5 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -488,7 +488,6 @@ static Lisp_Object | |||
| 488 | select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | 488 | select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) |
| 489 | { | 489 | { |
| 490 | register struct window *w; | 490 | register struct window *w; |
| 491 | register struct window *ow; | ||
| 492 | struct frame *sf; | 491 | struct frame *sf; |
| 493 | 492 | ||
| 494 | CHECK_LIVE_WINDOW (window); | 493 | CHECK_LIVE_WINDOW (window); |
| @@ -524,12 +523,25 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | |||
| 524 | else | 523 | else |
| 525 | fset_selected_window (sf, window); | 524 | fset_selected_window (sf, window); |
| 526 | 525 | ||
| 526 | select_window_1 (window, inhibit_point_swap); | ||
| 527 | |||
| 528 | bset_last_selected_window (XBUFFER (w->buffer), window); | ||
| 529 | windows_or_buffers_changed++; | ||
| 530 | return window; | ||
| 531 | } | ||
| 532 | |||
| 533 | /* Select window with a minimum of fuss, i.e. don't record the change anywhere | ||
| 534 | (not even for rediaplay's benefit), and assume that the window's frame is | ||
| 535 | already selected. */ | ||
| 536 | void | ||
| 537 | select_window_1 (Lisp_Object window, bool inhibit_point_swap) | ||
| 538 | { | ||
| 527 | /* Store the old selected window's buffer's point in pointm of the old | 539 | /* Store the old selected window's buffer's point in pointm of the old |
| 528 | selected window. It belongs to that window, and when the window is | 540 | selected window. It belongs to that window, and when the window is |
| 529 | not selected, must be in the window. */ | 541 | not selected, must be in the window. */ |
| 530 | if (!inhibit_point_swap) | 542 | if (!inhibit_point_swap) |
| 531 | { | 543 | { |
| 532 | ow = XWINDOW (selected_window); | 544 | struct window *ow = XWINDOW (selected_window); |
| 533 | if (! NILP (ow->buffer)) | 545 | if (! NILP (ow->buffer)) |
| 534 | set_marker_both (ow->pointm, ow->buffer, | 546 | set_marker_both (ow->pointm, ow->buffer, |
| 535 | BUF_PT (XBUFFER (ow->buffer)), | 547 | BUF_PT (XBUFFER (ow->buffer)), |
| @@ -537,7 +549,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | |||
| 537 | } | 549 | } |
| 538 | 550 | ||
| 539 | selected_window = window; | 551 | selected_window = window; |
| 540 | bset_last_selected_window (XBUFFER (w->buffer), window); | ||
| 541 | 552 | ||
| 542 | /* Go to the point recorded in the window. | 553 | /* Go to the point recorded in the window. |
| 543 | This is important when the buffer is in more | 554 | This is important when the buffer is in more |
| @@ -545,7 +556,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | |||
| 545 | redisplay_window has altered point after scrolling, | 556 | redisplay_window has altered point after scrolling, |
| 546 | because it makes the change only in the window. */ | 557 | because it makes the change only in the window. */ |
| 547 | { | 558 | { |
| 548 | register ptrdiff_t new_point = marker_position (w->pointm); | 559 | register ptrdiff_t new_point = marker_position (XWINDOW (window)->pointm); |
| 549 | if (new_point < BEGV) | 560 | if (new_point < BEGV) |
| 550 | SET_PT (BEGV); | 561 | SET_PT (BEGV); |
| 551 | else if (new_point > ZV) | 562 | else if (new_point > ZV) |
| @@ -553,9 +564,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | |||
| 553 | else | 564 | else |
| 554 | SET_PT (new_point); | 565 | SET_PT (new_point); |
| 555 | } | 566 | } |
| 556 | |||
| 557 | windows_or_buffers_changed++; | ||
| 558 | return window; | ||
| 559 | } | 567 | } |
| 560 | 568 | ||
| 561 | DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, | 569 | DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, |
diff --git a/src/window.h b/src/window.h index f4f42a25af4..716b9771160 100644 --- a/src/window.h +++ b/src/window.h | |||
| @@ -261,7 +261,7 @@ struct window | |||
| 261 | EMACS_INT last_overlay_modified; | 261 | EMACS_INT last_overlay_modified; |
| 262 | 262 | ||
| 263 | /* Value of point at that time. Since this is a position in a buffer, | 263 | /* Value of point at that time. Since this is a position in a buffer, |
| 264 | it should be positive. */ | 264 | it should be positive. */ |
| 265 | ptrdiff_t last_point; | 265 | ptrdiff_t last_point; |
| 266 | 266 | ||
| 267 | /* Scaling factor for the glyph_matrix size calculation in this window. | 267 | /* Scaling factor for the glyph_matrix size calculation in this window. |
| @@ -290,7 +290,7 @@ struct window | |||
| 290 | /* Non-zero if this window is a minibuffer window. */ | 290 | /* Non-zero if this window is a minibuffer window. */ |
| 291 | unsigned mini : 1; | 291 | unsigned mini : 1; |
| 292 | 292 | ||
| 293 | /* Non-zero means must regenerate mode line of this window */ | 293 | /* Non-zero means must regenerate mode line of this window. */ |
| 294 | unsigned update_mode_line : 1; | 294 | unsigned update_mode_line : 1; |
| 295 | 295 | ||
| 296 | /* Non-nil if the buffer was "modified" when the window | 296 | /* Non-nil if the buffer was "modified" when the window |
| @@ -343,7 +343,7 @@ struct window | |||
| 343 | y-direction (smooth scrolling). */ | 343 | y-direction (smooth scrolling). */ |
| 344 | int vscroll; | 344 | int vscroll; |
| 345 | 345 | ||
| 346 | /* Z_BYTE - the buffer position of the last glyph in the current matrix of W. | 346 | /* Z_BYTE - Buffer position of the last glyph in the current matrix of W. |
| 347 | Should be nonnegative, and only valid if window_end_valid is not nil. */ | 347 | Should be nonnegative, and only valid if window_end_valid is not nil. */ |
| 348 | ptrdiff_t window_end_bytepos; | 348 | ptrdiff_t window_end_bytepos; |
| 349 | }; | 349 | }; |
| @@ -934,7 +934,7 @@ extern EMACS_INT minibuf_level; | |||
| 934 | extern int update_mode_lines; | 934 | extern int update_mode_lines; |
| 935 | 935 | ||
| 936 | /* Nonzero if window sizes or contents have changed since last | 936 | /* Nonzero if window sizes or contents have changed since last |
| 937 | redisplay that finished */ | 937 | redisplay that finished. */ |
| 938 | 938 | ||
| 939 | extern int windows_or_buffers_changed; | 939 | extern int windows_or_buffers_changed; |
| 940 | 940 | ||
| @@ -978,6 +978,7 @@ struct glyph *get_phys_cursor_glyph (struct window *w); | |||
| 978 | extern Lisp_Object Qwindowp, Qwindow_live_p; | 978 | extern Lisp_Object Qwindowp, Qwindow_live_p; |
| 979 | extern Lisp_Object Vwindow_list; | 979 | extern Lisp_Object Vwindow_list; |
| 980 | 980 | ||
| 981 | extern void select_window_1 (Lisp_Object window, bool inhibit_point_swap); | ||
| 981 | extern struct window *decode_live_window (Lisp_Object); | 982 | extern struct window *decode_live_window (Lisp_Object); |
| 982 | extern struct window *decode_any_window (Lisp_Object); | 983 | extern struct window *decode_any_window (Lisp_Object); |
| 983 | extern bool compare_window_configurations (Lisp_Object, Lisp_Object, bool); | 984 | extern bool compare_window_configurations (Lisp_Object, Lisp_Object, bool); |
diff --git a/src/xdisp.c b/src/xdisp.c index 9941f7be35d..b9db0c3e80d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -871,7 +871,6 @@ static void push_it (struct it *, struct text_pos *); | |||
| 871 | static void iterate_out_of_display_property (struct it *); | 871 | static void iterate_out_of_display_property (struct it *); |
| 872 | static void pop_it (struct it *); | 872 | static void pop_it (struct it *); |
| 873 | static void sync_frame_with_window_matrix_rows (struct window *); | 873 | static void sync_frame_with_window_matrix_rows (struct window *); |
| 874 | static void select_frame_for_redisplay (Lisp_Object); | ||
| 875 | static void redisplay_internal (void); | 874 | static void redisplay_internal (void); |
| 876 | static int echo_area_display (int); | 875 | static int echo_area_display (int); |
| 877 | static void redisplay_windows (Lisp_Object); | 876 | static void redisplay_windows (Lisp_Object); |
| @@ -1335,7 +1334,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1335 | BVAR (current_buffer, header_line_format)); | 1334 | BVAR (current_buffer, header_line_format)); |
| 1336 | 1335 | ||
| 1337 | start_display (&it, w, top); | 1336 | start_display (&it, w, top); |
| 1338 | move_it_to (&it, charpos, -1, it.last_visible_y-1, -1, | 1337 | move_it_to (&it, charpos, -1, it.last_visible_y - 1, -1, |
| 1339 | (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y); | 1338 | (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y); |
| 1340 | 1339 | ||
| 1341 | if (charpos >= 0 | 1340 | if (charpos >= 0 |
| @@ -1343,7 +1342,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1343 | && IT_CHARPOS (it) >= charpos) | 1342 | && IT_CHARPOS (it) >= charpos) |
| 1344 | /* When scanning backwards under bidi iteration, move_it_to | 1343 | /* When scanning backwards under bidi iteration, move_it_to |
| 1345 | stops at or _before_ CHARPOS, because it stops at or to | 1344 | stops at or _before_ CHARPOS, because it stops at or to |
| 1346 | the _right_ of the character at CHARPOS. */ | 1345 | the _right_ of the character at CHARPOS. */ |
| 1347 | || (it.bidi_p && it.bidi_it.scan_dir == -1 | 1346 | || (it.bidi_p && it.bidi_it.scan_dir == -1 |
| 1348 | && IT_CHARPOS (it) <= charpos))) | 1347 | && IT_CHARPOS (it) <= charpos))) |
| 1349 | { | 1348 | { |
| @@ -13020,7 +13019,9 @@ select_frame_for_redisplay (Lisp_Object frame) | |||
| 13020 | eassert (FRAMEP (frame) && FRAME_LIVE_P (XFRAME (frame))); | 13019 | eassert (FRAMEP (frame) && FRAME_LIVE_P (XFRAME (frame))); |
| 13021 | 13020 | ||
| 13022 | selected_frame = frame; | 13021 | selected_frame = frame; |
| 13023 | selected_window = XFRAME (frame)->selected_window; | 13022 | /* If redisplay causes scrolling, it sets point in the window, so we need to |
| 13023 | be careful with the selected-window's point handling. */ | ||
| 13024 | select_window_1 (XFRAME (frame)->selected_window, 0); | ||
| 13024 | 13025 | ||
| 13025 | do { | 13026 | do { |
| 13026 | for (tail = XFRAME (frame)->param_alist; | 13027 | for (tail = XFRAME (frame)->param_alist; |
| @@ -13551,10 +13552,8 @@ redisplay_internal (void) | |||
| 13551 | 13552 | ||
| 13552 | if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf) | 13553 | if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf) |
| 13553 | { | 13554 | { |
| 13554 | if (! EQ (frame, selected_frame)) | 13555 | /* Select the frame, for the sake of frame-local variables. */ |
| 13555 | /* Select the frame, for the sake of frame-local | 13556 | ensure_selected_frame (frame); |
| 13556 | variables. */ | ||
| 13557 | select_frame_for_redisplay (frame); | ||
| 13558 | 13557 | ||
| 13559 | /* Mark all the scroll bars to be removed; we'll redeem | 13558 | /* Mark all the scroll bars to be removed; we'll redeem |
| 13560 | the ones we want when we redisplay their windows. */ | 13559 | the ones we want when we redisplay their windows. */ |
| @@ -13851,8 +13850,8 @@ mark_window_display_accurate_1 (struct window *w, int accurate_p) | |||
| 13851 | { | 13850 | { |
| 13852 | struct buffer *b = XBUFFER (w->buffer); | 13851 | struct buffer *b = XBUFFER (w->buffer); |
| 13853 | 13852 | ||
| 13854 | w->last_modified = accurate_p ? BUF_MODIFF(b) : 0; | 13853 | w->last_modified = accurate_p ? BUF_MODIFF (b) : 0; |
| 13855 | w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF(b) : 0; | 13854 | w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF (b) : 0; |
| 13856 | w->last_had_star | 13855 | w->last_had_star |
| 13857 | = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b); | 13856 | = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b); |
| 13858 | 13857 | ||
| @@ -20465,8 +20464,11 @@ display_mode_lines (struct window *w) | |||
| 20465 | Lisp_Object old_frame_selected_window = XFRAME (new_frame)->selected_window; | 20464 | Lisp_Object old_frame_selected_window = XFRAME (new_frame)->selected_window; |
| 20466 | int n = 0; | 20465 | int n = 0; |
| 20467 | 20466 | ||
| 20468 | selected_frame = w->frame; | 20467 | selected_frame = new_frame; |
| 20468 | /* FIXME: If we were to allow the mode-line's computation changing the buffer | ||
| 20469 | or window's point, then we'd need select_window_1 here as well. */ | ||
| 20469 | XSETWINDOW (selected_window, w); | 20470 | XSETWINDOW (selected_window, w); |
| 20471 | XFRAME (new_frame)->selected_window = selected_window; | ||
| 20470 | 20472 | ||
| 20471 | /* These will be set while the mode line specs are processed. */ | 20473 | /* These will be set while the mode line specs are processed. */ |
| 20472 | line_number_displayed = 0; | 20474 | line_number_displayed = 0; |