do not use PATH_MAX on GNU/Hurd (even if it *was* defined), but use
some glibc-only functions that don’t require its use instead tested on gnubber, where (admittedly) sysconf(_PC_PATH_MAX) == 1024…
This commit is contained in:
5
Build.sh
5
Build.sh
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.429 2009/10/16 18:51:30 tg Exp $'
|
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.430 2009/10/27 16:59:59 tg Exp $'
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
||||||
# Thorsten Glaser <tg@mirbsd.org>
|
# Thorsten Glaser <tg@mirbsd.org>
|
||||||
@ -362,7 +362,8 @@ DragonFly)
|
|||||||
FreeBSD)
|
FreeBSD)
|
||||||
;;
|
;;
|
||||||
GNU)
|
GNU)
|
||||||
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
|
# define NO_PATH_MAX to use Hurd-only functions
|
||||||
|
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -DNO_PATH_MAX"
|
||||||
;;
|
;;
|
||||||
GNU/kFreeBSD)
|
GNU/kFreeBSD)
|
||||||
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
|
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
|
||||||
|
4
check.t
4
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.334 2009/10/18 12:30:04 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.335 2009/10/27 17:00:00 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -25,7 +25,7 @@
|
|||||||
# http://www.research.att.com/~gsf/public/ifs.sh
|
# http://www.research.att.com/~gsf/public/ifs.sh
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R39 2009/10/18
|
@(#)MIRBSD KSH R39 2009/10/27
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
|
24
funcs.c
24
funcs.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.140 2009/10/15 16:36:26 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.141 2009/10/27 17:00:01 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -267,12 +267,29 @@ do_realpath(const char *upath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get symlink(7) target */
|
/* get symlink(7) target */
|
||||||
|
#ifdef NO_PATH_MAX
|
||||||
|
if (ldest) {
|
||||||
|
afree(ldest, ATEMP);
|
||||||
|
ldest = NULL;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
struct stat hurd_sb;
|
||||||
|
|
||||||
|
if (lstat(Xstring(xs, xp), &hurd_sb))
|
||||||
|
goto notfound;
|
||||||
|
ldest = alloc(hurd_sb.st_size + 1, ATEMP);
|
||||||
|
if ((llen = readlink(Xstring(xs, xp), ldest,
|
||||||
|
hurd_sb.st_size)) < 0)
|
||||||
|
goto notfound;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (!ldest)
|
if (!ldest)
|
||||||
ldest = alloc(PATH_MAX + 1, ATEMP);
|
ldest = alloc(PATH_MAX + 1, ATEMP);
|
||||||
if ((llen = readlink(Xstring(xs, xp), ldest,
|
if ((llen = readlink(Xstring(xs, xp), ldest,
|
||||||
PATH_MAX)) < 0)
|
PATH_MAX)) < 0)
|
||||||
/* oops... */
|
/* oops... */
|
||||||
goto notfound;
|
goto notfound;
|
||||||
|
#endif
|
||||||
ldest[llen] = '\0';
|
ldest[llen] = '\0';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -398,7 +415,12 @@ c_cd(const char **wp)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NO_PATH_MAX
|
||||||
|
/* only a first guess; make_path will enlarge xs if necessary */
|
||||||
|
XinitN(xs, 1024, ATEMP);
|
||||||
|
#else
|
||||||
XinitN(xs, PATH_MAX, ATEMP);
|
XinitN(xs, PATH_MAX, ATEMP);
|
||||||
|
#endif
|
||||||
|
|
||||||
cdpath = str_val(global("CDPATH"));
|
cdpath = str_val(global("CDPATH"));
|
||||||
do {
|
do {
|
||||||
|
11
misc.c
11
misc.c
@ -29,7 +29,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.125 2009/10/02 18:08:35 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.126 2009/10/27 17:00:02 tg Exp $");
|
||||||
|
|
||||||
#undef USE_CHVT
|
#undef USE_CHVT
|
||||||
/* XXX conditions correct? */
|
/* XXX conditions correct? */
|
||||||
@ -1038,10 +1038,19 @@ ksh_get_wd(size_t *dlen)
|
|||||||
char *ret, *b;
|
char *ret, *b;
|
||||||
size_t len = 1;
|
size_t len = 1;
|
||||||
|
|
||||||
|
#ifdef NO_PATH_MAX
|
||||||
|
if ((b = get_current_dir_name())) {
|
||||||
|
len = strlen(b) + 1;
|
||||||
|
strndupx(ret, b, len - 1, ATEMP);
|
||||||
|
free(b);
|
||||||
|
} else
|
||||||
|
ret = NULL;
|
||||||
|
#else
|
||||||
if ((ret = getcwd((b = alloc(PATH_MAX + 1, ATEMP)), PATH_MAX)))
|
if ((ret = getcwd((b = alloc(PATH_MAX + 1, ATEMP)), PATH_MAX)))
|
||||||
ret = aresize(b, len = (strlen(b) + 1), ATEMP);
|
ret = aresize(b, len = (strlen(b) + 1), ATEMP);
|
||||||
else
|
else
|
||||||
afree(b, ATEMP);
|
afree(b, ATEMP);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (dlen)
|
if (dlen)
|
||||||
*dlen = len;
|
*dlen = len;
|
||||||
|
11
sh.h
11
sh.h
@ -134,9 +134,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.357 2009/10/18 12:30:05 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.358 2009/10/27 17:00:02 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R39 2009/10/18"
|
#define MKSH_VERSION "R39 2009/10/27"
|
||||||
|
|
||||||
#ifndef MKSH_INCLUDES_ONLY
|
#ifndef MKSH_INCLUDES_ONLY
|
||||||
|
|
||||||
@ -211,9 +211,13 @@ typedef int bool;
|
|||||||
#define ksh_isdash(s) (((s) != NULL) && ((s)[0] == '-') && ((s)[1] == '\0'))
|
#define ksh_isdash(s) (((s) != NULL) && ((s)[0] == '-') && ((s)[1] == '\0'))
|
||||||
#define ksh_isspace(c) ((((c) >= 0x09) && ((c) <= 0x0D)) || ((c) == 0x20))
|
#define ksh_isspace(c) ((((c) >= 0x09) && ((c) <= 0x0D)) || ((c) == 0x20))
|
||||||
|
|
||||||
|
#ifdef NO_PATH_MAX
|
||||||
|
#undef PATH_MAX
|
||||||
|
#else
|
||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
#define PATH_MAX 1024
|
#define PATH_MAX 1024
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#ifndef SIZE_MAX
|
#ifndef SIZE_MAX
|
||||||
#ifdef SIZE_T_MAX
|
#ifdef SIZE_T_MAX
|
||||||
#define SIZE_MAX SIZE_T_MAX
|
#define SIZE_MAX SIZE_T_MAX
|
||||||
@ -344,9 +348,6 @@ typedef uint32_t mksh_uari_t;
|
|||||||
#define NOT '!' /* might use ^ (ie, [!...] vs [^..]) */
|
#define NOT '!' /* might use ^ (ie, [!...] vs [^..]) */
|
||||||
|
|
||||||
#define LINE 4096 /* input line size */
|
#define LINE 4096 /* input line size */
|
||||||
#ifndef PATH_MAX
|
|
||||||
#define PATH_MAX 1024 /* pathname size */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EXTERN struct {
|
EXTERN struct {
|
||||||
const char *kshname_; /* $0 */
|
const char *kshname_; /* $0 */
|
||||||
|
Reference in New Issue
Block a user