mirror of
https://github.com/mirror/make.git
synced 2025-01-16 23:31:08 +08:00
* src/implicit.c (pattern_search): Set lastslash correctly
If filename contained multiple slashes lastslash is wrongly set to 0. * configure.ac: Check for the GNU memrchr() extension function. * src/misc.c (memrchr): Supply memrchr() if not available.
This commit is contained in:
parent
057e33d6b5
commit
c72205b28b
@ -138,7 +138,7 @@ AS_IF([test "$ac_cv_func_gettimeofday" = yes],
|
|||||||
[Define to 1 if you have a standard gettimeofday function])
|
[Define to 1 if you have a standard gettimeofday function])
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_CHECK_FUNCS([strdup strndup umask mkstemp mktemp fdopen \
|
AC_CHECK_FUNCS([strdup strndup memrchr umask mkstemp mktemp fdopen \
|
||||||
dup dup2 getcwd realpath sigsetmask sigaction \
|
dup dup2 getcwd realpath sigsetmask sigaction \
|
||||||
getgroups seteuid setegid setlinebuf setreuid setregid \
|
getgroups seteuid setegid setlinebuf setreuid setregid \
|
||||||
getrlimit setrlimit setvbuf pipe strsignal \
|
getrlimit setrlimit setvbuf pipe strsignal \
|
||||||
|
@ -265,7 +265,7 @@ pattern_search (struct file *file, int archive,
|
|||||||
/* Set LASTSLASH to point at the last slash in FILENAME
|
/* Set LASTSLASH to point at the last slash in FILENAME
|
||||||
but not counting any slash at the end. (foo/bar/ counts as
|
but not counting any slash at the end. (foo/bar/ counts as
|
||||||
bar/ in directory foo/, not empty in directory foo/bar/.) */
|
bar/ in directory foo/, not empty in directory foo/bar/.) */
|
||||||
lastslash = strrchr (filename, '/');
|
lastslash = memrchr (filename, '/', namelen - 1);
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
if (lastslash == NULL)
|
if (lastslash == NULL)
|
||||||
lastslash = strrchr (filename, ']');
|
lastslash = strrchr (filename, ']');
|
||||||
@ -278,18 +278,16 @@ pattern_search (struct file *file, int archive,
|
|||||||
/* Handle backslashes (possibly mixed with forward slashes)
|
/* Handle backslashes (possibly mixed with forward slashes)
|
||||||
and the case of "d:file". */
|
and the case of "d:file". */
|
||||||
{
|
{
|
||||||
char *bslash = strrchr (filename, '\\');
|
char *bslash = memrchr (filename, '\\', namelen - 1);
|
||||||
if (lastslash == 0 || bslash > lastslash)
|
if (lastslash == 0 || bslash > lastslash)
|
||||||
lastslash = bslash;
|
lastslash = bslash;
|
||||||
if (lastslash == 0 && filename[0] && filename[1] == ':')
|
if (lastslash == 0 && filename[0] && filename[1] == ':')
|
||||||
lastslash = filename + 1;
|
lastslash = filename + 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (lastslash != 0 && lastslash[1] == '\0')
|
|
||||||
lastslash = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pathlen = lastslash - filename + 1;
|
pathlen = lastslash ? lastslash - filename + 1 : 0;
|
||||||
|
|
||||||
/* First see which pattern rules match this target and may be considered.
|
/* First see which pattern rules match this target and may be considered.
|
||||||
Put them in TRYRULES. */
|
Put them in TRYRULES. */
|
||||||
|
24
src/misc.c
24
src/misc.c
@ -260,6 +260,30 @@ xstrndup (const char *str, size_t length)
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_MEMRCHR
|
||||||
|
void *
|
||||||
|
memrchr(const void* str, int ch, size_t len)
|
||||||
|
{
|
||||||
|
const char* sp = str;
|
||||||
|
const char* cp = sp;
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cp += len - 1;
|
||||||
|
|
||||||
|
while (cp[0] != ch)
|
||||||
|
{
|
||||||
|
if (cp == sp)
|
||||||
|
return NULL;
|
||||||
|
--cp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (void*)cp;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Limited INDEX:
|
/* Limited INDEX:
|
||||||
|
Loading…
Reference in New Issue
Block a user