alexk / rpms / rpm

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