1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-09 09:06:38 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Bart Schaefer 8adfbfc1f0 unposted: "typeset -p" has problems with special parameters having NULL values 2024-03-12 18:02:38 -07:00
Bart Schaefer 7c875adb09 52742: fix bad interactions of "typeset -p" with GLOBAL_EXPORT 2024-03-12 18:00:19 -07:00
Oliver Kiddle 37f434498e 52724: fix .zle.sgr for empty sequences 2024-03-13 00:35:10 +01:00
4 changed files with 51 additions and 15 deletions

View File

@ -1,3 +1,15 @@
2024-03-12 Bart Schaefer <schaefer@zsh.org>
* unposted: Src/Modules/ksh93.c: "typeset -p" has problems with
special parameters having NULL values, use a dummy static instead.
* 52742: Src/builtin.c: fix bad interactions of "typeset -p" with
GLOBAL_EXPORT, plus some other inconsistencies.
2024-03-13 Oliver Kiddle <opk@zsh.org>
* 52724: Src/Modules/hlgroup.c: fix .zle.sgr for empty sequences
2024-03-09 Bart Schaefer <schaefer@zsh.org>
* 52725: Src/Modules/ksh93.c: updated named reference semantics

View File

@ -59,6 +59,10 @@ convertattr(char *attrstr, int sgr)
*t = ';';
c++;
}
if (t <= s) { /* always return at least "0" */
*s = '0';
t = s + 1;
}
*t = '\0';
len = t - s;
}

View File

@ -102,9 +102,10 @@ static const struct gsu_scalar sh_name_gsu =
static const struct gsu_scalar sh_subscript_gsu =
{ strvargetfn, nullstrsetfn, nullunsetfn };
static char *sh_name;
static char *sh_subscript;
static char *sh_edchar;
static char sh_unsetval[2]; /* Dummy to treat as NULL */
static char *sh_name = sh_unsetval;
static char *sh_subscript = sh_unsetval;
static char *sh_edchar = sh_unsetval;
static char sh_edmode[2];
/*
@ -193,7 +194,7 @@ ksh93_wrapper(Eprog prog, FuncWrap w, char *name)
strcpy(sh_edmode, "\033");
else
strcpy(sh_edmode, "");
if (!sh_edchar)
if (sh_edchar == sh_unsetval)
sh_edchar = dupstring(getsparam("KEYS"));
if (varedarg) {
char *ie = itype_end((sh_name = dupstring(varedarg)), INAMESPC, 0);
@ -204,16 +205,16 @@ ksh93_wrapper(Eprog prog, FuncWrap w, char *name)
ie = sh_subscript + strlen(sh_subscript);
*--ie = '\0';
} else
sh_subscript = NULL;
sh_subscript = sh_unsetval;
if ((pm = createparam(".sh.value", LOCAL_NAMEREF))) {
pm->level = locallevel;
setloopvar(".sh.value", "BUFFER"); /* Hack */
pm->node.flags |= PM_READONLY;
}
} else
sh_name = sh_subscript = NULL;
sh_name = sh_subscript = sh_unsetval;
} else {
sh_edchar = sh_name = sh_subscript = NULL;
sh_edchar = sh_name = sh_subscript = sh_unsetval;
strcpy(sh_edmode, "");
/* TODO:
* - disciplines

View File

@ -2059,7 +2059,7 @@ typeset_single(char *cname, char *pname, Param pm, int func,
* POSIXBUILTINS horror: we need to retain the 'readonly' or 'export'
* flags of an unset parameter.
*/
usepm = pm && (!(pm->node.flags & PM_UNSET) ||
usepm = pm && (!(pm->node.flags & PM_UNSET) || OPT_ISSET(ops, 'p') ||
(isset(POSIXBUILTINS) &&
(pm->node.flags & (PM_READONLY|PM_EXPORTED))));
@ -2195,7 +2195,7 @@ typeset_single(char *cname, char *pname, Param pm, int func,
else if (newspecial != NS_NONE && strcmp(pname, "SECONDS") == 0)
newspecial = NS_SECONDS;
if (isset(POSIXBUILTINS)) {
if (isset(POSIXBUILTINS) && !OPT_ISSET(ops,'p')) {
/*
* Stricter rules about retaining readonly attribute in this case.
*/
@ -2224,7 +2224,8 @@ typeset_single(char *cname, char *pname, Param pm, int func,
* ii. we are creating a new local parameter
*/
if (usepm) {
if (OPT_MINUS(ops,'p') && on && !(on & pm->node.flags))
if (OPT_MINUS(ops,'p') && on &&
!((on & pm->node.flags) || ((on & PM_LOCAL) && pm->level)))
return NULL;
else if (OPT_PLUS(ops,'p') && off && !(off & pm->node.flags))
return NULL;
@ -2339,7 +2340,8 @@ typeset_single(char *cname, char *pname, Param pm, int func,
return NULL;
pm->node.flags |= (on & PM_READONLY);
return pm;
}
} else if (OPT_ISSET(ops,'p'))
return NULL; /* Nothing to print */
if ((asg->flags & ASG_ARRAY) ?
!(on & (PM_ARRAY|PM_HASHED)) :
@ -2686,6 +2688,15 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
if (func == BIN_READONLY && isset(POSIXBUILTINS) && !OPT_PLUS(ops, 'g'))
ops->ind['g'] = 1;
#if 0
/* "local" rejects -m, this should too ... what about +m ? */
if (locallevel && OPT_MINUS(ops, 'm') &&
!(OPT_MINUS(ops, 'g') || OPT_ISSET(ops, 'p'))) {
zerrnam(name, "bad option: -m");
return 1;
}
#endif
/* Translate the options into PM_* flags. *
* Unfortunately, this depends on the order *
* these flags are defined in zsh.h */
@ -2788,10 +2799,18 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
return 0;
}
if (!(OPT_ISSET(ops,'g') || OPT_ISSET(ops,'x') || OPT_ISSET(ops,'m')) ||
OPT_PLUS(ops,'g') || *name == 'l' ||
(!isset(GLOBALEXPORT) && !OPT_ISSET(ops,'g')))
on |= PM_LOCAL;
/* Using *name here is cheating, "local" allows no -g option */
if ((*name == 'l' || OPT_PLUS(ops,'g')))
on |= PM_LOCAL;
else if (!OPT_ISSET(ops,'g')) {
if (OPT_MINUS(ops, 'x')) {
if (isset(GLOBALEXPORT))
ops->ind['g'] = 1;
else if (locallevel)
on |= PM_LOCAL;
} else if (!(OPT_ISSET(ops,'x') || OPT_ISSET(ops,'m')))
on |= PM_LOCAL;
}
if ((on & PM_TIED) && !OPT_ISSET(ops, 'p')) {
Param apm;