"1.2021.7beta4" %version() contains no 0 before patch number 7

0 votes
asked May 23, 2021 in Bug by kirchsth (2,270 points)
edited May 23, 2021 by kirchsth

Based on docu  the the version patch starts with 0 if there is only one patch digit (xxxx.08 not xxxx.8)

%versionReturn PlantUML current version%version()1.2020.08 for example

 but current beta version returns xxxx.7beta instead of xxxx.07beta and a version check  is not possible.

I tested it with "PlantUML Server / version 1202105"

@startuml
Bob -> Alice : hello %version()
@enduml


Thank you and best regards
Helmut

PS.: I checked it with an older version and it returns "1.2021.01"

1 Answer

0 votes
answered May 24, 2021 by plantuml (265,020 points)

Older versions indeed put an extra 0.

But we have decided to normalize this (see https://forum.plantuml.net/13004/why-there-preceding-the-patch-version-reported-version-flag )

We have also updated the documentation.

commented May 24, 2021 by kirchsth (2,270 points)

Ok, I have written a check function "$equalOrGreaterVersion()" which can work with both notations (If somebody needs it).
BR Helmut

!unquoted function $normalizedVersion($ver)
  ' add missing 0 if patch has only one digit
  ' 1.2021.7beta1 -> 1.2021.07beta1
  ' 1.2021.07 -> 1.2021.07
  ' 1.2021.7 -> 1.2021.07

  !local $expDigit2 =%substr($ver,8,1)
  !if ($expDigit2<"0" || $expDigit2>"9")
    !$ver = %substr($ver,0,7) + "0" + %substr($ver,7,10)
  !endif
  !return $ver
!endfunction

!unquoted function $equalOrGreaterVersion($currentVer, $requiredVer)
  ' add z that beta1,... are handled too (1.2021.7z -> 1.2021.07beta1z)
  !$currentVer = $normalizedVersion($currentVer) + "z"
  !$requiredVer = $normalizedVersion($requiredVer) + "z"
  !if ($currentVer >= $requiredVer)
    !return %true()
  !endif
  !return %false()
!endfunction

...