Mercurial > octave-nkf
comparison scripts/miscellaneous/compare_versions.m @ 7125:f084ba47812b
[project @ 2007-11-08 02:29:23 by jwe]
author | jwe |
---|---|
date | Thu, 08 Nov 2007 02:29:24 +0000 |
parents | c76471cc72d1 |
children | aeeb646f6538 |
comparison
equal
deleted
inserted
replaced
7124:d07cb867891b | 7125:f084ba47812b |
---|---|
67 | 67 |
68 ## TODO?: This allows a single equal sign "=" to indicate equality, do | 68 ## TODO?: This allows a single equal sign "=" to indicate equality, do |
69 ## we want to require a double equal since that is the boolean operator? | 69 ## we want to require a double equal since that is the boolean operator? |
70 | 70 |
71 function out = compare_versions (v1, v2, operator) | 71 function out = compare_versions (v1, v2, operator) |
72 | |
73 if (nargin != 3) | |
74 print_usage (); | |
75 endif | |
72 | 76 |
73 ## Make sure that the version numbers are valid. | 77 ## Make sure that the version numbers are valid. |
74 if (! (ischar (v1) && ischar (v2))) | 78 if (! (ischar (v1) && ischar (v2))) |
75 error ("compare_versions: both version numbers must be strings"); | 79 error ("compare_versions: both version numbers must be strings"); |
76 elseif (size (v1, 1) != 1 || size (v2, 1) != 1) | 80 elseif (size (v1, 1) != 1 || size (v2, 1) != 1) |
182 out = false; | 186 out = false; |
183 endif | 187 endif |
184 | 188 |
185 ## Reverse the output if not is given. | 189 ## Reverse the output if not is given. |
186 out = xor (not_op, out); | 190 out = xor (not_op, out); |
191 | |
187 endfunction | 192 endfunction |
188 | 193 |
189 ## tests | 194 ## tests |
190 ## test both equality symbols | 195 ## test both equality symbols |
191 %!assert(compare_versions("1", "1", "="), true) | 196 %!assert(compare_versions("1", "1", "="), true) |