diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-05-25 14:14:42 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-05-25 14:17:33 +0300 |
commit | b5a0f6876c79bb43d649024056b62c6df61ad548 (patch) | |
tree | d60065444c84a0707fb5eaf3023a5e231c0eb4d8 /build/files.c | |
parent | 185596818f763af1249f19161f38134ee93092d2 (diff) | |
download | librpm-tizen-b5a0f6876c79bb43d649024056b62c6df61ad548.tar.gz librpm-tizen-b5a0f6876c79bb43d649024056b62c6df61ad548.tar.bz2 librpm-tizen-b5a0f6876c79bb43d649024056b62c6df61ad548.zip |
Refactor getSpecialDocDir() so it cannot fail
- Spit a warning on illegal _docdir_fmt and fall back to the default
format (which cannot fail). This just isn't worth dying for and
avoids having to deal with such a petty error elsewhere.
Diffstat (limited to 'build/files.c')
-rw-r--r-- | build/files.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/build/files.c b/build/files.c index 5bd5ba6c9..da2dfac1c 100644 --- a/build/files.c +++ b/build/files.c @@ -1693,22 +1693,24 @@ exit: static char * getSpecialDocDir(Header h) { - const char *errstr, *docdir_fmt = "%{NAME}-%{VERSION}"; - char *fmt_macro, *fmt; + const char *errstr = NULL; + const char *fmt_default = "%{NAME}-%{VERSION}"; + char *fmt_macro = rpmExpand("%{?_docdir_fmt}", NULL); + char *fmt = NULL; char *res = NULL; - fmt_macro = rpmExpand("%{?_docdir_fmt}", NULL); if (fmt_macro && strlen(fmt_macro) > 0) { - docdir_fmt = fmt_macro; + fmt = headerFormat(h, fmt_macro, &errstr); + if (errstr) { + rpmlog(RPMLOG_WARNING, _("illegal _docdir_fmt %s: %s\n"), + fmt_macro, errstr); + } } - fmt = headerFormat(h, docdir_fmt, &errstr); + if (fmt == NULL) + fmt = headerFormat(h, fmt_default, &errstr); - if (fmt) { - res = rpmGetPath("%{_docdir}/", fmt, NULL); - } else { - rpmlog(RPMLOG_ERR, _("illegal _docdir_fmt: %s\n"), errstr); - } + res = rpmGetPath("%{_docdir}/", fmt, NULL); free(fmt); free(fmt_macro); @@ -1852,8 +1854,8 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, /* Now process special doc, if there is one */ if (specialDoc) { char *docDir = getSpecialDocDir(pkg->header); - if (docDir == NULL || processSpecialDocs(spec, docDir, specialDoc, - installSpecialDoc, test)) { + if (processSpecialDocs(spec, docDir, specialDoc, + installSpecialDoc, test)) { fl.processingFailed = 1; } else { /* Reset for %doc */ |