Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH 3/3] Constify two local variables.



---
I assume that v->pm->gsu.a->getfn() has no access to v->start and v->end, hence
changing the order is safe.

Are there any compilers that choke on 'char **const' (const pointer to pointer
to char)?

Cheers,

Daniel

 Src/params.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Src/params.c b/Src/params.c
index d8bf83d..142697f 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2552,18 +2552,20 @@ setarrvalue(Value v, char **val)
 	     v->pm->node.nam);
 	return;
     } else {
-	char **old, **new, **p, **q, **r;
-	int pre_assignment_length;
+	char **const old = v->pm->gsu.a->getfn(v->pm);
+	char **new;
+	char **p, **q, **r; /* index variables */
+	const int pre_assignment_length = arrlen(old);
 	int post_assignment_length;
 	int i;
 
+	q = old;
+
 	if ((v->flags & VALFLAG_INV) && unset(KSHARRAYS)) {
 	    if (v->start > 0)
 		v->start--;
 	    v->end--;
 	}
-	q = old = v->pm->gsu.a->getfn(v->pm);
-	pre_assignment_length = arrlen(old);
 	if (v->start < 0) {
 	    v->start += pre_assignment_length;
 	    if (v->start < 0)
-- 
2.1.4



Messages sorted by: Reverse Date, Date, Thread, Author