char *original = s1;
/* Find the end of s1. */
- while (*s1 != 0) s1++;
+ while (*s1++ != 0) ;
+ s1--;
/* Now copy s2 to the end of s1. */
while (*s1++ = *s2++) /* nothing */ ;
return(original);
/* $Header$ */
-int strcmp(s1, s2)
-register char *s1, *s2;
+int
+strcmp(s, t)
+ register char *s, *t;
{
-/* Compare 2 strings. */
-
- for(;;) {
- if (*s1 != *s2) {
- if (!*s1) return -1;
- if (!*s2) return 1;
- return(*s1 - *s2);
- }
- if (*s1++ == 0) return(0);
- s2++;
- }
+ while (*s == *t++)
+ if (*s++ == '\0')
+ return 0;
+ return *s - *--t;
}
/* $Header$ */
-int strlen(s)
-char *s;
+int
+strlen(s)
+ char *s;
{
-/* Return length of s. */
+ register char *b = s;
- char *original = s;
-
- while (*s != 0) s++;
- return(s - original);
+ while (*b++)
+ ;
+ return b - s - 1;
}
if (n <= 0) return(s1);
/* Find the end of s1. */
- while (*s1 != 0) s1++;
+ while (*s1++ != 0) ;
+
+ s1--;
/* Now copy s2 to the end of s1. */
while (*s1++ = *s2++) {
/* $Header$ */
int
-strncmp(s1, s2, n)
- register char *s1, *s2;
- int n;
+strncmp(s, t, n)
+ register char *s, *t;
+ register int n;
{
-/* Compare two strings, but at most n characters. */
-
- while (n-- > 0) {
- if (*s1 != *s2) {
- if (!*s1) return -1;
- if (!*s2) return 1;
- return(*s1 - *s2);
+ while (n-- > 0) {
+ if (*s == *t++) {
+ if (*s++ == '\0')
+ return 0;
+ }
+ else
+ return *s - *--t;
}
- if (*s1++ == 0) break;
- s2++;
- }
- return 0;
+ return 0;
}