aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2009-03-20 01:23:12 +0100
committerAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2009-03-20 01:31:04 +0100
commite025e1b8be908dccb561b4e11e426ac84f3f5561 (patch)
tree25e47e7b0883fda807e8ce092e76094913f4a891
parentbd997cad023cd799551a1c2e7463e2006ae26b46 (diff)
downloadpaludis-e025e1b8be908dccb561b4e11e426ac84f3f5561.tar.gz
paludis-e025e1b8be908dccb561b4e11e426ac84f3f5561.tar.xz
ever: Rather than being a number, the index parameter can be a separator...
... such as '-', '.', '_'. In this case, the first separator of this kind is selected.
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_ever_setup.sh6
-rw-r--r--paludis/repositories/e/pipe_command_handler.cc64
2 files changed, 53 insertions, 17 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_ever_setup.sh b/paludis/repositories/e/e_repository_TEST_ever_setup.sh
index c412b62..de5b5ff 100755
--- a/paludis/repositories/e/e_repository_TEST_ever_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_ever_setup.sh
@@ -198,6 +198,9 @@ pkg_setup() {
check "2" _ "1-scm" "1-scm"
check "3" _ "1_beta2" "1_beta2"
check "99" . "1.2.3-r4" "1.2.3-r4"
+ check "-" . "1.2-scm-r1" "1.2.scm-r1"
+ check "_" - "1.2.3_alpha1" "1.2.3-alpha1"
+ check "." - "1.2.3_alpha1" "1-2.3_alpha1"
}
END
mkdir -p "packages/cat/ever-replace_all"
@@ -242,6 +245,9 @@ pkg_setup() {
check 2 "1.2.3" "1.23"
check 3 "1.2.3" "1.2.3"
check 1 "1_beta2-try3" "1beta2-try3"
+ check "-" "1.2-scm-r1" "1.2scm-r1"
+ check "." "1.2.3_alpha1" "12.3_alpha1"
+ check "_" "1.2.3_alpha1" "1.2.3alpha1"
}
END
mkdir -p "packages/cat/ever-delete_all"
diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc
index 5053ec0..f2892c2 100644
--- a/paludis/repositories/e/pipe_command_handler.cc
+++ b/paludis/repositories/e/pipe_command_handler.cc
@@ -480,35 +480,65 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
VersionSpec v(tokens[5]);
int current_pos(0);
- int replace_pos(destringify<int>(tokens[3]));
std::string replacement(tokens[4]);
std::string result;
- for (VersionSpec::ConstIterator c(v.begin()), c_end(v.end()) ;
- c != c_end ; ++c)
+ switch (tokens[3].at(0))
{
- if (c->text().empty())
- continue;
+ case '.':
+ case '-':
+ case '_':
+ {
+ bool replacing_done(false);
+ char replace_separator(tokens[3].at(0));
- switch (c->text().at(0))
- {
- case '.':
- case '-':
- case '_':
+ for (VersionSpec::ConstIterator c(v.begin()), c_end(v.end()) ;
+ c != c_end ; ++c)
{
- if (current_pos == replace_pos)
+ if (c->text().empty())
+ continue;
+
+ if (! replacing_done && replace_separator == c->text().at(0))
+ {
result.append(replacement + c->text().substr(1));
+ replacing_done = true;
+ }
else
result.append(c->text());
}
- break;
+ }
+ break;
- default:
- result.append(c->text());
- break;
- }
+ default:
+ int replace_pos(destringify<int>(tokens[3]));
- ++current_pos;
+ for (VersionSpec::ConstIterator c(v.begin()), c_end(v.end()) ;
+ c != c_end ; ++c)
+ {
+ if (c->text().empty())
+ continue;
+
+ switch (c->text().at(0))
+ {
+ case '.':
+ case '-':
+ case '_':
+ {
+ if (current_pos == replace_pos)
+ result.append(replacement + c->text().substr(1));
+ else
+ result.append(c->text());
+ }
+ break;
+
+ default:
+ result.append(c->text());
+ break;
+ }
+
+ ++current_pos;
+ }
+ break;
}
return "O0;" + result;