mirror of
https://github.com/mirror/make.git
synced 2025-03-03 22:30:59 +08:00
Set PATH_MAX on systems without a default value
Some systems (HURD) use fully-dynamic pathnames, with no limit. We can't support this without significant effort so for now set PATH_MAX to a large value. * src/makeint.h: Set PATH_MAX to 4096 if not set and MAXPATHLEN is also not set. Remove MAXPATHLEN setting: we won't use it. * src/misc.c (get_path_max): If we can't get the path max via pathconf() use the default PATH_MAX. * src/dir.c (find_directory) [W32]: Use MAX_PATH not MAXPATHLEN. (local_stat) [W32]: Ditto. * src/job.c (create_batch_file) [W32]: Ditto. * src/remake.c (name_mtime) [W32]: Ditto. * src/w32/w32os.c (os_anontmp) [W32]: Ditto.
This commit is contained in:
parent
bb0c05a7f0
commit
f364e0d8d6
@ -521,7 +521,7 @@ find_directory (const char *name)
|
||||
/* See if the directory exists. */
|
||||
#if defined(WINDOWS32)
|
||||
{
|
||||
char tem[MAXPATHLEN], *tstart, *tend;
|
||||
char tem[MAX_PATH+1], *tstart, *tend;
|
||||
size_t len = strlen (name);
|
||||
|
||||
/* Remove any trailing slashes. Windows32 stat fails even on
|
||||
@ -1314,10 +1314,10 @@ local_stat (const char *path, struct stat *buf)
|
||||
foo/. => foo without checking first that foo is a directory. */
|
||||
if (plen > 2 && path[plen - 1] == '.' && ISDIRSEP (path[plen - 2]))
|
||||
{
|
||||
char parent[MAXPATHLEN+1];
|
||||
char parent[MAX_PATH+1];
|
||||
|
||||
strncpy (parent, path, MAXPATHLEN);
|
||||
parent[MIN(plen - 2, MAXPATHLEN)] = '\0';
|
||||
strncpy (parent, path, MAX_PATH);
|
||||
parent[MIN(plen - 2, MAX_PATH)] = '\0';
|
||||
if (stat (parent, buf) < 0 || !_S_ISDIR (buf->st_mode))
|
||||
return -1;
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ create_batch_file (char const *base, int unixy, int *fd)
|
||||
{
|
||||
const char *const ext = unixy ? "sh" : "bat";
|
||||
const char *error_string = NULL;
|
||||
char temp_path[MAXPATHLEN]; /* need to know its length */
|
||||
char temp_path[MAX_PATH+1]; /* need to know its length */
|
||||
unsigned path_size = GetTempPath (sizeof temp_path, temp_path);
|
||||
int path_is_dot = 0;
|
||||
/* The following variable is static so we won't try to reuse a name
|
||||
|
@ -152,13 +152,14 @@ extern int errno;
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
# ifndef POSIX
|
||||
# ifdef MAXPATHLEN
|
||||
# define PATH_MAX MAXPATHLEN
|
||||
# else
|
||||
/* Some systems (HURD) have fully dynamic pathnames with no maximum.
|
||||
Ideally we'd support this but it will take some work. */
|
||||
# define PATH_MAX 4096
|
||||
# endif
|
||||
#endif
|
||||
#ifndef MAXPATHLEN
|
||||
# define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
#ifdef PATH_MAX
|
||||
# define GET_PATH_MAX PATH_MAX
|
||||
|
@ -769,11 +769,11 @@ get_path_max (void)
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
long int x = pathconf ("/", _PC_PATH_MAX);
|
||||
long x = pathconf ("/", _PC_PATH_MAX);
|
||||
if (x > 0)
|
||||
value = x;
|
||||
value = (unsigned int) x;
|
||||
else
|
||||
return MAXPATHLEN;
|
||||
value = PATH_MAX;
|
||||
}
|
||||
|
||||
return value;
|
||||
|
@ -34,6 +34,7 @@ this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
#include <starlet.h>
|
||||
#endif
|
||||
#ifdef WINDOWS32
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <sys/stat.h>
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1200
|
||||
@ -1551,7 +1552,7 @@ name_mtime (const char *name)
|
||||
|
||||
#if defined(WINDOWS32)
|
||||
{
|
||||
char tem[MAXPATHLEN], *tstart, *tend;
|
||||
char tem[MAX_PATH+1], *tstart, *tend;
|
||||
const char *p = name + strlen (name);
|
||||
|
||||
/* Remove any trailing slashes and "."/"..". MS-Windows stat
|
||||
|
@ -115,7 +115,7 @@ check_io_state ()
|
||||
int
|
||||
os_anontmp ()
|
||||
{
|
||||
char temp_path[MAXPATHLEN];
|
||||
char temp_path[MAX_PATH+1];
|
||||
unsigned path_size = GetTempPath (sizeof (temp_path), temp_path);
|
||||
int using_cwd = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user