aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-28 04:58:26 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-28 04:58:26 +0000
commitc16b4c134eb93a0b4b1e7e0598838881be3fb9b7 (patch)
treed127392d55b117e64025af6bcbc86d3ecb767115
parentf4ebe045f1145b284970baa1917433777945115f (diff)
downloadpaludis-c16b4c134eb93a0b4b1e7e0598838881be3fb9b7.tar.gz
paludis-c16b4c134eb93a0b4b1e7e0598838881be3fb9b7.tar.xz
Recognise (but don't support) -> in SRC_URI
-rw-r--r--paludis/dep_spec-fwd.hh5
-rw-r--r--paludis/dep_spec.cc35
-rw-r--r--paludis/dep_spec.hh26
-rw-r--r--paludis/dep_spec_TEST.cc16
-rw-r--r--paludis/dep_spec_flattener.cc13
-rw-r--r--paludis/dep_spec_flattener.hh4
-rw-r--r--paludis/dep_spec_pretty_printer.cc12
-rw-r--r--paludis/dep_spec_pretty_printer.hh2
-rw-r--r--paludis/dep_spec_pretty_printer_TEST.cc4
-rw-r--r--paludis/eapi.cc4
-rw-r--r--paludis/eapi.sr1
-rw-r--r--paludis/portage_dep_lexer.cc2
-rw-r--r--paludis/portage_dep_lexer.hh3
-rw-r--r--paludis/portage_dep_parser.cc167
-rw-r--r--paludis/portage_dep_parser_TEST.cc44
-rw-r--r--paludis/qa/dep_flags_check.cc4
-rw-r--r--paludis/qa/extract_check.cc4
-rw-r--r--paludis/qa/homepage_check.cc7
-rw-r--r--paludis/qa/src_uri_check.cc32
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.cc39
-rw-r--r--src/output/console_query_task.cc5
21 files changed, 380 insertions, 49 deletions
diff --git a/paludis/dep_spec-fwd.hh b/paludis/dep_spec-fwd.hh
index 548782f..43da8cf 100644
--- a/paludis/dep_spec-fwd.hh
+++ b/paludis/dep_spec-fwd.hh
@@ -30,6 +30,7 @@ namespace paludis
class DepSpec;
class PackageDepSpec;
class PlainTextDepSpec;
+ class URIDepSpec;
class AllDepSpec;
class AnyDepSpec;
class UseDepSpec;
@@ -58,6 +59,7 @@ namespace paludis
GenericSpecTree,
DepSpec,
TreeLeaf<GenericSpecTree, PlainTextDepSpec>,
+ TreeLeaf<GenericSpecTree, URIDepSpec>,
TreeLeaf<GenericSpecTree, PackageDepSpec>,
TreeLeaf<GenericSpecTree, BlockDepSpec>,
ConstTreeSequence<GenericSpecTree, AllDepSpec>,
@@ -83,7 +85,7 @@ namespace paludis
VisitorTypes<
URISpecTree,
DepSpec,
- TreeLeaf<URISpecTree, PlainTextDepSpec>,
+ TreeLeaf<URISpecTree, URIDepSpec>,
ConstTreeSequence<URISpecTree, AllDepSpec>,
ConstTreeSequence<URISpecTree, UseDepSpec>
>
@@ -95,6 +97,7 @@ namespace paludis
FlattenableSpecTree,
DepSpec,
TreeLeaf<FlattenableSpecTree, PlainTextDepSpec>,
+ TreeLeaf<FlattenableSpecTree, URIDepSpec>,
TreeLeaf<FlattenableSpecTree, PackageDepSpec>,
TreeLeaf<FlattenableSpecTree, BlockDepSpec>,
ConstTreeSequence<FlattenableSpecTree, AllDepSpec>,
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index 18cf74a..79f4e7b 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -40,6 +40,7 @@ template class ConstAcceptInterface<GenericSpecTree>;
template class TreeLeaf<GenericSpecTree, PackageDepSpec>;
template class TreeLeaf<GenericSpecTree, BlockDepSpec>;
template class TreeLeaf<GenericSpecTree, PlainTextDepSpec>;
+template class TreeLeaf<GenericSpecTree, URIDepSpec>;
template class ConstTreeSequence<GenericSpecTree, AllDepSpec>;
template class ConstTreeSequence<GenericSpecTree, AnyDepSpec>;
template class ConstTreeSequence<GenericSpecTree, UseDepSpec>;
@@ -53,7 +54,7 @@ template class ConstTreeSequence<LicenseSpecTree, UseDepSpec>;
template class ConstVisitor<URISpecTree>;
template class ConstAcceptInterface<URISpecTree>;
-template class TreeLeaf<URISpecTree, PlainTextDepSpec>;
+template class TreeLeaf<URISpecTree, URIDepSpec>;
template class ConstTreeSequence<URISpecTree, AllDepSpec>;
template class ConstTreeSequence<URISpecTree, UseDepSpec>;
@@ -62,6 +63,7 @@ template class ConstAcceptInterface<FlattenableSpecTree>;
template class TreeLeaf<FlattenableSpecTree, PackageDepSpec>;
template class TreeLeaf<FlattenableSpecTree, BlockDepSpec>;
template class TreeLeaf<FlattenableSpecTree, PlainTextDepSpec>;
+template class TreeLeaf<FlattenableSpecTree, URIDepSpec>;
template class ConstTreeSequence<FlattenableSpecTree, AllDepSpec>;
template class ConstTreeSequence<FlattenableSpecTree, UseDepSpec>;
@@ -975,3 +977,34 @@ BlockDepSpec::clone() const
return tr1::shared_ptr<DepSpec>(new BlockDepSpec(tr1::static_pointer_cast<PackageDepSpec>(_spec->clone())));
}
+URIDepSpec::URIDepSpec(const std::string & s) :
+ StringDepSpec(s)
+{
+}
+
+std::string
+URIDepSpec::original_url() const
+{
+ std::string::size_type p(text().find(" -> "));
+ if (std::string::npos == p)
+ return text();
+ else
+ return text().substr(0, p);
+}
+
+std::string
+URIDepSpec::renamed_url_suffix() const
+{
+ std::string::size_type p(text().find(" -> "));
+ if (std::string::npos == p)
+ return "";
+ else
+ return text().substr(p + 4);
+}
+
+tr1::shared_ptr<DepSpec>
+URIDepSpec::clone() const
+{
+ return tr1::shared_ptr<URIDepSpec>(new URIDepSpec(text()));
+}
+
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index 18b38d5..7f50c56 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -365,8 +365,7 @@ namespace paludis
};
/**
- * A PlainTextDepSpec represents a plain text entry (for example,
- * a URI in SRC_URI).
+ * A PlainTextDepSpec represents a plain text entry.
*
* \ingroup grpdepspecs
* \nosubgrouping
@@ -386,6 +385,29 @@ namespace paludis
};
/**
+ * A URIDepSpec represents a URI part.
+ *
+ * \ingroup grpdepspecs
+ * \nosubgrouping
+ */
+ class PALUDIS_VISIBLE URIDepSpec :
+ public StringDepSpec
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ URIDepSpec(const std::string &);
+
+ ///\}
+
+ std::string original_url() const;
+ std::string renamed_url_suffix() const;
+
+ virtual tr1::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ /**
* Thrown if an invalid package dep spec specification is encountered.
*
* \ingroup grpexceptions
diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc
index 9059a38..9e6862a 100644
--- a/paludis/dep_spec_TEST.cc
+++ b/paludis/dep_spec_TEST.cc
@@ -188,6 +188,22 @@ namespace test_cases
}
} test_package_dep_spec;
+ struct URIDepSpecTest : TestCase
+ {
+ URIDepSpecTest() : TestCase("uri dep spec") { }
+
+ void run()
+ {
+ URIDepSpec a("foo");
+ TEST_CHECK_EQUAL(a.original_url(), "foo");
+ TEST_CHECK_EQUAL(a.renamed_url_suffix(), "");
+
+ URIDepSpec b("fnord -> bar");
+ TEST_CHECK_EQUAL(b.original_url(), "fnord");
+ TEST_CHECK_EQUAL(b.renamed_url_suffix(), "bar");
+ }
+ } test_uri_dep_spec;
+
struct PackageDepSpecUnspecificTest : TestCase
{
PackageDepSpecUnspecificTest() : TestCase("package dep spec unspecific") { }
diff --git a/paludis/dep_spec_flattener.cc b/paludis/dep_spec_flattener.cc
index 35f444f..56864a8 100644
--- a/paludis/dep_spec_flattener.cc
+++ b/paludis/dep_spec_flattener.cc
@@ -45,7 +45,7 @@ namespace paludis
const PackageDatabaseEntry * const pkg;
- mutable std::list<const StringDepSpec *> specs;
+ mutable std::list<tr1::shared_ptr<const StringDepSpec > > specs;
Implementation(const Environment * const e,
const PackageDatabaseEntry * const p) :
@@ -90,16 +90,21 @@ void DepSpecFlattener::visit_sequence(const UseDepSpec & u,
void DepSpecFlattener::visit_leaf(const PlainTextDepSpec & p)
{
- _imp->specs.push_back(&p);
+ _imp->specs.push_back(tr1::static_pointer_cast<const StringDepSpec>(p.clone()));
}
void DepSpecFlattener::visit_leaf(const PackageDepSpec & p)
{
- _imp->specs.push_back(&p);
+ _imp->specs.push_back(tr1::static_pointer_cast<const StringDepSpec>(p.clone()));
}
void DepSpecFlattener::visit_leaf(const BlockDepSpec & p)
{
- _imp->specs.push_back(&p);
+ _imp->specs.push_back(tr1::static_pointer_cast<const StringDepSpec>(p.clone()));
+}
+
+void DepSpecFlattener::visit_leaf(const URIDepSpec & p)
+{
+ _imp->specs.push_back(tr1::static_pointer_cast<const StringDepSpec>(p.clone()));
}
diff --git a/paludis/dep_spec_flattener.hh b/paludis/dep_spec_flattener.hh
index d160142..469dad0 100644
--- a/paludis/dep_spec_flattener.hh
+++ b/paludis/dep_spec_flattener.hh
@@ -68,6 +68,8 @@ namespace paludis
void visit_leaf(const BlockDepSpec &);
+ void visit_leaf(const URIDepSpec &);
+
///}
///\name Basic operations
@@ -83,7 +85,7 @@ namespace paludis
///\name Iterate over our dep specs
///{
- typedef libwrapiter::ForwardIterator<DepSpecFlattener, const StringDepSpec *> Iterator;
+ typedef libwrapiter::ForwardIterator<DepSpecFlattener, const tr1::shared_ptr<const StringDepSpec> > Iterator;
Iterator begin() const;
diff --git a/paludis/dep_spec_pretty_printer.cc b/paludis/dep_spec_pretty_printer.cc
index 92fe189..de03563 100644
--- a/paludis/dep_spec_pretty_printer.cc
+++ b/paludis/dep_spec_pretty_printer.cc
@@ -140,6 +140,18 @@ DepSpecPrettyPrinter::visit_leaf(const PlainTextDepSpec & p)
}
void
+DepSpecPrettyPrinter::visit_leaf(const URIDepSpec & p)
+{
+ if (! p.renamed_url_suffix().empty())
+ {
+ _imp->s << indent() << p.original_url() << " -> " << p.renamed_url_suffix();
+ }
+ else
+ _imp->s << indent() << p.original_url();
+ _imp->s << newline();
+}
+
+void
DepSpecPrettyPrinter::visit_leaf(const BlockDepSpec & b)
{
_imp->s << indent() << "!" << *b.blocked_spec();
diff --git a/paludis/dep_spec_pretty_printer.hh b/paludis/dep_spec_pretty_printer.hh
index e6a2e31..a422eaa 100644
--- a/paludis/dep_spec_pretty_printer.hh
+++ b/paludis/dep_spec_pretty_printer.hh
@@ -77,6 +77,8 @@ namespace paludis
void visit_leaf(const BlockDepSpec &);
+ void visit_leaf(const URIDepSpec &);
+
///}
};
diff --git a/paludis/dep_spec_pretty_printer_TEST.cc b/paludis/dep_spec_pretty_printer_TEST.cc
index 80edc4d..23b29cd 100644
--- a/paludis/dep_spec_pretty_printer_TEST.cc
+++ b/paludis/dep_spec_pretty_printer_TEST.cc
@@ -50,6 +50,10 @@ namespace test_cases
DepSpecPrettyPrinter p4(0, false);
PortageDepParser::parse_license("( ( ( ) a ) b )", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4);
TEST_CHECK_STRINGIFY_EQUAL(p4, "a b");
+
+ DepSpecPrettyPrinter p5(0, false);
+ PortageDepParser::parse_uri("( a -> b c x? ( d e ) )", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p5);
+ TEST_CHECK_STRINGIFY_EQUAL(p5, "a -> b c x? ( d e )");
}
} test_pretty_printer_no_indent;
diff --git a/paludis/eapi.cc b/paludis/eapi.cc
index 592d2ba..a2aed0d 100644
--- a/paludis/eapi.cc
+++ b/paludis/eapi.cc
@@ -41,6 +41,7 @@ namespace paludis
.strict_iuse_flag_parse_mode(iuse_pm_eapi_0_strict)
.breaks_portage(false)
.has_pkg_pretend(false)
+ .uri_supports_arrow(false)
.want_aa_var(true)
.want_arch_var(true)
.want_portage_emulation_vars(true)
@@ -58,6 +59,7 @@ namespace paludis
.has_pkg_pretend(true)
.want_aa_var(false)
.want_arch_var(true)
+ .uri_supports_arrow(true)
.want_portage_emulation_vars(false)
.require_use_expand_in_iuse(false))))));
@@ -72,6 +74,7 @@ namespace paludis
.want_aa_var(false)
.want_arch_var(false)
.want_portage_emulation_vars(false)
+ .uri_supports_arrow(true)
.require_use_expand_in_iuse(false))))));
values.insert(std::make_pair("exheres-0", EAPI("exheres-0", tr1::shared_ptr<SupportedEAPI>(new SupportedEAPI(SupportedEAPI::create()
@@ -85,6 +88,7 @@ namespace paludis
.want_aa_var(false)
.want_arch_var(false)
.want_portage_emulation_vars(false)
+ .uri_supports_arrow(true)
.require_use_expand_in_iuse(true))))));
}
};
diff --git a/paludis/eapi.sr b/paludis/eapi.sr
index 56a4b8e..97735e4 100644
--- a/paludis/eapi.sr
+++ b/paludis/eapi.sr
@@ -7,6 +7,7 @@ make_class_SupportedEAPI()
key dependency_spec_tree_parse_mode DependencySpecTreeParseMode
key iuse_flag_parse_mode IUseFlagParseMode
key strict_iuse_flag_parse_mode IUseFlagParseMode
+ key uri_supports_arrow bool
key breaks_portage bool
diff --git a/paludis/portage_dep_lexer.cc b/paludis/portage_dep_lexer.cc
index 741c4d9..050526d 100644
--- a/paludis/portage_dep_lexer.cc
+++ b/paludis/portage_dep_lexer.cc
@@ -76,6 +76,8 @@ PortageDepLexer::PortageDepLexer(const std::string & s) :
_imp->tokens.push_back(std::make_pair(dpl_double_bar, *t));
else if ('|' == (*t)[0])
throw DepStringLexError(s, "'|' should be followed by '|'");
+ else if (*t == "->")
+ _imp->tokens.push_back(std::make_pair(dpl_arrow, *t));
else if (*t == "(")
_imp->tokens.push_back(std::make_pair(dpl_open_paren, *t));
else if ('(' == (*t)[0])
diff --git a/paludis/portage_dep_lexer.hh b/paludis/portage_dep_lexer.hh
index 4bc4171..4d06687 100644
--- a/paludis/portage_dep_lexer.hh
+++ b/paludis/portage_dep_lexer.hh
@@ -83,7 +83,8 @@ namespace paludis
dpl_use_flag, ///< a use flag
dpl_double_bar, ///< a double bar ('any' marker)
dpl_open_paren, ///< open paren
- dpl_close_paren ///< close paren
+ dpl_close_paren, ///< close paren
+ dpl_arrow ///< arrow
};
/**
diff --git a/paludis/portage_dep_parser.cc b/paludis/portage_dep_parser.cc
index df9a619..366b163 100644
--- a/paludis/portage_dep_parser.cc
+++ b/paludis/portage_dep_parser.cc
@@ -56,7 +56,10 @@ namespace
dps_had_double_bar_space,
dps_had_paren,
dps_had_use_flag,
- dps_had_use_flag_space
+ dps_had_use_flag_space,
+ dps_had_text_arrow,
+ dps_had_text_arrow_space,
+ dps_had_text_arrow_text
};
template <typename H_>
@@ -108,6 +111,13 @@ namespace
p->add(tr1::shared_ptr<TreeLeaf<H_, PackageDepSpec> >(new TreeLeaf<H_, PackageDepSpec>(
tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(s, _parse_mode)))));
}
+
+ template <typename H_>
+ void
+ add_arrow(const std::string & lhs, const std::string & rhs, tr1::shared_ptr<Composite<H_> > &) const
+ {
+ throw DepStringParseError(lhs + " -> " + rhs, "Arrows not allowed in this context");
+ }
};
struct ParsePackageOrBlockDepSpec
@@ -131,6 +141,13 @@ namespace
tr1::shared_ptr<BlockDepSpec>(new BlockDepSpec(
tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(s.substr(1), _parse_mode)))))));
}
+
+ template <typename H_>
+ void
+ add_arrow(const std::string & lhs, const std::string & rhs, tr1::shared_ptr<Composite<H_> > &) const
+ {
+ throw DepStringParseError(lhs + " -> " + rhs, "Arrows not allowed in this context");
+ }
};
struct ParseTextDepSpec
@@ -142,6 +159,42 @@ namespace
p->add(tr1::shared_ptr<TreeLeaf<H_, PlainTextDepSpec> >(new TreeLeaf<H_, PlainTextDepSpec>(
tr1::shared_ptr<PlainTextDepSpec>(new PlainTextDepSpec(s)))));
}
+
+ template <typename H_>
+ void
+ add_arrow(const std::string & lhs, const std::string & rhs, tr1::shared_ptr<Composite<H_> > &) const
+ {
+ throw DepStringParseError(lhs + " -> " + rhs, "Arrows not allowed in this context");
+ }
+ };
+
+ struct ParseURIDepSpec
+ {
+ const bool _supports_arrow;
+
+ ParseURIDepSpec(bool a) :
+ _supports_arrow(a)
+ {
+ }
+
+ template <typename H_>
+ void
+ add(const std::string & s, tr1::shared_ptr<Composite<H_> > & p) const
+ {
+ p->add(tr1::shared_ptr<TreeLeaf<H_, URIDepSpec> >(new TreeLeaf<H_, URIDepSpec>(
+ tr1::shared_ptr<URIDepSpec>(new URIDepSpec(s)))));
+ }
+
+ template <typename H_>
+ void
+ add_arrow(const std::string & lhs, const std::string & rhs, tr1::shared_ptr<Composite<H_> > & p) const
+ {
+ if (_supports_arrow)
+ p->add(tr1::shared_ptr<TreeLeaf<H_, URIDepSpec> >(new TreeLeaf<H_, URIDepSpec>(
+ tr1::shared_ptr<URIDepSpec>(new URIDepSpec(lhs + " -> " + rhs)))));
+ else
+ throw DepStringParseError(lhs + " -> " + rhs, "Arrows not allowed in this EAPI");
+ }
};
template <typename H_, bool>
@@ -232,6 +285,7 @@ PortageDepParser::_parse(const std::string & s, bool disallow_any_use, const I_
tr1::shared_ptr<ConstTreeSequence<H_, AllDepSpec> >(new ConstTreeSequence<H_, AllDepSpec>(
tr1::shared_ptr<AllDepSpec>(new AllDepSpec))))), false));
+ std::string arrow_lhs;
PortageDepParserState state(dps_initial);
PortageDepLexer lexer(s);
PortageDepLexer::Iterator i(lexer.begin()), i_end(lexer.end());
@@ -252,11 +306,24 @@ PortageDepParser::_parse(const std::string & s, bool disallow_any_use, const I_
case dpl_whitespace:
continue;
+ case dpl_arrow:
+ throw DepStringParseError(s, "Arrow not allowed here");
+
case dpl_text:
{
if (i->second.empty())
throw DepStringParseError(i->second, "Empty text entry");
- p.template add<H_>(i->second, stack.top().first);
+
+ PortageDepLexer::Iterator i_fwd(next(i));
+ if (i_fwd != i_end && i_fwd->first == dpl_whitespace && ++i_fwd != i_end
+ && i_fwd->first == dpl_arrow)
+ {
+ arrow_lhs = i->second;
+ i = i_fwd;
+ state = dps_had_text_arrow;
+ }
+ else
+ p.template add<H_>(i->second, stack.top().first);
}
continue;
@@ -308,6 +375,7 @@ PortageDepParser::_parse(const std::string & s, bool disallow_any_use, const I_
continue;
case dpl_text:
+ case dpl_arrow:
case dpl_use_flag:
case dpl_double_bar:
case dpl_open_paren:
@@ -334,6 +402,7 @@ PortageDepParser::_parse(const std::string & s, bool disallow_any_use, const I_
case dpl_use_flag:
case dpl_double_bar:
case dpl_close_paren:
+ case dpl_arrow:
throw DepStringParseError(s, "Expected '(' after '|| '");
}
throw InternalError(PALUDIS_HERE,
@@ -355,6 +424,7 @@ PortageDepParser::_parse(const std::string & s, bool disallow_any_use, const I_
case dpl_double_bar:
case dpl_open_paren:
case dpl_close_paren:
+ case dpl_arrow:
throw DepStringParseError(s, "Expected space after '(' or ')'");
}
throw InternalError(PALUDIS_HERE,
@@ -376,6 +446,7 @@ PortageDepParser::_parse(const std::string & s, bool disallow_any_use, const I_
case dpl_double_bar:
case dpl_open_paren:
case dpl_close_paren:
+ case dpl_arrow:
throw DepStringParseError(s, "Expected space after use flag");
}
throw InternalError(PALUDIS_HERE,
@@ -397,12 +468,83 @@ PortageDepParser::_parse(const std::string & s, bool disallow_any_use, const I_
case dpl_use_flag:
case dpl_double_bar:
case dpl_close_paren:
+ case dpl_arrow:
throw DepStringParseError(s, "Expected '(' after use flag");
}
throw InternalError(PALUDIS_HERE,
"dps_had_use_flag_space: i->first is " + stringify(i->first));
} while (0);
continue;
+
+ case dps_had_text_arrow:
+ do
+ {
+ switch (i->first)
+ {
+ case dpl_whitespace:
+ state = dps_had_text_arrow_space;
+ continue;
+
+ case dpl_text:
+ case dpl_open_paren:
+ case dpl_use_flag:
+ case dpl_double_bar:
+ case dpl_close_paren:
+ case dpl_arrow:
+ throw DepStringParseError(s, "Expected whitespace after arrow");
+ }
+ throw InternalError(PALUDIS_HERE,
+ "dps_had_text_arrow: i->first is " + stringify(i->first));
+ } while (0);
+ continue;
+
+ case dps_had_text_arrow_space:
+ do
+ {
+ switch (i->first)
+ {
+ case dpl_whitespace:
+ continue;
+
+ case dpl_text:
+ state = dps_had_text_arrow_text;
+ p.template add_arrow<H_>(arrow_lhs, i->second, stack.top().first);
+ continue;
+
+ case dpl_open_paren:
+ case dpl_use_flag:
+ case dpl_double_bar:
+ case dpl_close_paren:
+ case dpl_arrow:
+ throw DepStringParseError(s, "Expected text after whitespace after arrow");
+ }
+ throw InternalError(PALUDIS_HERE,
+ "dps_had_text_arrow_space: i->first is " + stringify(i->first));
+ } while (0);
+ continue;
+
+ case dps_had_text_arrow_text:
+ do
+ {
+ switch (i->first)
+ {
+ case dpl_whitespace:
+ state = dps_initial;
+ continue;
+
+ case dpl_text:
+ case dpl_open_paren:
+ case dpl_use_flag:
+ case dpl_close_paren:
+ case dpl_double_bar:
+ case dpl_arrow:
+ throw DepStringParseError(s, "Expected whitespace after text after whitespace after arrow");
+ }
+ throw InternalError(PALUDIS_HERE,
+ "dps_had_text_arrow_text: i->first is " + stringify(i->first));
+ }
+ while (0);
+ continue;
}
throw InternalError(PALUDIS_HERE,
"state is " + stringify(state));
@@ -412,6 +554,23 @@ PortageDepParser::_parse(const std::string & s, bool disallow_any_use, const I_
if (stack.empty())
throw DepStringNestingError(s);
+
+ switch (state)
+ {
+ case dps_initial:
+ case dps_had_paren:
+ case dps_had_text_arrow_text:
+ case dps_had_text_arrow_space:
+ break;
+
+ case dps_had_double_bar_space:
+ case dps_had_double_bar:
+ case dps_had_use_flag:
+ case dps_had_use_flag_space:
+ case dps_had_text_arrow:
+ throw DepStringParseError(s, "Unexpected end of string");
+ }
+
tr1::shared_ptr<Composite<H_> > result(stack.top().first);
stack.pop();
if (! stack.empty())
@@ -456,8 +615,8 @@ PortageDepParser::parse_uri(const std::string & s, const EAPI & e)
if (! e.supported)
throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' URIs");
- return _parse<URISpecTree, ParseTextDepSpec, false, true>(s, false,
- ParseTextDepSpec());
+ return _parse<URISpecTree, ParseURIDepSpec, false, true>(s, false,
+ ParseURIDepSpec(e.supported->uri_supports_arrow));
}
tr1::shared_ptr<LicenseSpecTree::ConstItem>
diff --git a/paludis/portage_dep_parser_TEST.cc b/paludis/portage_dep_parser_TEST.cc
index e4c1b62..0164242 100644
--- a/paludis/portage_dep_parser_TEST.cc
+++ b/paludis/portage_dep_parser_TEST.cc
@@ -211,6 +211,25 @@ namespace test_cases
}
} test_dep_spec_parser_inv_use;
+ struct PortageDepParserURITest : TestCase
+ {
+ PortageDepParserURITest() : TestCase("uri") { }
+
+ void run()
+ {
+ DepSpecPrettyPrinter d(0, true);
+ PortageDepParser::parse_uri("a\n->\tb", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
+ TEST_CHECK_EQUAL(stringify(d), "a -> b\n");
+
+ DepSpecPrettyPrinter e(0, true);
+ PortageDepParser::parse_uri("a-> b", EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(e);
+ TEST_CHECK_EQUAL(stringify(e), "a->\nb\n");
+
+ TEST_CHECK_THROWS(PortageDepParser::parse_uri("a -> b",
+ EAPIData::get_instance()->eapi_from_string("0"))->accept(d), DepStringError);
+ }
+ } test_dep_spec_parser_uri;
+
/**
* \test Test PortageDepParser nesting errors.
*
@@ -246,6 +265,12 @@ namespace test_cases
void run()
{
DepSpecPrettyPrinter d(0, false);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend("||",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend("|| ",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_depend("foo?",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(PortageDepParser::parse_depend("!foo? ||",
EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(PortageDepParser::parse_depend("(((",
@@ -254,6 +279,25 @@ namespace test_cases
EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(PortageDepParser::parse_depend("(foo/bar)",
EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_license("a -> b",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+
+ TEST_CHECK_THROWS(PortageDepParser::parse_uri("( -> )",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_uri("( -> )",
+ EAPIData::get_instance()->eapi_from_string("0"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_uri("foo? -> bar",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_uri("a ->",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_uri("a -> ( )",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_uri("a -> )",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_uri("a -> || ( )",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
+ TEST_CHECK_THROWS(PortageDepParser::parse_uri("a -> foo? ( )",
+ EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
}
} test_dep_spec_parser_bad_values;
}
diff --git a/paludis/qa/dep_flags_check.cc b/paludis/qa/dep_flags_check.cc
index 9935684..8c977c6 100644
--- a/paludis/qa/dep_flags_check.cc
+++ b/paludis/qa/dep_flags_check.cc
@@ -116,6 +116,10 @@ namespace
{
}
+ void visit_leaf(const URIDepSpec &)
+ {
+ }
+
void visit_leaf(const BlockDepSpec &)
{
}
diff --git a/paludis/qa/extract_check.cc b/paludis/qa/extract_check.cc
index 633296b..0cca37e 100644
--- a/paludis/qa/extract_check.cc
+++ b/paludis/qa/extract_check.cc
@@ -57,6 +57,10 @@ namespace
need_zip = true;
}
+ void visit_leaf(const URIDepSpec &)
+ {
+ }
+
void visit_leaf(const BlockDepSpec &)
{
}
diff --git a/paludis/qa/homepage_check.cc b/paludis/qa/homepage_check.cc
index 86f3eba..ed4f33c 100644
--- a/paludis/qa/homepage_check.cc
+++ b/paludis/qa/homepage_check.cc
@@ -46,15 +46,18 @@ namespace
{
}
- void visit_leaf(const PlainTextDepSpec & t)
+ void visit_leaf(const URIDepSpec & t)
{
- std::string text(t.text());
+ std::string text(t.original_url());
if (std::string::npos == text.find("http://") &&
std::string::npos == text.find("https://") &&
std::string::npos == text.find("ftp://"))
result << Message(qal_major, "HOMEPAGE part '" + text + "' doesn't look like a URL");
+ if (! t.renamed_url_suffix().empty())
+ result << Message(qal_major, "HOMEPAGE part '" + text + "' uses '->'");
+
found_one = true;
}
};
diff --git a/paludis/qa/src_uri_check.cc b/paludis/qa/src_uri_check.cc
index 63469b5..184906a 100644
--- a/paludis/qa/src_uri_check.cc
+++ b/paludis/qa/src_uri_check.cc
@@ -50,32 +50,32 @@ namespace
{
}
- void visit_leaf(const PlainTextDepSpec & a)
+ void visit_leaf(const URIDepSpec & a)
{
- if (a.text().empty())
+ if (a.original_url().empty())
return;
std::string::size_type p(std::string::npos);
if ((std::string::npos != p) &&
- (("http" != a.text().substr(0, p)) &&
- ("https" != a.text().substr(0, p)) &&
- ("mirror" != a.text().substr(0, p)) &&
- ("ftp" != a.text().substr(0, p))))
- result << Message(qal_major, "Unrecognised protocol for '" + a.text() + "'");
-
- else if ((std::string::npos != a.text().find("dev.gentoo.org")) ||
- (std::string::npos != a.text().find("cvs.gentoo.org")) ||
- (std::string::npos != a.text().find("toucan.gentoo.org")) ||
- (std::string::npos != a.text().find("emu.gentoo.org")) ||
- (std::string::npos != a.text().find("alpha.gnu.org")) ||
- (std::string::npos != a.text().find("geocities.com")))
+ (("http" != a.original_url().substr(0, p)) &&
+ ("https" != a.original_url().substr(0, p)) &&
+ ("mirror" != a.original_url().substr(0, p)) &&
+ ("ftp" != a.original_url().substr(0, p))))
+ result << Message(qal_major, "Unrecognised protocol for '" + a.original_url() + "'");
+
+ else if ((std::string::npos != a.original_url().find("dev.gentoo.org")) ||
+ (std::string::npos != a.original_url().find("cvs.gentoo.org")) ||
+ (std::string::npos != a.original_url().find("toucan.gentoo.org")) ||
+ (std::string::npos != a.original_url().find("emu.gentoo.org")) ||
+ (std::string::npos != a.original_url().find("alpha.gnu.org")) ||
+ (std::string::npos != a.original_url().find("geocities.com")))
result << Message(qal_major, "Unreliable host for '" + a.text() + "'");
else
{
- if (0 == a.text().compare(0, 9, "mirror://"))
+ if (0 == a.original_url().compare(0, 9, "mirror://"))
{
- std::string mirror_host(a.text().substr(9));
+ std::string mirror_host(a.original_url().substr(9));
std::string::size_type pos(mirror_host.find('/'));
if (std::string::npos == pos)
result << Message(qal_major, "Malformed SRC_URI component '" + a.text() + "'");
diff --git a/paludis/repositories/gentoo/ebuild_entries.cc b/paludis/repositories/gentoo/ebuild_entries.cc
index 63cce7b..1f7d7b1 100644
--- a/paludis/repositories/gentoo/ebuild_entries.cc
+++ b/paludis/repositories/gentoo/ebuild_entries.cc
@@ -177,15 +177,15 @@ namespace
public ConstVisitor<URISpecTree>::VisitConstSequence<AAFinder, UseDepSpec>
{
private:
- mutable std::list<const StringDepSpec *> _specs;
+ mutable std::list<const URIDepSpec *> _specs;
public:
- void visit_leaf(const PlainTextDepSpec & a)
+ void visit_leaf(const URIDepSpec & a)
{
_specs.push_back(&a);
}
- typedef std::list<const StringDepSpec *>::const_iterator Iterator;
+ typedef std::list<const URIDepSpec *>::const_iterator Iterator;
Iterator begin()
{
@@ -338,23 +338,28 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
DepSpecFlattener f(_imp->params.environment, &e);
metadata->ebuild_interface->src_uri()->accept(f);
- for (DepSpecFlattener::Iterator ff(f.begin()), ff_end(f.end()) ; ff != ff_end ; ++ff)
+ for (DepSpecFlattener::Iterator i(f.begin()), i_end(f.end()) ; i != i_end ; ++i)
{
- std::string::size_type pos((*ff)->text().rfind('/'));
+ const tr1::shared_ptr<const URIDepSpec> spec(tr1::static_pointer_cast<const URIDepSpec>(*i));
+ if (! spec->renamed_url_suffix().empty())
+ throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ + stringify(v) + "' since it uses SRC_URI arrow components");
+
+ std::string::size_type pos(spec->original_url().rfind('/'));
if (std::string::npos == pos)
{
- if (already_in_archives.end() == already_in_archives.find((*ff)->text()))
+ if (already_in_archives.end() == already_in_archives.find(spec->original_url()))
{
- archives.append((*ff)->text());
- already_in_archives.insert((*ff)->text());
+ archives.append(spec->original_url());
+ already_in_archives.insert(spec->original_url());
}
}
else
{
- if (already_in_archives.end() == already_in_archives.find((*ff)->text().substr(pos + 1)))
+ if (already_in_archives.end() == already_in_archives.find(spec->original_url().substr(pos + 1)))
{
- archives.append((*ff)->text().substr(pos + 1));
- already_in_archives.insert((*ff)->text().substr(pos + 1));
+ archives.append(spec->original_url().substr(pos + 1));
+ already_in_archives.insert(spec->original_url().substr(pos + 1));
}
}
archives.append(" ");
@@ -362,11 +367,11 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
/* add * mirror entries */
tr1::shared_ptr<const MirrorsCollection> star_mirrors(_imp->params.environment->mirrors("*"));
for (MirrorsCollection::Iterator m(star_mirrors->begin()), m_end(star_mirrors->end()) ; m != m_end ; ++m)
- flat_src_uri.append(*m + "/" + (*ff)->text().substr(pos + 1) + " ");
+ flat_src_uri.append(*m + "/" + spec->original_url().substr(pos + 1) + " ");
- if (0 == (*ff)->text().compare(0, 9, "mirror://"))
+ if (0 == spec->original_url().compare(0, 9, "mirror://"))
{
- std::string mirror((*ff)->text().substr(9));
+ std::string mirror(spec->original_url().substr(9));
std::string::size_type spos(mirror.find('/'));
if (std::string::npos == spos)
@@ -390,7 +395,7 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
flat_src_uri.append(m->second + "/" + mirror.substr(spos + 1) + " ");
}
else
- flat_src_uri.append((*ff)->text());
+ flat_src_uri.append(spec->original_url());
flat_src_uri.append(" ");
/* add mirror://gentoo/ entries */
@@ -400,13 +405,13 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
tr1::shared_ptr<const MirrorsCollection> repo_mirrors(_imp->params.environment->mirrors(master_mirror));
for (MirrorsCollection::Iterator m(repo_mirrors->begin()), m_end(repo_mirrors->end()) ; m != m_end ; ++m)
- flat_src_uri.append(*m + "/" + (*ff)->text().substr(pos + 1) + " ");
+ flat_src_uri.append(*m + "/" + spec->original_url().substr(pos + 1) + " ");
for (RepositoryMirrorsInterface::MirrorsIterator
m(_imp->portage_repository->begin_mirrors(master_mirror)),
m_end(_imp->portage_repository->end_mirrors(master_mirror)) ;
m != m_end ; ++m)
- flat_src_uri.append(m->second + "/" + (*ff)->text().substr(pos + 1) + " ");
+ flat_src_uri.append(m->second + "/" + spec->original_url().substr(pos + 1) + " ");
}
}
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 24f7106..1768084 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -313,6 +313,11 @@ namespace
empty = false;
}
+ void visit_leaf(const URIDepSpec &)
+ {
+ empty = false;
+ }
+
void visit_leaf(const PlainTextDepSpec &)
{
empty = false;