/* * s t r c m p . c */ /*)LIBRARY */ #ifdef DOCUMENTATION title strcmp String Compare index String compare synopsis .s.nf int strcmp(s1, s2); char *s1; char *s2; .s.f Description Compare two strings, returning -1 if s1 < s2 0 if s1 == s2 +1 if s1 > s2 Bugs #endif #define EOS 0 int strcmp(s1, s2) register char *s1; register char *s2; /* * Compare two strings. */ { while (*s1++ == *s2) { if (*s2++ == EOS) return (0); } return ((s1[-1] < *s2) ? -1 : 1); }