unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* srfi-13 bug [WAS: guile-gnome-glib 2.3.993]
       [not found] ` <87isan90sd.fsf@peder.flower>
@ 2004-09-13 18:43   ` Jan Nieuwenhuizen
  2004-09-13 19:30     ` srfi-13 bug2 Jan Nieuwenhuizen
  2004-09-22  1:15     ` srfi-13 bug Marius Vollmer
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Nieuwenhuizen @ 2004-09-13 18:43 UTC (permalink / raw)
  Cc: guile-gtk discussions, guile-devel

Jan Nieuwenhuizen writes:

> Andy Wingo writes:
>
>> http://ambient.2y.net/wingo/tmp/guile-gnome-glib-2.3.993.tar.gz
>>
>> Give it a whirl
>
> It doesn't work for me with CVS guile, generate-wrapset hangs during make:

Found it.  It turns out that

    guile -c '(string-contains "" "a")'

hangs with guile CVS.  See fix below.

Greetings,
Jan.


Index: ChangeLog
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/ChangeLog,v
retrieving revision 1.2146
diff -p -u -r1.2146 ChangeLog
--- ChangeLog	8 Sep 2004 23:04:08 -0000	1.2146
+++ ChangeLog	13 Sep 2004 18:40:58 -0000
@@ -1,3 +1,8 @@
+2004-09-13  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+	* srfi-13.c (scm_string_contains): Bugfix: when subtracting
+	unsigned values, make sure that result does not wrap.
+
 2004-09-09  Kevin Ryde  <user42@zip.com.au>
 
 	* filesys.c, stime.c (_POSIX_C_SOURCE): Use this only on hpux, it
Index: srfi-13.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/srfi-13.c,v
retrieving revision 1.4
diff -p -u -r1.4 srfi-13.c
--- srfi-13.c	7 Sep 2004 13:48:49 -0000	1.4
+++ srfi-13.c	13 Sep 2004 18:40:59 -0000
@@ -2253,7 +2253,7 @@ SCM_DEFINE (scm_string_contains, "string
 				   5, start2, cstart2,
 				   6, end2, cend2);
   len2 = cend2 - cstart2;
-  while (cstart1 <= cend1 - len2)
+  while (cstart1 <= cend1 - len2 && cend1 >= len2)
     {
       i = cstart1;
       j = cstart2;

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien       | http://www.lilypond.org


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: srfi-13 bug2
  2004-09-13 18:43   ` srfi-13 bug [WAS: guile-gnome-glib 2.3.993] Jan Nieuwenhuizen
@ 2004-09-13 19:30     ` Jan Nieuwenhuizen
  2004-09-22  1:15     ` srfi-13 bug Marius Vollmer
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Nieuwenhuizen @ 2004-09-13 19:30 UTC (permalink / raw)


Jan Nieuwenhuizen writes:

> Found it.  It turns out that
>
>     guile -c '(string-contains "" "a")'
>
> hangs with guile CVS.  See fix below.

Too quick.  Same for string-contains-ci, of course.

Jan.


? do-diff
? doconf
Index: libguile/ChangeLog
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/ChangeLog,v
retrieving revision 1.2146
diff -p -u -r1.2146 ChangeLog
--- libguile/ChangeLog	8 Sep 2004 23:04:08 -0000	1.2146
+++ libguile/ChangeLog	13 Sep 2004 19:29:14 -0000
@@ -1,3 +1,9 @@
+2004-09-13  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+	* srfi-13.c (scm_string_contains, s_scm_string_contains_ci):
+	Bugfix: when subtracting unsigned values, make sure that result
+	does not wrap.
+
 2004-09-09  Kevin Ryde  <user42@zip.com.au>
 
 	* filesys.c, stime.c (_POSIX_C_SOURCE): Use this only on hpux, it
Index: libguile/srfi-13.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/srfi-13.c,v
retrieving revision 1.4
diff -p -u -r1.4 srfi-13.c
--- libguile/srfi-13.c	7 Sep 2004 13:48:49 -0000	1.4
+++ libguile/srfi-13.c	13 Sep 2004 19:29:15 -0000
@@ -2253,7 +2253,7 @@ SCM_DEFINE (scm_string_contains, "string
 				   5, start2, cstart2,
 				   6, end2, cend2);
   len2 = cend2 - cstart2;
-  while (cstart1 <= cend1 - len2)
+  while (cstart1 <= cend1 - len2 && cend1 >= len2)
     {
       i = cstart1;
       j = cstart2;
@@ -2299,7 +2299,7 @@ SCM_DEFINE (scm_string_contains_ci, "str
 				   5, start2, cstart2,
 				   6, end2, cend2);
   len2 = cend2 - cstart2;
-  while (cstart1 <= cend1 - len2)
+  while (cstart1 <= cend1 - len2 && cend1 >= len2)
     {
       i = cstart1;
       j = cstart2;

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien       | http://www.lilypond.org


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: srfi-13 bug
  2004-09-13 18:43   ` srfi-13 bug [WAS: guile-gnome-glib 2.3.993] Jan Nieuwenhuizen
  2004-09-13 19:30     ` srfi-13 bug2 Jan Nieuwenhuizen
@ 2004-09-22  1:15     ` Marius Vollmer
  2004-09-22 20:22       ` Jan Nieuwenhuizen
  1 sibling, 1 reply; 4+ messages in thread
From: Marius Vollmer @ 2004-09-22  1:15 UTC (permalink / raw)
  Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

Jan Nieuwenhuizen <janneke@gnu.org> writes:

> Found it.  It turns out that
>
>     guile -c '(string-contains "" "a")'
>
> hangs with guile CVS.  See fix below.

Thanks, excellent!  What about the variant below?  It is more
'logical' I think, immediately returning false when s1 is shorter than
s2.


[-- Attachment #2: Type: text/plain, Size: 2015 bytes --]

Index: libguile/srfi-13.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/srfi-13.c,v
retrieving revision 1.6
diff -u -r1.6 srfi-13.c
--- libguile/srfi-13.c	20 Sep 2004 22:50:31 -0000	1.6
+++ libguile/srfi-13.c	22 Sep 2004 01:13:38 -0000
@@ -2253,22 +2253,23 @@
 				   5, start2, cstart2,
 				   6, end2, cend2);
   len2 = cend2 - cstart2;
-  while (cstart1 <= cend1 - len2 && cend1 >= len2)
-    {
-      i = cstart1;
-      j = cstart2;
-      while (i < cend1 && j < cend2 && cs1[i] == cs2[j])
-	{
-	  i++;
-	  j++;
-	}
-      if (j == cend2)
-	{
-	  scm_remember_upto_here_2 (s1, s2);
-	  return scm_from_size_t (cstart1);
-	}
-      cstart1++;
-    }
+  if (cend1 - cstart1 >= len2)
+    while (cstart1 <= cend1 - len2)
+      {
+	i = cstart1;
+	j = cstart2;
+	while (i < cend1 && j < cend2 && cs1[i] == cs2[j])
+	  {
+	    i++;
+	    j++;
+	  }
+	if (j == cend2)
+	  {
+	    scm_remember_upto_here_2 (s1, s2);
+	    return scm_from_size_t (cstart1);
+	  }
+	cstart1++;
+      }
 
   scm_remember_upto_here_2 (s1, s2);
   return SCM_BOOL_F;
@@ -2299,23 +2300,24 @@
 				   5, start2, cstart2,
 				   6, end2, cend2);
   len2 = cend2 - cstart2;
-  while (cstart1 <= cend1 - len2 && cend1 >= len2)
-    {
-      i = cstart1;
-      j = cstart2;
-      while (i < cend1 && j < cend2 &&
-	     scm_c_downcase (cs1[i]) == scm_c_downcase (cs2[j]))
-	{
-	  i++;
-	  j++;
-	}
-      if (j == cend2)
-	{
-	  scm_remember_upto_here_2 (s1, s2);
-	  return scm_from_size_t (cstart1);
-	}
-      cstart1++;
-    }
+  if (cend1 - cstart1 >= len2)
+    while (cstart1 <= cend1 - len2)
+      {
+	i = cstart1;
+	j = cstart2;
+	while (i < cend1 && j < cend2 &&
+	       scm_c_downcase (cs1[i]) == scm_c_downcase (cs2[j]))
+	  {
+	    i++;
+	    j++;
+	  }
+	if (j == cend2)
+	  {
+	    scm_remember_upto_here_2 (s1, s2);
+	    return scm_from_size_t (cstart1);
+	  }
+	cstart1++;
+      }
   
   scm_remember_upto_here_2 (s1, s2);
   return SCM_BOOL_F;

[-- Attachment #3: Type: text/plain, Size: 72 bytes --]


-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405

[-- Attachment #4: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: srfi-13 bug
  2004-09-22  1:15     ` srfi-13 bug Marius Vollmer
@ 2004-09-22 20:22       ` Jan Nieuwenhuizen
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Nieuwenhuizen @ 2004-09-22 20:22 UTC (permalink / raw)
  Cc: guile-devel

Marius Vollmer writes:

> Thanks, excellent!  What about the variant below?  It is more
> 'logical' I think, immediately returning false when s1 is shorter than
> s2.

Yes, it reads better (but the diff is bigger :-)

Jan.
-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien       | http://www.lilypond.org


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-09-22 20:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1094681451.3785.368.camel@localhost>
     [not found] ` <87isan90sd.fsf@peder.flower>
2004-09-13 18:43   ` srfi-13 bug [WAS: guile-gnome-glib 2.3.993] Jan Nieuwenhuizen
2004-09-13 19:30     ` srfi-13 bug2 Jan Nieuwenhuizen
2004-09-22  1:15     ` srfi-13 bug Marius Vollmer
2004-09-22 20:22       ` Jan Nieuwenhuizen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).