• Build.sh: fix NSIG detection for gcc-snapshot
• all: bump version to R50-current; add more comments; whitespace • all: remove all mkssert(); we’ll do full re-runs of scan-build and, hopefully, Coverity Scan/Prevent • check.t: fix a testcase (sed could exit false, but we don’t care) • eval.c: fix tilde_ok data type (only unsigned may shl constantly) • exec.c: fix shebang buf array accesses to always go via uint8_t *
This commit is contained in:
parent
371ee4af07
commit
2f52b993a1
16
Build.sh
16
Build.sh
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.670 2014/11/25 20:00:36 tg Exp $'
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.671 2014/11/25 21:13:18 tg Exp $'
|
||||
#-
|
||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012, 2013, 2014
|
||||
@ -1784,7 +1784,7 @@ else
|
||||
#define EXTERN
|
||||
#define MKSH_INCLUDES_ONLY
|
||||
#include "sh.h"
|
||||
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.670 2014/11/25 20:00:36 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.671 2014/11/25 21:13:18 tg Exp $");
|
||||
int main(void) { printf("Hello, World!\n"); return (isatty(0)); }
|
||||
EOF
|
||||
case $cm in
|
||||
@ -2263,6 +2263,11 @@ mksh_cfg= NSIG
|
||||
;' >conftest.c
|
||||
# GNU sed 2.03 segfaults when optimising this to sed -n
|
||||
NSIG=`vq "$CPP $CFLAGS $CPPFLAGS $NOWARN conftest.c" | \
|
||||
grep -v '^#' | \
|
||||
sed '/mksh_cfg.*= *$/{
|
||||
N
|
||||
s/\n/ /
|
||||
}' | \
|
||||
grep '^ *mksh_cfg *=' | \
|
||||
sed 's/^ *mksh_cfg *=[ ]*\([()0-9x+-][()0-9x+ -]*\).*$/\1/'`
|
||||
case $NSIG in
|
||||
@ -2294,6 +2299,11 @@ mksh_cfg= NSIG
|
||||
echo ';' >>conftest.c
|
||||
# GNU sed 2.03 croaks on optimising this, too
|
||||
vq "$CPP $CFLAGS $CPPFLAGS $NOWARN conftest.c" | \
|
||||
grep -v '^#' | \
|
||||
sed '/mksh_cfg.*= *$/{
|
||||
N
|
||||
s/\n/ /
|
||||
}' | \
|
||||
grep '^ *mksh_cfg *=' | \
|
||||
sed 's/^ *mksh_cfg *=[ ]*\([0-9][0-9x]*\).*$/:\1 '$name/
|
||||
done | sed -n '/^:[^ ]/s/^://p' | while read nr name; do
|
||||
@ -2315,7 +2325,7 @@ addsrcs '!' HAVE_STRLCPY strlcpy.c
|
||||
addsrcs USE_PRINTF_BUILTIN printf.c
|
||||
test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
|
||||
test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
|
||||
add_cppflags -DMKSH_BUILD_R=504
|
||||
add_cppflags -DMKSH_BUILD_R=509
|
||||
|
||||
$e $bi$me: Finished configuration testing, now producing output.$ao
|
||||
|
||||
|
4
Makefile
4
Makefile
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/Makefile,v 1.138 2014/10/07 15:22:13 tg Exp $
|
||||
# $MirOS: src/bin/mksh/Makefile,v 1.139 2014/11/25 21:13:19 tg Exp $
|
||||
#-
|
||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012, 2013, 2014
|
||||
@ -55,7 +55,7 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 -DMKSH_DISABLE_DEPRECATED \
|
||||
-DHAVE_SETGROUPS=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 \
|
||||
-DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \
|
||||
-DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \
|
||||
-DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=504
|
||||
-DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=509
|
||||
CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U}
|
||||
CPPFLAGS+= -I.
|
||||
COPTS+= -std=c89 -Wall
|
||||
|
8
check.t
8
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.670 2014/11/19 18:44:09 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.671 2014/11/25 21:13:19 tg Exp $
|
||||
# OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44
|
||||
#-
|
||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
@ -27,7 +27,7 @@
|
||||
# http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain
|
||||
|
||||
expected-stdout:
|
||||
@(#)MIRBSD KSH R50 2014/11/19
|
||||
@(#)MIRBSD KSH R50 2014/11/25
|
||||
description:
|
||||
Check version of shell.
|
||||
stdin:
|
||||
@ -36,7 +36,7 @@ name: KSH_VERSION
|
||||
category: shell:legacy-no
|
||||
---
|
||||
expected-stdout:
|
||||
@(#)LEGACY KSH R50 2014/11/19
|
||||
@(#)LEGACY KSH R50 2014/11/25
|
||||
description:
|
||||
Check version of legacy shell.
|
||||
stdin:
|
||||
@ -7141,6 +7141,7 @@ description:
|
||||
XXX if the OS can already execute them, we lose
|
||||
note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
|
||||
note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
|
||||
XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan)
|
||||
need-pass: no
|
||||
category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
|
||||
env-setup: !FOO=BAR!
|
||||
@ -11060,6 +11061,7 @@ stdin:
|
||||
(mypid=$$; try mypid)
|
||||
echo =15
|
||||
) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
|
||||
exit ${PIPESTATUS[0]}
|
||||
expected-stdout:
|
||||
y
|
||||
=1
|
||||
|
5
edit.c
5
edit.c
@ -28,7 +28,7 @@
|
||||
|
||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.279 2014/11/19 21:52:16 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.280 2014/11/25 21:13:22 tg Exp $");
|
||||
|
||||
/*
|
||||
* in later versions we might use libtermcap for this, but since external
|
||||
@ -593,8 +593,6 @@ x_cf_glob(int *flagsp, const char *buf, int buflen, int pos, int *startp,
|
||||
char **words = NULL;
|
||||
bool is_command;
|
||||
|
||||
mkssert(buf != NULL);
|
||||
|
||||
len = x_locate_word(buf, buflen, pos, startp, &is_command);
|
||||
if (!((*flagsp) & XCF_COMMAND))
|
||||
is_command = false;
|
||||
@ -2240,7 +2238,6 @@ x_push(int nchars)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
mkssert(xcp != NULL);
|
||||
strndupx(cp, xcp, nchars, AEDIT);
|
||||
if (killstack[killsp])
|
||||
afree(killstack[killsp], AEDIT);
|
||||
|
5
eval.c
5
eval.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.159 2014/11/19 21:49:12 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.160 2014/11/25 21:13:23 tg Exp $");
|
||||
|
||||
/*
|
||||
* string expansion
|
||||
@ -237,7 +237,7 @@ expand(
|
||||
/* record number of trailing newlines in COMSUB */
|
||||
int newlines = 0;
|
||||
bool saw_eq, make_magic;
|
||||
int tilde_ok;
|
||||
unsigned int tilde_ok;
|
||||
size_t len;
|
||||
char *cp;
|
||||
|
||||
@ -516,7 +516,6 @@ expand(
|
||||
|
||||
/* check for special cases */
|
||||
d = str_val(st->var);
|
||||
mkssert(d != NULL);
|
||||
switch (*pat) {
|
||||
case '#':
|
||||
/* anchor at begin */
|
||||
|
13
exec.c
13
exec.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.137 2014/10/19 21:53:07 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.138 2014/11/25 21:13:24 tg Exp $");
|
||||
|
||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
||||
@ -924,11 +924,12 @@ scriptexec(struct op *tp, const char **ap)
|
||||
*tp->args-- = (char *)cp;
|
||||
}
|
||||
noshebang:
|
||||
if (buf[0] == 0x7F && buf[1] == 'E' && buf[2] == 'L' &&
|
||||
buf[3] == 'F')
|
||||
cp = (unsigned char *)buf;
|
||||
if (cp[0] == 0x7F && cp[1] == 'E' && cp[2] == 'L' &&
|
||||
cp[3] == 'F')
|
||||
errorf("%s: not executable: %d-bit ELF file", tp->str,
|
||||
32 * ((uint8_t)buf[4]));
|
||||
fd = buf[0] << 8 | buf[1];
|
||||
32 * cp[4]);
|
||||
fd = cp[0] << 8 | cp[1];
|
||||
if ((fd == /* OMAGIC */ 0407) ||
|
||||
(fd == /* NMAGIC */ 0410) ||
|
||||
(fd == /* ZMAGIC */ 0413) ||
|
||||
@ -1006,8 +1007,6 @@ define(const char *name, struct op *t)
|
||||
|
||||
while (/* CONSTCOND */ 1) {
|
||||
tp = findfunc(name, nhash, true);
|
||||
/* because findfunc:create=true */
|
||||
mkssert(tp != NULL);
|
||||
|
||||
if (tp->flag & ISSET)
|
||||
was_set = true;
|
||||
|
4
funcs.c
4
funcs.c
@ -38,7 +38,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.260 2014/11/25 20:00:37 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.261 2014/11/25 21:13:25 tg Exp $");
|
||||
|
||||
#if HAVE_KILLPG
|
||||
/*
|
||||
@ -2797,8 +2797,6 @@ c_test(const char **wp)
|
||||
|
||||
for (argc = 0; wp[argc]; argc++)
|
||||
;
|
||||
mkssert(argc > 0);
|
||||
mkssert(wp[0] != NULL);
|
||||
|
||||
if (strcmp(wp[0], "[") == 0) {
|
||||
if (strcmp(wp[--argc], "]") != 0) {
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.135 2014/11/25 20:00:38 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.136 2014/11/25 21:13:26 tg Exp $");
|
||||
|
||||
Trap sigtraps[NSIG + 1];
|
||||
static struct sigaction Sigact_ign;
|
||||
@ -634,7 +634,6 @@ histsave(int *lnp, const char *cmd, bool dowrite MKSH_A_UNUSED, bool ignoredups)
|
||||
char **hp;
|
||||
char *c, *cp;
|
||||
|
||||
mkssert(cmd != NULL);
|
||||
strdupx(c, cmd, APERM);
|
||||
if ((cp = strchr(c, '\n')) != NULL)
|
||||
*cp = '\0';
|
||||
|
42
jobs.c
42
jobs.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.105 2014/10/03 12:32:48 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.106 2014/11/25 21:13:27 tg Exp $");
|
||||
|
||||
#if HAVE_KILLPG
|
||||
#define mksh_killpg killpg
|
||||
@ -1047,7 +1047,7 @@ j_async(void)
|
||||
static void
|
||||
j_set_async(Job *j)
|
||||
{
|
||||
Job *jl, *oldest;
|
||||
Job *jl, *oldest;
|
||||
|
||||
if (async_job && (async_job->flags & (JF_KNOWN|JF_ZOMBIE)) == JF_ZOMBIE)
|
||||
remove_job(async_job, "async");
|
||||
@ -1084,7 +1084,7 @@ j_set_async(Job *j)
|
||||
static void
|
||||
j_startjob(Job *j)
|
||||
{
|
||||
Proc *p;
|
||||
Proc *p;
|
||||
|
||||
j->flags |= JF_STARTED;
|
||||
for (p = j->proc_list; p->next; p = p->next)
|
||||
@ -1421,8 +1421,8 @@ j_sigchld(int sig MKSH_A_UNUSED)
|
||||
static void
|
||||
check_job(Job *j)
|
||||
{
|
||||
int jstate;
|
||||
Proc *p;
|
||||
int jstate;
|
||||
Proc *p;
|
||||
|
||||
/* XXX debugging (nasty - interrupt routine using shl_out) */
|
||||
if (!(j->flags & JF_STARTED)) {
|
||||
@ -1524,14 +1524,14 @@ check_job(Job *j)
|
||||
static void
|
||||
j_print(Job *j, int how, struct shf *shf)
|
||||
{
|
||||
Proc *p;
|
||||
int state;
|
||||
int status;
|
||||
int coredumped;
|
||||
char jobchar = ' ';
|
||||
char buf[64];
|
||||
Proc *p;
|
||||
int state;
|
||||
int status;
|
||||
int coredumped;
|
||||
char jobchar = ' ';
|
||||
char buf[64];
|
||||
const char *filler;
|
||||
int output = 0;
|
||||
int output = 0;
|
||||
|
||||
if (how == JP_PGRP) {
|
||||
/*
|
||||
@ -1737,8 +1737,8 @@ static Proc *free_procs;
|
||||
static Job *
|
||||
new_job(void)
|
||||
{
|
||||
int i;
|
||||
Job *newj, *j;
|
||||
int i;
|
||||
Job *newj, *j;
|
||||
|
||||
if (free_jobs != NULL) {
|
||||
newj = free_jobs;
|
||||
@ -1766,7 +1766,7 @@ new_job(void)
|
||||
static Proc *
|
||||
new_proc(void)
|
||||
{
|
||||
Proc *p;
|
||||
Proc *p;
|
||||
|
||||
if (free_procs != NULL) {
|
||||
p = free_procs;
|
||||
@ -1786,10 +1786,9 @@ new_proc(void)
|
||||
static void
|
||||
remove_job(Job *j, const char *where)
|
||||
{
|
||||
Proc *p, *tmp;
|
||||
Job **prev, *curr;
|
||||
Proc *p, *tmp;
|
||||
Job **prev, *curr;
|
||||
|
||||
mkssert(j != NULL);
|
||||
prev = &job_list;
|
||||
curr = job_list;
|
||||
while (curr && curr != j) {
|
||||
@ -1830,9 +1829,8 @@ remove_job(Job *j, const char *where)
|
||||
static void
|
||||
put_job(Job *j, int where)
|
||||
{
|
||||
Job **prev, *curr;
|
||||
Job **prev, *curr;
|
||||
|
||||
mkssert(j != NULL);
|
||||
/* Remove job from list (if there) */
|
||||
prev = &job_list;
|
||||
curr = job_list;
|
||||
@ -1869,8 +1867,8 @@ put_job(Job *j, int where)
|
||||
static int
|
||||
kill_job(Job *j, int sig)
|
||||
{
|
||||
Proc *p;
|
||||
int rval = 0;
|
||||
Proc *p;
|
||||
int rval = 0;
|
||||
|
||||
for (p = j->proc_list; p != NULL; p = p->next)
|
||||
if (p->pid != 0)
|
||||
|
4
main.c
4
main.c
@ -34,7 +34,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.285 2014/10/12 21:58:52 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.286 2014/11/25 21:13:28 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -1014,8 +1014,6 @@ cleanup_parents_env(void)
|
||||
struct env *ep;
|
||||
int fd;
|
||||
|
||||
mkssert(e != NULL);
|
||||
|
||||
/*
|
||||
* Don't clean up temporary files - parent will probably need them.
|
||||
* Also, can't easily reclaim memory since variables, etc. could be
|
||||
|
3
misc.c
3
misc.c
@ -30,7 +30,7 @@
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.220 2014/11/25 20:00:39 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.221 2014/11/25 21:13:29 tg Exp $");
|
||||
|
||||
#define KSH_CHVT_FLAG
|
||||
#ifdef MKSH_SMALL
|
||||
@ -485,7 +485,6 @@ parse_args(const char **argv,
|
||||
if (arrayset) {
|
||||
const char *ccp = NULL;
|
||||
|
||||
mkssert(array != NULL);
|
||||
if (*array)
|
||||
ccp = skip_varname(array, false);
|
||||
if (!ccp || !(!ccp[0] || (ccp[0] == '+' && !ccp[1]))) {
|
||||
|
6
sh.h
6
sh.h
@ -169,9 +169,9 @@
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.704 2014/11/19 21:49:12 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.705 2014/11/25 21:13:29 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R50 2014/11/19"
|
||||
#define MKSH_VERSION "R50 2014/11/25"
|
||||
|
||||
/* arithmetic types: C implementation */
|
||||
#if !HAVE_CAN_INTTYPES
|
||||
@ -533,7 +533,7 @@ char *ucstrstr(char *, const char *);
|
||||
#define mkssert(e) do { } while (/* CONSTCOND */ 0)
|
||||
#endif
|
||||
|
||||
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 504)
|
||||
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 509)
|
||||
#error Must run Build.sh to compile this.
|
||||
extern void thiswillneverbedefinedIhope(void);
|
||||
int
|
||||
|
5
var.c
5
var.c
@ -28,7 +28,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.183 2014/10/04 11:47:19 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.184 2014/11/25 21:13:31 tg Exp $");
|
||||
|
||||
/*-
|
||||
* Variables
|
||||
@ -308,7 +308,6 @@ local(const char *n, bool copy)
|
||||
* dereference namerefs; must come first
|
||||
*/
|
||||
n = array_index_calc(n, &array, &val);
|
||||
mkssert(n != NULL);
|
||||
h = hash(n);
|
||||
if (!ksh_isalphx(*n)) {
|
||||
vp = &vtemp;
|
||||
@ -679,8 +678,6 @@ exportprep(struct tbl *vp, const char *val)
|
||||
char *op = (vp->flag&ALLOC) ? vp->val.s : NULL;
|
||||
size_t namelen, vallen;
|
||||
|
||||
mkssert(val != NULL);
|
||||
|
||||
namelen = strlen(vp->name);
|
||||
vallen = strlen(val) + 1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user