aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2012-11-16 22:28:01 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2012-11-16 22:28:15 +0000
commit35d31ee2fa13358f20b2a75b67666b78956ae03b (patch)
tree125aaa65486d2cf8b5e53891d91f82643c48963f
parent4d0e01e9f2490ca7be09ef4c3424dbb9f7a64e45 (diff)
downloadpaludis-35d31ee2fa13358f20b2a75b67666b78956ae03b.tar.gz
paludis-35d31ee2fa13358f20b2a75b67666b78956ae03b.tar.xz
Trim whitespace before deciding whether key values are empty
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc29
-rw-r--r--paludis/repositories/e/ebuild_id.cc17
2 files changed, 24 insertions, 22 deletions
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index c25d58b..899cb40 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -40,6 +40,7 @@
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/fs_stat.hh>
#include <paludis/util/singleton-impl.hh>
+#include <paludis/util/strip.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
@@ -242,7 +243,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->defined_phases()->name()).stat().exists())
{
std::string d(file_contents(_imp->dir / vars->defined_phases()->name()));
- if (! d.empty())
+ if (! strip_leading(d, " \t\r\n").empty())
{
_imp->keys->defined_phases = EStringSetKeyStore::get_instance()->fetch(vars->defined_phases(),
d, mkt_internal);
@@ -299,7 +300,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->required_use()->name()).stat().exists())
{
std::string v(file_contents(_imp->dir / vars->required_use()->name()));
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
_imp->keys->required_use = std::make_shared<ERequiredUseKey>(_imp->environment, vars->required_use(),
eapi(), v, mkt_internal, is_installed());
@@ -336,7 +337,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->dependencies()->name()).stat().exists())
{
std::string v(file_contents(_imp->dir / vars->dependencies()->name()));
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
_imp->keys->dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->dependencies()->name(),
vars->dependencies()->description(), v,
@@ -351,7 +352,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->build_depend()->name()).stat().exists())
{
std::string v(file_contents(_imp->dir / vars->build_depend()->name()));
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
_imp->keys->build_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->build_depend()->name(),
vars->build_depend()->description(), v,
@@ -364,7 +365,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->run_depend()->name()).stat().exists())
{
std::string v(file_contents(_imp->dir / vars->run_depend()->name()));
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
_imp->keys->run_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->run_depend()->name(),
vars->run_depend()->description(), v,
@@ -378,7 +379,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->pdepend()->name()).stat().exists())
{
std::string v(file_contents(_imp->dir / vars->pdepend()->name()));
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
_imp->keys->post_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->pdepend()->name(),
vars->pdepend()->description(), v,
@@ -393,7 +394,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->restrictions()->name()).stat().exists())
{
std::string v(file_contents(_imp->dir / vars->restrictions()->name()));
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
_imp->keys->restrictions = std::make_shared<EPlainTextSpecKey>(_imp->environment, vars->restrictions(),
eapi(), v, mkt_internal, is_installed());
@@ -405,7 +406,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->properties()->name()).stat().exists())
{
std::string v(file_contents(_imp->dir / vars->properties()->name()));
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
_imp->keys->properties = std::make_shared<EPlainTextSpecKey>(_imp->environment, vars->properties(),
eapi(), v, mkt_internal, is_installed());
@@ -433,7 +434,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->long_description()->name()).stat().exists())
{
std::string value(file_contents(_imp->dir / vars->long_description()->name()));
- if (! value.empty())
+ if (! strip_leading(value, " \t\r\n").empty())
{
_imp->keys->long_description = std::make_shared<LiteralMetadataValueKey<std::string> >(vars->long_description()->name(),
vars->long_description()->description(), mkt_significant, value);
@@ -445,7 +446,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->upstream_changelog()->name()).stat().exists())
{
std::string value(file_contents(_imp->dir / vars->upstream_changelog()->name()));
- if (! value.empty())
+ if (! strip_leading(value, " \t\r\n").empty())
{
_imp->keys->upstream_changelog = std::make_shared<ESimpleURIKey>(_imp->environment,
vars->upstream_changelog(), eapi(), value, mkt_normal, is_installed());
@@ -457,7 +458,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->upstream_release_notes()->name()).stat().exists())
{
std::string value(file_contents(_imp->dir / vars->upstream_release_notes()->name()));
- if (! value.empty())
+ if (! strip_leading(value, " \t\r\n").empty())
{
_imp->keys->upstream_release_notes = std::make_shared<ESimpleURIKey>(_imp->environment,
vars->upstream_release_notes(), eapi(), value, mkt_normal, is_installed());
@@ -469,7 +470,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->upstream_documentation()->name()).stat().exists())
{
std::string value(file_contents(_imp->dir / vars->upstream_documentation()->name()));
- if (! value.empty())
+ if (! strip_leading(value, " \t\r\n").empty())
{
_imp->keys->upstream_documentation = std::make_shared<ESimpleURIKey>(_imp->environment,
vars->upstream_documentation(), eapi(), value, mkt_normal, is_installed());
@@ -481,7 +482,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->bugs_to()->name()).stat().exists())
{
std::string value(file_contents(_imp->dir / vars->bugs_to()->name()));
- if (! value.empty())
+ if (! strip_leading(value, " \t\r\n").empty())
{
_imp->keys->bugs_to = std::make_shared<EPlainTextSpecKey>(_imp->environment, vars->bugs_to(), eapi(), value, mkt_normal, is_installed());
add_metadata_key(_imp->keys->bugs_to);
@@ -492,7 +493,7 @@ EInstalledRepositoryID::need_keys_added() const
if ((_imp->dir / vars->remote_ids()->name()).stat().exists())
{
std::string value(file_contents(_imp->dir / vars->remote_ids()->name()));
- if (! value.empty())
+ if (! strip_leading(value, " \t\r\n").empty())
{
_imp->keys->remote_ids = std::make_shared<EPlainTextSpecKey>(_imp->environment,
vars->remote_ids(), eapi(), value, mkt_internal, is_installed());
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index f0c36b2..6a849aa 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -71,6 +71,7 @@
#include <paludis/util/join.hh>
#include <paludis/util/upper_lower.hh>
#include <paludis/util/safe_ifstream.hh>
+#include <paludis/util/strip.hh>
#include <set>
#include <iterator>
@@ -1039,7 +1040,7 @@ EbuildID::load_long_description(const std::string & r, const std::string & h, co
void
EbuildID::load_dependencies(const std::string & r, const std::string & h, const std::string & v) const
{
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
Lock l(_imp->mutex);
_imp->dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
@@ -1052,7 +1053,7 @@ void
EbuildID::load_build_depend(const std::string & r, const std::string & h, const std::string & v,
bool rewritten) const
{
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
Lock l(_imp->mutex);
_imp->build_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
@@ -1065,7 +1066,7 @@ void
EbuildID::load_run_depend(const std::string & r, const std::string & h, const std::string & v,
bool rewritten) const
{
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
Lock l(_imp->mutex);
_imp->run_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
@@ -1078,7 +1079,7 @@ void
EbuildID::load_post_depend(const std::string & r, const std::string & h, const std::string & v,
bool rewritten) const
{
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
Lock l(_imp->mutex);
_imp->post_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
@@ -1114,7 +1115,7 @@ EbuildID::load_license(const std::shared_ptr<const EAPIMetadataVariable> & m, co
void
EbuildID::load_restrict(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const
{
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
Lock l(_imp->mutex);
_imp->restrictions = std::make_shared<EPlainTextSpecKey>(_imp->environment, m, eapi(), v, mkt_internal, is_installed());
@@ -1125,7 +1126,7 @@ EbuildID::load_restrict(const std::shared_ptr<const EAPIMetadataVariable> & m, c
void
EbuildID::load_properties(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const
{
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
Lock l(_imp->mutex);
_imp->properties = std::make_shared<EPlainTextSpecKey>(_imp->environment, m, eapi(), v, mkt_internal, is_installed());
@@ -1152,7 +1153,7 @@ EbuildID::load_myoptions(const std::shared_ptr<const EAPIMetadataVariable> & h,
void
EbuildID::load_required_use(const std::shared_ptr<const EAPIMetadataVariable> & k, const std::string & v) const
{
- if (! v.empty())
+ if (! strip_leading(v, " \t\r\n").empty())
{
Lock l(_imp->mutex);
_imp->required_use = std::make_shared<ERequiredUseKey>(_imp->environment, k, eapi(), v, mkt_internal, is_installed());
@@ -1187,7 +1188,7 @@ EbuildID::load_inherited(const std::shared_ptr<const EAPIMetadataVariable> & r,
void
EbuildID::load_defined_phases(const std::shared_ptr<const EAPIMetadataVariable> & h, const std::string & v) const
{
- if (v.empty())
+ if (strip_leading(v, " \t\r\n").empty())
throw InternalError(PALUDIS_HERE, "v should not be empty");
Lock l(_imp->mutex);