annotate scripts/strings/strcmpi.m @ 7016:93c65f2a5668

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