[PATCH] Warn when whitespace is missing before macro body
Alexey Tourbin
alexey.tourbin at gmail.com
Mon Jan 21 18:43:51 UTC 2013
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
More information about the Rpm-list
mailing list