delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/03/18/18:06:41

Message-Id: <199703182253.RAA14918@delorie.com>
From: Oberhumer Markus <k3040e4 AT c210 DOT edvz DOT uni-linz DOT ac DOT at>
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

===============================================================================
Markus F.X.J. Oberhumer <markus DOT oberhumer AT jk DOT uni-linz DOT ac DOT at>

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 <string.h>
#include <ctype.h>

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 <string.h>

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019