summaryrefslogtreecommitdiff
path: root/lib/libF77/s_cmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libF77/s_cmp.c')
-rw-r--r--lib/libF77/s_cmp.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/libF77/s_cmp.c b/lib/libF77/s_cmp.c
new file mode 100644
index 000000000000..9e4c12619a2f
--- /dev/null
+++ b/lib/libF77/s_cmp.c
@@ -0,0 +1,42 @@
+#include "f2c.h"
+
+/* compare two strings */
+
+#ifdef KR_headers
+integer s_cmp(a, b, la, lb) register char *a, *b; ftnlen la, lb;
+#else
+integer s_cmp(register char *a, register char *b, ftnlen la, ftnlen lb)
+#endif
+{
+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);
+}