richardphibel / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
976aaf
From 9cbc1fe444b048c3f7cf5ea09ab650d1c146d54a Mon Sep 17 00:00:00 2001
976aaf
From: Panu Matilainen <pmatilai@redhat.com>
976aaf
Date: Wed, 20 Feb 2019 14:49:19 +0200
976aaf
Subject: [PATCH] When doing the same thing more than once, use a loop...
976aaf
976aaf
No functional changes but this'll simplify the next commit quite a bit.
976aaf
---
976aaf
 build/spec.c | 12 +++++-------
976aaf
 1 file changed, 5 insertions(+), 7 deletions(-)
976aaf
976aaf
diff --git a/build/spec.c b/build/spec.c
976aaf
index e414e4102..80eaca611 100644
976aaf
--- a/build/spec.c
976aaf
+++ b/build/spec.c
976aaf
@@ -303,15 +303,13 @@ rpmSpec newSpec(void)
976aaf
     spec->pool = rpmstrPoolCreate();
976aaf
     
976aaf
 #ifdef WITH_LUA
976aaf
-    {
976aaf
     /* make sure patches and sources tables always exist */
976aaf
     rpmlua lua = NULL; /* global state */
976aaf
-    rpmluaDelVar(lua, "patches");
976aaf
-    rpmluaDelVar(lua, "sources");
976aaf
-    rpmluaPushTable(lua, "patches");
976aaf
-    rpmluaPushTable(lua, "sources");
976aaf
-    rpmluaPop(lua);
976aaf
-    rpmluaPop(lua);
976aaf
+    const char * luavars[] = { "patches", "sources", NULL, };
976aaf
+    for (const char **vp = luavars; vp && *vp; vp++) {
976aaf
+	rpmluaDelVar(lua, *vp);
976aaf
+	rpmluaPushTable(lua, *vp);
976aaf
+	rpmluaPop(lua);
976aaf
     }
976aaf
 #endif
976aaf
     return spec;
976aaf
-- 
976aaf
2.26.2
976aaf