diff --git a/prism/src/prism/Prism.java b/prism/src/prism/Prism.java index 9bdc1ca7..431ade4a 100644 --- a/prism/src/prism/Prism.java +++ b/prism/src/prism/Prism.java @@ -450,6 +450,76 @@ public class Prism implements PrismSettingsListener } } + // Compare two version numbers of PRISM (strings) + // Returns: 1 if v1>v2, -1 if v1 s2) ? 1 : -1; + } + else return -1; + } + if (ss2[i].matches("beta.*")) return 1; + // 2 < 2.1, etc. + if (ss1[i].equals("")) { if (ss2[i].equals("")) return 0; else return -1; } + if (ss2[i].equals("")) return 1; + // 2.1 < 2.1.dev, etc. + if (ss1[i].matches("dev.*")) { + if (ss2[i].matches("dev.*")) { + // 2.1.dev < 2.1.dev2 < 2.1.dev3, etc. + try { if (ss1[i].length() == 3) s1 = 0; else s1 = Integer.parseInt(ss1[i].substring(3)); } catch (NumberFormatException e) { return 0; } + try { if (ss2[i].length() == 3) s2 = 0; else s2 = Integer.parseInt(ss2[i].substring(3)); } catch (NumberFormatException e) { return 0; } + if (s1 == s2) return 0; else return (s1 > s2) ? 1 : -1; + } + else return -1; + } + if (ss2[i].matches("dev.*")) return 1; + // See if strings are integers + try { s1num = true; s1 = Integer.parseInt(ss1[i]); } catch (NumberFormatException e) { s1num = false; } + try { s2num = true; s2 = Integer.parseInt(ss2[i]); } catch (NumberFormatException e) { s2num = false; } + // 2.5 < 3.1, etc. + if (s1num && s2num) { + if (s1 < s2) return -1; + if (s1 > s2) return 1; + if (s1 == s2) continue; + } + } + + return 0; + } + // initialise public void initialise() throws PrismException