Re: Regression with declare -i and arrays
On 4/3/15 10:48 PM, Eduardo A. Bustamante López wrote: -#define NEXT_VARIABLE() free (name); list = list-next; continue +#define NEXT_VARIABLE() do { free (name); list = list-next; continue; } while(0) That won't work; adding the do {...} while (0) negates the continue in the code block. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: Regression with declare -i and arrays
On 4/3/15 8:40 PM, Eduardo A. Bustamante López wrote: Hello Chet, You introduced a regression: [dual...@ma.sdf.org /tmp/tmp.ps6HXrLSZX/devel-]$ ./bash -c 'typeset -i x; x=([0]=1+1); echo $x' 1+1 vs dualbus@yaqui ~ % bash -c 'typeset -i x; x=([0]=1+1); echo $x' 2 Thanks, it's an easy fix. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Regression with declare -i and arrays
Hello Chet, You introduced a regression: [dual...@ma.sdf.org /tmp/tmp.ps6HXrLSZX/devel-]$ ./bash -c 'typeset -i x; x=([0]=1+1); echo $x' 1+1 vs dualbus@yaqui ~ % bash -c 'typeset -i x; x=([0]=1+1); echo $x' 2 The regression was introduced here: 06c3a57511953d09ac9ea262bc18bfdbcff23fc4 The patch that causes it: diff --git a/builtins/declare.def b/builtins/declare.def index 69c4703..5ed83a0 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -506,13 +506,13 @@ declare_internal (list, local_var) if (flags_on att_assoc) { var = make_new_assoc_variable (name); - if (offset == 0 no_invisible_vars == 0) + if (var offset == 0 no_invisible_vars == 0) VSETATTR (var, att_invisible); } else if ((flags_on att_array) || making_array_special) { var = make_new_array_variable (name); - if (offset == 0 no_invisible_vars == 0) + if (var offset == 0 no_invisible_vars == 0) VSETATTR (var, att_invisible); } else @@ -522,9 +522,11 @@ declare_internal (list, local_var) else { var = mkglobal ? bind_global_variable (name, (char *)NULL, 0) : bind_variable (name, (char *)NULL, 0); - if (no_invisible_vars == 0) + if (var no_invisible_vars == 0) VSETATTR (var, att_invisible); } + if (var == 0) + NEXT_VARIABLE (); } /* Can't take an existing array variable and make it a nameref */ else if ((array_p (var) || assoc_p (var)) (flags_on att_nameref)) Thanks to Geir, because he split the commits into logical commits and I was able to find this faster with git bisect. I caught it by running: make tests -- Eduardo Bustamante https://dualbus.me/
Re: Regression with declare -i and arrays
Nevermind. The patch is wrong, but at least it shows where the problem is (if needs braces, around line 529) El abr 3, 2015 8:48 PM, Eduardo A. Bustamante López dual...@gmail.com escribió: Here's a patch: diff --git a/builtins/declare.def b/builtins/declare.def index 5ed83a0..f0f9a6d 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -280,7 +280,7 @@ declare_internal (list, local_var) return (sh_chkwrite (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS)); } -#define NEXT_VARIABLE() free (name); list = list-next; continue +#define NEXT_VARIABLE() do { free (name); list = list-next; continue; } while(0) /* There are arguments left, so we are making variables. */ while (list) /* declare [-aAfFirx] name [name ...] */ -- Eduardo Bustamante https://dualbus.me/
Re: Regression with declare -i and arrays
Here's a patch: diff --git a/builtins/declare.def b/builtins/declare.def index 5ed83a0..f0f9a6d 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -280,7 +280,7 @@ declare_internal (list, local_var) return (sh_chkwrite (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS)); } -#define NEXT_VARIABLE() free (name); list = list-next; continue +#define NEXT_VARIABLE() do { free (name); list = list-next; continue; } while(0) /* There are arguments left, so we are making variables. */ while (list) /* declare [-aAfFirx] name [name ...] */ -- Eduardo Bustamante https://dualbus.me/