Make "xfree (NULL)" a no-op; remove useless if-before-xfree.
[bpt/emacs.git] / src / w32.c
index 5667f99..81accb6 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -4,10 +4,10 @@
 
 This file is part of GNU Emacs.
 
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,10 +15,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/*
    Geoff Voelker (voelker@cs.washington.edu)                         7-29-94
 */
 #include <stddef.h> /* for offsetof */
@@ -101,6 +100,7 @@ Boston, MA 02110-1301, USA.
 #include "ndir.h"
 #include "w32heap.h"
 #include "systime.h"
+#include "dispextern.h"                /* for xstrcasecmp */
 
 typedef HRESULT (WINAPI * ShGetFolderPath_fn)
   (IN HWND, IN int, IN HANDLE, IN DWORD, OUT char *);
@@ -721,7 +721,7 @@ getpwnam (char *name)
   if (!pw)
     return pw;
 
-  if (stricmp (name, pw->pw_name))
+  if (xstrcasecmp (name, pw->pw_name))
     return NULL;
 
   return pw;
@@ -755,7 +755,7 @@ init_user_info ()
     {
       strcpy (dflt_passwd.pw_name, uname);
       /* Determine a reasonable uid value.  */
-      if (stricmp ("administrator", uname) == 0)
+      if (xstrcasecmp ("administrator", uname) == 0)
        {
          dflt_passwd.pw_uid = 500; /* well-known Administrator uid */
          dflt_passwd.pw_gid = 513; /* well-known None gid */
@@ -787,7 +787,7 @@ init_user_info ()
   else if (GetUserName (uname, &ulength))
     {
       strcpy (dflt_passwd.pw_name, uname);
-      if (stricmp ("administrator", uname) == 0)
+      if (xstrcasecmp ("administrator", uname) == 0)
        dflt_passwd.pw_uid = 0;
       else
        dflt_passwd.pw_uid = 123;
@@ -1128,7 +1128,7 @@ w32_get_resource (key, lpdwtype)
          return (lpvalue);
        }
 
-      if (lpvalue) xfree (lpvalue);
+      xfree (lpvalue);
 
       RegCloseKey (hrootkey);
     }
@@ -1145,7 +1145,7 @@ w32_get_resource (key, lpdwtype)
          return (lpvalue);
        }
 
-      if (lpvalue) xfree (lpvalue);
+      xfree (lpvalue);
 
       RegCloseKey (hrootkey);
     }
@@ -1297,7 +1297,7 @@ init_environment (char ** argv)
        abort ();
       *p = 0;
 
-      if ((p = strrchr (modname, '\\')) && stricmp (p, "\\bin") == 0)
+      if ((p = strrchr (modname, '\\')) && xstrcasecmp (p, "\\bin") == 0)
        {
          char buf[SET_ENV_BUF_SIZE];
 
@@ -1313,7 +1313,7 @@ init_environment (char ** argv)
       /* FIXME: should use substring of get_emacs_configuration ().
         But I don't think the Windows build supports alpha, mips etc
          anymore, so have taken the easy option for now.  */
-      else if (p && stricmp (p, "\\i386") == 0)
+      else if (p && xstrcasecmp (p, "\\i386") == 0)
        {
          *p = 0;
          p = strrchr (modname, '\\');
@@ -1321,7 +1321,7 @@ init_environment (char ** argv)
            {
              *p = 0;
              p = strrchr (modname, '\\');
-             if (p && stricmp (p, "\\src") == 0)
+             if (p && xstrcasecmp (p, "\\src") == 0)
                {
                  char buf[SET_ENV_BUF_SIZE];
 
@@ -1346,7 +1346,7 @@ init_environment (char ** argv)
                /* Also ignore empty environment variables.  */
                || *lpval == 0)
              {
-               if (lpval) xfree (lpval);
+               xfree (lpval);
                lpval = env_vars[i].def_value;
                dwType = REG_EXPAND_SZ;
                dont_free = 1;
@@ -1653,7 +1653,7 @@ lookup_volume_info (char * root_dir)
   volume_info_data * info;
 
   for (info = volume_cache; info; info = info->next)
-    if (stricmp (info->root_dir, root_dir) == 0)
+    if (xstrcasecmp (info->root_dir, root_dir) == 0)
       break;
   return info;
 }
@@ -1931,10 +1931,10 @@ is_exec (const char * name)
   char * p = strrchr (name, '.');
   return
     (p != NULL
-     && (stricmp (p, ".exe") == 0 ||
-        stricmp (p, ".com") == 0 ||
-        stricmp (p, ".bat") == 0 ||
-        stricmp (p, ".cmd") == 0));
+     && (xstrcasecmp (p, ".exe") == 0 ||
+        xstrcasecmp (p, ".com") == 0 ||
+        xstrcasecmp (p, ".bat") == 0 ||
+        xstrcasecmp (p, ".cmd") == 0));
 }
 
 /* Emulate the Unix directory procedures opendir, closedir,
@@ -2878,7 +2878,7 @@ stat (const char * path, struct stat * buf)
       if (dir_find_handle != INVALID_HANDLE_VALUE
          && strnicmp (name, dir_pathname, len) == 0
          && IS_DIRECTORY_SEP (name[len])
-         && stricmp (name + len + 1, dir_static.d_name) == 0)
+         && xstrcasecmp (name + len + 1, dir_static.d_name) == 0)
        {
          /* This was the last entry returned by readdir.  */
          wfd = dir_find_data;
@@ -2962,8 +2962,7 @@ stat (const char * path, struct stat * buf)
 
       get_file_owner_and_group (NULL, name, buf);
     }
-  if (psd)
-    xfree (psd);
+  xfree (psd);
 
 #if 0
   /* Not sure if there is any point in this.  */
@@ -3104,10 +3103,10 @@ fstat (int desc, struct stat * buf)
 #if 0 /* no way of knowing the filename */
       char * p = strrchr (name, '.');
       if (p != NULL &&
-         (stricmp (p, ".exe") == 0 ||
-          stricmp (p, ".com") == 0 ||
-          stricmp (p, ".bat") == 0 ||
-          stricmp (p, ".cmd") == 0))
+         (xstrcasecmp (p, ".exe") == 0 ||
+          xstrcasecmp (p, ".com") == 0 ||
+          xstrcasecmp (p, ".bat") == 0 ||
+          xstrcasecmp (p, ".cmd") == 0))
        permission |= S_IEXEC;
 #endif
     }