annotate scripts/strings/strncmpi.m @ 6746:a8105a726e68

[project @ 2007-06-19 08:18:34 by dbateman]
author dbateman
date Tue, 19 Jun 2007 08:18:34 +0000
parents ff5e6cf72bda
children 93c65f2a5668
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:
diff changeset
1 ## Copyright (C) 2000 Bill Lash
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
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 2, or (at your option)
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
8 ## any later version.
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
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
18 ## 02110-1301, USA.
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
19
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefn {Function File} {} strncmpi (@var{s1}, @var{s2}, @var{n})
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
22 ## 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
23 ## 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
24 ##
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
25 ## 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
26 ## 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
27 ## 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
28 ## 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
29 ## or character string.
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
30 ##
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
31 ## @strong{Caution:} For compatibility with @sc{Matlab}, Octave's strncmpi
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
32 ## 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
33 ## 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
34 ## @seealso{strcmp, strcmpi, strncmp}
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
35 ## @end deftypefn
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
36
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
37 function retval = strncmpi (s1, s2, n)
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
38
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
39 if (nargin == 3)
5676
9c9eac3a6513 [project @ 2006-03-16 04:09:07 by jwe]
jwe
parents: 5674
diff changeset
40 ## 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
41 ## handle cell arrays of strings.
6250
ff5e6cf72bda [project @ 2007-01-23 18:37:52 by jwe]
jwe
parents: 6046
diff changeset
42 retval = strncmp (lower (s1), lower (s2), n);
5674
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
43 else
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5676
diff changeset
44 print_usage ();
5674
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
45 endif
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
46
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
47 endfunction