7017
|
1 ## Copyright (C) 2000, 2005, 2006, 2007 Bill Lash |
5185
|
2 ## |
5186
|
3 ## This file is part of Octave. |
5185
|
4 ## |
5186
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
5186
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
5185
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
5185
|
18 |
5186
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} strcmpi (@var{s1}, @var{s2}) |
5674
|
21 ## Ignoring case, return 1 if the character strings @var{s1} and @var{s2} |
|
22 ## are the same, and 0 otherwise. |
5185
|
23 ## |
5674
|
24 ## If either @var{s1} or @var{s2} is a cell array of strings, then an array |
|
25 ## of the same size is returned, containing the values described above for |
|
26 ## every member of the cell array. The other argument may also be a cell |
|
27 ## array of strings (of the same size or with only one element), char matrix |
|
28 ## or character string. |
|
29 ## |
|
30 ## @strong{Caution:} For compatibility with @sc{Matlab}, Octave's strcmpi |
|
31 ## function returns 1 if the character strings are equal, and 0 otherwise. |
|
32 ## This is just the opposite of the corresponding C library function. |
|
33 ## @seealso{strcmp, strncmp, strncmpi} |
5186
|
34 ## @end deftypefn |
5185
|
35 |
|
36 ## Author: Bill Lash <lash@tellabs.com> |
5186
|
37 ## Adapted-by: jwe |
5185
|
38 |
5674
|
39 function retval = strcmpi (s1, s2) |
5185
|
40 |
5186
|
41 if (nargin == 2) |
5762
|
42 if ((ischar(s1) || iscellstr(s1)) && (ischar(s2) || iscellstr(s2))) |
|
43 ## Note that we don't use tolower here because we need to be able |
|
44 ## to handle cell arrays of strings. |
|
45 retval = strcmp (lower (s1), lower (s2)); |
|
46 else |
|
47 retval = false; |
|
48 endif |
5186
|
49 else |
6046
|
50 print_usage (); |
5185
|
51 endif |
|
52 |
|
53 endfunction |