Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
d0e63a3a
Commit
d0e63a3a
authored
May 07, 2012
by
Yukihiro Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RMatch.src should not be mrb_value
parent
c51c8dd1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
21 deletions
+19
-21
include/mruby/string.h
include/mruby/string.h
+1
-1
src/re.c
src/re.c
+14
-16
src/re.h
src/re.h
+1
-1
src/string.c
src/string.c
+3
-3
No files found.
include/mruby/string.h
View file @
d0e63a3a
...
@@ -110,7 +110,7 @@ void mrb_str_setter(mrb_state *mrb, mrb_value val, mrb_sym id, mrb_value *var);
...
@@ -110,7 +110,7 @@ void mrb_str_setter(mrb_state *mrb, mrb_value val, mrb_sym id, mrb_value *var);
int
mrb_str_is_ascii_only_p
(
mrb_state
*
mrb
,
mrb_value
str
);
int
mrb_str_is_ascii_only_p
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_inspect
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_inspect
(
mrb_state
*
mrb
,
mrb_value
str
);
int
mrb_str_equal
(
mrb_state
*
mrb
,
mrb_value
str1
,
mrb_value
str2
);
int
mrb_str_equal
(
mrb_state
*
mrb
,
mrb_value
str1
,
mrb_value
str2
);
mrb_value
str_new4
(
mrb_state
*
mrb
,
enum
mrb_vtype
ttype
,
mrb_value
str
);
mrb_value
str_new4
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
*
mrb_svar
(
mrb_int
cnt
);
mrb_value
*
mrb_svar
(
mrb_int
cnt
);
mrb_value
mrb_str_drop_bytes
(
mrb_state
*
mrb
,
mrb_value
str
,
long
len
);
mrb_value
mrb_str_drop_bytes
(
mrb_state
*
mrb
,
mrb_value
str
,
long
len
);
mrb_value
mrb_str_dump
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_dump
(
mrb_state
*
mrb
,
mrb_value
str
);
...
...
src/re.c
View file @
d0e63a3a
...
@@ -237,7 +237,7 @@ static void
...
@@ -237,7 +237,7 @@ static void
match_check
(
mrb_state
*
mrb
,
mrb_value
match
)
match_check
(
mrb_state
*
mrb
,
mrb_value
match
)
{
{
struct
RMatch
*
m
=
mrb_match_ptr
(
match
);
struct
RMatch
*
m
=
mrb_match_ptr
(
match
);
if
(
!
m
->
str
.
tt
)
{
if
(
!
m
->
str
)
{
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"uninitialized Match"
);
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"uninitialized Match"
);
}
}
}
}
...
@@ -262,7 +262,7 @@ mrb_reg_nth_match(mrb_state *mrb, mrb_int nth, mrb_value match)
...
@@ -262,7 +262,7 @@ mrb_reg_nth_match(mrb_state *mrb, mrb_int nth, mrb_value match)
if
(
start
==
-
1
)
return
mrb_nil_value
();
if
(
start
==
-
1
)
return
mrb_nil_value
();
end
=
m
->
rmatch
->
regs
.
end
[
nth
];
end
=
m
->
rmatch
->
regs
.
end
[
nth
];
len
=
end
-
start
;
len
=
end
-
start
;
str
=
mrb_str_substr
(
mrb
,
m
->
str
,
start
,
len
);
str
=
mrb_str_substr
(
mrb
,
m
rb_obj_value
(
m
->
str
)
,
start
,
len
);
return
str
;
return
str
;
}
}
...
@@ -581,7 +581,7 @@ mrb_reg_search(mrb_state *mrb, mrb_value re, mrb_value str, mrb_int pos, mrb_int
...
@@ -581,7 +581,7 @@ mrb_reg_search(mrb_state *mrb, mrb_value re, mrb_value str, mrb_int pos, mrb_int
onig_region_free
(
regs
,
0
);
onig_region_free
(
regs
,
0
);
}
}
RMATCH
(
match
)
->
str
=
str_new4
(
mrb
,
str
.
tt
,
str
);
RMATCH
(
match
)
->
str
=
mrb_str_ptr
(
str
);
RMATCH
(
match
)
->
regexp
=
mrb_regex_ptr
(
re
);
RMATCH
(
match
)
->
regexp
=
mrb_regex_ptr
(
re
);
RMATCH
(
match
)
->
rmatch
->
char_offset_updated
=
0
;
RMATCH
(
match
)
->
rmatch
->
char_offset_updated
=
0
;
mrb_backref_set
(
mrb
,
match
);
mrb_backref_set
(
mrb
,
match
);
...
@@ -1673,7 +1673,7 @@ match_alloc(mrb_state *mrb)
...
@@ -1673,7 +1673,7 @@ match_alloc(mrb_state *mrb)
// NEWOBJ(match, struct RMatch);
// NEWOBJ(match, struct RMatch);
// OBJSETUP(match, klass, T_MATCH);
// OBJSETUP(match, klass, T_MATCH);
m
->
str
=
mrb_nil_value
()
;
m
->
str
=
0
;
m
->
rmatch
=
0
;
m
->
rmatch
=
0
;
m
->
regexp
=
0
;
m
->
regexp
=
0
;
m
->
rmatch
=
mrb_malloc
(
mrb
,
sizeof
(
struct
rmatch
));
//ALLOC(struct rmatch);
m
->
rmatch
=
mrb_malloc
(
mrb
,
sizeof
(
struct
rmatch
));
//ALLOC(struct rmatch);
...
@@ -1791,7 +1791,7 @@ update_char_offset(mrb_state *mrb, mrb_value match)
...
@@ -1791,7 +1791,7 @@ update_char_offset(mrb_state *mrb, mrb_value match)
rm
->
char_offset_num_allocated
=
num_regs
;
rm
->
char_offset_num_allocated
=
num_regs
;
}
}
enc
=
mrb_enc_get
(
mrb
,
RMATCH
(
match
)
->
str
);
enc
=
mrb_enc_get
(
mrb
,
mrb_obj_value
(
RMATCH
(
match
)
->
str
)
);
if
(
mrb_enc_mbmaxlen
(
enc
)
==
1
)
{
if
(
mrb_enc_mbmaxlen
(
enc
)
==
1
)
{
for
(
i
=
0
;
i
<
num_regs
;
i
++
)
{
for
(
i
=
0
;
i
<
num_regs
;
i
++
)
{
rm
->
char_offset
[
i
].
beg
=
BEG
(
i
);
rm
->
char_offset
[
i
].
beg
=
BEG
(
i
);
...
@@ -1813,7 +1813,7 @@ update_char_offset(mrb_state *mrb, mrb_value match)
...
@@ -1813,7 +1813,7 @@ update_char_offset(mrb_state *mrb, mrb_value match)
}
}
qsort
(
pairs
,
num_pos
,
sizeof
(
pair_t
),
pair_byte_cmp
);
qsort
(
pairs
,
num_pos
,
sizeof
(
pair_t
),
pair_byte_cmp
);
s
=
p
=
R
STRING_PTR
(
RMATCH
(
match
)
->
str
)
;
s
=
p
=
R
MATCH
(
match
)
->
str
->
buf
;
c
=
0
;
c
=
0
;
for
(
i
=
0
;
i
<
num_pos
;
i
++
)
{
for
(
i
=
0
;
i
<
num_pos
;
i
++
)
{
q
=
s
+
pairs
[
i
].
byte_pos
;
q
=
s
+
pairs
[
i
].
byte_pos
;
...
@@ -1886,7 +1886,7 @@ match_array(mrb_state *mrb, mrb_value match, int start)
...
@@ -1886,7 +1886,7 @@ match_array(mrb_state *mrb, mrb_value match, int start)
{
{
struct
re_registers
*
regs
;
struct
re_registers
*
regs
;
mrb_value
ary
;
mrb_value
ary
;
mrb_value
target
;
struct
RString
*
target
;
int
i
;
int
i
;
match_check
(
mrb
,
match
);
match_check
(
mrb
,
match
);
...
@@ -1899,7 +1899,7 @@ match_array(mrb_state *mrb, mrb_value match, int start)
...
@@ -1899,7 +1899,7 @@ match_array(mrb_state *mrb, mrb_value match, int start)
mrb_ary_push
(
mrb
,
ary
,
mrb_nil_value
());
mrb_ary_push
(
mrb
,
ary
,
mrb_nil_value
());
}
}
else
{
else
{
mrb_value
str
=
mrb_str_subseq
(
mrb
,
target
,
regs
->
beg
[
i
],
regs
->
end
[
i
]
-
regs
->
beg
[
i
]);
mrb_value
str
=
mrb_str_subseq
(
mrb
,
mrb_obj_value
(
target
)
,
regs
->
beg
[
i
],
regs
->
end
[
i
]
-
regs
->
beg
[
i
]);
mrb_ary_push
(
mrb
,
ary
,
str
);
mrb_ary_push
(
mrb
,
ary
,
str
);
}
}
}
}
...
@@ -2084,7 +2084,7 @@ mrb_match_offset(mrb_state *mrb, mrb_value match/*, mrb_value n*/)
...
@@ -2084,7 +2084,7 @@ mrb_match_offset(mrb_state *mrb, mrb_value match/*, mrb_value n*/)
mrb_value
mrb_value
mrb_reg_match_post
(
mrb_state
*
mrb
,
mrb_value
match
)
mrb_reg_match_post
(
mrb_state
*
mrb
,
mrb_value
match
)
{
{
mrb_value
str
;
struct
RString
*
str
;
long
pos
;
long
pos
;
struct
re_registers
*
regs
;
struct
re_registers
*
regs
;
...
@@ -2094,9 +2094,7 @@ mrb_reg_match_post(mrb_state *mrb, mrb_value match)
...
@@ -2094,9 +2094,7 @@ mrb_reg_match_post(mrb_state *mrb, mrb_value match)
if
(
BEG
(
0
)
==
-
1
)
return
mrb_nil_value
();
if
(
BEG
(
0
)
==
-
1
)
return
mrb_nil_value
();
str
=
RMATCH
(
match
)
->
str
;
str
=
RMATCH
(
match
)
->
str
;
pos
=
END
(
0
);
pos
=
END
(
0
);
str
=
mrb_str_subseq
(
mrb
,
str
,
pos
,
RSTRING_LEN
(
str
)
-
pos
);
return
mrb_str_subseq
(
mrb
,
mrb_obj_value
(
str
),
pos
,
str
->
len
-
pos
);
return
str
;
}
}
/* 15.2.16.3.9 */
/* 15.2.16.3.9 */
...
@@ -2121,7 +2119,7 @@ mrb_reg_match_pre(mrb_state *mrb, mrb_value match)
...
@@ -2121,7 +2119,7 @@ mrb_reg_match_pre(mrb_state *mrb, mrb_value match)
match_check
(
mrb
,
match
);
match_check
(
mrb
,
match
);
regs
=
RMATCH_REGS
(
match
);
regs
=
RMATCH_REGS
(
match
);
if
(
BEG
(
0
)
==
-
1
)
return
mrb_nil_value
();
if
(
BEG
(
0
)
==
-
1
)
return
mrb_nil_value
();
str
=
mrb_str_subseq
(
mrb
,
RMATCH
(
match
)
->
str
,
0
,
BEG
(
0
));
str
=
mrb_str_subseq
(
mrb
,
mrb_obj_value
(
RMATCH
(
match
)
->
str
)
,
0
,
BEG
(
0
));
return
str
;
return
str
;
}
}
...
@@ -2141,7 +2139,7 @@ static mrb_value
...
@@ -2141,7 +2139,7 @@ static mrb_value
mrb_match_string
(
mrb_state
*
mrb
,
mrb_value
match
)
mrb_match_string
(
mrb_state
*
mrb
,
mrb_value
match
)
{
{
match_check
(
mrb
,
match
);
match_check
(
mrb
,
match
);
return
RMATCH
(
match
)
->
str
;
/* str is frozen */
return
mrb_obj_value
(
RMATCH
(
match
)
->
str
);
}
}
/* 15.2.16.3.12 */
/* 15.2.16.3.12 */
...
@@ -2584,8 +2582,8 @@ mrb_match_equal(mrb_state *mrb, mrb_value match1)
...
@@ -2584,8 +2582,8 @@ mrb_match_equal(mrb_state *mrb, mrb_value match1)
mrb_get_args
(
mrb
,
"o"
,
&
match2
);
mrb_get_args
(
mrb
,
"o"
,
&
match2
);
if
(
mrb_obj_equal
(
mrb
,
match1
,
match2
))
return
mrb_true_value
();
if
(
mrb_obj_equal
(
mrb
,
match1
,
match2
))
return
mrb_true_value
();
if
(
mrb_type
(
match2
)
!=
MRB_TT_MATCH
)
return
mrb_false_value
();
if
(
mrb_type
(
match2
)
!=
MRB_TT_MATCH
)
return
mrb_false_value
();
if
(
!
mrb_str_equal
(
mrb
,
RMATCH
(
match1
)
->
str
,
RMATCH
(
match2
)
->
str
))
return
mrb_false_value
();
if
(
!
mrb_str_equal
(
mrb
,
mrb_obj_value
(
RMATCH
(
match1
)
->
str
),
mrb_obj_value
(
RMATCH
(
match2
)
->
str
)))
return
mrb_false_value
();
if
(
!
reg_equal
(
mrb
,
RMATCH
(
match1
)
->
regexp
,
RMATCH
(
match2
)
->
regexp
))
return
mrb_false_value
();
if
(
!
reg_equal
(
mrb
,
RMATCH
(
match1
)
->
regexp
,
RMATCH
(
match2
)
->
regexp
))
return
mrb_false_value
();
regs1
=
RMATCH_REGS
(
match1
);
regs1
=
RMATCH_REGS
(
match1
);
regs2
=
RMATCH_REGS
(
match2
);
regs2
=
RMATCH_REGS
(
match2
);
...
...
src/re.h
View file @
d0e63a3a
...
@@ -37,7 +37,7 @@ struct rmatch {
...
@@ -37,7 +37,7 @@ struct rmatch {
//};
//};
struct
RMatch
{
struct
RMatch
{
MRUBY_OBJECT_HEADER
;
MRUBY_OBJECT_HEADER
;
mrb_value
str
;
struct
RString
*
str
;
struct
rmatch
*
rmatch
;
struct
rmatch
*
rmatch
;
struct
RRegexp
*
regexp
;
struct
RRegexp
*
regexp
;
};
};
...
...
src/string.c
View file @
d0e63a3a
...
@@ -479,11 +479,11 @@ mrb_enc_cr_str_exact_copy(mrb_state *mrb, mrb_value dest, mrb_value src)
...
@@ -479,11 +479,11 @@ mrb_enc_cr_str_exact_copy(mrb_state *mrb, mrb_value dest, mrb_value src)
#endif //INCLUDE_ENCODING
#endif //INCLUDE_ENCODING
mrb_value
mrb_value
str_new4
(
mrb_state
*
mrb
,
enum
mrb_vtype
ttype
,
mrb_value
str
)
str_new4
(
mrb_state
*
mrb
,
mrb_value
str
)
{
{
mrb_value
str2
;
mrb_value
str2
;
str2
=
mrb_obj_value
(
mrb_obj_alloc
(
mrb
,
ttype
,
mrb
->
string_class
));
//str_alloc(klass
);
str2
=
mrb_obj_value
(
mrb_obj_alloc
(
mrb
,
MRB_TT_STRING
,
mrb
->
string_class
)
);
RSTRING
(
str2
)
->
len
=
RSTRING_LEN
(
str
);
RSTRING
(
str2
)
->
len
=
RSTRING_LEN
(
str
);
RSTRING
(
str2
)
->
buf
=
RSTRING_PTR
(
str
);
RSTRING
(
str2
)
->
buf
=
RSTRING_PTR
(
str
);
...
@@ -2225,7 +2225,7 @@ mrb_str_new_frozen(mrb_state *mrb, mrb_value orig)
...
@@ -2225,7 +2225,7 @@ mrb_str_new_frozen(mrb_state *mrb, mrb_value orig)
}
}
}
}
else
{
else
{
str
=
str_new4
(
mrb
,
orig
.
tt
,
orig
);
str
=
str_new4
(
mrb
,
orig
);
}
}
return
str
;
return
str
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment