• Build.sh, strlcpy.c: gcc-current conversion &c. warnings cleanup
• histrap.c, lex.c, misc.c: get average stack frame size to <= 768 bytes • check.t, sh.h: bump version
This commit is contained in:
30
Build.sh
30
Build.sh
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.394 2009/05/20 10:10:35 tg Exp $'
|
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.395 2009/05/27 09:58:20 tg Stab $'
|
||||||
#-
|
#-
|
||||||
# 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>
|
||||||
@@ -867,7 +867,7 @@ ac_test attribute_bounded attribute 0 'for __attribute__((bounded))' <<-'EOF'
|
|||||||
__attribute__((bounded (buffer, 2, 3)));
|
__attribute__((bounded (buffer, 2, 3)));
|
||||||
int main(int ac, char *av[]) { return (xcopy(av[0], av[--ac], 1)); }
|
int main(int ac, char *av[]) { return (xcopy(av[0], av[--ac], 1)); }
|
||||||
int xcopy(const void *s, void *d, size_t n) {
|
int xcopy(const void *s, void *d, size_t n) {
|
||||||
memmove(d, s, n); return (n);
|
memmove(d, s, n); return ((int)n);
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -1060,7 +1060,7 @@ ac_testn arc4random <<-'EOF'
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
extern u_int32_t arc4random(void);
|
extern u_int32_t arc4random(void);
|
||||||
int main(void) { return (arc4random()); }
|
int main(void) { return ((int)(arc4random() & 0xFF)); }
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
save_LIBS=$LIBS
|
save_LIBS=$LIBS
|
||||||
@@ -1084,7 +1084,8 @@ ac_test arc4random_pushb arc4random 0 <<-'EOF'
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
extern uint32_t arc4random_pushb(void *, size_t);
|
extern uint32_t arc4random_pushb(void *, size_t);
|
||||||
int main(int ac, char *av[]) { return (arc4random_pushb(*av, ac)); }
|
int main(int ac, char *av[]) { return ((int)(arc4random_pushb(*av,
|
||||||
|
(size_t)ac)) & 0xFF); }
|
||||||
EOF
|
EOF
|
||||||
LIBS=$save_LIBS
|
LIBS=$save_LIBS
|
||||||
|
|
||||||
@@ -1094,7 +1095,7 @@ ac_testn flock_ex '' 'flock and mmap' <<-'EOF'
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
int main(void) { return ((void *)mmap(NULL, flock(0, LOCK_EX),
|
int main(void) { return ((void *)mmap(NULL, (size_t)flock(0, LOCK_EX),
|
||||||
PROT_READ, MAP_PRIVATE, 0, 0) == (void *)NULL ? 1 :
|
PROT_READ, MAP_PRIVATE, 0, 0) == (void *)NULL ? 1 :
|
||||||
munmap(NULL, 0)); }
|
munmap(NULL, 0)); }
|
||||||
EOF
|
EOF
|
||||||
@@ -1104,7 +1105,8 @@ ac_test getrusage <<-'EOF'
|
|||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
int main(void) {
|
int main(void) {
|
||||||
struct rusage ru;
|
struct rusage ru;
|
||||||
return (getrusage(RUSAGE_SELF + RUSAGE_CHILDREN, &ru));
|
return (getrusage(RUSAGE_SELF, &ru) +
|
||||||
|
getrusage(RUSAGE_CHILDREN, &ru));
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -1113,7 +1115,7 @@ ac_test mknod '' 'if to use mknod(), makedev() and friends' <<-'EOF'
|
|||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
int main(int ac, char *av[]) {
|
int main(int ac, char *av[]) {
|
||||||
dev_t dv;
|
dev_t dv;
|
||||||
dv = makedev(ac, 1);
|
dv = makedev((unsigned int)ac, 1);
|
||||||
return (mknod(av[0], 0, dv) ? (int)major(dv) : (int)minor(dv));
|
return (mknod(av[0], 0, dv) ? (int)major(dv) : (int)minor(dv));
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@@ -1156,13 +1158,13 @@ EOF
|
|||||||
ac_test setlocale_ctype '' 'setlocale(LC_CTYPE, "")' <<-'EOF'
|
ac_test setlocale_ctype '' 'setlocale(LC_CTYPE, "")' <<-'EOF'
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
int main(void) { return ((ptrdiff_t)(void *)setlocale(LC_CTYPE, "")); }
|
int main(void) { return ((int)(ptrdiff_t)(void *)setlocale(LC_CTYPE, "")); }
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
ac_test langinfo_codeset setlocale_ctype 0 'nl_langinfo(CODESET)' <<-'EOF'
|
ac_test langinfo_codeset setlocale_ctype 0 'nl_langinfo(CODESET)' <<-'EOF'
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
int main(void) { return ((ptrdiff_t)(void *)nl_langinfo(CODESET)); }
|
int main(void) { return ((int)(ptrdiff_t)(void *)nl_langinfo(CODESET)); }
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
ac_test setmode mknod 1 <<-'EOF'
|
ac_test setmode mknod 1 <<-'EOF'
|
||||||
@@ -1198,7 +1200,7 @@ ac_test strcasestr <<-'EOF'
|
|||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
int main(int ac, char *av[]) {
|
int main(int ac, char *av[]) {
|
||||||
return ((ptrdiff_t)(void *)strcasestr(*av, av[ac]));
|
return ((int)(ptrdiff_t)(void *)strcasestr(*av, av[ac]));
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -1216,25 +1218,25 @@ ac_test '!' arc4random_decl arc4random 1 'if arc4random() does not need to be de
|
|||||||
#define MKSH_INCLUDES_ONLY
|
#define MKSH_INCLUDES_ONLY
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
long arc4random(void); /* this clashes if defined before */
|
long arc4random(void); /* this clashes if defined before */
|
||||||
int main(void) { return (arc4random()); }
|
int main(void) { return ((int)arc4random()); }
|
||||||
EOF
|
EOF
|
||||||
ac_test '!' arc4random_pushb_decl arc4random_pushb 1 'if arc4random_pushb() does not need to be declared' <<-'EOF'
|
ac_test '!' arc4random_pushb_decl arc4random_pushb 1 'if arc4random_pushb() does not need to be declared' <<-'EOF'
|
||||||
#define MKSH_INCLUDES_ONLY
|
#define MKSH_INCLUDES_ONLY
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
int arc4random_pushb(char, int); /* this clashes if defined before */
|
int arc4random_pushb(char, int); /* this clashes if defined before */
|
||||||
int main(int ac, char *av[]) { return (arc4random_pushb(**av, ac)); }
|
int main(int ac, char *av[]) { return ((int)arc4random_pushb(**av, ac)); }
|
||||||
EOF
|
EOF
|
||||||
ac_test '!' flock_decl flock_ex 1 'if flock() does not need to be declared' <<-'EOF'
|
ac_test '!' flock_decl flock_ex 1 'if flock() does not need to be declared' <<-'EOF'
|
||||||
#define MKSH_INCLUDES_ONLY
|
#define MKSH_INCLUDES_ONLY
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
long flock(void); /* this clashes if defined before */
|
long flock(void); /* this clashes if defined before */
|
||||||
int main(void) { return (flock()); }
|
int main(void) { return ((int)flock()); }
|
||||||
EOF
|
EOF
|
||||||
ac_test '!' revoke_decl revoke 1 'if revoke() does not need to be declared' <<-'EOF'
|
ac_test '!' revoke_decl revoke 1 'if revoke() does not need to be declared' <<-'EOF'
|
||||||
#define MKSH_INCLUDES_ONLY
|
#define MKSH_INCLUDES_ONLY
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
long revoke(void); /* this clashes if defined before */
|
long revoke(void); /* this clashes if defined before */
|
||||||
int main(void) { return (revoke()); }
|
int main(void) { return ((int)revoke()); }
|
||||||
EOF
|
EOF
|
||||||
ac_test sys_siglist_decl sys_siglist 1 'if sys_siglist[] does not need to be declared' <<-'EOF'
|
ac_test sys_siglist_decl sys_siglist 1 'if sys_siglist[] does not need to be declared' <<-'EOF'
|
||||||
#define MKSH_INCLUDES_ONLY
|
#define MKSH_INCLUDES_ONLY
|
||||||
|
4
check.t
4
check.t
@@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.279 2009/05/21 14:28:32 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.280 2009/05/27 09:58:21 tg Stab $
|
||||||
# $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 R38 2009/05/21
|
@(#)MIRBSD KSH R38 2009/05/27
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
|
33
histrap.c
33
histrap.c
@@ -26,7 +26,7 @@
|
|||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.81 2009/05/16 18:40:06 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.82 2009/05/27 09:58:22 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* MirOS: This is the default mapping type, and need not be specified.
|
* MirOS: This is the default mapping type, and need not be specified.
|
||||||
@@ -781,8 +781,8 @@ hist_count_lines(unsigned char *base, int bytes)
|
|||||||
static int
|
static int
|
||||||
hist_shrink(unsigned char *oldbase, int oldbytes)
|
hist_shrink(unsigned char *oldbase, int oldbytes)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd, rv = 0;
|
||||||
char nfile[PATH_MAX];
|
char *nfile = NULL;
|
||||||
struct stat statb;
|
struct stat statb;
|
||||||
unsigned char *nbase = oldbase;
|
unsigned char *nbase = oldbase;
|
||||||
int nbytes = oldbytes;
|
int nbytes = oldbytes;
|
||||||
@@ -796,27 +796,32 @@ hist_shrink(unsigned char *oldbase, int oldbytes)
|
|||||||
/*
|
/*
|
||||||
* create temp file
|
* create temp file
|
||||||
*/
|
*/
|
||||||
shf_snprintf(nfile, sizeof(nfile), "%s.%d", hname, (int)procpid);
|
nfile = shf_smprintf("%s.%d", hname, (int)procpid);
|
||||||
if ((fd = open(nfile, O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0)
|
if ((fd = open(nfile, O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0)
|
||||||
return 1;
|
goto errout;
|
||||||
if (fstat(histfd, &statb) >= 0 &&
|
if (fstat(histfd, &statb) >= 0 &&
|
||||||
chown(nfile, statb.st_uid, statb.st_gid))
|
chown(nfile, statb.st_uid, statb.st_gid))
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
if (sprinkle(fd) || write(fd, nbase, nbytes) != nbytes) {
|
if (sprinkle(fd) || write(fd, nbase, nbytes) != nbytes)
|
||||||
errout:
|
goto errout;
|
||||||
close(fd);
|
|
||||||
unlink(nfile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
fd = -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rename
|
* rename
|
||||||
*/
|
*/
|
||||||
if (rename(nfile, hname) < 0)
|
if (rename(nfile, hname) < 0) {
|
||||||
return 1;
|
errout:
|
||||||
return 0;
|
if (fd >= 0) {
|
||||||
|
close(fd);
|
||||||
|
if (nfile)
|
||||||
|
unlink(nfile);
|
||||||
|
}
|
||||||
|
rv = 1;
|
||||||
|
}
|
||||||
|
afree(nfile, ATEMP);
|
||||||
|
return (rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
6
lex.c
6
lex.c
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.83 2009/05/16 16:59:37 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.84 2009/05/27 09:58:22 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* states while lexing word
|
* states while lexing word
|
||||||
@@ -127,11 +127,7 @@ static int ignore_backslash_newline;
|
|||||||
#define getsc_() ((*source->str != '\0') && !(source->flags & SF_FIRST) \
|
#define getsc_() ((*source->str != '\0') && !(source->flags & SF_FIRST) \
|
||||||
? *source->str++ : getsc__())
|
? *source->str++ : getsc__())
|
||||||
|
|
||||||
#ifdef MKSH_SMALL
|
|
||||||
#define STATE_BSIZE 32
|
#define STATE_BSIZE 32
|
||||||
#else
|
|
||||||
#define STATE_BSIZE 48
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PUSH_STATE(s) do { \
|
#define PUSH_STATE(s) do { \
|
||||||
if (++statep == state_info.end) \
|
if (++statep == state_info.end) \
|
||||||
|
25
misc.c
25
misc.c
@@ -29,7 +29,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.106 2009/05/16 18:40:07 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.107 2009/05/27 09:58:23 tg Exp $");
|
||||||
|
|
||||||
#undef USE_CHVT
|
#undef USE_CHVT
|
||||||
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
||||||
@@ -1300,10 +1300,10 @@ static char *
|
|||||||
do_phys_path(XString *xsp, char *xp, const char *pathl)
|
do_phys_path(XString *xsp, char *xp, const char *pathl)
|
||||||
{
|
{
|
||||||
const char *p, *q;
|
const char *p, *q;
|
||||||
int len, llen;
|
int len, llen, savepos;
|
||||||
int savepos;
|
char *lbuf;
|
||||||
char lbuf[PATH_MAX];
|
|
||||||
|
|
||||||
|
lbuf = alloc(PATH_MAX, ATEMP);
|
||||||
Xcheck(*xsp, xp);
|
Xcheck(*xsp, xp);
|
||||||
for (p = pathl; p; p = q) {
|
for (p = pathl; p; p = q) {
|
||||||
while (*p == '/')
|
while (*p == '/')
|
||||||
@@ -1329,22 +1329,25 @@ do_phys_path(XString *xsp, char *xp, const char *pathl)
|
|||||||
xp += len;
|
xp += len;
|
||||||
*xp = '\0';
|
*xp = '\0';
|
||||||
|
|
||||||
llen = readlink(Xstring(*xsp, xp), lbuf, sizeof(lbuf) - 1);
|
llen = readlink(Xstring(*xsp, xp), lbuf, PATH_MAX - 1);
|
||||||
if (llen < 0) {
|
if (llen < 0) {
|
||||||
/* EINVAL means it wasn't a symlink... */
|
/* EINVAL means it wasn't a symlink... */
|
||||||
if (errno != EINVAL)
|
if (errno != EINVAL) {
|
||||||
return NULL;
|
xp = NULL;
|
||||||
continue;
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lbuf[llen] = '\0';
|
lbuf[llen] = '\0';
|
||||||
|
|
||||||
/* If absolute path, start from scratch.. */
|
/* If absolute path, start from scratch.. */
|
||||||
xp = lbuf[0] == '/' ? Xstring(*xsp, xp) :
|
xp = lbuf[0] == '/' ? Xstring(*xsp, xp) :
|
||||||
Xrestpos(*xsp, xp, savepos);
|
Xrestpos(*xsp, xp, savepos);
|
||||||
if (!(xp = do_phys_path(xsp, xp, lbuf)))
|
if ((xp = do_phys_path(xsp, xp, lbuf)) == NULL)
|
||||||
return NULL;
|
break;
|
||||||
}
|
}
|
||||||
return xp;
|
out:
|
||||||
|
afree(lbuf, ATEMP);
|
||||||
|
return (xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_CHVT
|
#ifdef USE_CHVT
|
||||||
|
4
sh.h
4
sh.h
@@ -122,9 +122,9 @@
|
|||||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.302 2009/05/21 14:28:35 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.303 2009/05/27 09:58:23 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R38 2009/05/21"
|
#define MKSH_VERSION "R38 2009/05/27"
|
||||||
|
|
||||||
#ifndef MKSH_INCLUDES_ONLY
|
#ifndef MKSH_INCLUDES_ONLY
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2006, 2008
|
* Copyright (c) 2006, 2008, 2009
|
||||||
* Thorsten Glaser <tg@mirbsd.org>
|
* Thorsten Glaser <tg@mirbsd.org>
|
||||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/strlcpy.c,v 1.5 2009/05/16 18:57:54 tg Rel $");
|
__RCSID("$MirOS: src/bin/mksh/strlcpy.c,v 1.6 2009/05/27 09:58:24 tg Rel $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy src to string dst of size siz. At most siz-1 characters
|
* Copy src to string dst of size siz. At most siz-1 characters
|
||||||
@@ -48,5 +48,5 @@ strlcpy(char *dst, const char *src, size_t siz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* count does not include NUL */
|
/* count does not include NUL */
|
||||||
return (s - src - 1);
|
return ((size_t)(s - src - 1));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user