Message-Id: <199703182253.RAA14918@delorie.com> From: Oberhumer Markus Subject: memicmp() To: djgpp-workers AT delorie DOT com (djgpp-workers), dj AT delorie DOT com Date: Tue, 18 Mar 1997 23:50:53 +0100 (MET) Return-Read-To: markus DOT oberhumer AT jk DOT uni-linz DOT ac DOT at Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 1998 =============================================================================== Markus F.X.J. Oberhumer Subject: memicmp() To: djgpp-workers AT delorie DOT com, dj AT delorie DOT com =============================================================================== Below are my patches for an implemention of memicmp(). I've also noticed that stricmp.txh contains documentation of a function called 'strcase' - this should be removed. *** string.old Sun Nov 12 17:35:00 1995 --- string.h Mon Mar 17 09:41:48 1997 *************** *** 51,54 **** --- 51,55 ---- char * index(const char *_string, int _c); void * memccpy(void *_to, const void *_from, int c, size_t n); + int memicmp(const void *_s1, const void *_s2, size_t _n); char * rindex(const char *_string, int _c); char * stpcpy(char *_dest, const char *_src); *** src/libc/compat/string/makefile *** 4a5 > SRC += memicmp.c *** src/libc/compat/string/memicmp.c *** /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ #include #include int memicmp(const void *s1, const void *s2, size_t n) { if (n != 0) { const unsigned char *p1 = s1, *p2 = s2; do { if (*p1 != *p2) { int c = toupper(*p1) - toupper(*p2); if (c) return c; } p1++; p2++; } while (--n != 0); } return 0; } *** src/libc/compat/string/memicmp.txh *** @node memicmp, memory @subheading Syntax @example #include int memicmp(const void *s1, const void *s2, size_t num); @end example @subheading Description This function compares two regions of memory, at @var{s1} and @var{s2}, for @var{num} bytes, disregarding case. @subheading Return Value Zero if they're the same, nonzero if different, the sign indicates "order". @subheading Example @example if (memicmp(arg, "-i", 2) == 0) /* '-I' or '-include' etc. */ do_include(); @end example