• rewrite code to no longer use statements-as-expressions
• optimise a little • Build.sh: remove HAVE_EXPSTMT test • Build.sh, */Makefile: sort tests, regenerate • mksh.hts: sync clog
This commit is contained in:
parent
5167e7398b
commit
88d7b7d08b
63
Build.sh
63
Build.sh
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.363 2008/10/26 21:57:47 ahoka Exp $'
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.364 2008/10/28 14:32:36 tg Exp $'
|
||||
#-
|
||||
# Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
|
||||
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NOPWNAM MKSH_NOVI
|
||||
@ -706,9 +706,9 @@ else
|
||||
fi
|
||||
# other flags: just add them if they are supported
|
||||
i=0
|
||||
phase=u
|
||||
if test $ct = gcc; then
|
||||
NOWARN=$DOWARN # scan for flags with -Werror
|
||||
# The following tests run with -Werror (gcc only) if possible
|
||||
NOWARN=$DOWARN; phase=u
|
||||
ac_flags 1 fnostrictaliasing -fno-strict-aliasing
|
||||
ac_flags 1 fstackprotectorall -fstack-protector-all
|
||||
ac_flags 1 fwrapv -fwrapv
|
||||
@ -761,7 +761,7 @@ elif test $ct = tcc; then
|
||||
elif test $ct = clang; then
|
||||
i=1
|
||||
fi
|
||||
# flags common to a subset of compilers
|
||||
# flags common to a subset of compilers (run with -Werror on gcc)
|
||||
if test 1 = $i; then
|
||||
ac_flags 1 stdg99 -std=gnu99 'for support of ISO C99 + GCC extensions'
|
||||
test 1 = $HAVE_CAN_STDG99 || \
|
||||
@ -769,17 +769,8 @@ if test 1 = $i; then
|
||||
ac_flags 1 wall -Wall
|
||||
fi
|
||||
phase=x
|
||||
NOWARN=$save_NOWARN # gcc runs with -Werror until here
|
||||
ac_test expstmt '' "if the compiler supports statements as expressions" <<-'EOF'
|
||||
#define ksh_isspace(c) ({ \
|
||||
unsigned int ksh_isspace_c = (c); \
|
||||
(ksh_isspace_c >= 0x09 && ksh_isspace_c <= 0x0D) || \
|
||||
(ksh_isspace_c == 0x20); \
|
||||
})
|
||||
int main(int ac, char *av[]) { return (ksh_isspace(ac + **av)); }
|
||||
EOF
|
||||
|
||||
# The following tests are run with -Werror if possible
|
||||
# The following tests run with -Werror or similar (all compilers) if possible
|
||||
NOWARN=$DOWARN
|
||||
|
||||
#
|
||||
@ -1035,28 +1026,6 @@ ac_testn flock_ex '' 'flock and mmap' <<-'EOF'
|
||||
PROT_READ, MAP_PRIVATE, 0, 0) == (void *)NULL ? 1 : 0); }
|
||||
EOF
|
||||
|
||||
ac_test mkstemp <<-'EOF'
|
||||
#include <stdlib.h>
|
||||
int main(void) { char tmpl[] = "X"; return (mkstemp(tmpl)); }
|
||||
EOF
|
||||
|
||||
ac_test nice <<-'EOF'
|
||||
#include <unistd.h>
|
||||
int main(void) { return (nice(4)); }
|
||||
EOF
|
||||
|
||||
ac_test setlocale_ctype '' 'setlocale(LC_CTYPE, "")' <<-'EOF'
|
||||
#include <locale.h>
|
||||
#include <stddef.h>
|
||||
int main(void) { return ((ptrdiff_t)(void *)setlocale(LC_CTYPE, "")); }
|
||||
EOF
|
||||
|
||||
ac_test langinfo_codeset setlocale_ctype 0 'nl_langinfo(CODESET)' <<-'EOF'
|
||||
#include <langinfo.h>
|
||||
#include <stddef.h>
|
||||
int main(void) { return ((ptrdiff_t)(void *)nl_langinfo(CODESET)); }
|
||||
EOF
|
||||
|
||||
ac_test mknod '' 'if to use mknod(), makedev() and friends' <<-'EOF'
|
||||
#define MKSH_INCLUDES_ONLY
|
||||
#include "sh.h"
|
||||
@ -1067,6 +1036,16 @@ ac_test mknod '' 'if to use mknod(), makedev() and friends' <<-'EOF'
|
||||
}
|
||||
EOF
|
||||
|
||||
ac_test mkstemp <<-'EOF'
|
||||
#include <stdlib.h>
|
||||
int main(void) { char tmpl[] = "X"; return (mkstemp(tmpl)); }
|
||||
EOF
|
||||
|
||||
ac_test nice <<-'EOF'
|
||||
#include <unistd.h>
|
||||
int main(void) { return (nice(4)); }
|
||||
EOF
|
||||
|
||||
ac_test realpath mksh_full 0 <<-'EOF'
|
||||
#if HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
@ -1091,6 +1070,18 @@ ac_test revoke mksh_full 0 <<-'EOF'
|
||||
int main(int ac, char *av[]) { return (ac + revoke(av[0])); }
|
||||
EOF
|
||||
|
||||
ac_test setlocale_ctype '' 'setlocale(LC_CTYPE, "")' <<-'EOF'
|
||||
#include <locale.h>
|
||||
#include <stddef.h>
|
||||
int main(void) { return ((ptrdiff_t)(void *)setlocale(LC_CTYPE, "")); }
|
||||
EOF
|
||||
|
||||
ac_test langinfo_codeset setlocale_ctype 0 'nl_langinfo(CODESET)' <<-'EOF'
|
||||
#include <langinfo.h>
|
||||
#include <stddef.h>
|
||||
int main(void) { return ((ptrdiff_t)(void *)nl_langinfo(CODESET)); }
|
||||
EOF
|
||||
|
||||
ac_test setmode mknod 1 <<-'EOF'
|
||||
#if defined(__MSVCRT__) || defined(__CYGWIN__)
|
||||
/* force a failure: Win32 setmode() is not what we want… */
|
||||
|
12
Makefile
12
Makefile
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/Makefile,v 1.63 2008/10/26 22:03:05 tg Exp $
|
||||
# $MirOS: src/bin/mksh/Makefile,v 1.64 2008/10/28 14:32:37 tg Exp $
|
||||
#-
|
||||
# use CPPFLAGS=-DDEBUG __CRAZY=Yes to check for certain more stuff
|
||||
|
||||
@ -12,17 +12,17 @@ SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \
|
||||
CPPFLAGS+= -DMKSH_AFREE_DEBUG # MirOS development version
|
||||
. endif
|
||||
CPPFLAGS+= -DMKSH_ASSUME_UTF8 \
|
||||
-DHAVE_EXPSTMT=1 -DHAVE_ATTRIBUTE=1 \
|
||||
-DHAVE_ATTRIBUTE_BOUNDED=1 -DHAVE_ATTRIBUTE_USED=1 \
|
||||
-DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 \
|
||||
-DHAVE_ATTRIBUTE=1 -DHAVE_ATTRIBUTE_BOUNDED=1 \
|
||||
-DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_PARAM_H=1 \
|
||||
-DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 \
|
||||
-DHAVE_SYS_SYSMACROS_H=0 -DHAVE_LIBGEN_H=1 -DHAVE_LIBUTIL_H=0 \
|
||||
-DHAVE_PATHS_H=1 -DHAVE_STDBOOL_H=1 -DHAVE_GRP_H=1 \
|
||||
-DHAVE_ULIMIT_H=0 -DHAVE_VALUES_H=0 -DHAVE_STDINT_H=1 \
|
||||
-DHAVE_RLIM_T=1 -DHAVE_SIG_T=1 -DHAVE_SYS_SIGNAME=1 \
|
||||
-DHAVE_SYS_SIGLIST=1 -DHAVE_STRSIGNAL=0 -DHAVE_ARC4RANDOM=1 \
|
||||
-DHAVE_ARC4RANDOM_PUSHB=1 -DHAVE_MKSTEMP=1 -DHAVE_NICE=1 \
|
||||
-DHAVE_ARC4RANDOM_PUSHB=1 -DHAVE_MKNOD=1 -DHAVE_MKSTEMP=1 \
|
||||
-DHAVE_NICE=1 -DHAVE_REALPATH=1 -DHAVE_REVOKE=1 \
|
||||
-DHAVE_SETLOCALE_CTYPE=1 -DHAVE_LANGINFO_CODESET=1 \
|
||||
-DHAVE_MKNOD=1 -DHAVE_REALPATH=1 -DHAVE_REVOKE=1 \
|
||||
-DHAVE_SETMODE=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 \
|
||||
-DHAVE_STRCASESTR=1 -DHAVE_STRLCPY=1 -DHAVE_ARC4RANDOM_DECL=1 \
|
||||
-DHAVE_ARC4RANDOM_PUSHB_DECL=1 -DHAVE_FLOCK_DECL=1 \
|
||||
|
4
check.t
4
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.236 2008/10/26 20:59:39 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.237 2008/10/28 14:32:37 tg 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: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||
@ -7,7 +7,7 @@
|
||||
# http://www.research.att.com/~gsf/public/ifs.sh
|
||||
|
||||
expected-stdout:
|
||||
@(#)MIRBSD KSH R36 2008/10/26
|
||||
@(#)MIRBSD KSH R36 2008/10/28
|
||||
description:
|
||||
Check version of shell.
|
||||
stdin:
|
||||
|
65
edit.c
65
edit.c
@ -5,7 +5,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.140 2008/10/26 20:59:39 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.141 2008/10/28 14:32:38 tg Exp $");
|
||||
|
||||
/* tty driver characters we are interested in */
|
||||
typedef struct {
|
||||
@ -539,7 +539,7 @@ add_glob(const char *str, int slen)
|
||||
if (slen < 0)
|
||||
return NULL;
|
||||
|
||||
toglob = str_nsave(str, slen + 1, ATEMP); /* + 1 for "*" */
|
||||
strndupx(toglob, str, slen + 1, ATEMP); /* + 1 for "*" */
|
||||
toglob[slen] = '\0';
|
||||
|
||||
/*
|
||||
@ -637,10 +637,14 @@ glob_table(const char *pat, XPtrV *wp, struct table *tp)
|
||||
struct tstate ts;
|
||||
struct tbl *te;
|
||||
|
||||
for (ktwalk(&ts, tp); (te = ktnext(&ts)); ) {
|
||||
if (gmatchx(te->name, pat, false))
|
||||
XPput(*wp, str_save(te->name, ATEMP));
|
||||
}
|
||||
ktwalk(&ts, tp);
|
||||
while ((te = ktnext(&ts)))
|
||||
if (gmatchx(te->name, pat, false)) {
|
||||
char *cp;
|
||||
|
||||
strdupx(cp, te->name, ATEMP);
|
||||
XPput(*wp, cp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -782,31 +786,6 @@ utf_mbswidth(const char *s)
|
||||
return (width);
|
||||
}
|
||||
|
||||
void
|
||||
utf_cptradj(const char *src, const char **dst)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if (!Flag(FUTFHACK) || *(const unsigned char *)src < 0xC2 ||
|
||||
(len = utf_mbtowc(NULL, src)) == (size_t)-1)
|
||||
len = 1;
|
||||
if (dst)
|
||||
*dst = src + len;
|
||||
/* return (len); */
|
||||
}
|
||||
|
||||
#if HAVE_EXPSTMT
|
||||
#define utf_ptradj(s,d) ({ \
|
||||
union mksh_cchack utf_ptradj_o; \
|
||||
char **utf_ptradj_d = (d); \
|
||||
\
|
||||
utf_cptradj((s), &utf_ptradj_o.ro); \
|
||||
*utf_ptradj_d = utf_ptradj_o.rw; \
|
||||
})
|
||||
#else
|
||||
#define utf_ptradj(s,d) utf_cptradj((s), (const char **)(d))
|
||||
#endif
|
||||
|
||||
const char *
|
||||
utf_skipcols(const char *p, int cols)
|
||||
{
|
||||
@ -1650,7 +1629,7 @@ x_del_char(int c __unused)
|
||||
|
||||
cp = xcp;
|
||||
while (i < x_arg) {
|
||||
utf_ptradj(cp, &cp2);
|
||||
utf_ptradjx(cp, cp2);
|
||||
if (cp2 > xep)
|
||||
break;
|
||||
cp = cp2;
|
||||
@ -1784,7 +1763,7 @@ x_bword(void)
|
||||
}
|
||||
x_goto(cp);
|
||||
for (cp = xcp; cp < (xcp + nb); ++nc)
|
||||
utf_ptradj(cp, &cp);
|
||||
utf_ptradjx(cp, cp);
|
||||
return nc;
|
||||
}
|
||||
|
||||
@ -1805,7 +1784,7 @@ x_fword(int move)
|
||||
cp++;
|
||||
}
|
||||
for (cp2 = xcp; cp2 < cp; ++nc)
|
||||
utf_ptradj(cp2, &cp2);
|
||||
utf_ptradjx(cp2, cp2);
|
||||
if (move)
|
||||
x_goto(cp);
|
||||
return nc;
|
||||
@ -1943,7 +1922,7 @@ x_mv_forw(int c __unused)
|
||||
return KSTD;
|
||||
}
|
||||
while (x_arg--) {
|
||||
utf_ptradj(cp, &cp2);
|
||||
utf_ptradjx(cp, cp2);
|
||||
if (cp2 > xep)
|
||||
break;
|
||||
cp = cp2;
|
||||
@ -2468,7 +2447,9 @@ x_kill(int c __unused)
|
||||
static void
|
||||
x_push(int nchars)
|
||||
{
|
||||
char *cp = str_nsave(xcp, nchars, AEDIT);
|
||||
char *cp;
|
||||
|
||||
strndupx(cp, xcp, nchars, AEDIT);
|
||||
if (killstack[killsp])
|
||||
afree((void *)killstack[killsp], AEDIT);
|
||||
killstack[killsp] = cp;
|
||||
@ -2541,7 +2522,8 @@ x_mapin(const char *cp, Area *ap)
|
||||
{
|
||||
char *new, *op;
|
||||
|
||||
op = new = str_save(cp, ap);
|
||||
strdupx(new, cp, ap);
|
||||
op = new;
|
||||
while (*cp) {
|
||||
/* XXX -- should handle \^ escape? */
|
||||
if (*cp == '^') {
|
||||
@ -3105,7 +3087,9 @@ x_version(int c __unused)
|
||||
char *o_xbuf = xbuf, *o_xend = xend;
|
||||
char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp;
|
||||
int vlen, lim = x_lastcp() - xbp;
|
||||
char *v = str_save(KSH_VERSION, ATEMP);
|
||||
char *v;
|
||||
|
||||
strdupx(v, KSH_VERSION, ATEMP);
|
||||
|
||||
xbuf = xbp = xcp = v;
|
||||
xend = xep = v + (vlen = strlen(v));
|
||||
@ -4204,8 +4188,9 @@ vi_cmd(int argcnt, const char *cmd)
|
||||
if (*cmd == 'c' &&
|
||||
(cmd[1] == 'w' || cmd[1] == 'W') &&
|
||||
!ksh_isspace(es->cbuf[es->cursor])) {
|
||||
while (ksh_isspace(es->cbuf[--ncursor]))
|
||||
;
|
||||
do {
|
||||
--ncursor;
|
||||
} while (ksh_isspace(es->cbuf[ncursor]));
|
||||
ncursor++;
|
||||
}
|
||||
if (ncursor > es->cursor) {
|
||||
|
30
eval.c
30
eval.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.48 2008/10/24 20:52:22 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.49 2008/10/28 14:32:39 tg Exp $");
|
||||
|
||||
#ifdef MKSH_SMALL
|
||||
#define MKSH_NOPWNAM
|
||||
@ -357,7 +357,7 @@ expand(const char *cp, /* input word */
|
||||
flen = strlen(beg);
|
||||
if (num < 0 || num > flen)
|
||||
num = flen;
|
||||
x.str = str_nsave(beg, num, ATEMP);
|
||||
strndupx(x.str, beg, num, ATEMP);
|
||||
goto do_CSUBST;
|
||||
}
|
||||
case '/': {
|
||||
@ -425,8 +425,8 @@ expand(const char *cp, /* input word */
|
||||
goto no_repl;
|
||||
|
||||
/* prepare string on which to work */
|
||||
tpat0 = str_val(st->var);
|
||||
sbeg = s = str_save(tpat0, ATEMP);
|
||||
strdupx(s, str_val(st->var), ATEMP);
|
||||
sbeg = s;
|
||||
|
||||
/* first see if we have any match at all */
|
||||
tpat0 = pat;
|
||||
@ -477,7 +477,7 @@ expand(const char *cp, /* input word */
|
||||
break;
|
||||
p--;
|
||||
}
|
||||
end = str_nsave_(s, sbeg - s, ATEMP);
|
||||
strndupx(end, s, sbeg - s, ATEMP);
|
||||
d = shf_smprintf("%s%s%s", end, rrep, p);
|
||||
afree(end, ATEMP);
|
||||
sbeg = d + (sbeg - s) + strlen(rrep);
|
||||
@ -1112,16 +1112,17 @@ trimsub(char *str, char *pat, int how)
|
||||
}
|
||||
break;
|
||||
case '%': /* shortest match at end */
|
||||
for (p = end; p >= str; p--) {
|
||||
if (gmatchx(p, pat, false))
|
||||
return str_nsave(str, p - str, ATEMP);
|
||||
}
|
||||
for (p = end; p >= str; p--)
|
||||
if (gmatchx(p, pat, false)) {
|
||||
trimsub_match:
|
||||
strndupx(end, str, p - str, ATEMP);
|
||||
return (end);
|
||||
}
|
||||
break;
|
||||
case '%'|0x80: /* longest match at end */
|
||||
for (p = str; p <= end; p++) {
|
||||
for (p = str; p <= end; p++)
|
||||
if (gmatchx(p, pat, false))
|
||||
return str_nsave(str, p - str, ATEMP);
|
||||
}
|
||||
goto trimsub_match;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1222,7 +1223,8 @@ globit(XString *xs, /* dest string */
|
||||
*xp = '\0';
|
||||
}
|
||||
}
|
||||
XPput(*wp, str_nsave(Xstring(*xs, xp), Xlength(*xs, xp), ATEMP));
|
||||
strndupx(np, Xstring(*xs, xp), Xlength(*xs, xp), ATEMP);
|
||||
XPput(*wp, np);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1404,7 +1406,7 @@ homedir(char *name)
|
||||
pw = getpwnam(name);
|
||||
if (pw == NULL)
|
||||
return NULL;
|
||||
ap->val.s = str_save(pw->pw_dir, APERM);
|
||||
strdupx(ap->val.s, pw->pw_dir, APERM);
|
||||
ap->flag |= DEFINED|ISSET|ALLOC;
|
||||
}
|
||||
return ap->val.s;
|
||||
|
13
exec.c
13
exec.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.44 2008/05/17 18:46:58 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.45 2008/10/28 14:32:39 tg Exp $");
|
||||
|
||||
static int comexec(struct op *, struct tbl *volatile, const char **,
|
||||
int volatile);
|
||||
@ -929,14 +929,9 @@ findcom(const char *name, int flags)
|
||||
npath.ro = search(name, flags & FC_DEFPATH ? def_path : path,
|
||||
X_OK, &tp->u2.errno_);
|
||||
if (npath.ro) {
|
||||
/* XXX unsure about this, oksh does that
|
||||
if (tp == &temp)
|
||||
tp->val.s = npath.ro;
|
||||
else */ {
|
||||
tp->val.s = str_save(npath.ro, APERM);
|
||||
if (npath.ro != name)
|
||||
afree(npath.rw, ATEMP);
|
||||
}
|
||||
strdupx(tp->val.s, npath.ro, APERM);
|
||||
if (npath.ro != name)
|
||||
afree(npath.rw, ATEMP);
|
||||
tp->flag |= ISSET|ALLOC;
|
||||
} else if ((flags & FC_FUNC) &&
|
||||
(fpath = str_val(global("FPATH"))) != null &&
|
||||
|
14
expr.c
14
expr.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.18 2008/07/12 16:56:38 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.19 2008/10/28 14:32:40 tg Exp $");
|
||||
|
||||
/* The order of these enums is constrained by the order of opinfo[] */
|
||||
enum token {
|
||||
@ -470,22 +470,20 @@ exprtoken(Expr_state *es)
|
||||
es->val = tempvar();
|
||||
es->val->flag |= EXPRLVALUE;
|
||||
} else {
|
||||
tvar = str_nsave(es->tokp, cp - es->tokp, ATEMP);
|
||||
strndupx(tvar, es->tokp, cp - es->tokp, ATEMP);
|
||||
es->val = global(tvar);
|
||||
afree(tvar, ATEMP);
|
||||
}
|
||||
es->tok = VAR;
|
||||
} else if (c == '1' && cp[1] == '#') {
|
||||
utf_cptradj(cp + 2, &cp);
|
||||
tvar = str_nsave(es->tokp, cp - es->tokp, ATEMP);
|
||||
cp += 2;
|
||||
utf_ptradjx(cp, cp);
|
||||
strndupx(tvar, es->tokp, cp - es->tokp, ATEMP);
|
||||
goto process_tvar;
|
||||
} else if (ksh_isdigit(c)) {
|
||||
int i;
|
||||
|
||||
while (c != '_' && (ksh_isalnux(c) || c == '#'))
|
||||
c = *cp++;
|
||||
i = --cp - es->tokp;
|
||||
tvar = str_nsave(es->tokp, i, ATEMP);
|
||||
strndupx(tvar, es->tokp, --cp - es->tokp, ATEMP);
|
||||
process_tvar:
|
||||
es->val = tempvar();
|
||||
es->val->flag &= ~INTEGER;
|
||||
|
17
funcs.c
17
funcs.c
@ -5,7 +5,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.89 2008/09/30 19:25:50 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.90 2008/10/28 14:32:40 tg Exp $");
|
||||
|
||||
/* A leading = means assignments before command are kept;
|
||||
* a leading * means a POSIX special builtin;
|
||||
@ -169,7 +169,8 @@ c_cd(const char **wp)
|
||||
}
|
||||
} else if (!wp[1]) {
|
||||
/* One argument: - or dir */
|
||||
if (ksh_isdash((dir = allocd = str_save(wp[0], ATEMP)))) {
|
||||
strdupx(allocd, wp[0], ATEMP);
|
||||
if (ksh_isdash((dir = allocd))) {
|
||||
afree(allocd, ATEMP);
|
||||
allocd = NULL;
|
||||
dir = str_val(oldpwd_s);
|
||||
@ -1074,8 +1075,8 @@ c_alias(const char **wp)
|
||||
int h;
|
||||
|
||||
if ((val = cstrchr(alias, '='))) {
|
||||
h = val++ - alias;
|
||||
alias = xalias = str_nsave(alias, h, ATEMP);
|
||||
strndupx(xalias, alias, val++ - alias, ATEMP);
|
||||
alias = xalias;
|
||||
}
|
||||
h = hash(alias);
|
||||
if (val == NULL && !tflag && !xflag) {
|
||||
@ -1106,7 +1107,7 @@ c_alias(const char **wp)
|
||||
/* ignore values for -t (at&t ksh does this) */
|
||||
newval = tflag ? search(alias, path, X_OK, NULL) : val;
|
||||
if (newval) {
|
||||
ap->val.s = str_save(newval, APERM);
|
||||
strdupx(ap->val.s, newval, APERM);
|
||||
ap->flag |= ALLOC|ISSET;
|
||||
} else
|
||||
ap->flag &= ~ISSET;
|
||||
@ -1500,7 +1501,7 @@ c_bind(const char **wp)
|
||||
if ((cp = cstrchr(*wp, '=')) == NULL)
|
||||
up = NULL;
|
||||
else {
|
||||
up = str_save(*wp, ATEMP);
|
||||
strdupx(up, *wp, ATEMP);
|
||||
up[cp++ - *wp] = '\0';
|
||||
}
|
||||
if (x_bind(up ? up : *wp, cp, macro, 0))
|
||||
@ -1781,7 +1782,7 @@ c_read(const char **wp)
|
||||
shf = shf_reopen(fd, SHF_RD | SHF_INTERRUPT | can_seek(fd), shl_spare);
|
||||
|
||||
if ((cp = cstrchr(*wp, '?')) != NULL) {
|
||||
wpalloc = str_save(*wp, ATEMP);
|
||||
strdupx(wpalloc, *wp, ATEMP);
|
||||
wpalloc[cp - *wp] = '\0';
|
||||
*wp = wpalloc;
|
||||
if (isatty(fd)) {
|
||||
@ -2110,7 +2111,7 @@ c_set(const char **wp)
|
||||
owp = wp += argi - 1;
|
||||
wp[0] = l->argv[0]; /* save $0 */
|
||||
while (*++wp != NULL)
|
||||
*wp = str_save(*wp, &l->area);
|
||||
strdupx(*wp, *wp, &l->area);
|
||||
l->argc = wp - owp - 1;
|
||||
l->argv = (const char **)alloc(sizeofN(char *, l->argc+2),
|
||||
&l->area);
|
||||
|
17
histrap.c
17
histrap.c
@ -3,7 +3,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.72 2008/10/14 19:48:27 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.73 2008/10/28 14:32:41 tg Exp $");
|
||||
|
||||
/*-
|
||||
* MirOS: This is the default mapping type, and need not be specified.
|
||||
@ -118,7 +118,7 @@ c_fc(const char **wp)
|
||||
|
||||
/* Check for pattern replacement argument */
|
||||
if (*wp && **wp && (p = cstrchr(*wp + 1, '='))) {
|
||||
pat = str_save(*wp, ATEMP);
|
||||
strdupx(pat, *wp, ATEMP);
|
||||
rep = pat + (p - *wp);
|
||||
*rep++ = '\0';
|
||||
wp++;
|
||||
@ -306,7 +306,7 @@ hist_replace(char **hp, const char *pat, const char *rep, int globr)
|
||||
char *line;
|
||||
|
||||
if (!pat)
|
||||
line = str_save(*hp, ATEMP);
|
||||
strdupx(line, *hp, ATEMP);
|
||||
else {
|
||||
char *s, *s1;
|
||||
int pat_len = strlen(pat);
|
||||
@ -579,7 +579,7 @@ histsave(int *lnp, const char *cmd, bool dowrite __unused, bool ignoredups)
|
||||
char **hp;
|
||||
char *c, *cp;
|
||||
|
||||
c = str_save(cmd, APERM);
|
||||
strdupx(c, cmd, APERM);
|
||||
if ((cp = strchr(c, '\n')) != NULL)
|
||||
*cp = '\0';
|
||||
|
||||
@ -648,7 +648,7 @@ hist_init(Source *s)
|
||||
#if HAVE_PERSISTENT_HISTORY
|
||||
if ((hname = str_val(global("HISTFILE"))) == NULL)
|
||||
return;
|
||||
hname = str_save(hname, APERM);
|
||||
strdupx(hname, hname, APERM);
|
||||
|
||||
retry:
|
||||
/* we have a file and are interactive */
|
||||
@ -885,7 +885,7 @@ histinsert(Source *s, int lno, const char *line)
|
||||
hp = &histptr[lno - s->line];
|
||||
if (*hp)
|
||||
afree((void*)*hp, APERM);
|
||||
*hp = str_save(line, APERM);
|
||||
strdupx(*hp, line, APERM);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1014,7 +1014,8 @@ inittraps(void)
|
||||
|
||||
if (!strncasecmp(cs, "SIG", 3))
|
||||
cs += 3;
|
||||
sigtraps[i].name = s = str_save(cs, APERM);
|
||||
strdupx(s, cs, APERM);
|
||||
sigtraps[i].name = s;
|
||||
while ((*s = ksh_toupper(*s)))
|
||||
++s;
|
||||
}
|
||||
@ -1279,7 +1280,7 @@ settrap(Trap *p, const char *s)
|
||||
|
||||
if (p->trap)
|
||||
afree(p->trap, APERM);
|
||||
p->trap = str_save(s, APERM); /* handles s == 0 */
|
||||
strdupx(p->trap, s, APERM); /* handles s == 0 */
|
||||
p->flags |= TF_CHANGED;
|
||||
f = !s ? SIG_DFL : s[0] ? trapsig : SIG_IGN;
|
||||
|
||||
|
6
lex.c
6
lex.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.73 2008/10/10 21:30:42 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.74 2008/10/28 14:32:41 tg Exp $");
|
||||
|
||||
/*
|
||||
* states while lexing word
|
||||
@ -1099,7 +1099,7 @@ getsc__(void)
|
||||
source->flags |= s->flags & SF_ALIAS;
|
||||
s = source;
|
||||
} else if (*s->u.tblp->val.s &&
|
||||
ksh_isspace(strnul(s->u.tblp->val.s)[-1])) {
|
||||
(c = strnul(s->u.tblp->val.s)[-1], ksh_isspace(c))) {
|
||||
source = s = s->next; /* pop source stack */
|
||||
/* Note that this alias ended with a space,
|
||||
* enabling alias expansion on the following
|
||||
@ -1285,7 +1285,7 @@ set_prompt(int to, Source *s)
|
||||
*/
|
||||
} else {
|
||||
char *cp = substitute(ps1, 0);
|
||||
prompt = str_save(cp, saved_atemp);
|
||||
strdupx(prompt, cp, saved_atemp);
|
||||
}
|
||||
quitenv(NULL);
|
||||
}
|
||||
|
4
main.c
4
main.c
@ -13,7 +13,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.104 2008/10/20 19:29:23 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.105 2008/10/28 14:32:41 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -445,7 +445,7 @@ include(const char *name, int argc, const char **argv, int intr_ok)
|
||||
}
|
||||
s = pushs(SFILE, ATEMP);
|
||||
s->u.shf = shf;
|
||||
s->file = str_save(name, ATEMP);
|
||||
strdupx(s->file, name, ATEMP);
|
||||
i = shell(s, false);
|
||||
quitenv(s->u.shf);
|
||||
if (old_argv) {
|
||||
|
42
misc.c
42
misc.c
@ -6,7 +6,7 @@
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.87 2008/10/26 21:51:26 ahoka Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.88 2008/10/28 14:32:42 tg Exp $");
|
||||
|
||||
#undef USE_CHVT
|
||||
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
||||
@ -63,34 +63,6 @@ initctypes(void)
|
||||
setctypes(" \n\t\"#$&'()*;<>?[]\\`|", C_QUOTE);
|
||||
}
|
||||
|
||||
#if defined(MKSH_SMALL) || !HAVE_EXPSTMT
|
||||
char *
|
||||
str_nsave(const char *s, int n, Area *ap)
|
||||
{
|
||||
char *rv = NULL;
|
||||
|
||||
if ((n >= 0) && (s != NULL))
|
||||
strlcpy(rv = alloc(n + 1, ap), s, n + 1);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
char *
|
||||
str_save(const char *s, Area *ap)
|
||||
{
|
||||
#ifdef MKSH_SMALL
|
||||
return (s ? str_nsave(s, strlen(s), ap) : NULL);
|
||||
#else
|
||||
char *rv = NULL;
|
||||
|
||||
if (s != NULL) {
|
||||
size_t sz = strlen(s) + 1;
|
||||
strlcpy(rv = alloc(sz, ap), s, sz);
|
||||
}
|
||||
return (rv);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* called from XcheckN() to grow buffer */
|
||||
char *
|
||||
Xcheck_grow_(XString *xsp, const char *xp, unsigned int more)
|
||||
@ -230,7 +202,8 @@ getoptions(void)
|
||||
for (i = 0; i < NELEM(options); i++)
|
||||
if (options[i].c && Flag(i))
|
||||
*cp++ = options[i].c;
|
||||
return (str_nsave_(m, cp - m, ATEMP));
|
||||
strndupx(cp, m, cp - m, ATEMP);
|
||||
return (cp);
|
||||
}
|
||||
|
||||
/* change a Flag(*) value; takes care of special actions */
|
||||
@ -1449,12 +1422,3 @@ stristr(const char *b, const char *l)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !HAVE_EXPSTMT
|
||||
bool
|
||||
ksh_isspace_(unsigned int ksh_isspace_c)
|
||||
{
|
||||
return ((ksh_isspace_c >= 0x09 && ksh_isspace_c <= 0x0D) ||
|
||||
(ksh_isspace_c == 0x20));
|
||||
}
|
||||
#endif
|
||||
|
71
sh.h
71
sh.h
@ -100,9 +100,9 @@
|
||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.247 2008/10/26 21:51:27 ahoka Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.248 2008/10/28 14:32:42 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R36 2008/10/26"
|
||||
#define MKSH_VERSION "R36 2008/10/28"
|
||||
|
||||
#ifndef MKSH_INCLUDES_ONLY
|
||||
|
||||
@ -158,17 +158,7 @@ typedef int bool;
|
||||
#define ksh_tolower(c) (((c) >= 'A') && ((c) <= 'Z') ? (c) - 'A' + 'a' : (c))
|
||||
#define ksh_toupper(c) (((c) >= 'a') && ((c) <= 'z') ? (c) - 'a' + 'A' : (c))
|
||||
#define ksh_isdash(s) (((s) != NULL) && ((s)[0] == '-') && ((s)[1] == '\0'))
|
||||
|
||||
#if HAVE_EXPSTMT
|
||||
/* this macro must not evaluate its arguments several times */
|
||||
#define ksh_isspace(c) ({ \
|
||||
unsigned int ksh_isspace_c = (c); \
|
||||
(ksh_isspace_c >= 0x09 && ksh_isspace_c <= 0x0D) || \
|
||||
(ksh_isspace_c == 0x20); \
|
||||
})
|
||||
#else
|
||||
#define ksh_isspace(c) ksh_isspace_((unsigned int)(c))
|
||||
#endif
|
||||
#define ksh_isspace(c) ((((c) >= 0x09) && ((c) <= 0x0D)) || ((c) == 0x20))
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
@ -345,6 +335,40 @@ char *ucstrstr(char *, const char *);
|
||||
/* use this ipv strchr(s, 0) but no side effects in s! */
|
||||
#define strnul(s) ((s) + strlen(s))
|
||||
|
||||
#define utf_ptradjx(src, dst) do { \
|
||||
size_t utf_ptradjx_len; \
|
||||
\
|
||||
if (!Flag(FUTFHACK) || \
|
||||
*(const unsigned char *)(src) < 0xC2 || \
|
||||
(utf_ptradjx_len = utf_mbtowc(NULL, (src))) == (size_t)-1) \
|
||||
utf_ptradjx_len = 1; \
|
||||
(dst) = (src) + utf_ptradjx_len; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
||||
/* be careful to evaluate arguments only once! */
|
||||
#define strdupx(d, s, ap) do { \
|
||||
const char *strdup_src = (s); \
|
||||
char *strdup_dst = NULL; \
|
||||
\
|
||||
if (strdup_src != NULL) { \
|
||||
size_t strdup_len = strlen(strdup_src) + 1; \
|
||||
strdup_dst = alloc(strdup_len, (ap)); \
|
||||
strlcpy(strdup_dst, strdup_src, strdup_len); \
|
||||
} \
|
||||
(d) = strdup_dst; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#define strndupx(d, s, n, ap) do { \
|
||||
const char *strdup_src = (s); \
|
||||
char *strdup_dst = NULL; \
|
||||
\
|
||||
if (strdup_src != NULL) { \
|
||||
size_t strdup_len = (n) + 1; \
|
||||
strdup_dst = alloc(strdup_len, (ap)); \
|
||||
strlcpy(strdup_dst, strdup_src, strdup_len); \
|
||||
} \
|
||||
(d) = strdup_dst; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
||||
#if HAVE_STRCASESTR
|
||||
#define stristr(b,l) ((const char *)strcasestr((b), (l)))
|
||||
#endif
|
||||
@ -1231,7 +1255,6 @@ int x_bind(const char *, const char *, int, int);
|
||||
/* UTF-8 hack stuff */
|
||||
size_t utf_mbtowc(unsigned int *, const char *);
|
||||
size_t utf_wctomb(char *, unsigned int);
|
||||
void utf_cptradj(const char *, const char **);
|
||||
int utf_widthadj(const char *, const char **);
|
||||
int utf_mbswidth(const char *);
|
||||
int utf_wcwidth(unsigned int);
|
||||
@ -1424,23 +1447,6 @@ struct tbl **ktsort(struct table *);
|
||||
/* misc.c */
|
||||
void setctypes(const char *, int);
|
||||
void initctypes(void);
|
||||
#if defined(MKSH_SMALL) || !HAVE_EXPSTMT
|
||||
#define str_save_ str_save
|
||||
#define str_nsave_ str_nsave
|
||||
char *str_save(const char *, Area *);
|
||||
char *str_nsave(const char *, int, Area *);
|
||||
#else
|
||||
#define str_save_(s,ap) str_nsave_((s), strlen(s), (ap))
|
||||
#define str_nsave_(s,n,ap) ({ \
|
||||
size_t str_save_sz = (n) + 1; \
|
||||
char *str_save_rv = alloc(str_save_sz, (ap)); \
|
||||
strlcpy(str_save_rv, (s), str_save_sz); \
|
||||
(str_save_rv); \
|
||||
})
|
||||
#define str_save(s,ap) (!(s) ? NULL : str_save_((s), (ap)))
|
||||
#define str_nsave(s,n,ap) \
|
||||
(!(s) || (n) < 0 ? NULL : str_nsave_((s), (n), (ap)))
|
||||
#endif
|
||||
size_t option(const char *);
|
||||
char *getoptions(void);
|
||||
void change_flag(enum sh_flag, int, char);
|
||||
@ -1466,9 +1472,6 @@ int make_path(const char *, const char *, char **, XString *, int *);
|
||||
void simplify_path(char *);
|
||||
char *get_phys_path(const char *);
|
||||
void set_current_wd(char *);
|
||||
#if !HAVE_EXPSTMT
|
||||
bool ksh_isspace_(unsigned int);
|
||||
#endif
|
||||
/* shf.c */
|
||||
struct shf *shf_open(const char *, int, int, int);
|
||||
struct shf *shf_fdopen(int, int, struct shf *);
|
||||
|
4
syn.c
4
syn.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.27 2008/10/10 21:30:43 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.28 2008/10/28 14:32:43 tg Exp $");
|
||||
|
||||
struct nesting_state {
|
||||
int start_token; /* token than began nesting (eg, FOR) */
|
||||
@ -366,7 +366,7 @@ get_command(int cf)
|
||||
if (!is_wdvarname(yylval.cp, true))
|
||||
yyerror("%s: bad identifier\n",
|
||||
c == FOR ? "for" : "select");
|
||||
t->str = str_save_(ident, ATEMP);
|
||||
strdupx(t->str, ident, ATEMP);
|
||||
nesting_push(&old_nesting, c);
|
||||
t->vars = wordlist();
|
||||
t->left = dogroup();
|
||||
|
9
tree.c
9
tree.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.20 2008/10/13 23:06:04 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.21 2008/10/28 14:32:43 tg Exp $");
|
||||
|
||||
#define INDENT 4
|
||||
|
||||
@ -426,7 +426,10 @@ tcopy(struct op *t, Area *ap)
|
||||
r->type = t->type;
|
||||
r->u.evalflags = t->u.evalflags;
|
||||
|
||||
r->str = t->type == TCASE ? wdcopy(t->str, ap) : str_save(t->str, ap);
|
||||
if (t->type == TCASE)
|
||||
r->str = wdcopy(t->str, ap);
|
||||
else
|
||||
strdupx(r->str, t->str, ap);
|
||||
|
||||
if (t->vars == NULL)
|
||||
r->vars = NULL;
|
||||
@ -629,7 +632,7 @@ iocopy(struct ioword **iow, Area *ap)
|
||||
if (p->delim != NULL)
|
||||
q->delim = wdcopy(p->delim, ap);
|
||||
if (p->heredoc != NULL)
|
||||
q->heredoc = str_save(p->heredoc, ap);
|
||||
strdupx(q->heredoc, p->heredoc, ap);
|
||||
}
|
||||
ior[i] = NULL;
|
||||
|
||||
|
32
var.c
32
var.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.57 2008/07/12 16:56:40 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.58 2008/10/28 14:32:43 tg Exp $");
|
||||
|
||||
/*
|
||||
* Variables
|
||||
@ -130,10 +130,10 @@ array_index_calc(const char *n, bool *arrayp, uint32_t *valp)
|
||||
|
||||
/* Calculate the value of the subscript */
|
||||
*arrayp = true;
|
||||
tmp = str_nsave(p + 1, len - 2, ATEMP);
|
||||
strndupx(tmp, p + 1, len - 2, ATEMP);
|
||||
sub = substitute(tmp, 0);
|
||||
afree(tmp, ATEMP);
|
||||
n = str_nsave(n, p - n, ATEMP);
|
||||
strndupx(n, n, p - n, ATEMP);
|
||||
evaluate(sub, &rval, KSH_UNWIND_ERROR, true);
|
||||
*valp = (uint32_t)rval;
|
||||
afree(sub, ATEMP);
|
||||
@ -326,7 +326,7 @@ str_val(struct tbl *vp)
|
||||
if (vp->flag & (RJUST|LJUST)) /* case already dealt with */
|
||||
s = formatstr(vp, s);
|
||||
else
|
||||
s = str_save(s, ATEMP);
|
||||
strdupx(s, s, ATEMP);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@ -376,7 +376,7 @@ setstr(struct tbl *vq, const char *s, int error_ok)
|
||||
if ((vq->flag&EXPORT))
|
||||
export(vq, s);
|
||||
else {
|
||||
vq->val.s = str_save(s, vq->areap);
|
||||
strdupx(vq->val.s, s, vq->areap);
|
||||
vq->flag |= ALLOC;
|
||||
}
|
||||
} else { /* integer dest */
|
||||
@ -642,14 +642,13 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
|
||||
}
|
||||
val += len;
|
||||
}
|
||||
if (*val == '=') {
|
||||
int i = val++ - var;
|
||||
tvar = str_nsave(var, i, ATEMP);
|
||||
} else {
|
||||
if (*val == '=')
|
||||
strndupx(tvar, var, val++ - var, ATEMP);
|
||||
else {
|
||||
/* Importing from original environment: must have an = */
|
||||
if (set & IMPORT)
|
||||
return NULL;
|
||||
tvar = str_save(var, ATEMP);
|
||||
strdupx(tvar, var, ATEMP);
|
||||
val = NULL;
|
||||
}
|
||||
|
||||
@ -1062,7 +1061,7 @@ setspec(struct tbl *vp)
|
||||
if (path)
|
||||
afree(path, APERM);
|
||||
s = str_val(vp);
|
||||
path = str_save(s, APERM);
|
||||
strdupx(path, s, APERM);
|
||||
flushcom(1); /* clear tracked aliases */
|
||||
break;
|
||||
case V_IFS:
|
||||
@ -1088,7 +1087,7 @@ setspec(struct tbl *vp)
|
||||
s = str_val(vp);
|
||||
if (s[0] == '/' && access(s, W_OK|X_OK) == 0 &&
|
||||
stat(s, &statb) == 0 && S_ISDIR(statb.st_mode))
|
||||
tmpdir = str_save(s, APERM);
|
||||
strdupx(tmpdir, s, APERM);
|
||||
}
|
||||
break;
|
||||
case V_HISTSIZE:
|
||||
@ -1141,7 +1140,7 @@ unsetspec(struct tbl *vp)
|
||||
case V_PATH:
|
||||
if (path)
|
||||
afree(path, APERM);
|
||||
path = str_save(def_path, APERM);
|
||||
strdupx(path, def_path, APERM);
|
||||
flushcom(1); /* clear tracked aliases */
|
||||
break;
|
||||
case V_IFS:
|
||||
@ -1241,12 +1240,15 @@ char *
|
||||
arrayname(const char *str)
|
||||
{
|
||||
const char *p;
|
||||
char *rv;
|
||||
|
||||
if ((p = cstrchr(str, '[')) == 0)
|
||||
/* Shouldn't happen, but why worry? */
|
||||
return str_save(str, ATEMP);
|
||||
strdupx(rv, str, ATEMP);
|
||||
else
|
||||
strndupx(rv, str, p - str, ATEMP);
|
||||
|
||||
return str_nsave(str, p - str, ATEMP);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
/* Set (or overwrite, if !reset) the array variable var to the values in vals.
|
||||
|
Loading…
x
Reference in New Issue
Block a user