aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-01-29 08:25:15 +0000
committerUlrich Drepper <drepper@redhat.com>2002-01-29 08:25:15 +0000
commit92f120d446433f74d4d2612587bb38a992050a04 (patch)
tree3cbab71124841be7472ab55114b9123fd54a9038
parentfa8d436c87f156d18208df3819fecee9fc1dbd9e (diff)
downloadglibc-92f120d446433f74d4d2612587bb38a992050a04.zip
glibc-92f120d446433f74d4d2612587bb38a992050a04.tar.gz
glibc-92f120d446433f74d4d2612587bb38a992050a04.tar.bz2
Update.
2002-01-29 Ulrich Drepper <drepper@redhat.com> * misc/hsearch_r.c (hsearch_r): Don't insert anything if entry is found. * misc/Makefile (tests): Add tst-hsearch. * misc/tst-hsearch.c: New file.
-rw-r--r--ChangeLog7
-rw-r--r--misc/Makefile4
-rw-r--r--misc/hsearch_r.c8
-rw-r--r--misc/tst-hsearch.c31
4 files changed, 41 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 8268adc..c2742e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-01-29 Ulrich Drepper <drepper@redhat.com>
+
+ * misc/hsearch_r.c (hsearch_r): Don't insert anything if entry is
+ found.
+ * misc/Makefile (tests): Add tst-hsearch.
+ * misc/tst-hsearch.c: New file.
+
2002-01-18 Wolfram Gloger <wg@malloc.de>
* malloc/malloc.c: Rewrite, adapted from Doug Lea's malloc-2.7.0.c.
diff --git a/misc/Makefile b/misc/Makefile
index 6f935a5..a5cee87 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-1999,2000,01 Free Software Foundation, Inc.
+# Copyright (C) 1991-1999, 2000, 2001, 2002 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
@@ -70,7 +70,7 @@ install-lib := libbsd-compat.a libg.a
endif
gpl2lgpl := error.c error.h
-tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent
+tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch
CFLAGS-tsearch.c = $(exceptions)
CFLAGS-lsearch.c = $(exceptions)
diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c
index 59964eb..a7629a5 100644
--- a/misc/hsearch_r.c
+++ b/misc/hsearch_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993.
@@ -168,9 +168,6 @@ hsearch_r (item, action, retval, htab)
if (htab->table[idx].used == hval
&& strcmp (item.key, htab->table[idx].entry.key) == 0)
{
- if (action == ENTER)
- htab->table[idx].entry.data = item.data;
-
*retval = &htab->table[idx].entry;
return 1;
}
@@ -195,9 +192,6 @@ hsearch_r (item, action, retval, htab)
if (htab->table[idx].used == hval
&& strcmp (item.key, htab->table[idx].entry.key) == 0)
{
- if (action == ENTER)
- htab->table[idx].entry.data = item.data;
-
*retval = &htab->table[idx].entry;
return 1;
}
diff --git a/misc/tst-hsearch.c b/misc/tst-hsearch.c
new file mode 100644
index 0000000..6c19b22
--- /dev/null
+++ b/misc/tst-hsearch.c
@@ -0,0 +1,31 @@
+#include <search.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+ int a = 1;
+ int b = 2;
+ ENTRY i;
+ ENTRY *e;
+
+ if (hcreate (20) == 0)
+ {
+ puts ("hcreate failed");
+ return 1;
+ }
+
+ i.key = (char *) "one";
+ i.data = &a;
+ if (hsearch (i, ENTER) == NULL)
+ return 1;
+
+ i.key = (char *) "one";
+ i.data = &b;
+ e = hsearch (i, ENTER);
+ printf ("e.data = %d\n", *(int *) e->data);
+ if (*(int *) e->data != 1)
+ return 1;
+
+ return 0;
+}