From patchwork Thu Dec 6 00:46:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 204075 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 4F7DF2C0134 for ; Thu, 6 Dec 2012 11:51:04 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E602C4A12E; Thu, 6 Dec 2012 01:50:59 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fR9clRw2Uvs9; Thu, 6 Dec 2012 01:50:59 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6392C4A14E; Thu, 6 Dec 2012 01:50:26 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A65794A149 for ; Thu, 6 Dec 2012 01:50:21 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IQ04rEHXLLPe for ; Thu, 6 Dec 2012 01:50:19 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-qc0-f202.google.com (mail-qc0-f202.google.com [209.85.216.202]) by theia.denx.de (Postfix) with ESMTPS id 3C03E4A127 for ; Thu, 6 Dec 2012 01:50:16 +0100 (CET) Received: by mail-qc0-f202.google.com with SMTP id s25so749523qcq.3 for ; Wed, 05 Dec 2012 16:50:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=vtD+P4kDPv5kaJ6sEuGlmri/0a9tsolHYFje7y6jN8w=; b=TMVN5LiffS6Ea7pt7NN3Sqrh0T5fywWZAb1CZ45QSqBikgRnM2wYLki/weHbL7tuE+ i+wF1SFIBW8IuPmFxjdUt/Xj7lflWunL4Zz6PMgGWmCX6UdP8VFt8Z6AtPqHCHLKNotY FkOMKHaB0pliupi9FlC5ZOn/pom01F6+3N5lQxDT3rzQAaXsUJFOhxdaBHuX1bPj/biL 7FfyigMsAQqi2L9B0OHqYQUxaStAzxiQIg/dz5g2F7kR8NVySvdv4TXfd05ZrDfeYl+O 2u+Wf0qIXft3aA+NnBeuvI7ccjDdylsho1mpiTO0shL/wnF6ET1Z5ZiMcEVrISU6JLo9 IDMQ== Received: by 10.236.183.202 with SMTP id q50mr12538077yhm.29.1354755015256; Wed, 05 Dec 2012 16:50:15 -0800 (PST) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id u20si276150anj.3.2012.12.05.16.50.15 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 05 Dec 2012 16:50:15 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn3.hot.corp.google.com (Postfix) with ESMTP id 00D73100047; Wed, 5 Dec 2012 16:50:15 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id B54A9160952; Wed, 5 Dec 2012 16:50:14 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Wed, 5 Dec 2012 16:46:35 -0800 Message-Id: <1354754807-21449-9-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1354754807-21449-1-git-send-email-sjg@chromium.org> References: <1354754807-21449-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmtBiuh0dk4VEZQttgxpTCfDKlbqbPsmELhf6rOq3PfoDkwACT1jpo34gQWaSrA1aSStzKYDZfmBVs9uHal7cxeqSeSmu7jZjuXCHrymtPlmh13A5iH03kUiWNbrKG2mIPM/KlbXArvfS0AqCXRfxNsywSf5oVPDtsyUIF5QCMpQbPNKhaKjANhUBpcpH50FCL/rEM2 Cc: Kim Phillips , Kumar Gala , Andy Fleming , Tom Rini , Stefan Roese Subject: [U-Boot] [PATCH v3 08/20] Add strcasecmp() and strncasecmp() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de strncasecmp() is present as strnicmp() but disabled. Make it available and define strcasecmp() also. There is a only a small performance penalty to having strcasecmp() call strncasecmp(), so do this instead of a standalone function, to save code space. Update the prototype in arch-specific headers as needed to avoid warnings. Signed-off-by: Simon Glass --- Changes in v3: - Rename stricmp() to strcasecmp() to match Linux / POSIX - Bracket strcasecmp() declarations with __HAVE_ARCH_... Changes in v2: - Add stricmp() patch again since it is used in this series arch/m68k/include/asm/string.h | 2 +- arch/powerpc/include/asm/string.h | 2 +- arch/sparc/include/asm/string.h | 2 +- include/linux/string.h | 7 +++++-- lib/string.c | 16 ++++++++++++---- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/arch/m68k/include/asm/string.h b/arch/m68k/include/asm/string.h index e0773a8..ecf5e56 100644 --- a/arch/m68k/include/asm/string.h +++ b/arch/m68k/include/asm/string.h @@ -16,7 +16,7 @@ #endif extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, int); +extern int strncasecmp(const char *, const char *, __kernel_size_t); extern char * strcpy(char *,const char *); extern char * strncpy(char *,const char *, __kernel_size_t); extern __kernel_size_t strlen(const char *); diff --git a/arch/powerpc/include/asm/string.h b/arch/powerpc/include/asm/string.h index d912a6b..036805e 100644 --- a/arch/powerpc/include/asm/string.h +++ b/arch/powerpc/include/asm/string.h @@ -14,7 +14,7 @@ #define __HAVE_ARCH_MEMCHR extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, int); +extern int strncasecmp(const char *, const char *, __kernel_size_t); extern char * strcpy(char *,const char *); extern char * strncpy(char *,const char *, __kernel_size_t); extern __kernel_size_t strlen(const char *); diff --git a/arch/sparc/include/asm/string.h b/arch/sparc/include/asm/string.h index c6bbc20..af6faea 100644 --- a/arch/sparc/include/asm/string.h +++ b/arch/sparc/include/asm/string.h @@ -40,7 +40,7 @@ */ extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, int); +extern int strncasecmp(const char *, const char *, __kernel_size_t); extern char *strcpy(char *, const char *); extern char *strncpy(char *, const char *, __kernel_size_t); extern __kernel_size_t strlen(const char *); diff --git a/include/linux/string.h b/include/linux/string.h index 9a8cbc2..de83355 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -38,8 +38,11 @@ extern int strcmp(const char *,const char *); #ifndef __HAVE_ARCH_STRNCMP extern int strncmp(const char *,const char *,__kernel_size_t); #endif -#if 0 /* not used - was: #ifndef __HAVE_ARCH_STRNICMP */ -extern int strnicmp(const char *, const char *, __kernel_size_t); +#ifndef __HAVE_ARCH_STRCASECMP +int strcasecmp(const char *s1, const char *s2); +#endif +#ifndef __HAVE_ARCH_STRNCASECMP +extern int strncasecmp(const char *s1, const char *s2, __kernel_size_t len); #endif #ifndef __HAVE_ARCH_STRCHR extern char * strchr(const char *,int); diff --git a/lib/string.c b/lib/string.c index c3ad055..68f60be 100644 --- a/lib/string.c +++ b/lib/string.c @@ -21,14 +21,13 @@ #include -#if 0 /* not used - was: #ifndef __HAVE_ARCH_STRNICMP */ /** - * strnicmp - Case insensitive, length-limited string comparison + * strncasecmp - Case insensitive, length-limited string comparison * @s1: One string * @s2: The other string * @len: the maximum number of characters to compare */ -int strnicmp(const char *s1, const char *s2, size_t len) +int strncasecmp(const char *s1, const char *s2, size_t len) { /* Yes, Virginia, it had better be unsigned */ unsigned char c1, c2; @@ -52,7 +51,16 @@ int strnicmp(const char *s1, const char *s2, size_t len) } return (int)c1 - (int)c2; } -#endif + +/** + * strcasecmp - Case insensitive string comparison + * @s1: One string + * @s2: The other string + */ +int strcasecmp(const char *s1, const char *s2) +{ + return strncasecmp(s1, s2, -1U); +} char * ___strtok;