From: Ulrich Drepper Date: Fri, 30 Jan 1998 17:25:57 +0000 (+0000) Subject: (memmem): An empty needle is at the beginning of haystack. X-Git-Tag: cvs/before-sparc-2_0_x-branch~238 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b80b0e179d588a4ae12e7223a409bf4660660109;p=thirdparty%2Fglibc.git (memmem): An empty needle is at the beginning of haystack. --- diff --git a/sysdeps/generic/memmem.c b/sysdeps/generic/memmem.c index 099897ab80a..6e14f5513e6 100644 --- a/sysdeps/generic/memmem.c +++ b/sysdeps/generic/memmem.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993, 1994, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 94, 96, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -34,8 +34,8 @@ DEFUN(memmem, (haystack, haystack_len, if (needle_len == 0) /* The first occurrence of the empty string is deemed to occur at - the end of the string. */ - return (PTR) &((CONST char *) haystack)[haystack_len - 1]; + the beginning of the string. */ + return (PTR) haystack; for (begin = (CONST char *) haystack; begin <= last_possible; ++begin) if (begin[0] == ((CONST char *) needle)[0] &&