4
|
1 function status = strcmp (s1, s2) |
|
2 |
|
3 # usage: strcmp (s1, s2) |
|
4 # |
|
5 # Compare two strings. |
|
6 # |
|
7 # WARNING: Unlike the C function of the same name, this function |
|
8 # returns 1 for equal and zero for not equal. Why? To be compatible |
|
9 # with Matlab, of course. |
|
10 |
|
11 if (nargin != 2) |
|
12 error ("usage: strcmp (s, t)"); |
|
13 endif |
|
14 |
|
15 status = 0; |
|
16 if (isstr (s1) && isstr(s2) && length (s1) == length (s2)) |
|
17 tmp = implicit_str_to_num_ok; |
|
18 implicit_str_to_num_ok = "true"; |
|
19 status = all (s1 == s2); |
|
20 implicit_str_to_num_ok = tmp; |
|
21 endif |
|
22 |
|
23 endfunction |