Skip to content

Commit

Permalink
Fix to allow tabs in names when parsing Depends (#56)
Browse files Browse the repository at this point in the history
* Fix to allow tabs in names when parsing Depends

See https://fantom.org/forum/topic/2765
  • Loading branch information
SlimerDude authored Aug 15, 2024
1 parent 8124e15 commit b737d24
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/sys/es/fan/Depend.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class DependParser {

#name() {
let s = ""
while (this.cur != 32) {
while (this.cur != 32 && this.cur != 9) {
if (this.cur < 0) throw new Error();
s += String.fromCharCode(this.cur);
this.consume();
Expand Down
4 changes: 2 additions & 2 deletions src/sys/java/fan/sys/Depend.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Depend parse()
private String name()
{
StringBuilder s = new StringBuilder();
while (cur != ' ')
while (cur != ' ' && cur != '\t')
{
if (cur < 0) throw new RuntimeException();
s.append((char)cur);
Expand Down Expand Up @@ -306,4 +306,4 @@ static class Constraint
private final Constraint[] constraints;
private String str;

}
}
2 changes: 1 addition & 1 deletion src/sys/js/fan/Depend.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fan.sys.DependParser.prototype.parse = function()
fan.sys.DependParser.prototype.$name = function()
{
var s = ""
while (this.m_cur != 32)
while (this.m_cur != 32 && this.m_cur != 9)
{
if (this.m_cur < 0) throw new Error();
s += String.fromCharCode(this.m_cur);
Expand Down
7 changes: 7 additions & 0 deletions src/testSys/fan/DependTest.fan
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ class DependTest : Test
verifyEq(d.isRange, true)
verifyEq(d.endVersion, Version.make([3, 4, 5]))

d = Depend.fromStr("foo\t1.2")
verifyEq(d.toStr, "foo 1.2")
d = Depend.fromStr("foo\t\t\t1.2")
verifyEq(d.toStr, "foo 1.2")
d = Depend.fromStr("foo\t1.2\t-\t3.4.5")
verifyEq(d.toStr, "foo 1.2-3.4.5")

d = Depend.fromStr("foo 1, 1.1.88-2.3, 5+")
verifyEq(d.toStr, "foo 1,1.1.88-2.3,5+")
verifyEq(d.equals(Depend.fromStr("foo 1,1.1.88-2.3,5+")), true)
Expand Down

0 comments on commit b737d24

Please sign in to comment.