#include <stdio.h>
#include <string.h>

char *
strdup(str)
#if defined(AIX) || defined(ultrix)
	char *str;
#else
        const char *str;
#endif
{
        size_t len;
        char *copy;

	if (str==NULL)   /* This shouldn't happen.. but it does...  */ {
		if (!(copy = (char *)malloc(1)))
			return((char *)NULL);
		*copy=NULL;
		return(copy);
	}
        len = strlen(str) + 1;
        if (!(copy = (char *)malloc(len)))
                return((char *)NULL);
        memcpy(copy, str, len);
        return(copy);
}


int
strcmp(s1, s2)
#if defined(AIX) || defined(ultrix)
	char *s1, *s2;
#else
        register const char *s1, *s2;
#endif
{
/* Up to the while loop, this is normally extraneous.. but I've seen a few broken
   strcmp's in the coredumps....
*/
	if (s1 == NULL)
		if (s2 == NULL)
			return (0);
		else
			return (1);
	else
		if (s2 == NULL)
			return (-1);
		else{
			while (*s1 == *s2++)
				if (*s1++ == 0)
					return (0);
			return (*(unsigned char *)s1 - *(unsigned char *)--s2);
		}
}
