[PATCH] Warn when whitespace is missing before macro body

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This will now issue a warning when macro definition is possibly
incorrect or ambigous, such as the one found in FC18 lvm2.spec:

%define util-linux_version 2.22.1
warning: Macro %util needs whitespace before body
---
 rpmio/macro.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/rpmio/macro.c b/rpmio/macro.c
index 5362512..9229580 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -515,6 +515,7 @@ doDefine(MacroBuf mb, const char * se, int level, int expandbody)
     char *b, *be, *ebody = NULL;
     int c;
     int oc = ')';
+    const char *sbody; /* as-is body start */
 
     /* Copy name */
     COPYNAME(ne, s, c);
@@ -530,6 +531,7 @@ doDefine(MacroBuf mb, const char * se, int level, int expandbody)
 
     /* Copy body, skipping over escaped newlines */
     b = be = oe + 1;
+    sbody = s;
     SKIPBLANK(s, c);
     if (c == '{') {	/* XXX permit silent {...} grouping */
 	if ((se = matchchar(s, c, '}')) == NULL) {
@@ -606,6 +608,9 @@ doDefine(MacroBuf mb, const char * se, int level, int expandbody)
 	goto exit;
     }
 
+    if (!isblank(*sbody) && !(*sbody == '\\' && iseol(sbody[1])))
+	rpmlog(RPMLOG_WARNING, _("Macro %%%s needs whitespace before body\n"), n);
+
     if (expandbody) {
 	if (expandThis(mb, b, 0, &ebody)) {
 	    rpmlog(RPMLOG_ERR, _("Macro %%%s failed to expand\n"), n);
-- 
1.8.1

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list


[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux