mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-12-28 16:15:02 +01:00
Add typeset -C to control whether to assert the cached length
This commit is contained in:
parent
b7c2ddf65c
commit
f4ab07b48c
4 changed files with 30 additions and 18 deletions
|
@ -55,7 +55,7 @@ static struct builtin builtins[] =
|
|||
BUILTIN("cd", BINF_SKIPINVALID | BINF_SKIPDASH | BINF_DASHDASHVALID, bin_cd, 0, 2, BIN_CD, "qsPL", NULL),
|
||||
BUILTIN("chdir", BINF_SKIPINVALID | BINF_SKIPDASH | BINF_DASHDASHVALID, bin_cd, 0, 2, BIN_CD, "qsPL", NULL),
|
||||
BUILTIN("continue", BINF_PSPECIAL, bin_break, 0, 1, BIN_CONTINUE, NULL, NULL),
|
||||
BUILTIN("declare", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%acfghi:%klmprtuxz", NULL),
|
||||
BUILTIN("declare", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "ACE:%F:%HL:%R:%TUZ:%acfghi:%klmprtuxz", NULL),
|
||||
BUILTIN("dirs", 0, bin_dirs, 0, -1, 0, "clpv", NULL),
|
||||
BUILTIN("disable", 0, bin_enable, 0, -1, BIN_DISABLE, "afmprs", NULL),
|
||||
BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL),
|
||||
|
@ -88,7 +88,7 @@ static struct builtin builtins[] =
|
|||
BUILTIN("jobs", 0, bin_fg, 0, -1, BIN_JOBS, "dlpZrs", NULL),
|
||||
BUILTIN("kill", BINF_HANDLES_OPTS, bin_kill, 0, -1, 0, NULL, NULL),
|
||||
BUILTIN("let", 0, bin_let, 1, -1, 0, NULL, NULL),
|
||||
BUILTIN("local", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%achi:%lprtux", NULL),
|
||||
BUILTIN("local", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "ACE:%F:%HL:%R:%TUZ:%achi:%lprtux", NULL),
|
||||
BUILTIN("log", 0, bin_log, 0, 0, 0, NULL, NULL),
|
||||
BUILTIN("logout", 0, bin_break, 0, 1, BIN_LOGOUT, NULL, NULL),
|
||||
|
||||
|
@ -108,7 +108,7 @@ static struct builtin builtins[] =
|
|||
BUILTIN("pwd", 0, bin_pwd, 0, 0, 0, "rLP", NULL),
|
||||
BUILTIN("r", 0, bin_fc, 0, -1, BIN_R, "IlLnr", NULL),
|
||||
BUILTIN("read", 0, bin_read, 0, -1, 0, "cd:ek:%lnpqrst:%zu:AE", NULL),
|
||||
BUILTIN("readonly", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, BIN_READONLY, "AE:%F:%HL:%R:%TUZ:%acfghi:%lptux", "r"),
|
||||
BUILTIN("readonly", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, BIN_READONLY, "ACE:%F:%HL:%R:%TUZ:%acfghi:%lptux", "r"),
|
||||
BUILTIN("rehash", 0, bin_hash, 0, 0, 0, "df", "r"),
|
||||
BUILTIN("return", BINF_PSPECIAL, bin_break, 0, 1, BIN_RETURN, NULL, NULL),
|
||||
BUILTIN("set", BINF_PSPECIAL | BINF_HANDLES_OPTS, bin_set, 0, -1, 0, NULL, NULL),
|
||||
|
@ -122,7 +122,7 @@ static struct builtin builtins[] =
|
|||
BUILTIN("trap", BINF_PSPECIAL | BINF_HANDLES_OPTS, bin_trap, 0, -1, 0, NULL, NULL),
|
||||
BUILTIN("true", 0, bin_true, 0, -1, 0, NULL, NULL),
|
||||
BUILTIN("type", 0, bin_whence, 0, -1, 0, "ampfsSw", "v"),
|
||||
BUILTIN("typeset", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%acfghi:%klprtuxmz", NULL),
|
||||
BUILTIN("typeset", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "ACE:%F:%HL:%R:%TUZ:%acfghi:%klprtuxmz", NULL),
|
||||
BUILTIN("umask", 0, bin_umask, 0, 1, 0, "S", NULL),
|
||||
BUILTIN("unalias", 0, bin_unhash, 0, -1, BIN_UNALIAS, "ams", NULL),
|
||||
BUILTIN("unfunction", 0, bin_unhash, 1, -1, BIN_UNFUNCTION, "m", "f"),
|
||||
|
|
29
Src/params.c
29
Src/params.c
|
@ -28,7 +28,6 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
//#define assert(x)
|
||||
|
||||
#include "zsh.mdh"
|
||||
#include "params.pro"
|
||||
|
@ -1470,7 +1469,8 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
|
|||
return !down;
|
||||
if (v->pm->node.flags & PM_CACHELEN) {
|
||||
len = arrcachelen(v->pm);
|
||||
assert(len == arrlen(ta));
|
||||
if (v->pm->node.flags & PM_CHECKLEN)
|
||||
assert(len == arrlen(ta));
|
||||
} else
|
||||
len = arrlen(ta);
|
||||
if (beg < 0)
|
||||
|
@ -1497,7 +1497,8 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
|
|||
ta = sepsplit(d = s = getstrvalue(v), sep, 1, 1);
|
||||
if (v->pm->node.flags & PM_CACHELEN) {
|
||||
len = arrcachelen(v->pm);
|
||||
assert(len == arrlen(ta));
|
||||
if (v->pm->node.flags & PM_CHECKLEN)
|
||||
assert(len == arrlen(ta));
|
||||
} else
|
||||
len = arrlen(ta);
|
||||
if (beg < 0)
|
||||
|
@ -2051,7 +2052,8 @@ getstrvalue(Value v)
|
|||
else {
|
||||
if (v->pm->node.flags & PM_CACHELEN) {
|
||||
int len = arrcachelen(v->pm);
|
||||
assert(v->pm->length == arrlen(ss));
|
||||
if (v->pm->node.flags & PM_CHECKLEN)
|
||||
assert(v->pm->length == arrlen(ss));
|
||||
if (v->start < 0)
|
||||
v->start += len;
|
||||
s = (v->start >= len || v->start < 0) ?
|
||||
|
@ -2258,7 +2260,8 @@ getarrvalue(Value v)
|
|||
return s;
|
||||
if (v->pm->node.flags & PM_CACHELEN) {
|
||||
int len = arrcachelen(v->pm);
|
||||
assert(v->pm->length == arrlen(s));
|
||||
if (v->pm->node.flags & PM_CHECKLEN)
|
||||
assert(v->pm->length == arrlen(s));
|
||||
if (v->start < 0)
|
||||
v->start += v->pm->length;
|
||||
if (v->end < 0)
|
||||
|
@ -2612,9 +2615,10 @@ setarrvalue(Value v, char **val)
|
|||
int post_assignment_length;
|
||||
int i;
|
||||
|
||||
if (v->pm->node.flags & PM_CACHELEN)
|
||||
assert(v->pm->length == arrlen(old));
|
||||
else
|
||||
if (v->pm->node.flags & PM_CACHELEN) {
|
||||
if (v->pm->node.flags & PM_CHECKLEN)
|
||||
assert(v->pm->length == arrlen(old));
|
||||
} else
|
||||
pre_assignment_length = arrlen(old);
|
||||
q = old;
|
||||
|
||||
|
@ -2728,7 +2732,8 @@ getaparam(char *s, int *len)
|
|||
if (len) {
|
||||
if (v->pm->node.flags & PM_CACHELEN) {
|
||||
*len = arrcachelen(v->pm);
|
||||
assert (*len == arrlen(v->pm->gsu.a->getfn(v->pm)));
|
||||
if (v->pm->node.flags & PM_CHECKLEN)
|
||||
assert (*len == arrlen(v->pm->gsu.a->getfn(v->pm)));
|
||||
} else
|
||||
*len = arrlen(v->pm->gsu.a->getfn(v->pm));
|
||||
}
|
||||
|
@ -3006,7 +3011,8 @@ assignaparam(char *s, char **val, int flags)
|
|||
v->start =
|
||||
//arrlen(v->pm->gsu.a->getfn(v->pm));
|
||||
arrcachelen(v->pm);
|
||||
assert(v->pm->length == arrlen(v->pm->gsu.a->getfn(v->pm)));
|
||||
if (v->pm->node.flags & PM_CHECKLEN)
|
||||
assert(v->pm->length == arrlen(v->pm->gsu.a->getfn(v->pm)));
|
||||
} else {
|
||||
v->start =
|
||||
arrlen(v->pm->gsu.a->getfn(v->pm));
|
||||
|
@ -3022,7 +3028,8 @@ assignaparam(char *s, char **val, int flags)
|
|||
v->end
|
||||
//= arrlen(v->pm->gsu.a->getfn(v->pm)) + v->end;
|
||||
+= arrcachelen(v->pm);
|
||||
assert(v->pm->length == arrlen(v->pm->gsu.a->getfn(v->pm)));
|
||||
if (v->pm->node.flags & PM_CHECKLEN)
|
||||
assert(v->pm->length == arrlen(v->pm->gsu.a->getfn(v->pm)));
|
||||
} else {
|
||||
v->end
|
||||
= arrlen(v->pm->gsu.a->getfn(v->pm)) + v->end;
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "zsh.mdh"
|
||||
#include "subst.pro"
|
||||
|
||||
|
@ -2551,9 +2553,11 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
|
|||
* to avoid the multsub() horror.
|
||||
*/
|
||||
int tmplen;
|
||||
if (v->pm->node.flags & PM_CACHELEN)
|
||||
if (v->pm->node.flags & PM_CACHELEN) {
|
||||
tmplen = arrcachelen(v->pm);
|
||||
else
|
||||
if (v->pm->node.flags & PM_CHECKLEN)
|
||||
assert(tmplen == arrlen(v->pm->gsu.a->getfn(v->pm)));
|
||||
} else
|
||||
tmplen = arrlen(v->pm->gsu.a->getfn(v->pm));
|
||||
|
||||
if (v->start < 0)
|
||||
|
|
|
@ -1792,6 +1792,7 @@ struct tieddata {
|
|||
#define PM_KSHSTORED (1<<17) /* function stored in ksh form */
|
||||
#define PM_ZSHSTORED (1<<18) /* function stored in zsh form */
|
||||
#define PM_CACHELEN (1<<19) /* length is cached */
|
||||
#define PM_CHECKLEN (1<<20) /* cached length is checked */
|
||||
|
||||
/* Remaining flags do not correspond directly to command line arguments */
|
||||
#define PM_LOCAL (1<<21) /* this parameter will be made local */
|
||||
|
@ -1810,7 +1811,7 @@ struct tieddata {
|
|||
#define PM_NAMEDDIR (1<<30) /* has a corresponding nameddirtab entry */
|
||||
|
||||
/* The option string corresponds to the first of the variables above */
|
||||
#define TYPESET_OPTSTR "aiEFALRZlurtxUhHTkzc"
|
||||
#define TYPESET_OPTSTR "aiEFALRZlurtxUhHTkzcC"
|
||||
|
||||
/* These typeset options take an optional numeric argument */
|
||||
#define TYPESET_OPTNUM "LRZiEF"
|
||||
|
|
Loading…
Reference in a new issue