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
e53628eb
Commit
e53628eb
authored
Mar 12, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #984 from monaka/pr-make-mrb_str_new2-obsolete
Remove mrb_str_new2().
parents
7ba30960
be506de3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
19 deletions
+19
-19
include/mruby.h
include/mruby.h
+0
-1
mrbgems/mruby-sprintf/src/sprintf.c
mrbgems/mruby-sprintf/src/sprintf.c
+1
-1
mrbgems/mruby-struct/src/struct.c
mrbgems/mruby-struct/src/struct.c
+1
-1
src/error.c
src/error.c
+3
-3
src/string.c
src/string.c
+14
-13
No files found.
include/mruby.h
View file @
e53628eb
...
...
@@ -203,7 +203,6 @@ void *mrb_free(mrb_state*, void*);
mrb_value
mrb_str_new
(
mrb_state
*
mrb
,
const
char
*
p
,
int
len
);
/* mrb_str_new */
mrb_value
mrb_str_new_cstr
(
mrb_state
*
,
const
char
*
);
mrb_value
mrb_str_new2
(
mrb_state
*
mrb
,
const
char
*
p
);
mrb_state
*
mrb_open
(
void
);
mrb_state
*
mrb_open_allocf
(
mrb_allocf
,
void
*
ud
);
...
...
mrbgems/mruby-sprintf/src/sprintf.c
View file @
e53628eb
...
...
@@ -111,7 +111,7 @@ mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base)
}
}
return
mrb_str_new
2
(
mrb
,
b
);
return
mrb_str_new
_cstr
(
mrb
,
b
);
}
#define FNONE 0
...
...
mrbgems/mruby-struct/src/struct.c
View file @
e53628eb
...
...
@@ -288,7 +288,7 @@ mrb_struct_define(mrb_state *mrb, const char *name, ...)
char
*
mem
;
if
(
!
name
)
nm
=
mrb_nil_value
();
else
nm
=
mrb_str_new
2
(
mrb
,
name
);
else
nm
=
mrb_str_new
_cstr
(
mrb
,
name
);
ary
=
mrb_ary_new
(
mrb
);
va_start
(
ar
,
name
);
...
...
src/error.c
View file @
e53628eb
...
...
@@ -89,7 +89,7 @@ exc_to_s(mrb_state *mrb, mrb_value exc)
{
mrb_value
mesg
=
mrb_attr_get
(
mrb
,
exc
,
mrb_intern
(
mrb
,
"mesg"
));
if
(
mrb_nil_p
(
mesg
))
return
mrb_str_new
2
(
mrb
,
mrb_obj_classname
(
mrb
,
exc
));
if
(
mrb_nil_p
(
mesg
))
return
mrb_str_new
_cstr
(
mrb
,
mrb_obj_classname
(
mrb
,
exc
));
return
mesg
;
}
...
...
@@ -140,7 +140,7 @@ exc_inspect(mrb_state *mrb, mrb_value exc)
}
}
else
{
str
=
mrb_str_new
2
(
mrb
,
mrb_obj_classname
(
mrb
,
exc
));
str
=
mrb_str_new
_cstr
(
mrb
,
mrb_obj_classname
(
mrb
,
exc
));
if
(
!
mrb_nil_p
(
mesg
)
&&
RSTRING_LEN
(
mesg
)
>
0
)
{
mrb_str_cat2
(
mrb
,
str
,
": "
);
mrb_str_append
(
mrb
,
str
,
mesg
);
...
...
@@ -218,7 +218,7 @@ void
mrb_raise
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
const
char
*
msg
)
{
mrb_value
mesg
;
mesg
=
mrb_str_new
2
(
mrb
,
msg
);
mesg
=
mrb_str_new
_cstr
(
mrb
,
msg
);
mrb_exc_raise
(
mrb
,
mrb_exc_new3
(
mrb
,
c
,
mesg
));
}
...
...
src/string.c
View file @
e53628eb
...
...
@@ -236,17 +236,6 @@ mrb_str_new(mrb_state *mrb, const char *p, mrb_int len)
return
mrb_obj_value
(
s
);
}
mrb_value
mrb_str_new2
(
mrb_state
*
mrb
,
const
char
*
ptr
)
{
struct
RString
*
s
;
if
(
!
ptr
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"NULL pointer given"
);
}
s
=
str_new
(
mrb
,
ptr
,
strlen
(
ptr
));
return
mrb_obj_value
(
s
);
}
/*
* call-seq: (Caution! NULL string)
* String.new(str="") => new_str
...
...
@@ -258,11 +247,23 @@ mrb_value
mrb_str_new_cstr
(
mrb_state
*
mrb
,
const
char
*
p
)
{
struct
RString
*
s
;
int
len
=
strlen
(
p
);
size_t
len
;
if
(
p
)
{
len
=
strlen
(
p
);
if
(
len
>
MRB_INT_MAX
)
{
len
=
MRB_INT_MAX
;
}
}
else
{
len
=
0
;
}
s
=
mrb_obj_alloc_string
(
mrb
);
s
->
ptr
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
memcpy
(
s
->
ptr
,
p
,
len
);
if
(
p
)
{
memcpy
(
s
->
ptr
,
p
,
len
);
}
s
->
ptr
[
len
]
=
0
;
s
->
len
=
len
;
s
->
aux
.
capa
=
len
;
...
...
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