delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/11/28/14:12:46

Message-Id: <199611281906.OAA13959@delorie.com>
From: Oberhumer Markus <k3040e4 AT c210 DOT edvz DOT uni-linz DOT ac DOT at>
Subject: Bug: memchr() is not 8-bit clean
To: dj AT delorie DOT com
Date: Thu, 28 Nov 1996 20:06:05 +0100 (MET)
Cc: djgpp-workers AT delorie DOT com (djgpp-workers)
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: Bug: memchr() is not 8-bit clean
To: DJ, djgpp-workers AT delorie DOT com
===============================================================================

This is the correct version of src/libc/ansi/string/memchr.c:

/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <string.h>
#include <libc/unconst.h>

void *
memchr(const void *s, int c, size_t n)
{
  if (n)
  {
    const char *p = s;
    char cc = c;
    do {
      if (*p == cc)
        return unconst(p, void *);
      p++;
    } while (--n != 0);
  }
  return 0;
}

- Raw text -


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