[librep] let string-match and string-looking at return Qnil if one of the passed arguements is not a string (



commit 9171c2cd3d01b91678d54cbbfab257b95f94164b
Author: Christopher Roy Bratusek <zanghar freenet de>
Date:   Sun Aug 29 07:42:33 2010 +0200

    let string-match and string-looking at return Qnil
    if one of the passed arguements is not a string (and output a msg)

 src/find.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/src/find.c b/src/find.c
index 6f9ec6f..5ac6cc8 100644
--- a/src/find.c
+++ b/src/find.c
@@ -280,8 +280,16 @@ still case-significant.
 {
     rep_regexp *prog;
     long xstart;
-    rep_DECLARE1(re, rep_STRINGP);
-    rep_DECLARE2(str, rep_STRINGP);
+    if(rep_STRINGP(re) && rep_STRINGP(str))
+      {
+	rep_DECLARE1(re, rep_STRINGP);
+	rep_DECLARE2(str, rep_STRINGP);
+      }
+    else
+      {
+	fprintf (stdout, " ** only strings are allowed to be passed to `string-match'.");
+	return Qnil;
+      }
     rep_DECLARE3_OPT(start, rep_INTP);
     xstart = rep_INTP(start) ? rep_INT(start) : 0;
     prog = rep_compile_regexp(re);
@@ -312,8 +320,16 @@ Updates the match data.
 {
     rep_regexp *prog;
     long xstart;
-    rep_DECLARE1(re, rep_STRINGP);
-    rep_DECLARE2(string, rep_STRINGP);
+    if(rep_STRINGP(re) && rep_STRINGP(string))
+      {
+	rep_DECLARE1(re, rep_STRINGP);
+	rep_DECLARE2(string, rep_STRINGP);
+      }
+    else
+      {
+	fprintf (stdout, " ** only strings are allowed to be passed to `string-looking-at'.");
+	return Qnil;
+      }
     rep_DECLARE3_OPT(start, rep_INTP);
     xstart = rep_INTP(start) ? rep_INT(start) : 0;
     prog = rep_compile_regexp(re);



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