Mercurial > hg > octave-nkf
annotate scripts/strings/strncmpi.m @ 9051:1bf0ce0930be
Grammar check TexInfo in all .m files
Cleanup documentation sources to follow a few consistent rules.
Spellcheck was NOT done. (but will be in another changeset)
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Fri, 27 Mar 2009 22:31:03 -0700 |
parents | eb63fbe60fab |
children |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2000, 2006, 2007, 2009 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 | |
8442
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
22 ## strings (or character arrays) @var{s1} and @var{s2} are the same, and |
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
23 ## 0 otherwise. |
5674 | 24 ## |
25 ## If either @var{s1} or @var{s2} is a cell array of strings, then an array | |
26 ## of the same size is returned, containing the values described above for | |
8442
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
27 ## every member of the cell array. The other argument may also be a cell |
5674 | 28 ## array of strings (of the same size or with only one element), char matrix |
29 ## or character string. | |
30 ## | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
31 ## @strong{Caution:} For compatibility with @sc{matlab}, Octave's strncmpi |
5674 | 32 ## function returns 1 if the character strings are equal, and 0 otherwise. |
33 ## This is just the opposite of the corresponding C library function. | |
34 ## @seealso{strcmp, strcmpi, strncmp} | |
35 ## @end deftypefn | |
36 | |
37 function retval = strncmpi (s1, s2, n) | |
38 | |
39 if (nargin == 3) | |
5676 | 40 ## Note that we don't use tolower here because we need to be able to |
41 ## handle cell arrays of strings. | |
6250 | 42 retval = strncmp (lower (s1), lower (s2), n); |
5674 | 43 else |
6046 | 44 print_usage (); |
5674 | 45 endif |
46 | |
47 endfunction | |
8442
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
48 |
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
49 %!assert (strncmpi("abc123", "ABC456", 3), logical(1)); |