]> code.delx.au - gnu-emacs/blobdiff - src/w32.c
Merge from emacs--devo--0
[gnu-emacs] / src / w32.c
index cbc78f8a5d5c1d117f465e03f206b3638f3f18b4..9ad82c7a231aa0ecbb6d9f46396f4c749314ae4d 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -1,6 +1,6 @@
 /* Utility and Unix shadow routines for GNU Emacs on the Microsoft W32 API.
    Copyright (C) 1994, 1995, 2000, 2001, 2002, 2003, 2004,
-                 2005, 2006 Free Software Foundation, Inc.
+                 2005, 2006, 2007 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -32,6 +32,7 @@ Boston, MA 02110-1301, USA.
 #include <sys/file.h>
 #include <sys/time.h>
 #include <sys/utime.h>
+#include <mbstring.h>  /* for _mbspbrk */
 
 /* must include CRT headers *before* config.h */
 
@@ -153,7 +154,8 @@ typedef PSID_IDENTIFIER_AUTHORITY (WINAPI * GetSidIdentifierAuthority_Proc) (
     PSID pSid);
 
   /* ** A utility function ** */
-static BOOL is_windows_9x ()
+static BOOL
+is_windows_9x ()
 {
   static BOOL s_b_ret=0;
   OSVERSIONINFO os_ver;
@@ -738,7 +740,7 @@ get_long_basename (char * name, char * buf, int size)
   int len = 0;
 
   /* must be valid filename, no wild cards or other invalid characters */
-  if (strpbrk (name, "*?|<>\""))
+  if (_mbspbrk (name, "*?|<>\""))
     return 0;
 
   dir_handle = FindFirstFile (name, &find_data);
@@ -813,7 +815,7 @@ is_unc_volume (const char *filename)
   if (!IS_DIRECTORY_SEP (ptr[0]) || !IS_DIRECTORY_SEP (ptr[1]) || !ptr[2])
     return 0;
 
-  if (strpbrk (ptr + 2, "*?|<>\"\\/"))
+  if (_mbspbrk (ptr + 2, "*?|<>\"\\/"))
     return 0;
 
   return 1;
@@ -2385,8 +2387,12 @@ stat (const char * path, struct stat * buf)
     }
 
   name = (char *) map_w32_filename (path, &path);
-  /* must be valid filename, no wild cards or other invalid characters */
-  if (strpbrk (name, "*?|<>\""))
+  /* Must be valid filename, no wild cards or other invalid
+     characters.  We use _mbspbrk to support multibyte strings that
+     might look to strpbrk as if they included literal *, ?, and other
+     characters mentioned below that are disallowed by Windows
+     filesystems.  */
+  if (_mbspbrk (name, "*?|<>\""))
     {
       errno = ENOENT;
       return -1;
@@ -2871,7 +2877,8 @@ int h_errno = 0;
 /* function to set h_errno for compatability; map winsock error codes to
    normal system codes where they overlap (non-overlapping definitions
    are already in <sys/socket.h> */
-static void set_errno ()
+static void
+set_errno ()
 {
   if (winsock_lib == NULL)
     h_errno = EINVAL;
@@ -2892,7 +2899,8 @@ static void set_errno ()
   errno = h_errno;
 }
 
-static void check_errno ()
+static void
+check_errno ()
 {
   if (h_errno == 0 && winsock_lib != NULL)
     pfn_WSASetLastError (0);
@@ -3676,7 +3684,8 @@ _sys_read_ahead (int fd)
   return cp->status;
 }
 
-int _sys_wait_accept (int fd)
+int
+_sys_wait_accept (int fd)
 {
   HANDLE hEv;
   child_process * cp;
@@ -3698,10 +3707,10 @@ int _sys_wait_accept (int fd)
     {
       rc = WaitForSingleObject (hEv, INFINITE);
       pfn_WSAEventSelect (SOCK_HANDLE (fd), NULL, 0);
-      pfn_WSACloseEvent (hEv);
       if (rc == WAIT_OBJECT_0)
        cp->status = STATUS_READ_SUCCEEDED;
     }
+  pfn_WSACloseEvent (hEv);
 
   return cp->status;
 }
@@ -4127,7 +4136,7 @@ BOOL WINAPI shutdown_handler(DWORD type)
       shut_down_emacs (0, 0, Qnil);
     }
 
-  /* Allow other handlers to handle this signal.  */  
+  /* Allow other handlers to handle this signal.  */
   return FALSE;
 }
 
@@ -4136,7 +4145,8 @@ BOOL WINAPI shutdown_handler(DWORD type)
        must always be initialized on startup even when the global variable
        initialized is non zero (see the function main in emacs.c).
 */
-void globals_of_w32 ()
+void
+globals_of_w32 ()
 {
   g_b_init_is_windows_9x = 0;
   g_b_init_open_process_token = 0;