[Rpm-maint] [PATCH] Check for undefined macros

Dmitry V. Levin ldv at altlinux.org
Wed Feb 6 01:48:58 UTC 2013


On Sun, Jan 27, 2013 at 05:27:09AM +0000, Alexey Tourbin wrote:
[...]
> --- a/build/pack.c
> +++ b/build/pack.c
> @@ -22,6 +22,7 @@
>  #include "build/rpmbuild_misc.h"
>  
>  #include "debug.h"
> +#include <libgen.h>
>  
>  typedef struct cpioSourceArchive_s {
>      rpm_loff_t	cpioArchiveSize;
> @@ -91,12 +92,14 @@ static rpmRC addFileToTag(rpmSpec spec, const char * file,
>  	}
>      }
>  
> +    int lineNum = 0;
>      while (fgets(buf, sizeof(buf), f)) {
> -	if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
> -	    rpmlog(RPMLOG_ERR, _("%s: line: %s\n"), fn, buf);
> +	char *exp = rpmExpandMacros(spec->macros, buf,
> +			basename(fn), ++lineNum, NULL, NULL);
> +	if (exp == NULL)
>  	    goto exit;
> -	}
> -	appendStringBuf(sb, buf);
> +	appendStringBuf(sb, exp);
> +	free(exp);
>      }
>      headerPutString(h, tag, getStringBuf(sb));
>      rc = RPMRC_OK;

There is no need to include <libgen.h>, just otherwise, since configure.ac
uses AC_USE_SYSTEM_EXTENSIONS, you should avoid including <libgen.h> to
get the GNU version of basename().


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20130206/2ebeab3e/attachment.asc>


More information about the Rpm-maint mailing list