Just published my smallest ever open source project - 1 unit (not counting the

Just published my smallest ever open source project - 1 unit (not counting the
unit tests) https://github.com/VSoftTechnologies/SemanticVersion

A simple Semantic Version 2.0 parser - I needed one, couldn't find one for delphi so I baked my own.

https://github.com/VSoftTechnologies/SemanticVersion

Comments

  1. Some time ago I had to write something similar myself. One question: Why do you call the third digit of the version Release? It's called Patch or Bug version, isn't it?

    ReplyDelete
  2. Good question, I wrote this a while ago as part of a larger project, Ill change it.

    ReplyDelete
  3. seriously ?

    class function TSemanticVersion.IsDigit(const value: Char): boolean;
    const
    digits = ['0'..'9'];
    begin
    result := CharInSet(value,digits);
    end;

    once upon a time, Pascal lets you write value in ['0' .. '9']

    ReplyDelete
  4. So try result := value in digits;

    [dcc32 Warning] VSoft.SemanticVersion.pas(157): W1050 WideChar reduced to byte char in set expressions. Consider using 'CharInSet' function in 'SysUtils' unit.

    This is one of thise things that was introduced with unicode support. I seem to recall in newer versions (than XE7, which I use every day) this has been reversed?

    ReplyDelete
  5. I think you are missing some of the specifics for comparisons for pre-release - see paragraph 11 ("identifiers consisting of only digits are compared numerically and identifiers with letters or hyphens are compared lexically in ASCII sort order" and "Numeric identifiers always have lower precedence than non-numeric identifiers. A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.") - following test fails for example: 1.0.0-beta.2 < 1.0.0-beta.11

    P.S. I am kinda disappointed that despite using DUnitX not using attributes for different version comparisons but write them all down manually in tests like IsGreaterThanEqualTo or IsGreaterThanPreRelease - see this for example: https://github.com/adamreeve/semver.net/blob/master/test/SemVer.Tests/VersionComparison.cs

    ReplyDelete
  6. I'll revisit the comparisons tomorrow. The tests were written with dunit years ago and i did a quicck n dirty conversation

    ReplyDelete
  7. There is also:
    uses System.Character;
    ...
    result := value.IsDigit;

    ReplyDelete
  8. Uwe Raabe what version of delphi was this added in. Wanted to have broad compiper support without having an inc file and ifdefs everywhere

    ReplyDelete
  9. Vincent Parrett As a record helper since XE4, as a class function since D2009.

    ReplyDelete
  10. Uwe Raabe not sure I like the way it is coded against Value in ['0'..'9']...

    ReplyDelete
  11. Paul TOTH Well, at least it works for any Unicode digit (not sure if this is actually needed here):
    fileformat.info - Unicode Characters in the 'Number, Decimal Digit' Category

    ReplyDelete
  12. Uwe Raabe I don't think that telugu or tamil number signs are valid here ;)

    ReplyDelete
  13. Stefan Glienke Pushed some changes today, now comparing the labels correctly (I think), at least it's passing the tests you pointed me to. Also compiles and passes tests on XE2, I don't have any earlier versions installed to test on.

    ReplyDelete

Post a Comment