oksh sync, simplify *all* if(x)free(x); constructs, simplify x_push() and sync boilerplate while here

This commit is contained in:
tg 2015-09-05 19:19:12 +00:00
parent 719778193a
commit 4adcfe8b58
23 changed files with 87 additions and 105 deletions

View File

@ -1,9 +1,9 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.689 2015/07/10 17:16:23 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.690 2015/09/05 19:18:59 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015
# Thorsten “mirabilos” Glaser <tg@mirbsd.org>
# mirabilos <tg@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
@ -2414,7 +2414,7 @@ cat >test.sh <<-EOF
args[\${#args[*]}]=\$TMPDIR
fi
print Testing mksh for conformance:
fgrep -e MirOS: -e MIRBSD "\$sflag"
fgrep -e Mir''OS: -e MIRBSD "\$sflag"
print "This shell is actually:\\n\\t\$KSH_VERSION"
print 'test.sh built for mksh $dstversion'
cstr='\$os = defined \$^O ? \$^O : "unknown";'

View File

@ -1,8 +1,8 @@
# $MirOS: src/bin/mksh/Makefile,v 1.142 2015/07/09 20:52:36 tg Exp $
# $MirOS: src/bin/mksh/Makefile,v 1.143 2015/09/05 19:19:00 tg Exp $
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015
# Thorsten “mirabilos” Glaser <tg@mirbsd.org>
# mirabilos <tg@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
@ -154,7 +154,7 @@ cats: ${MANALL} ${MANALL:S/.cat/.ps/}
.endif
.for _m _n in mksh 1
x=$$(ident ${SRCDIR:Q}/${_m}.${_n} | \
awk '/MirOS:/ { print $$4$$5; }' | \
awk '/Mir''OS:/ { print $$4$$5; }' | \
tr -dc 0-9); (( $${#x} == 14 )) || exit 1; exec \
${MKSH} ${BSDSRCDIR:Q}/contrib/hosted/tg/ps2pdfmir -c \
-o ${_m}.${_n}.pdf '[' /Author '(The MirOS Project)' \

View File

@ -1,9 +1,9 @@
# $MirOS: src/bin/mksh/check.pl,v 1.40 2015/07/10 19:36:31 tg Exp $
# $MirOS: src/bin/mksh/check.pl,v 1.41 2015/09/05 19:19:01 tg Exp $
# $OpenBSD: th,v 1.1 2013/12/02 20:39:44 millert Exp $
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011,
# 2012, 2013, 2014, 2015
# Thorsten Glaser <tg@mirbsd.org>
# mirabilos <tg@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission

20
edit.c
View File

@ -1,12 +1,12 @@
/* $OpenBSD: edit.c,v 1.40 2015/03/12 10:20:30 sthen Exp $ */
/* $OpenBSD: edit.c,v 1.41 2015/09/01 13:12:31 tedu Exp $ */
/* $OpenBSD: edit.h,v 1.9 2011/05/30 17:14:35 martynas Exp $ */
/* $OpenBSD: emacs.c,v 1.50 2015/03/25 12:10:52 jca Exp $ */
/* $OpenBSD: vi.c,v 1.28 2013/12/18 16:45:46 deraadt Exp $ */
/* $OpenBSD: emacs.c,v 1.51 2015/09/01 13:12:31 tedu Exp $ */
/* $OpenBSD: vi.c,v 1.29 2015/09/01 13:12:31 tedu Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014
* Thorsten Glaser <tg@mirbsd.org>
* 2011, 2012, 2013, 2014, 2015
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -28,7 +28,7 @@
#ifndef MKSH_NO_CMDLINE_EDITING
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.290 2015/07/10 19:36:34 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.291 2015/09/05 19:19:01 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@ -2262,12 +2262,8 @@ x_kill(int c MKSH_A_UNUSED)
static void
x_push(int nchars)
{
char *cp;
strndupx(cp, xcp, nchars, AEDIT);
if (killstack[killsp])
afree(killstack[killsp], AEDIT);
killstack[killsp] = cp;
afree(killstack[killsp], AEDIT);
strndupx(killstack[killsp], xcp, nchars, AEDIT);
killsp = (killsp + 1) % KILLSIZE;
}

4
eval.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.170 2015/07/06 17:45:33 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.171 2015/09/05 19:19:02 tg Exp $");
/*
* string expansion

4
exec.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.161 2015/09/05 17:20:18 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.162 2015/09/05 19:19:03 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"

4
expr.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.77 2014/12/15 23:26:36 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.78 2015/09/05 19:19:03 tg Exp $");
/* the order of these enums is constrained by the order of opinfo[] */
enum token {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: c_ksh.c,v 1.34 2013/12/17 16:37:05 deraadt Exp $ */
/* $OpenBSD: c_ksh.c,v 1.35 2015/09/01 13:12:31 tedu Exp $ */
/* $OpenBSD: c_sh.c,v 1.46 2015/07/20 20:46:24 guenther Exp $ */
/* $OpenBSD: c_test.c,v 1.18 2009/03/01 20:11:06 otto Exp $ */
/* $OpenBSD: c_ulimit.c,v 1.19 2013/11/28 10:33:37 sobrado Exp $ */
@ -6,7 +6,7 @@
/*-
* Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
* 2010, 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.282 2015/08/13 21:38:17 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.283 2015/09/05 19:19:04 tg Exp $");
#if HAVE_KILLPG
/*

View File

@ -1,10 +1,10 @@
/* $OpenBSD: history.c,v 1.40 2014/11/20 15:22:39 tedu Exp $ */
/* $OpenBSD: history.c,v 1.41 2015/09/01 13:12:31 tedu Exp $ */
/* $OpenBSD: trap.c,v 1.23 2010/05/19 17:36:08 jasper Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -27,7 +27,7 @@
#include <sys/file.h>
#endif
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.149 2015/07/09 20:52:40 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.150 2015/09/05 19:19:05 tg Exp $");
Trap sigtraps[ksh_NSIG + 1];
static struct sigaction Sigact_ign;
@ -898,8 +898,7 @@ histload(Source *s, unsigned char *base, size_t bytes)
if (lno >= s->line - (histptr - history) && lno <= s->line) {
hp = &histptr[lno - s->line];
if (*hp)
afree(*hp, APERM);
afree(*hp, APERM);
strdupx(*hp, (char *)(base + 4), APERM);
}
} else {
@ -1376,8 +1375,7 @@ settrap(Trap *p, const char *s)
{
sig_t f;
if (p->trap)
afree(p->trap, APERM);
afree(p->trap, APERM);
/* handles s == NULL */
strdupx(p->trap, s, APERM);
p->flags |= TF_CHANGED;

4
jobs.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011,
* 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.114 2015/09/05 17:20:19 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.115 2015/09/05 19:19:05 tg Exp $");
#if HAVE_KILLPG
#define mksh_killpg killpg

View File

@ -1,6 +1,6 @@
/*-
* Copyright (c) 2009, 2010, 2011, 2013, 2014
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -20,7 +20,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.21 2014/11/25 20:00:39 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.22 2015/09/05 19:19:06 tg Exp $");
/* build with CPPFLAGS+= -DUSE_REALLOC_MALLOC=0 on ancient systems */
#if defined(USE_REALLOC_MALLOC) && (USE_REALLOC_MALLOC == 0)

4
lex.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.205 2015/08/13 21:04:12 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.206 2015/09/05 19:19:06 tg Exp $");
/*
* states while lexing word

6
lksh.1
View File

@ -1,7 +1,7 @@
.\" $MirOS: src/bin/mksh/lksh.1,v 1.10 2015/04/12 22:32:12 tg Exp $
.\" $MirOS: src/bin/mksh/lksh.1,v 1.11 2015/09/05 19:19:06 tg Exp $
.\"-
.\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015
.\" Thorsten “mirabilos” Glaser <tg@mirbsd.org>
.\" mirabilos <tg@mirbsd.org>
.\"
.\" Provided that these terms and disclaimer and all copyright notices
.\" are retained or reproduced in an accompanying document, permission
@ -72,7 +72,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
.Dd $Mdocdate: April 12 2015 $
.Dd $Mdocdate: September 5 2015 $
.\"
.\" Check which macro package we use, and do other -mdoc setup.
.\"

10
main.c
View File

@ -1,12 +1,12 @@
/* $OpenBSD: main.c,v 1.55 2015/02/09 09:09:30 jsg Exp $ */
/* $OpenBSD: main.c,v 1.56 2015/09/01 17:46:31 tedu Exp $ */
/* $OpenBSD: tty.c,v 1.10 2014/08/10 02:44:26 guenther Exp $ */
/* $OpenBSD: io.c,v 1.25 2014/08/11 20:28:47 guenther Exp $ */
/* $OpenBSD: table.c,v 1.15 2012/02/19 07:52:30 otto Exp $ */
/* $OpenBSD: table.c,v 1.16 2015/09/01 13:12:31 tedu Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.301 2015/08/13 22:06:22 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.302 2015/09/05 19:19:06 tg Exp $");
extern char **environ;
@ -202,7 +202,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
/* do things like getpgrp() et al. */
chvt_reinit();
/* make sure argv[] is sane */
/* make sure argv[] is sane, for weird OSes */
if (!*argv) {
argv = empty_argv;
argc = 1;

View File

@ -1,6 +1,6 @@
/*-
* Copyright © 2011, 2014, 2015
* Thorsten mirabilos Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -44,7 +44,7 @@
#include <sys/types.h>
__RCSID("$MirOS: src/bin/mksh/mirhash.h,v 1.4 2015/05/30 22:14:06 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/mirhash.h,v 1.5 2015/09/05 19:19:07 tg Exp $");
/*-
* BAFH itself is defined by the following primitives:

12
misc.c
View File

@ -1,10 +1,10 @@
/* $OpenBSD: misc.c,v 1.40 2015/03/18 15:12:36 tedu Exp $ */
/* $OpenBSD: path.c,v 1.12 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: path.c,v 1.13 2015/09/05 09:47:08 jsg Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -30,7 +30,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.238 2015/07/10 19:36:36 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.239 2015/09/05 19:19:07 tg Exp $");
#define KSH_CHVT_FLAG
#ifdef MKSH_SMALL
@ -1570,16 +1570,14 @@ do_realpath(const char *upath)
}
/* return target path */
if (ldest != NULL)
afree(ldest, ATEMP);
afree(ldest, ATEMP);
afree(ipath, ATEMP);
return (Xclose(xs, xp));
notfound:
/* save; freeing memory might trash it */
llen = errno;
if (ldest != NULL)
afree(ldest, ATEMP);
afree(ldest, ATEMP);
afree(ipath, ATEMP);
Xfree(xs, xp);
errno = llen;

17
mksh.1
View File

@ -1,9 +1,9 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.379 2015/08/13 22:09:10 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.380 2015/09/05 19:19:08 tg Exp $
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
.\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
.\" 2010, 2011, 2012, 2013, 2014, 2015
.\" Thorsten “mirabilos” Glaser <tg@mirbsd.org>
.\" mirabilos <tg@mirbsd.org>
.\"
.\" Provided that these terms and disclaimer and all copyright notices
.\" are retained or reproduced in an accompanying document, permission
@ -74,7 +74,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
.Dd $Mdocdate: August 13 2015 $
.Dd $Mdocdate: September 5 2015 $
.\"
.\" Check which macro package we use, and do other -mdoc setup.
.\"
@ -6394,7 +6394,7 @@ contains the system and suid profile.
.An -nosplit
.Nm "The MirBSD Korn Shell"
is developed by
.An Thorsten Glaser Aq tg@mirbsd.org
.An mirabilos Aq tg@mirbsd.org
and currently maintained as part of The MirOS Project.
This shell is based on the public domain 7th edition Bourne shell clone by
.An Charles Forsyth ,
@ -6427,10 +6427,11 @@ The complete legalese is at:
.Pa https://www.mirbsd.org/TaC\-mksh.txt
.\"
.\" This boils down to: feel free to use mksh.ico as application icon
.\" or shortcut for mksh or mksh/Win32; distro patches are ok (but we
.\" request they amend $KSH_VERSION when modifying mksh). Authors are
.\" Marshall Kirk McKusick (UCB), Rick Collette (ekkoBSD), Thorsten
.\" Glaser, Benny Siegert (MirBSD), Michael Langguth (mksh/Win32).
.\" or shortcut for mksh or mksh/Win32 or OS/2; distro patches are ok
.\" (but we request they amend $KSH_VERSION when modifying mksh).
.\" Authors are Marshall Kirk McKusick (UCB), Rick Collette (ekkoBSD),
.\" mirabilos, Benny Siegert (MirBSD), Michael Langguth (mksh/Win32),
.\" KO Myung-Hun (mksh for OS/2).
.\"
.\" As far as MirBSD is concerned, the files themselves are free
.\" to modification and distribution under BSD/MirOS Licence, the

6
sh.h
View File

@ -2,7 +2,7 @@
/* $OpenBSD: shf.h,v 1.6 2005/12/11 18:53:51 deraadt Exp $ */
/* $OpenBSD: table.h,v 1.8 2012/02/19 07:52:30 otto Exp $ */
/* $OpenBSD: tree.h,v 1.10 2005/03/28 21:28:22 deraadt Exp $ */
/* $OpenBSD: expand.h,v 1.6 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: expand.h,v 1.7 2015/09/01 13:12:31 tedu Exp $ */
/* $OpenBSD: lex.h,v 1.13 2013/03/03 19:11:34 guenther Exp $ */
/* $OpenBSD: proto.h,v 1.35 2013/09/04 15:49:19 millert Exp $ */
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
@ -11,7 +11,7 @@
/*-
* Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -172,7 +172,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.741 2015/08/13 22:06:23 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.742 2015/09/05 19:19:10 tg Exp $");
#endif
#define MKSH_VERSION "R51 2015/08/13"

4
shf.c
View File

@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011,
* 2012, 2013, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -25,7 +25,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.66 2015/07/09 20:52:43 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.67 2015/09/05 19:19:11 tg Exp $");
/* flags to shf_emptybuf() */
#define EB_READSW 0x01 /* about to switch to reading */

View File

@ -1,6 +1,6 @@
/*-
* Copyright (c) 2006, 2008, 2009, 2013
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@ -18,7 +18,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/strlcpy.c,v 1.8 2013/11/05 22:10:15 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/strlcpy.c,v 1.9 2015/09/05 19:19:11 tg Exp $");
/*
* Copy src to string dst of size siz. At most siz-1 characters

6
syn.c
View File

@ -1,9 +1,9 @@
/* $OpenBSD: syn.c,v 1.29 2013/06/03 18:40:05 jca Exp $ */
/* $OpenBSD: syn.c,v 1.30 2015/09/01 13:12:31 tedu Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.102 2015/09/05 17:17:47 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.103 2015/09/05 19:19:11 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */

18
tree.c
View File

@ -1,9 +1,9 @@
/* $OpenBSD: tree.c,v 1.20 2012/06/27 07:17:19 otto Exp $ */
/* $OpenBSD: tree.c,v 1.21 2015/09/01 13:12:31 tedu Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.74 2015/08/13 20:54:03 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.75 2015/09/05 19:19:11 tg Exp $");
#define INDENT 8
@ -696,8 +696,7 @@ tfree(struct op *t, Area *ap)
if (t == NULL)
return;
if (t->str != NULL)
afree(t->str, ap);
afree(t->str, ap);
if (t->vars != NULL) {
for (w = t->vars; *w != NULL; w++)
@ -732,12 +731,9 @@ iofree(struct ioword **iow, Area *ap)
iop = iow;
while ((p = *iop++) != NULL) {
if (p->name != NULL)
afree(p->name, ap);
if (p->delim != NULL)
afree(p->delim, ap);
if (p->heredoc != NULL)
afree(p->heredoc, ap);
afree(p->name, ap);
afree(p->delim, ap);
afree(p->heredoc, ap);
afree(p, ap);
}
afree(iow, ap);

27
var.c
View File

@ -1,9 +1,9 @@
/* $OpenBSD: var.c,v 1.41 2015/04/17 17:20:41 deraadt Exp $ */
/* $OpenBSD: var.c,v 1.43 2015/09/01 13:12:31 tedu Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* Thorsten Glaser <tg@mirbsd.org>
* mirabilos <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
@ -28,7 +28,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.193 2015/07/10 19:36:38 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.194 2015/09/05 19:19:12 tg Exp $");
/*-
* Variables
@ -710,8 +710,7 @@ exportprep(struct tbl *vp, const char *val)
/* offset to value */
vp->type = xp - vp->val.s;
memcpy(xp, val, vallen);
if (op != NULL)
afree(op, vp->areap);
afree(op, vp->areap);
}
/*
@ -949,8 +948,7 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
t->type = 0;
}
}
if (free_me)
afree(free_me, t->areap);
afree(free_me, t->areap);
}
}
if (!ok)
@ -976,8 +974,7 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
/* setstr can't fail (readonly check already done) */
setstr(vp, val, KSH_RETURN_ERROR | 0x4);
if (tval != NULL)
afree(tval, ATEMP);
afree(tval, ATEMP);
}
/* only x[0] is ever exported, so use vpbase */
@ -1260,18 +1257,15 @@ setspec(struct tbl *vp)
ifs0 = *s;
return;
case V_PATH:
if (path)
afree(path, APERM);
afree(path, APERM);
s = str_val(vp);
strdupx(path, s, APERM);
/* clear tracked aliases */
flushcom(true);
return;
case V_TMPDIR:
if (tmpdir) {
afree(tmpdir, APERM);
tmpdir = NULL;
}
afree(tmpdir, APERM);
tmpdir = NULL;
/*
* Use tmpdir iff it is an absolute path, is writable
* and searchable and is a directory...
@ -1380,8 +1374,7 @@ unsetspec(struct tbl *vp)
ifs0 = ' ';
break;
case V_PATH:
if (path)
afree(path, APERM);
afree(path, APERM);
strdupx(path, def_path, APERM);
/* clear tracked aliases */
flushcom(true);