Imported Upstream version 4.4
[platform/upstream/make.git] / src / vpath.c
index d4e7dc7..9c95441 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of pattern-matching file search paths for GNU Make.
-Copyright (C) 1988-2020 Free Software Foundation, Inc.
+Copyright (C) 1988-2022 Free Software Foundation, Inc.
 This file is part of GNU Make.
 
 GNU Make is free software; you can redistribute it and/or modify it under the
@@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of 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
-this program.  If not, see <http://www.gnu.org/licenses/>.  */
+this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #include "makeint.h"
 #include "filedef.h"
@@ -239,8 +239,7 @@ construct_vpath_list (char *pattern, char *dirpath)
                 also define HAVE_DOS_PATHS would like us to recognize
                 colons after the drive letter in the likes of
                 "D:/foo/bar:C:/xyzzy".  */
-             && (*p != PATH_SEPARATOR_CHAR
-                 || (p == v + 1 && (p[1] == '/' || p[1] == '\\')))
+             && (*p != PATH_SEPARATOR_CHAR || (p == v + 1 && ISDIRSEP (p[1])))
 #else
              && *p != PATH_SEPARATOR_CHAR
 #endif
@@ -277,7 +276,7 @@ construct_vpath_list (char *pattern, char *dirpath)
          entry, to where the nil-pointer terminator goes.
          Usually this is maxelem - 1.  If not, shrink down.  */
       if (elem < (maxelem - 1))
-        vpath = xrealloc (vpath, (elem+1) * sizeof (const char *));
+        vpath = xrealloc ((void *)vpath, (elem+1) * sizeof (const char *));
 
       /* Put the nil-pointer terminator on the end of the VPATH list.  */
       vpath[elem] = NULL;
@@ -379,8 +378,7 @@ selective_vpath_search (struct vpath *path, const char *file,
       size_t vlen = strlen (vpath[i]);
 
       /* Put the next VPATH entry into NAME at P and increment P past it.  */
-      memcpy (p, vpath[i], vlen);
-      p += vlen;
+      p = mempcpy (p, vpath[i], vlen);
 
       /* Add the directory prefix already in *FILE.  */
       if (name_dplen > 0)
@@ -392,8 +390,7 @@ selective_vpath_search (struct vpath *path, const char *file,
           if ((*p != ':') && (*p != ']') && (*p != '>'))
             *p++ = '/';
 #endif
-          memcpy (p, file, name_dplen);
-          p += name_dplen;
+          p = mempcpy (p, file, name_dplen);
         }
 
 #ifdef HAVE_DOS_PATHS