changeset 2265:ea22c725914d

[project @ 1996-05-23 20:17:52 by jwe]
author jwe
date Thu, 23 May 1996 20:18:28 +0000
parents e9702bdc22e2
children 68c75296c582
files scripts/strings/strcmp.m
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/strings/strcmp.m	Thu May 23 20:04:22 1996 +0000
+++ b/scripts/strings/strcmp.m	Thu May 23 20:18:28 1996 +0000
@@ -20,11 +20,15 @@
 
 # usage: strcmp (s1, s2)
 #
-# Compare two strings.
+# Compare two strings.  Trailing blanks are significant.
 #
 # WARNING:  Unlike the C function of the same name, this function
 # returns 1 for equal and zero for not equal.  Why?  To be compatible
 # with Matlab, of course. 
+#
+# Why doesn't this always return a scalar instead of vector with
+# elements corresponding to the rows of the string array?  To be
+# compatible with Matlab, of course. 
 
   if (nargin != 2)
     usage ("strcmp (s, t)");
@@ -32,13 +36,13 @@
 
   status = 0;
   if (isstr (s1) && isstr(s2))
-    len_s1 = columns (s1);
-    len_s2 = columns (s2);
-    if (len_s1 == len_s2)
-      if (len_s1 == 0)
+    c1 = columns (s1);
+    c2 = columns (s2);
+    if (c1 == c2)
+      if (c1 == 0)
         status = 1;
       else
-        status = all (s1 == s2);
+        status = all (all (s1 == s2));
       endif
     endif
   endif