*** empty log message ***
[bpt/guile.git] / libguile / regex-posix.c
index d01b4e0..9b1ec07 100644 (file)
@@ -1,4 +1,4 @@
-/*     Copyright (C) 1997 Free Software Foundation, Inc.
+/*     Copyright (C) 1997, 1998 Free Software Foundation, Inc.
  * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -117,7 +117,7 @@ static scm_smobfuns regex_t_smob =
 
 SCM_SYMBOL (scm_regexp_error_key, "regular-expression-syntax");
 
-char *
+static char *
 scm_regexp_error_msg (regerrno, rx)
      int regerrno;
      SCM rx;
@@ -224,7 +224,7 @@ scm_regexp_exec (SCM rx, SCM str, SCM start, SCM flags)
     {
       SCM_ASSERT (SCM_INUMP (start), start, SCM_ARG3, s_regexp_exec);
       offset = SCM_INUM (start);
-      SCM_ASSERT (offset >= 0 && offset <= SCM_LENGTH (str), start,
+      SCM_ASSERT (offset >= 0 && (unsigned) offset <= SCM_LENGTH (str), start,
                  SCM_OUTOFRANGE, s_regexp_exec);
     }
 
@@ -252,8 +252,12 @@ scm_regexp_exec (SCM rx, SCM str, SCM start, SCM flags)
       mvec = scm_make_vector (SCM_MAKINUM (nmatches + 1), SCM_UNSPECIFIED);
       SCM_VELTS(mvec)[0] = str;
       for (i = 0; i < nmatches; ++i)
-       SCM_VELTS(mvec)[i+1] = scm_cons(SCM_MAKINUM(matches[i].rm_so + offset),
-                                       SCM_MAKINUM(matches[i].rm_eo + offset));
+       if (matches[i].rm_so == -1)
+         SCM_VELTS(mvec)[i+1] = scm_cons (SCM_MAKINUM (-1), SCM_MAKINUM (-1));
+       else
+         SCM_VELTS(mvec)[i+1]
+           = scm_cons(SCM_MAKINUM(matches[i].rm_so + offset),
+                      SCM_MAKINUM(matches[i].rm_eo + offset));
     }
   scm_must_free ((char *) matches);
   SCM_ALLOW_INTS;