Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### VersChk.tcl 1.5.0 mQARWRMG
- #REQUIREMENTS
- # PBinSrc.tcl fMrtKqyq
- #LICENSE
- # Copyright © 2013 Alberto Dietze "DoctorD90"
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- # Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
- #PATERNITY
- #Coder: DoctorD90
- #Network: irc.OnlineGamesNet.net
- #Chan: #eHito
- #Mail: [email protected]
- #PURPOSE
- #Compare 2 versions number made up of theorically infinity numbers, and know if 2nd is newer/older/equal than 1st basing
- #to used proc.
- #USAGE
- #Split versions numbers in lists of
- #elements (ex. 1.0.0 -> [split "1.0.0" "."]).
- #To know if 2nd is newer than 1st use [vers_newer v1st v2nd]. If it is, it returns 1.
- #To know if 2nd is older than 1st use [vers_older v1st v2nd]. If it is, it returns 1.
- #To know if 2nd is equal than 1st use [vers_equer v1st v2nd]. If it is, it returns 1.
- ### DON'T EDIT ANYTHING BELOW ###
- proc vers_newer {v1 v2} {
- return [vers_chker $v1 $v2]
- }
- proc vers_older {v1 v2} {
- return [vers_chker $v2 $v1]
- }
- proc vers_equer {v1 v2} {
- set s 0
- if {![vers_chker $v1 $v2] && ![vers_chker $v2 $v1]} {
- set s 1
- }
- return $s
- }
- proc vers_chker {v1 v2} {
- set l1 [llength $v1]
- set l2 [llength $v2]
- if {$l1 > $l2} {
- set l $l1
- while {$l != $l2} {
- lappend v2 0
- incr l2
- }
- } else {
- set l $l2
- while {$l != $l1} {
- lappend v1 0
- incr l1
- }
- }
- set s 0
- set n 0
- while {!$s && $l > $n} {
- if {[lindex $v2 $n] > [lindex $v1 $n]} { set s 1 }
- incr n
- }
- return $s
- }
- ###
- putlog "VersChk.tcl LOADED"
Advertisement