guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.11-29-ga5186


From: Mark H Weaver
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.11-29-ga5186f5
Date: Mon, 02 Jun 2014 00:53:45 +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 Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=a5186f506f69ef8a8accd234ca434efd13f302c9

The branch, stable-2.0 has been updated
       via  a5186f506f69ef8a8accd234ca434efd13f302c9 (commit)
       via  12c6a47773041ff5d0a3553421d2f358d9e479a9 (commit)
      from  a43fa1b70688b09a9eecac3c2ce8e9adea63bab6 (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 a5186f506f69ef8a8accd234ca434efd13f302c9
Author: Mark H Weaver <address@hidden>
Date:   Fri Apr 18 15:04:12 2014 -0400

    SRFI-1 'length+' raises an error unless passed a proper or circular list.
    
    Fixes <http://bugs.gnu.org/17296>.
    
    * libguile/srfi-1.c (scm_srfi1_length_plus): Rewrite to raise an error
      unless passed a proper or circular list, based on code from
      'scm_ilength'.
    
    * test-suite/tests/srfi-1.test (length+): Add tests.

commit 12c6a47773041ff5d0a3553421d2f358d9e479a9
Author: Mark H Weaver <address@hidden>
Date:   Sun Jun 1 19:08:25 2014 -0400

    Mark system async functions as SCM_API.
    
    Fixes <http://bugs.gnu.org/17661>.
    Reported and fixed by Chris Vine <address@hidden>.
    
    * libguile/async.h (scm_c_call_with_blocked_asyncs)
      (scm_c_call_with_unblocked_asyncs, scm_dynwind_block_asyncs)
      (scm_dynwind_unblock_asyncs): Mark as SCM_API.
    
    * THANKS: Add Chris Vine to fixes section.

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

Summary of changes:
 THANKS                       |    1 +
 libguile/async.h             |   11 ++++++-----
 libguile/srfi-1.c            |   32 ++++++++++++++++++++++++++++----
 test-suite/tests/srfi-1.test |    6 +++++-
 4 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/THANKS b/THANKS
index d34b951..e626873 100644
--- a/THANKS
+++ b/THANKS
@@ -182,6 +182,7 @@ For fixes or providing information which led to a fix:
           Aaron VanDevender
          Sjoerd Van Leent
        Andreas Vögele
+          Chris Vine
         Michael Talbot-Wilson
         Michael Tuexen
             Xin Wang
diff --git a/libguile/async.h b/libguile/async.h
index b3503de..3da808e 100644
--- a/libguile/async.h
+++ b/libguile/async.h
@@ -3,7 +3,8 @@
 #ifndef SCM_ASYNC_H
 #define SCM_ASYNC_H
 
-/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2004, 2005, 2006, 2008, 
2009 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2008, 2009,
+ *   2014 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -44,10 +45,10 @@ SCM_API SCM scm_run_asyncs (SCM list_of_a);
 SCM_API SCM scm_noop (SCM args);
 SCM_API SCM scm_call_with_blocked_asyncs (SCM proc);
 SCM_API SCM scm_call_with_unblocked_asyncs (SCM proc);
-void *scm_c_call_with_blocked_asyncs (void *(*p) (void *d), void *d);
-void *scm_c_call_with_unblocked_asyncs (void *(*p) (void *d), void *d);
-void scm_dynwind_block_asyncs (void);
-void scm_dynwind_unblock_asyncs (void);
+SCM_API void *scm_c_call_with_blocked_asyncs (void *(*p) (void *d), void *d);
+SCM_API void *scm_c_call_with_unblocked_asyncs (void *(*p) (void *d), void *d);
+SCM_API void scm_dynwind_block_asyncs (void);
+SCM_API void scm_dynwind_unblock_asyncs (void);
 
 /* Critical sections */
 
diff --git a/libguile/srfi-1.c b/libguile/srfi-1.c
index 54c7e2a..fcbf806 100644
--- a/libguile/srfi-1.c
+++ b/libguile/srfi-1.c
@@ -1,7 +1,7 @@
 /* srfi-1.c --- SRFI-1 procedures for Guile
  *
- * Copyright (C) 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2005, 2006,
- *   2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ * Copyright (C) 1995-1997, 2000-2003, 2005, 2006, 2008-2011,
+ *   2014 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -614,8 +614,32 @@ SCM_DEFINE (scm_srfi1_length_plus, "length+", 1, 0, 0,
            "circular.")
 #define FUNC_NAME s_scm_srfi1_length_plus
 {
-  long len = scm_ilength (lst);
-  return (len >= 0 ? SCM_I_MAKINUM (len) : SCM_BOOL_F);
+  size_t i = 0;
+  SCM tortoise = lst;
+  SCM hare = lst;
+
+  do
+    {
+      if (SCM_NULL_OR_NIL_P (hare))
+        return scm_from_size_t (i);
+      if (!scm_is_pair (hare))
+        scm_wrong_type_arg_msg (FUNC_NAME, 1, lst, "proper or circular list");
+      hare = SCM_CDR (hare);
+      i++;
+      if (SCM_NULL_OR_NIL_P (hare))
+        return scm_from_size_t (i);
+      if (!scm_is_pair (hare))
+        scm_wrong_type_arg_msg (FUNC_NAME, 1, lst, "proper or circular list");
+      hare = SCM_CDR (hare);
+      i++;
+      /* For every two steps the hare takes, the tortoise takes one.  */
+      tortoise = SCM_CDR(tortoise);
+    }
+  while (!scm_is_eq (hare, tortoise));
+
+  /* If the tortoise ever catches the hare, then the list must contain
+     a cycle.  */
+  return SCM_BOOL_F;
 }
 #undef FUNC_NAME
 
diff --git a/test-suite/tests/srfi-1.test b/test-suite/tests/srfi-1.test
index d40f8e1..bce0e86 100644
--- a/test-suite/tests/srfi-1.test
+++ b/test-suite/tests/srfi-1.test
@@ -1,6 +1,6 @@
 ;;;; srfi-1.test --- Test suite for Guile's SRFI-1 functions. -*- scheme -*-
 ;;;;
-;;;; Copyright 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Free Software 
Foundation, Inc.
+;;;; Copyright 2003-2006, 2008-2011, 2014 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -1329,6 +1329,10 @@
     (length+))
   (pass-if-exception "too many args" exception:wrong-num-args
     (length+ 123 456))
+  (pass-if-exception "not a pair" exception:wrong-type-arg
+    (length+ 'x))
+  (pass-if-exception "improper list" exception:wrong-type-arg
+    (length+ '(x y . z)))
   (pass-if (= 0 (length+ '())))
   (pass-if (= 1 (length+ '(x))))
   (pass-if (= 2 (length+ '(x y))))


hooks/post-receive
-- 
GNU Guile



reply via email to

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