annotate scripts/strings/strncmpi.m @ 7110:0e63f1126f01

[project @ 2007-11-06 22:36:22 by jwe]
author jwe
date Tue, 06 Nov 2007 22:36:22 +0000
parents a1dbe9d80eee
children 502e58a0d44f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 2000, 2006, 2007 Bill Lash
5674
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
2 ##
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
4 ##
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
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: 6250
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: 6250
diff changeset
8 ## your option) any later version.
5674
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
9 ##
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
14 ##
86adc85cc471 [project @ 2006-03-16 03:46:45 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: 6250
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: 6250
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5674
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
18
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
20 ## @deftypefn {Function File} {} strncmpi (@var{s1}, @var{s2}, @var{n})
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
21 ## Ignoring case, return 1 if the first @var{n} characters of character
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
22 ## strings @var{s1} and @var{s2} are the same, and 0 otherwise.
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
23 ##
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
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:
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:
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:
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:
diff changeset
28 ## or character string.
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
29 ##
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
30 ## @strong{Caution:} For compatibility with @sc{Matlab}, Octave's strncmpi
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
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:
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:
diff changeset
33 ## @seealso{strcmp, strcmpi, strncmp}
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
34 ## @end deftypefn
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
35
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
36 function retval = strncmpi (s1, s2, n)
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
37
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
38 if (nargin == 3)
5676
9c9eac3a6513 [project @ 2006-03-16 04:09:07 by jwe]
jwe
parents: 5674
diff changeset
39 ## Note that we don't use tolower here because we need to be able to
9c9eac3a6513 [project @ 2006-03-16 04:09:07 by jwe]
jwe
parents: 5674
diff changeset
40 ## handle cell arrays of strings.
6250
ff5e6cf72bda [project @ 2007-01-23 18:37:52 by jwe]
jwe
parents: 6046
diff changeset
41 retval = strncmp (lower (s1), lower (s2), n);
5674
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
42 else
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5676
diff changeset
43 print_usage ();
5674
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
44 endif
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
45
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
46 endfunction