Blame port/strcasecmp.c

Packit 7838c8
/* $Id: strcasecmp.c,v 1.4 2015-06-21 01:09:09 bfriesen Exp $ */
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * Copyright (c) 1987, 1993
Packit 7838c8
 *	The Regents of the University of California.  All rights reserved.
Packit 7838c8
 *
Packit 7838c8
 * Redistribution and use in source and binary forms, with or without
Packit 7838c8
 * modification, are permitted provided that the following conditions
Packit 7838c8
 * are met:
Packit 7838c8
 * 1. Redistributions of source code must retain the above copyright
Packit 7838c8
 *    notice, this list of conditions and the following disclaimer.
Packit 7838c8
 * 2. Redistributions in binary form must reproduce the above copyright
Packit 7838c8
 *    notice, this list of conditions and the following disclaimer in the
Packit 7838c8
 *    documentation and/or other materials provided with the distribution.
Packit 7838c8
 * 3. Neither the name of the University nor the names of its contributors
Packit 7838c8
 *    may be used to endorse or promote products derived from this software
Packit 7838c8
 *    without specific prior written permission.
Packit 7838c8
 *
Packit 7838c8
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
Packit 7838c8
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 7838c8
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 7838c8
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
Packit 7838c8
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 7838c8
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit 7838c8
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit 7838c8
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit 7838c8
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit 7838c8
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit 7838c8
 * SUCH DAMAGE.
Packit 7838c8
 */
Packit 7838c8
Packit 7838c8
#if 0
Packit 7838c8
static char sccsid[] = "@(#)strcasecmp.c	8.1 (Berkeley) 6/4/93";
Packit 7838c8
__RCSID("$NetBSD: strcasecmp.c,v 1.16 2003/08/07 16:43:49 agc Exp $");
Packit 7838c8
#endif
Packit 7838c8
Packit 7838c8
#include <ctype.h>
Packit 7838c8
#include <string.h>
Packit 7838c8
#include "libport.h"
Packit 7838c8
Packit 7838c8
int
Packit 7838c8
strcasecmp(const char *s1, const char *s2)
Packit 7838c8
{
Packit 7838c8
	const unsigned char *us1 = (const unsigned char *)s1,
Packit 7838c8
			*us2 = (const unsigned char *)s2;
Packit 7838c8
Packit 7838c8
	while (tolower((int) *us1) == tolower((int) *us2++))
Packit 7838c8
		if (*us1++ == '\0')
Packit 7838c8
			return (0);
Packit 7838c8
	return (tolower((int) *us1) - tolower((int) *--us2));
Packit 7838c8
}