annotate scripts/strings/strncmpi.m @ 5674:86adc85cc471

[project @ 2006-03-16 03:46:45 by jwe]
author jwe
date Thu, 16 Mar 2006 03:46:45 +0000
parents
children 9c9eac3a6513
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)
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
40 retval = strcmp (tolower (strtrunc (s1, n)), tolower (strtrunc (s2, n)));
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
41 else
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
42 usage ("strncmpi (s1, s2, n)");
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
43 endif
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
44
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents:
diff changeset
45 endfunction