Hi, could we allow Depend strings to contain tabs?
Depend
It is natural to want to use tabs when aligning dependencies in build.fan:
build.fan
depends = [ // ---- Fantom Core ----------------- "sys 1.0.70 - 1.0", "concurrent 1.0.70 - 1.0", "web 1.0.70 - 1.0", "dom 1.0.70 - 1.0", "domkit 1.0.70 - 1.0", ]
I know a few people who, after updating their build.fan, have been scratching their heads thinking the ParseErr refers to the versioning part.
ParseErr
The following patch shows the change should be pretty minor:
diff -r 52185c6ba69c src/sys/java/fan/sys/Depend.java --- a/src/sys/java/fan/sys/Depend.java Mon Aug 05 12:19:22 2019 -0400 +++ b/src/sys/java/fan/sys/Depend.java Tue Aug 06 19:45:04 2019 +0100 @@ -136,7 +136,7 @@ private void consumeSpaces() { - while (cur == ' ') consume(); + while (cur == ' ' || cur == '\t') consume(); } diff -r 52185c6ba69c src/sys/js/fan/Depend.js --- a/src/sys/js/fan/Depend.js Mon Aug 05 12:19:22 2019 -0400 +++ b/src/sys/js/fan/Depend.js Tue Aug 06 19:45:04 2019 +0100 @@ -270,7 +270,7 @@ fan.sys.DependParser.prototype.consumeSpaces = function() { - while (this.m_cur == 32) this.consume(); + while (this.m_cur == 32 || this.m_cur == 9) this.consume(); } diff -r 52185c6ba69c src/testSys/fan/DependTest.fan --- a/src/testSys/fan/DependTest.fan Mon Aug 05 12:19:22 2019 -0400 +++ b/src/testSys/fan/DependTest.fan Tue Aug 06 19:45:04 2019 +0100 @@ -107,6 +107,9 @@ verifyErr(ParseErr#) { x := Depend.fromStr(" 8") } verifyErr(ParseErr#) { x := Depend.fromStr(" foo 0") } verifyErr(ParseErr#) { x := Depend.fromStr("foo\n1.8") } + + d = Depend.fromStr("foo\t\t\t1.2") + verifyEq(d.toStr, "foo 1.2") }
I pushed that change
Ah, looks like the change didn't completely work. :'(
Fantom Shell v1.0.80 ('?' for help) fansh> Depend("sys\t1.0") sys::ParseErr: Invalid Depend: 'sys 1.0' fan.sys.Depend.fromStr (Depend.java:33) fan.sys.Depend.fromStr (Depend.java:23)
Revisiting this, I believe the name parsing just needs to be updated to ignore tabs.
For example, update Depend.java L73 from:
while (cur != ' ') { ... }
To:
while (cur != ' ' && cur != '\t') { ... }
Looks like a simple fix - can you want to send us a pull request with that change in the three different versions (es, js, and Java)
Sure, see GitHub here
Login or Signup to reply.
SlimerDude Tue 6 Aug 2019
Hi, could we allow
Depend
strings to contain tabs?It is natural to want to use tabs when aligning dependencies in
build.fan
:I know a few people who, after updating their build.fan, have been scratching their heads thinking the
ParseErr
refers to the versioning part.The following patch shows the change should be pretty minor:
brian Tue 6 Aug 2019
I pushed that change
SlimerDude Wed 14 Aug
Ah, looks like the change didn't completely work. :'(
Revisiting this, I believe the name parsing just needs to be updated to ignore tabs.
For example, update Depend.java L73 from:
To:
brian Wed 14 Aug
Looks like a simple fix - can you want to send us a pull request with that change in the three different versions (es, js, and Java)
SlimerDude Thu 15 Aug
Sure, see GitHub here