speeded up a bit
This commit is contained in:
parent
b1626ca895
commit
5187e46404
5 changed files with 30 additions and 36 deletions
|
@ -7,8 +7,9 @@ register char *s1, *s2;
|
||||||
char *original = s1;
|
char *original = s1;
|
||||||
|
|
||||||
/* Find the end of s1. */
|
/* Find the end of s1. */
|
||||||
while (*s1 != 0) s1++;
|
while (*s1++ != 0) ;
|
||||||
|
|
||||||
|
s1--;
|
||||||
/* Now copy s2 to the end of s1. */
|
/* Now copy s2 to the end of s1. */
|
||||||
while (*s1++ = *s2++) /* nothing */ ;
|
while (*s1++ = *s2++) /* nothing */ ;
|
||||||
return(original);
|
return(original);
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
int strcmp(s1, s2)
|
int
|
||||||
register char *s1, *s2;
|
strcmp(s, t)
|
||||||
|
register char *s, *t;
|
||||||
{
|
{
|
||||||
/* Compare 2 strings. */
|
while (*s == *t++)
|
||||||
|
if (*s++ == '\0')
|
||||||
for(;;) {
|
return 0;
|
||||||
if (*s1 != *s2) {
|
return *s - *--t;
|
||||||
if (!*s1) return -1;
|
|
||||||
if (!*s2) return 1;
|
|
||||||
return(*s1 - *s2);
|
|
||||||
}
|
|
||||||
if (*s1++ == 0) return(0);
|
|
||||||
s2++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
int strlen(s)
|
int
|
||||||
|
strlen(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
/* Return length of s. */
|
register char *b = s;
|
||||||
|
|
||||||
char *original = s;
|
while (*b++)
|
||||||
|
;
|
||||||
while (*s != 0) s++;
|
return b - s - 1;
|
||||||
return(s - original);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,9 @@ int n;
|
||||||
if (n <= 0) return(s1);
|
if (n <= 0) return(s1);
|
||||||
|
|
||||||
/* Find the end of s1. */
|
/* Find the end of s1. */
|
||||||
while (*s1 != 0) s1++;
|
while (*s1++ != 0) ;
|
||||||
|
|
||||||
|
s1--;
|
||||||
|
|
||||||
/* Now copy s2 to the end of s1. */
|
/* Now copy s2 to the end of s1. */
|
||||||
while (*s1++ = *s2++) {
|
while (*s1++ = *s2++) {
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
int
|
int
|
||||||
strncmp(s1, s2, n)
|
strncmp(s, t, n)
|
||||||
register char *s1, *s2;
|
register char *s, *t;
|
||||||
int n;
|
register int n;
|
||||||
{
|
{
|
||||||
/* Compare two strings, but at most n characters. */
|
|
||||||
|
|
||||||
while (n-- > 0) {
|
while (n-- > 0) {
|
||||||
if (*s1 != *s2) {
|
if (*s == *t++) {
|
||||||
if (!*s1) return -1;
|
if (*s++ == '\0')
|
||||||
if (!*s2) return 1;
|
return 0;
|
||||||
return(*s1 - *s2);
|
|
||||||
}
|
}
|
||||||
if (*s1++ == 0) break;
|
else
|
||||||
s2++;
|
return *s - *--t;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue