added lsearch and lfind
remove unknown infnanf and strtcopy functions git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27423 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
eabd7df4a2
commit
645fa87a21
@ -189,7 +189,6 @@ extern double yn(int x, double y);
|
||||
/* other stuff as defined in BeOS */
|
||||
extern int isinff(float value);
|
||||
extern int finitef(float value);
|
||||
extern float infnanf(int error);
|
||||
extern float dremf(float x, float y);
|
||||
extern float significandf(float x);
|
||||
extern float copysignf(float x, float y);
|
||||
|
@ -59,7 +59,6 @@ extern char *strcasestr(const char *string, const char *searchString);
|
||||
|
||||
extern char *strdup(const char *string);
|
||||
extern char *stpcpy(char *dest, const char *source);
|
||||
extern const char *strtcopy(char *dest, const char *source);
|
||||
|
||||
extern size_t strlcat(char *dest, const char *source, size_t length);
|
||||
extern size_t strlcpy(char *dest, const char *source, size_t length);
|
||||
|
@ -15,6 +15,7 @@ SubDirCcFlags -D_GNU_SOURCE -DUSE_IN_LIBIO ;
|
||||
MergeObject posix_gnu_misc.o :
|
||||
dirname.c
|
||||
insremque.c
|
||||
lsearch.c
|
||||
tsearch.c
|
||||
efgcvt.c
|
||||
efgcvt_r.c
|
||||
|
59
src/system/libroot/posix/glibc/misc/lsearch.c
Normal file
59
src/system/libroot/posix/glibc/misc/lsearch.c
Normal file
@ -0,0 +1,59 @@
|
||||
/* Linear search functions.
|
||||
Copyright (C) 1996,97,98,2002 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <search.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void *
|
||||
lsearch (const void *key, void *base, size_t *nmemb, size_t size,
|
||||
__compar_fn_t compar)
|
||||
{
|
||||
void *result;
|
||||
|
||||
/* Try to find it. */
|
||||
result = lfind (key, base, nmemb, size, compar);
|
||||
if (result == NULL)
|
||||
{
|
||||
/* Not available. Insert at the end. */
|
||||
result = memcpy (base + (*nmemb) * size, key, size);
|
||||
++(*nmemb);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
lfind (const void *key, const void *base, size_t *nmemb, size_t size,
|
||||
__compar_fn_t compar)
|
||||
{
|
||||
const void *result = base;
|
||||
size_t cnt = 0;
|
||||
|
||||
while (cnt < *nmemb && (*compar) (key, result) != 0)
|
||||
{
|
||||
result += size;
|
||||
++cnt;
|
||||
}
|
||||
|
||||
return cnt < *nmemb ? (void *) result : NULL;
|
||||
}
|
||||
libc_hidden_def (lfind)
|
Loading…
Reference in New Issue
Block a user