date and time created 83/01/21 11:18:53 by dlw
authorDavid Wasley <dlw@ucbvax.Berkeley.EDU>
Sat, 22 Jan 1983 03:18:53 +0000 (19:18 -0800)
committerDavid Wasley <dlw@ucbvax.Berkeley.EDU>
Sat, 22 Jan 1983 03:18:53 +0000 (19:18 -0800)
SCCS-vsn: usr.bin/f77/libF77/s_cmp.c 1.1

usr/src/usr.bin/f77/libF77/s_cmp.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/f77/libF77/s_cmp.c b/usr/src/usr.bin/f77/libF77/s_cmp.c
new file mode 100644 (file)
index 0000000..249cce0
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *     "@(#)s_cmp.c    1.1"
+ */
+
+int s_cmp(a, b, la, lb)        /* compare two strings */
+register char *a, *b;
+long int la, lb;
+{
+register char *aend, *bend;
+aend = a + la;
+bend = b + lb;
+
+if(la <= lb)
+       {
+       while(a < aend)
+               if(*a != *b)
+                       return( *a - *b );
+               else
+                       { ++a; ++b; }
+
+       while(b < bend)
+               if(*b != ' ')
+                       return( ' ' - *b );
+               else    ++b;
+       }
+
+else
+       {
+       while(b < bend)
+               if(*a == *b)
+                       { ++a; ++b; }
+               else
+                       return( *a - *b );
+       while(a < aend)
+               if(*a != ' ')
+                       return(*a - ' ');
+               else    ++a;
+       }
+return(0);
+}