string-match and string-looking-at
- From: Matthew Love <matth love gmail com>
- To: sawfish-list gnome org
- Subject: string-match and string-looking-at
- Date: Sat, 28 Aug 2010 19:26:43 -0600
Hi all,
I've noticed that 'string-match and 'string-looking-at both
return an error when one of the input strings is '(). 'string=
will return '() in such cases.
It seems it would be better for 'string-match and 'string-looking-at to
also return '() if one of the input "strings" is not actually a string,
as in such cases the strings do not technically match.
What do you think?
I have attached a patch that will have 'string-match and
'string-looking-at return '() if one of the input strings is not a
string. Im fairly new to c so im not sure if there is a better way
to do it.
Cheers.
diff --git a/src/find.c b/src/find.c
index 6f9ec6f..7d27183 100644
--- a/src/find.c
+++ b/src/find.c
@@ -280,8 +280,15 @@ 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
+ {
+ return Qnil;
+ }
rep_DECLARE3_OPT(start, rep_INTP);
xstart = rep_INTP(start) ? rep_INT(start) : 0;
prog = rep_compile_regexp(re);
@@ -312,8 +319,15 @@ 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
+ {
+ return Qnil;
+ }
rep_DECLARE3_OPT(start, rep_INTP);
xstart = rep_INTP(start) ? rep_INT(start) : 0;
prog = rep_compile_regexp(re);
--
mrl
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]