annotate scripts/strings/strncmp.m @ 6210:12b676a0b183 before-graphics-branch

[project @ 2006-12-07 02:37:17 by jwe]
author jwe
date Thu, 07 Dec 2006 02:37:17 +0000
parents 34f96dd5441b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5372
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 1996, 1997 John W. Eaton
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
2 ##
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
4 ##
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 2, or (at your option)
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
8 ## any later version.
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
9 ##
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
14 ##
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
18 ## 02110-1301, USA.
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
19
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefn {Function File} {} strncmp (@var{s1}, @var{s2}, @var{n})
5674
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents: 5443
diff changeset
22 ## Return 1 if the first @var{n} characters of character strings @var{s1}
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents: 5443
diff changeset
23 ## and @var{s2} are the same, and 0 otherwise.
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents: 5443
diff changeset
24 ##
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents: 5443
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: 5443
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: 5443
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: 5443
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: 5443
diff changeset
29 ## or character string.
5372
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
30 ##
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
31 ## @strong{Caution:} For compatibility with @sc{Matlab}, Octave's strncmp
5674
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents: 5443
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: 5443
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: 5443
diff changeset
34 ## @seealso{strcmp, strcmpi, strncmpi}
5372
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
35 ## @end deftypefn
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
36
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
37 function retval = strncmp (s1, s2, n)
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
38
5674
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents: 5443
diff changeset
39 if (nargin == 3)
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents: 5443
diff changeset
40 retval = strcmp (strtrunc (s1, n), strtrunc (s2, n));
86adc85cc471 [project @ 2006-03-16 03:46:45 by jwe]
jwe
parents: 5443
diff changeset
41 else
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5674
diff changeset
42 print_usage ();
5372
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
43 endif
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
44
b4485a3ce01b [project @ 2005-05-24 15:36:45 by jwe]
jwe
parents:
diff changeset
45 endfunction