7017
|
1 ## Copyright (C) 2000, 2006, 2007 Bill Lash |
5674
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
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. |
5674
|
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. |
|
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/>. |
5674
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} strncmpi (@var{s1}, @var{s2}, @var{n}) |
|
21 ## Ignoring case, return 1 if the first @var{n} characters of character |
|
22 ## strings @var{s1} and @var{s2} are the same, and 0 otherwise. |
|
23 ## |
|
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 strncmpi |
|
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, strcmpi, strncmp} |
|
34 ## @end deftypefn |
|
35 |
|
36 function retval = strncmpi (s1, s2, n) |
|
37 |
|
38 if (nargin == 3) |
5676
|
39 ## Note that we don't use tolower here because we need to be able to |
|
40 ## handle cell arrays of strings. |
6250
|
41 retval = strncmp (lower (s1), lower (s2), n); |
5674
|
42 else |
6046
|
43 print_usage (); |
5674
|
44 endif |
|
45 |
|
46 endfunction |