changeset 6395:f654b70b6a6e

* tools/makeinst-script.sh.in: compare version string for get latest rather than assume in order
author John Donoghue <john.donoghue@ieee.org>
date Sun, 04 Sep 2022 10:29:13 -0400
parents eb58a62c878e
children e9fc3d04f1dd
files tools/makeinst-script.sh.in
diffstat 1 files changed, 103 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tools/makeinst-script.sh.in	Sat Sep 03 18:33:31 2022 -0400
+++ b/tools/makeinst-script.sh.in	Sun Sep 04 10:29:13 2022 -0400
@@ -276,6 +276,97 @@
 FunctionEnd
 
 ######################################################################
+# function based on code from http://forums.winamp.com/attachment.php?attachmentid=31680&d=1112381115
+
+!macro VersionCompare_ un
+Function \${un}VersionCompare_
+  Exch \$1
+  Exch
+  Exch \$0
+  Exch
+  Push \$2
+  Push \$3
+  Push \$4
+  Push \$5
+  Push \$6
+  Push \$7
+
+begin:
+  StrCpy \$2 -1
+  IntOp \$2 \$2 + 1
+  StrCpy \$3 \$0 1 \$2
+  StrCmp \$3 '' +2
+  StrCmp \$3 '.' 0 -3
+  StrCpy \$4 \$0 \$2
+  IntOp \$2 \$2 + 1
+  StrCpy \$0 \$0 '' \$2
+
+  StrCpy \$2 -1
+  IntOp \$2 \$2 + 1
+  StrCpy \$3 \$1 1 \$2
+  StrCmp \$3 '' +2
+  StrCmp \$3 '.' 0 -3
+  StrCpy \$5 \$1 \$2
+  IntOp \$2 \$2 + 1
+  StrCpy \$1 \$1 '' \$2
+
+  StrCmp \$4\$5 '' equal
+
+  StrCpy \$6 -1
+  IntOp \$6 \$6 + 1
+  StrCpy \$3 \$4 1 \$6
+  StrCmp \$3 '0' -2
+  StrCmp \$3 '' 0 +2
+  StrCpy \$4 0
+
+  StrCpy \$7 -1
+  IntOp \$7 \$7 + 1
+  StrCpy \$3 \$5 1 \$7
+  StrCmp \$3 '0' -2
+  StrCmp \$3 '' 0 +2
+  StrCpy \$5 0
+
+  StrCmp \$4 0 0 +2
+  StrCmp \$5 0 begin newer2
+  StrCmp \$5 0 newer1
+  IntCmp \$6 \$7 0 newer1 newer2
+
+  StrCpy \$4 '1\$4'
+  StrCpy \$5 '1\$5'
+  IntCmp \$4 \$5 begin newer2 newer1
+
+equal:
+  StrCpy \$0 0
+  goto end
+newer1:
+  StrCpy \$0 1
+  goto end
+newer2:
+  StrCpy \$0 2
+
+end:
+  Pop \$7
+  Pop \$6
+  Pop \$5
+  Pop \$4
+  Pop \$3
+  Pop \$2
+  Pop \$1
+  Exch \$0
+FunctionEnd
+!macroend
+
+!insertmacro VersionCompare_ "un."
+!insertmacro VersionCompare_ ""
+
+!macro VersionCompare un _VER1 _VER2 _RESULT
+ Push '\${_VER1}'
+ Push '\${_VER2}'
+ Call \${un}VersionCompare_
+ Pop '\${_RESULT}'
+!macroend
+
+######################################################################
 ; custom options page functions
 
 Var InstallShortcuts
@@ -841,7 +932,9 @@
   Push \$R1
   Push \$R2
   Push \$R3
+  Push \$R4
 
+  StrCpy \$R4 ""
   StrCpy \$R0 ""
   StrCpy \$R1 0
 
@@ -871,11 +964,21 @@
   StrCpy \$R0 \$R2 "" 7
 \${EndIf}
 
+!insertmacro VersionCompare "\${un}" \$R4 \$R0 \$R2
+\${If} \$R2 == 2
+  # new one if bigger - save it
+  StrCpy \$R4 \$R0 
+\${EndIf}
+
 \${un}next_ver_loop:
   IntOp \$R1 \$R1 + 1
   GoTo \${un}octave_ver_loop 
 
 \${un}latest_octave_done:
+  # put result in r0
+  StrCpy \$R0 \$R4
+
+  Pop \$R4
   Pop \$R3
   Pop \$R2
   Pop \$R1