libtool-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Libtool branch, master, updated. v2.2.6-167-gc4e8bf3


From: Ralf Wildenhues
Subject: [SCM] GNU Libtool branch, master, updated. v2.2.6-167-gc4e8bf3
Date: Wed, 02 Dec 2009 22:17:23 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Libtool".

The branch, master has been updated
       via  c4e8bf31aaa471251092f5b89420bbd4701cb308 (commit)
       via  fea7fdee4e2a36b608708f5cbfaf373edfac916d (commit)
      from  2c9c38d8a12eb0a2ce7fe9c3862523026c3d5622 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c4e8bf31aaa471251092f5b89420bbd4701cb308
Author: Ralf Wildenhues <address@hidden>
Date:   Wed Dec 2 23:12:27 2009 +0100

    lt_dlloader_remove and lt_dlloader_find accept const arguments.
    
    * libltdl/lt_dlloader.c (lt_dlloader_remove, lt_dlloader_find):
    Accept `const char *' arguments, as documented.  Cast them to
    `void *' for the slist machinery.
    * libltdl/libltdl/lt_dlloader.h: Adjust prototypes.
    
    Signed-off-by: Ralf Wildenhues <address@hidden>

commit fea7fdee4e2a36b608708f5cbfaf373edfac916d
Author: Ralf Wildenhues <address@hidden>
Date:   Wed Dec 2 23:11:23 2009 +0100

    Test and fix slist.c.
    
    * libltdl/libltdl/slist.h: Include stddef.h, for size_t.
    (slist_remove): Return pointer to SList, not void.
    * libltdl/slist.c: Include stdlib.h, for malloc and free.
    (slist_remove): Adjust prototype as above.
    (slist_sort): Do not loop forever on one-item list.
    * tests/slist.at (SList functionality): New file, new test.
    * Makefile.am (TESTSUITE_AT): Add tests/slist.at.
    
    Signed-off-by: Ralf Wildenhues <address@hidden>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                     |   17 ++++
 Makefile.am                   |    1 +
 libltdl/libltdl/lt_dlloader.h |    4 +-
 libltdl/libltdl/slist.h       |    6 +-
 libltdl/lt_dlloader.c         |    8 +-
 libltdl/slist.c               |   10 ++-
 tests/slist.at                |  168 +++++++++++++++++++++++++++++++++++++++++
 7 files changed, 203 insertions(+), 11 deletions(-)
 create mode 100644 tests/slist.at

diff --git a/ChangeLog b/ChangeLog
index 7961cac..6e01e4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-12-02  Ralf Wildenhues  <address@hidden>
+
+       lt_dlloader_remove and lt_dlloader_find accept const arguments.
+       * libltdl/lt_dlloader.c (lt_dlloader_remove, lt_dlloader_find):
+       Accept `const char *' arguments, as documented.  Cast them to
+       `void *' for the slist machinery.
+       * libltdl/libltdl/lt_dlloader.h: Adjust prototypes.
+
+       Test and fix slist.c.
+       * libltdl/libltdl/slist.h: Include stddef.h, for size_t.
+       (slist_remove): Return pointer to SList, not void.
+       * libltdl/slist.c: Include stdlib.h, for malloc and free.
+       (slist_remove): Adjust prototype as above.
+       (slist_sort): Do not loop forever on one-item list.
+       * tests/slist.at (SList functionality): New file, new test.
+       * Makefile.am (TESTSUITE_AT): Add tests/slist.at.
+
 2009-11-30  Peter Rosin  <address@hidden>
 
        Please C++ compilers when calling strrchr.
diff --git a/Makefile.am b/Makefile.am
index 2fe2f88..e5d55eb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -484,6 +484,7 @@ TESTSUITE_AT        = tests/testsuite.at \
                  tests/lt_dlopen_a.at \
                  tests/lt_dlopenext.at \
                  tests/ltdl-api.at \
+                 tests/slist.at \
                  tests/need_lib_prefix.at \
                  tests/standalone.at \
                  tests/subproject.at \
diff --git a/libltdl/libltdl/lt_dlloader.h b/libltdl/libltdl/lt_dlloader.h
index ae131fa..589fd0d 100644
--- a/libltdl/libltdl/lt_dlloader.h
+++ b/libltdl/libltdl/lt_dlloader.h
@@ -73,8 +73,8 @@ typedef struct {
 LT_SCOPE int           lt_dlloader_add    (const lt_dlvtable *vtable);
 LT_SCOPE lt_dlloader   lt_dlloader_next   (const lt_dlloader loader);
 
-LT_SCOPE lt_dlvtable * lt_dlloader_remove      (char *name);
-LT_SCOPE const lt_dlvtable *lt_dlloader_find   (char *name);
+LT_SCOPE lt_dlvtable * lt_dlloader_remove      (const char *name);
+LT_SCOPE const lt_dlvtable *lt_dlloader_find   (const char *name);
 LT_SCOPE const lt_dlvtable *lt_dlloader_get    (lt_dlloader loader);
 
 
diff --git a/libltdl/libltdl/slist.h b/libltdl/libltdl/slist.h
index e4b7ead..4d56509 100644
--- a/libltdl/libltdl/slist.h
+++ b/libltdl/libltdl/slist.h
@@ -1,6 +1,6 @@
 /* slist.h -- generalised singly linked lists
 
-   Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2004, 2009 Free Software Foundation, Inc.
    Written by Gary V. Vaughan, 2000
 
    NOTE: The canonical source of this file is maintained with the
@@ -48,6 +48,8 @@ or obtained by writing to the Free Software Foundation, Inc.,
 #  define LT_SCOPE
 #endif
 
+#include <stddef.h>
+
 #if defined(__cplusplus)
 extern "C" {
 #endif
@@ -65,7 +67,7 @@ LT_SCOPE SList *slist_concat  (SList *head, SList *tail);
 LT_SCOPE SList *slist_cons     (SList *item, SList *slist);
 
 LT_SCOPE SList *slist_delete   (SList *slist, void (*delete_fct) (void *item));
-LT_SCOPE void *        slist_remove    (SList **phead, SListCallback *find,
+LT_SCOPE SList *slist_remove   (SList **phead, SListCallback *find,
                                 void *matchdata);
 LT_SCOPE SList *slist_reverse  (SList *slist);
 LT_SCOPE SList *slist_sort     (SList *slist, SListCompare *compare,
diff --git a/libltdl/lt_dlloader.c b/libltdl/lt_dlloader.c
index 4e66a6c..2c99a22 100644
--- a/libltdl/lt_dlloader.c
+++ b/libltdl/lt_dlloader.c
@@ -150,7 +150,7 @@ lt_dlloader_get     (lt_dlloader loader)
    modules need this loader; in either case, the loader list is not
    changed if NULL is returned.  */
 lt_dlvtable *
-lt_dlloader_remove (char *name)
+lt_dlloader_remove (const char *name)
 {
   const lt_dlvtable *  vtable  = lt_dlloader_find (name);
   static const char    id_string[] = "lt_dlloader_remove";
@@ -199,12 +199,12 @@ lt_dlloader_remove (char *name)
 
   /* If we got this far, remove the loader from our global list.  */
   return (lt_dlvtable *)
-      slist_unbox ((SList *) slist_remove (&loaders, loader_callback, name));
+      slist_unbox ((SList *) slist_remove (&loaders, loader_callback, (void *) 
name));
 }
 
 
 const lt_dlvtable *
-lt_dlloader_find (char *name)
+lt_dlloader_find (const char *name)
 {
-  return lt_dlloader_get (slist_find (loaders, loader_callback, name));
+  return lt_dlloader_get (slist_find (loaders, loader_callback, (void *) 
name));
 }
diff --git a/libltdl/slist.c b/libltdl/slist.c
index c99f399..25906a4 100644
--- a/libltdl/slist.c
+++ b/libltdl/slist.c
@@ -1,6 +1,6 @@
 /* slist.c -- generalised singly linked lists
 
-   Copyright (C) 2000, 2004, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
    Written by Gary V. Vaughan, 2000
 
    NOTE: The canonical source of this file is maintained with the
@@ -32,6 +32,7 @@ or obtained by writing to the Free Software Foundation, Inc.,
 
 #include "slist.h"
 #include <stddef.h>
+#include <stdlib.h>
 
 static SList * slist_sort_merge    (SList *left, SList *right,
                                     SListCompare *compare, void *userdata);
@@ -73,7 +74,7 @@ slist_delete (SList *head, void (*delete_fct) (void *item))
            the stale item, you should probably return that from FIND if
           it makes a successful match.  Don't forget to slist_unbox()
           every item in a boxed list before operating on its contents.   */
-void *
+SList *
 slist_remove (SList **phead, SListCallback *find, void *matchdata)
 {
   SList *stale = 0;
@@ -107,7 +108,7 @@ slist_remove (SList **phead, SListCallback *find, void 
*matchdata)
        }
     }
 
-  return result;
+  return (SList *) result;
 }
 
 /* Call FIND repeatedly with each element of SLIST and MATCHDATA, until
@@ -314,6 +315,9 @@ slist_sort (SList *slist, SListCompare *compare, void 
*userdata)
   left = slist;
   right = slist->next;
 
+  if (!right)
+    return left;
+
   /* Skip two items with RIGHT and one with SLIST, until RIGHT falls off
      the end.  SLIST must be about half way along.  */
   while (right && (right = right->next))
diff --git a/tests/slist.at b/tests/slist.at
new file mode 100644
index 0000000..741410c
--- /dev/null
+++ b/tests/slist.at
@@ -0,0 +1,168 @@
+# slist.at -- test slist.c                   -*- Autotest -*-
+#
+#   Copyright (C) 2009 Free Software Foundation, Inc.
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# GNU Libtool 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+####
+
+AT_SETUP([SList functionality])
+
+AT_DATA([test-slist.c], [[
+#include <config.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <stdio.h>
+#include "slist.h"
+
+void *find_string (SList *item, void *data)
+{
+  if (data != NULL && !strcmp ((const char *) item->userdata, (const char 
*)data))
+    return item;
+  else
+    return NULL;
+}
+
+void boxed_delete (void *item)
+{
+  free (slist_unbox ((SList *) item));
+}
+
+void *print_item (SList *item, void *userdata)
+{
+  userdata = userdata; /* unused */
+  printf ("%s\n", (const char*)item->userdata);
+  return NULL;
+}
+
+int list_compare (const SList *item1, const SList *item2, void *userdata)
+{
+  userdata = userdata;
+  return strcmp ((const char *) item1->userdata, (const char 
*)item2->userdata);
+}
+
+int main ()
+{
+  int i;
+  SList *empty_list = NULL, *list = NULL, *item, *list_save;
+  char *data = NULL;
+
+  /* slist_cons */
+  list = slist_cons (NULL, NULL);
+
+  for (i=0; i < 10; ++i) {
+    data = (char *) malloc (42);
+    assert (data);
+    sprintf (data, "foo%d", i);
+    list = slist_cons (slist_box (data), list);
+  }
+  list_save = list;
+  list = slist_cons (NULL, list);
+  assert (list == list_save);
+
+
+  /* slist_find */
+  assert (slist_find (NULL, find_string, (void *) "whatever") == NULL);
+  assert (slist_find (empty_list, find_string, (void *) "whatever") == NULL);
+  assert (slist_find (list, find_string, (void *) "foo10") == NULL);
+  item = (SList *) slist_find (list, find_string, (void *) "foo1");
+  assert (item != NULL);
+  assert (!strcmp ((const char *) item->userdata, "foo1"));
+
+  item = slist_nth (list, 10);
+  assert (item != NULL && !strcmp ((const char *) item->userdata, "foo0"));
+
+  puts ("list as inserted:");
+  slist_foreach (list, print_item, NULL);
+  puts ("reversed list:");
+  list = slist_reverse (list);
+  slist_foreach (list, print_item, NULL);
+
+  item = slist_nth (list, 1);
+  assert (item != NULL && !strcmp ((const char *) item->userdata, "foo0"));
+
+  assert (10 == slist_length (list));
+
+  /* slist_tail is the second item, not the last one */
+  item = slist_tail (list);
+  assert (item != NULL && !strcmp ((const char *) item->userdata, "foo1"));
+
+  assert (slist_tail (slist_nth (list, 10)) == NULL);
+
+  /* slist_sort and implicitly, slist_sort_merge */
+  assert (slist_sort (NULL, list_compare, NULL) == NULL);
+  list = slist_sort (list, list_compare, NULL);
+  puts ("list after no-op sort:");
+  slist_foreach (list, print_item, NULL);
+
+  list = slist_reverse (list);
+  puts ("reversed list:");
+  slist_foreach (list, print_item, NULL);
+  puts ("sorting reversed list:");
+  list = slist_sort (list, list_compare, NULL);
+  slist_foreach (list, print_item, NULL);
+
+  /* slist_remove */
+  assert (slist_remove (NULL, find_string, NULL) == NULL);
+  assert (slist_remove (&empty_list, find_string, NULL) == NULL);
+
+  list_save = list;
+  assert (slist_remove (&list, find_string, NULL) == NULL);
+  assert (list_save == list);
+
+  /* remove entries: middle, last, first, not present */
+  /* slist_reverse above has left us with increasing order */
+  list_save = list;
+  item = slist_remove (&list, find_string, (void *) "foo5");
+  assert (list_save == list);
+  assert (item != NULL && !strcmp (data = (char *) slist_unbox (item), 
"foo5"));
+  free (data);
+
+  list_save = list;
+  item = slist_remove (&list, find_string, (void *) "foo9");
+  assert (list_save == list);
+  assert (item != NULL && !strcmp (data = (char *) slist_unbox (item), 
"foo9"));
+  free (data);
+
+  list_save = list;
+  item = slist_remove (&list, find_string, (void *) "foo0");
+  assert (list_save != list);
+  assert (item != NULL && !strcmp (data = (char *) slist_unbox (item), 
"foo0"));
+  free (data);
+
+  list_save = list;
+  item = slist_remove (&list, find_string, (void *) "foo5");
+  assert (list_save == list);
+  assert (item == NULL);
+
+  assert (slist_delete (list, boxed_delete) == NULL);
+  return 0;
+}
+]])
+
+CPPFLAGS="-I$top_srcdir/libltdl -I$top_srcdir/libltdl/libltdl 
-I$abs_top_builddir"
+AT_CHECK([$CC $CPPFLAGS $CFLAGS -c test-slist.c],
+        [], [ignore], [ignore])
+AT_CHECK([$CC $CPPFLAGS $CFLAGS -c $top_srcdir/libltdl/slist.c],
+        [], [ignore], [ignore])
+AT_CHECK([$CC $CFLAGS $LDFLAGS -o test-slist test-slist.$OBJEXT slist.$OBJEXT],
+        [], [ignore], [ignore])
+LT_AT_EXEC_CHECK([./test-slist], [], [ignore], [ignore])
+
+AT_CLEANUP


hooks/post-receive
-- 
GNU Libtool




reply via email to

[Prev in Thread] Current Thread [Next in Thread]