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
00cf5e32
Commit
00cf5e32
authored
Mar 13, 2013
by
Tomoyuki Sahara
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into pr-systemcallerror
parents
b67fb972
c9f3fd47
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
50 deletions
+33
-50
include/mrbconf.h
include/mrbconf.h
+4
-0
include/mruby.h
include/mruby.h
+0
-1
include/mruby/string.h
include/mruby/string.h
+0
-3
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
+24
-41
No files found.
include/mrbconf.h
View file @
00cf5e32
...
...
@@ -46,6 +46,10 @@
/* page size of memory pool */
//#define POOL_PAGE_SIZE 16000
/* initial minimum size for string buffer */
//#define MRB_STR_BUF_MIN_SIZE 128
/* -DDISABLE_XXXX to drop following features */
//#define DISABLE_STDIO /* use of stdio */
...
...
include/mruby.h
View file @
00cf5e32
...
...
@@ -204,7 +204,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
);
...
...
include/mruby/string.h
View file @
00cf5e32
...
...
@@ -13,8 +13,6 @@ extern "C" {
#define IS_EVSTR(p,e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))
#define STR_BUF_MIN_SIZE 128
extern
const
char
mrb_digitmap
[];
typedef
struct
mrb_shared_string
{
...
...
@@ -55,7 +53,6 @@ mrb_value mrb_str_buf_cat(mrb_state *mrb, mrb_value str, const char *ptr, int le
char
*
mrb_string_value_cstr
(
mrb_state
*
mrb
,
mrb_value
*
ptr
);
char
*
mrb_string_value_ptr
(
mrb_state
*
mrb
,
mrb_value
ptr
);
int
mrb_str_sublen
(
mrb_state
*
mrb
,
mrb_value
str
,
int
pos
);
int
mrb_str_offset
(
mrb_state
*
mrb
,
mrb_value
str
,
int
pos
);
mrb_value
mrb_str_dup
(
mrb_state
*
mrb
,
mrb_value
str
);
/* mrb_str_dup */
mrb_value
mrb_str_intern
(
mrb_state
*
mrb
,
mrb_value
self
);
...
...
mrbgems/mruby-sprintf/src/sprintf.c
View file @
00cf5e32
...
...
@@ -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 @
00cf5e32
...
...
@@ -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 @
00cf5e32
...
...
@@ -90,7 +90,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
;
}
...
...
@@ -141,7 +141,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
);
...
...
@@ -219,7 +219,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 @
00cf5e32
...
...
@@ -106,21 +106,6 @@ str_mod_check(mrb_state *mrb, mrb_value str, char *p, mrb_int len)
#define mrb_obj_alloc_string(mrb) ((struct RString*)mrb_obj_alloc((mrb), MRB_TT_STRING, (mrb)->string_class))
static
struct
RString
*
str_alloc
(
mrb_state
*
mrb
,
struct
RClass
*
c
)
{
struct
RString
*
s
;
s
=
mrb_obj_alloc_string
(
mrb
);
s
->
c
=
c
;
s
->
ptr
=
0
;
s
->
len
=
0
;
s
->
aux
.
capa
=
0
;
return
s
;
}
/* char offset to byte offset */
int
mrb_str_offset
(
mrb_state
*
mrb
,
mrb_value
str
,
int
pos
)
...
...
@@ -131,8 +116,9 @@ mrb_str_offset(mrb_state *mrb, mrb_value str, int pos)
static
struct
RString
*
str_new
(
mrb_state
*
mrb
,
const
char
*
p
,
int
len
)
{
struct
RString
*
s
=
str_alloc
(
mrb
,
mrb
->
string_class
)
;
struct
RString
*
s
;
s
=
mrb_obj_alloc_string
(
mrb
);
s
->
len
=
len
;
s
->
aux
.
capa
=
len
;
s
->
ptr
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
...
...
@@ -158,6 +144,10 @@ mrb_str_new_empty(mrb_state *mrb, mrb_value str)
return
mrb_obj_value
(
s
);
}
#ifndef MRB_STR_BUF_MIN_SIZE
# define MRB_STR_BUF_MIN_SIZE 128
#endif
mrb_value
mrb_str_buf_new
(
mrb_state
*
mrb
,
int
capa
)
{
...
...
@@ -165,8 +155,8 @@ mrb_str_buf_new(mrb_state *mrb, int capa)
s
=
mrb_obj_alloc_string
(
mrb
);
if
(
capa
<
STR_BUF_MIN_SIZE
)
{
capa
=
STR_BUF_MIN_SIZE
;
if
(
capa
<
MRB_
STR_BUF_MIN_SIZE
)
{
capa
=
MRB_
STR_BUF_MIN_SIZE
;
}
s
->
len
=
0
;
s
->
aux
.
capa
=
capa
;
...
...
@@ -232,17 +222,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
...
...
@@ -254,11 +233,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
;
...
...
@@ -310,7 +301,7 @@ mrb_str_literal(mrb_state *mrb, mrb_value str)
struct
RString
*
s
,
*
orig
;
mrb_shared_string
*
shared
;
s
=
str_alloc
(
mrb
,
mrb
->
string_class
);
s
=
mrb_obj_alloc_string
(
mrb
);
orig
=
mrb_str_ptr
(
str
);
if
(
!
(
orig
->
flags
&
MRB_STR_SHARED
))
{
str_make_shared
(
mrb
,
mrb_str_ptr
(
str
));
...
...
@@ -319,6 +310,7 @@ mrb_str_literal(mrb_state *mrb, mrb_value str)
shared
->
refcnt
++
;
s
->
ptr
=
shared
->
ptr
;
s
->
len
=
shared
->
len
;
s
->
aux
.
capa
=
0
;
s
->
aux
.
shared
=
shared
;
s
->
flags
|=
MRB_STR_SHARED
;
...
...
@@ -1673,15 +1665,6 @@ mrb_str_rindex(mrb_state *mrb, mrb_value str, mrb_value sub, mrb_int pos)
}
}
#ifdef INCLUDE_ENCODING
/* byte offset to char offset */
int
mrb_str_sublen
(
mrb_state
*
mrb
,
mrb_value
str
,
long
pos
)
{
return
pos
;
}
#endif //INCLUDE_ENCODING
/* 15.2.10.5.31 */
/*
* call-seq:
...
...
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