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
b67fb972
Commit
b67fb972
authored
Mar 13, 2013
by
Tomoyuki Sahara
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into pr-systemcallerror
parents
7103e032
2134d6b4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
114 additions
and
84 deletions
+114
-84
include/mruby/string.h
include/mruby/string.h
+1
-1
mrbgems/mruby-sprintf/src/sprintf.c
mrbgems/mruby-sprintf/src/sprintf.c
+33
-19
src/parse.y
src/parse.y
+10
-10
src/string.c
src/string.c
+53
-36
src/variable.c
src/variable.c
+1
-0
test/driver.c
test/driver.c
+2
-1
tools/mirb/mirb.c
tools/mirb/mirb.c
+2
-1
tools/mruby/mruby.c
tools/mruby/mruby.c
+12
-16
No files found.
include/mruby/string.h
View file @
b67fb972
...
...
@@ -68,7 +68,7 @@ mrb_value mrb_str_buf_append(mrb_state *mrb, mrb_value str, mrb_value str2);
mrb_value
mrb_str_inspect
(
mrb_state
*
mrb
,
mrb_value
str
);
int
mrb_str_equal
(
mrb_state
*
mrb
,
mrb_value
str1
,
mrb_value
str2
);
mrb_value
mrb_str_dump
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_cat
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
,
long
len
);
mrb_value
mrb_str_cat
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
,
mrb_int
len
);
mrb_value
mrb_str_append
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_value
str2
);
int
mrb_str_cmp
(
mrb_state
*
mrb
,
mrb_value
str1
,
mrb_value
str2
);
...
...
mrbgems/mruby-sprintf/src/sprintf.c
View file @
b67fb972
...
...
@@ -26,7 +26,7 @@
#define BITSPERDIG (sizeof(mrb_int)*CHAR_BIT)
#define EXTENDSIGN(n, l) (((~0 << (n)) >> (((n)*(l)) % BITSPERDIG)) & ~(~0 << (n)))
static
void
fmt_setup
(
char
*
,
size_t
,
int
,
int
,
int
,
int
);
static
void
fmt_setup
(
char
*
,
size_t
,
int
,
int
,
mrb_int
,
mrb_
int
);
static
char
*
remove_sign_bits
(
char
*
str
,
int
base
)
...
...
@@ -78,7 +78,8 @@ static mrb_value
mrb_fix2binstr
(
mrb_state
*
mrb
,
mrb_value
x
,
int
base
)
{
char
buf
[
64
],
*
b
=
buf
+
sizeof
buf
;
unsigned
long
val
=
mrb_fixnum
(
x
);
mrb_int
num
=
mrb_fixnum
(
x
);
unsigned
long
val
=
(
unsigned
long
)
num
;
char
d
;
if
(
base
!=
2
)
{
...
...
@@ -96,7 +97,7 @@ mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base)
*--
b
=
mrb_digitmap
[(
int
)(
val
%
base
)];
}
while
(
val
/=
base
);
if
(
mrb_fixnum
(
x
)
<
0
)
{
if
(
num
<
0
)
{
b
=
remove_sign_bits
(
b
,
base
);
switch
(
base
)
{
case
16
:
d
=
'f'
;
break
;
...
...
@@ -495,10 +496,13 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
{
const
char
*
p
,
*
end
;
char
*
buf
;
long
blen
,
bsiz
;
mrb_int
blen
;
mrb_int
bsiz
;
mrb_value
result
;
int
n
;
int
width
,
prec
,
flags
=
FNONE
;
mrb_int
n
;
mrb_int
width
;
mrb_int
prec
;
int
flags
=
FNONE
;
int
nextarg
=
1
;
int
posarg
=
0
;
mrb_value
nextvalue
;
...
...
@@ -709,7 +713,8 @@ retry:
format_s:
{
mrb_value
arg
=
GETARG
();
long
len
,
slen
;
mrb_int
len
;
mrb_int
slen
;
if
(
*
p
==
'p'
)
arg
=
mrb_inspect
(
mrb
,
arg
);
str
=
mrb_obj_as_string
(
mrb
,
arg
);
...
...
@@ -760,12 +765,12 @@ retry:
case
'u'
:
{
mrb_value
val
=
GETARG
();
char
fbuf
[
32
],
nbuf
[
64
],
*
s
;
const
char
*
prefix
=
0
;
const
char
*
prefix
=
NULL
;
int
sign
=
0
,
dots
=
0
;
char
sc
=
0
;
long
v
=
0
,
org_v
=
0
;
mrb_int
v
=
0
,
org_v
=
0
;
int
base
;
int
len
;
mrb_
int
len
;
switch
(
*
p
)
{
case
'd'
:
...
...
@@ -807,7 +812,7 @@ retry:
val
=
mrb_str_to_inum
(
mrb
,
val
,
0
,
TRUE
);
goto
bin_retry
;
case
MRB_TT_FIXNUM
:
v
=
(
long
)
mrb_fixnum
(
val
);
v
=
mrb_fixnum
(
val
);
break
;
default:
val
=
mrb_Integer
(
mrb
,
val
);
...
...
@@ -888,7 +893,12 @@ retry:
}
}
}
len
=
(
int
)
strlen
(
s
);
{
size_t
size
;
size
=
strlen
(
s
);
/* PARANOID: assert(size <= MRB_INT_MAX) */
len
=
(
mrb_int
)
size
;
}
if
(
dots
)
{
prec
-=
2
;
...
...
@@ -906,22 +916,26 @@ retry:
if
(
prefix
&&
!
prefix
[
1
])
{
/* octal */
if
(
dots
)
{
prefix
=
0
;
prefix
=
NULL
;
}
else
if
(
len
==
1
&&
*
s
==
'0'
)
{
len
=
0
;
if
(
flags
&
FPREC
)
prec
--
;
}
else
if
((
flags
&
FPREC
)
&&
(
prec
>
len
))
{
prefix
=
0
;
prefix
=
NULL
;
}
}
else
if
(
len
==
1
&&
*
s
==
'0'
)
{
prefix
=
0
;
prefix
=
NULL
;
}
if
(
prefix
)
{
width
-=
(
int
)
strlen
(
prefix
);
size_t
size
;
size
=
strlen
(
prefix
);
/* PARANOID: assert(size <= MRB_INT_MAX).
* this check is absolutely paranoid. */
width
-=
(
mrb_int
)
size
;
}
if
((
flags
&
(
FZERO
|
FMINUS
|
FPREC
))
==
FZERO
)
{
...
...
@@ -1064,7 +1078,7 @@ retry:
}
static
void
fmt_setup
(
char
*
buf
,
size_t
size
,
int
c
,
int
flags
,
int
width
,
int
prec
)
fmt_setup
(
char
*
buf
,
size_t
size
,
int
c
,
int
flags
,
mrb_int
width
,
mrb_
int
prec
)
{
char
*
end
=
buf
+
size
;
int
n
;
...
...
@@ -1077,12 +1091,12 @@ fmt_setup(char *buf, size_t size, int c, int flags, int width, int prec)
if
(
flags
&
FSPACE
)
*
buf
++
=
' '
;
if
(
flags
&
FWIDTH
)
{
n
=
snprintf
(
buf
,
end
-
buf
,
"%d"
,
width
);
n
=
snprintf
(
buf
,
end
-
buf
,
"%d"
,
(
int
)
width
);
buf
+=
n
;
}
if
(
flags
&
FPREC
)
{
n
=
snprintf
(
buf
,
end
-
buf
,
".%d"
,
prec
);
n
=
snprintf
(
buf
,
end
-
buf
,
".%d"
,
(
int
)
prec
);
buf
+=
n
;
}
...
...
src/parse.y
View file @
b67fb972
...
...
@@ -3457,19 +3457,19 @@ read_escape(parser_state *p)
case '0': case '1': case '2': case '3': /* octal constant */
case '4': case '5': case '6': case '7':
{
int buf[3];
int i;
int buf[3];
int i;
buf[0] = c;
for (i=1; i<3; i++) {
buf[0] = c;
for (i=1; i<3; i++) {
buf[i] = nextc(p);
if (buf[i] == -1) goto eof;
if (buf[i] < '0' || '7' < buf[i]) {
pushback(p, buf[i]);
break;
}
}
c = scan_oct(buf, i, &i);
if (buf[i] < '0' || '7' < buf[i]) {
pushback(p, buf[i]);
break;
}
}
c = scan_oct(buf, i, &i);
}
return c;
...
...
src/string.c
View file @
b67fb972
...
...
@@ -6,6 +6,8 @@
#include "mruby.h"
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include "mruby/string.h"
#include "mruby/class.h"
...
...
@@ -20,7 +22,7 @@
const
char
mrb_digitmap
[]
=
"0123456789abcdefghijklmnopqrstuvwxyz"
;
static
mrb_value
str_replace
(
mrb_state
*
mrb
,
struct
RString
*
s1
,
struct
RString
*
s2
);
static
mrb_value
mrb_str_subseq
(
mrb_state
*
mrb
,
mrb_value
str
,
int
beg
,
int
len
);
static
mrb_value
mrb_str_subseq
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
beg
,
mrb_
int
len
);
#define RESIZE_CAPA(s,capacity) do {\
s->ptr = (char *)mrb_realloc(mrb, s->ptr, (capacity)+1);\
...
...
@@ -56,11 +58,11 @@ str_modify(mrb_state *mrb, struct RString *s)
}
else
{
char
*
ptr
,
*
p
;
long
len
;
mrb_int
len
;
p
=
s
->
ptr
;
len
=
s
->
len
;
ptr
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
ptr
=
(
char
*
)
mrb_malloc
(
mrb
,
(
size_t
)
len
+
1
);
if
(
p
)
{
memcpy
(
ptr
,
p
,
len
);
}
...
...
@@ -175,9 +177,11 @@ mrb_str_buf_new(mrb_state *mrb, int capa)
}
static
void
str_buf_cat
(
mrb_state
*
mrb
,
struct
RString
*
s
,
const
char
*
ptr
,
int
len
)
str_buf_cat
(
mrb_state
*
mrb
,
struct
RString
*
s
,
const
char
*
ptr
,
mrb_
int
len
)
{
long
capa
,
total
,
off
=
-
1
;
mrb_int
capa
;
mrb_int
total
;
ptrdiff_t
off
=
-
1
;
str_modify
(
mrb
,
s
);
if
(
ptr
>=
s
->
ptr
&&
ptr
<=
s
->
ptr
+
s
->
len
)
{
...
...
@@ -185,13 +189,13 @@ str_buf_cat(mrb_state *mrb, struct RString *s, const char *ptr, int len)
}
if
(
len
==
0
)
return
;
capa
=
s
->
aux
.
capa
;
if
(
s
->
len
>=
INT_MAX
-
len
)
{
if
(
s
->
len
>=
MRB_
INT_MAX
-
len
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"string sizes too big"
);
}
total
=
s
->
len
+
len
;
if
(
capa
<=
total
)
{
while
(
total
>
capa
)
{
if
(
capa
+
1
>=
INT_MAX
/
2
)
{
if
(
capa
+
1
>=
MRB_
INT_MAX
/
2
)
{
capa
=
(
total
+
4095
)
/
4096
;
break
;
}
...
...
@@ -208,7 +212,7 @@ str_buf_cat(mrb_state *mrb, struct RString *s, const char *ptr, int len)
}
mrb_value
mrb_str_buf_cat
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
,
int
len
)
mrb_str_buf_cat
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
,
mrb_
int
len
)
{
if
(
len
==
0
)
return
str
;
str_buf_cat
(
mrb
,
mrb_str_ptr
(
str
),
ptr
,
len
);
...
...
@@ -216,10 +220,14 @@ mrb_str_buf_cat(mrb_state *mrb, mrb_value str, const char *ptr, int len)
}
mrb_value
mrb_str_new
(
mrb_state
*
mrb
,
const
char
*
p
,
int
len
)
mrb_str_new
(
mrb_state
*
mrb
,
const
char
*
p
,
mrb_
int
len
)
{
struct
RString
*
s
;
if
(
len
<
0
)
{
len
=
0
;
}
s
=
str_new
(
mrb
,
p
,
len
);
return
mrb_obj_value
(
s
);
}
...
...
@@ -446,7 +454,7 @@ mrb_str_times(mrb_state *mrb, mrb_value self)
if
(
times
<
0
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"negative argument"
);
}
if
(
times
&&
INT_MAX
/
times
<
RSTRING_LEN
(
self
))
{
if
(
times
&&
MRB_INT_MAX
/
times
<
RSTRING_LEN
(
self
))
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"argument too big"
);
}
...
...
@@ -557,7 +565,9 @@ mrb_str_cmp_m(mrb_state *mrb, mrb_value str1)
static
int
str_eql
(
mrb_state
*
mrb
,
const
mrb_value
str1
,
const
mrb_value
str2
)
{
const
long
len
=
RSTRING_LEN
(
str1
);
const
size_t
len
=
RSTRING_LEN
(
str1
);
/* PARANOID: assert(SIZE_MAX >= MRB_INT_MAX) */
if
(
len
!=
RSTRING_LEN
(
str2
))
return
FALSE
;
if
(
memcmp
(
RSTRING_PTR
(
str1
),
RSTRING_PTR
(
str2
),
len
)
==
0
)
...
...
@@ -657,8 +667,8 @@ mrb_str_match(mrb_state *mrb, mrb_value self/* x */)
return
mrb_nil_value
();
}
static
inline
long
mrb_memsearch_qs
(
const
unsigned
char
*
xs
,
long
m
,
const
unsigned
char
*
ys
,
long
n
)
static
inline
mrb_int
mrb_memsearch_qs
(
const
unsigned
char
*
xs
,
mrb_int
m
,
const
unsigned
char
*
ys
,
mrb_int
n
)
{
const
unsigned
char
*
x
=
xs
,
*
xe
=
xs
+
m
;
const
unsigned
char
*
y
=
ys
;
...
...
@@ -677,8 +687,8 @@ mrb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long
return
-
1
;
}
static
int
mrb_memsearch
(
const
void
*
x0
,
int
m
,
const
void
*
y0
,
int
n
)
static
mrb_
int
mrb_memsearch
(
const
void
*
x0
,
mrb_int
m
,
const
void
*
y0
,
mrb_
int
n
)
{
const
unsigned
char
*
x
=
(
const
unsigned
char
*
)
x0
,
*
y
=
(
const
unsigned
char
*
)
y0
;
...
...
@@ -705,7 +715,8 @@ mrb_str_index(mrb_state *mrb, mrb_value str, mrb_value sub, mrb_int offset)
{
mrb_int
pos
;
char
*
s
,
*
sptr
;
int
len
,
slen
;
mrb_int
len
,
slen
;
len
=
RSTRING_LEN
(
str
);
slen
=
RSTRING_LEN
(
sub
);
if
(
offset
<
0
)
{
...
...
@@ -739,7 +750,7 @@ mrb_str_dup(mrb_state *mrb, mrb_value str)
static
mrb_value
mrb_str_aref
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_value
indx
)
{
long
idx
;
mrb_int
idx
;
if
(
!
strcmp
(
_obj_classname
(
mrb
,
indx
),
REGEXP_CLASS
))
{
mrb_raise
(
mrb
,
E_NOTIMP_ERROR
,
"Regexp Class not implemented"
);
...
...
@@ -920,7 +931,8 @@ mrb_str_chomp_bang(mrb_state *mrb, mrb_value str)
mrb_value
rs
;
mrb_int
newline
;
char
*
p
,
*
pp
;
long
len
,
rslen
;
mrb_int
rslen
;
mrb_int
len
;
struct
RString
*
s
=
mrb_str_ptr
(
str
);
str_modify
(
mrb
,
s
);
...
...
@@ -1157,7 +1169,7 @@ mrb_str_eql(mrb_state *mrb, mrb_value self)
}
static
mrb_value
mrb_str_subseq
(
mrb_state
*
mrb
,
mrb_value
str
,
int
beg
,
int
len
)
mrb_str_subseq
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
beg
,
mrb_
int
len
)
{
struct
RString
*
orig
,
*
s
;
mrb_shared_string
*
shared
;
...
...
@@ -1176,7 +1188,7 @@ mrb_str_subseq(mrb_state *mrb, mrb_value str, int beg, int len)
}
mrb_value
mrb_str_substr
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
beg
,
int
len
)
mrb_str_substr
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
beg
,
mrb_
int
len
)
{
mrb_value
str2
;
...
...
@@ -1267,7 +1279,7 @@ mrb_str_hash(mrb_state *mrb, mrb_value str)
{
/* 1-8-7 */
struct
RString
*
s
=
mrb_str_ptr
(
str
);
long
len
=
s
->
len
;
mrb_int
len
=
s
->
len
;
char
*
p
=
s
->
ptr
;
mrb_int
key
=
0
;
...
...
@@ -1381,7 +1393,7 @@ mrb_str_index_m(mrb_state *mrb, mrb_value str)
switch
(
mrb_type
(
sub
))
{
case
MRB_TT_FIXNUM
:
{
int
c
=
mrb_fixnum
(
sub
);
long
len
=
RSTRING_LEN
(
str
);
mrb_int
len
=
RSTRING_LEN
(
str
);
unsigned
char
*
p
=
(
unsigned
char
*
)
RSTRING_PTR
(
str
);
for
(;
pos
<
len
;
pos
++
)
{
...
...
@@ -1637,7 +1649,7 @@ mrb_str_rindex(mrb_state *mrb, mrb_value str, mrb_value sub, mrb_int pos)
char
*
s
,
*
sbeg
,
*
t
;
struct
RString
*
ps
=
mrb_str_ptr
(
str
);
struct
RString
*
psub
=
mrb_str_ptr
(
sub
);
long
len
=
psub
->
len
;
mrb_int
len
=
psub
->
len
;
/* substring longer than string */
if
(
ps
->
len
<
len
)
return
-
1
;
...
...
@@ -1728,7 +1740,7 @@ mrb_str_rindex_m(mrb_state *mrb, mrb_value str)
switch
(
mrb_type
(
sub
))
{
case
MRB_TT_FIXNUM
:
{
int
c
=
mrb_fixnum
(
sub
);
long
len
=
RSTRING_LEN
(
str
);
mrb_int
len
=
RSTRING_LEN
(
str
);
unsigned
char
*
p
=
(
unsigned
char
*
)
RSTRING_PTR
(
str
);
for
(
pos
=
len
;
pos
>=
0
;
pos
--
)
{
...
...
@@ -1865,7 +1877,9 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
int
argc
;
mrb_value
spat
=
mrb_nil_value
();
enum
{
awk
,
string
,
regexp
}
split_type
=
string
;
long
beg
,
end
,
i
=
0
,
lim_p
;
long
i
=
0
,
lim_p
;
mrb_int
beg
;
mrb_int
end
;
mrb_int
lim
=
0
;
mrb_value
result
,
tmp
;
...
...
@@ -1934,7 +1948,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
char
*
ptr
=
RSTRING_PTR
(
str
);
char
*
temp
=
ptr
;
char
*
eptr
=
RSTRING_END
(
str
);
long
slen
=
RSTRING_LEN
(
spat
);
mrb_int
slen
=
RSTRING_LEN
(
spat
);
if
(
slen
==
0
)
{
int
ai
=
mrb_gc_arena_save
(
mrb
);
...
...
@@ -1972,7 +1986,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
mrb_ary_push
(
mrb
,
result
,
tmp
);
}
if
(
!
lim_p
&&
lim
==
0
)
{
long
len
;
mrb_int
len
;
while
((
len
=
RARRAY_LEN
(
result
))
>
0
&&
(
tmp
=
RARRAY_PTR
(
result
)[
len
-
1
],
RSTRING_LEN
(
tmp
)
==
0
))
mrb_ary_pop
(
mrb
,
result
);
...
...
@@ -2054,7 +2068,7 @@ mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck)
char
*
end
;
char
sign
=
1
;
int
c
;
unsigned
long
val
;
mrb_int
val
;
#undef ISDIGIT
#define ISDIGIT(c) ('0' <= (c) && (c) <= '9')
...
...
@@ -2166,11 +2180,7 @@ mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck)
if
(
*
end
)
goto
bad
;
/* trailing garbage */
}
if
(
sign
)
return
mrb_fixnum_value
(
val
);
else
{
long
result
=
-
(
long
)
val
;
return
mrb_fixnum_value
(
result
);
}
return
mrb_fixnum_value
(
sign
?
val
:
-
val
);
bad:
mrb_raisef
(
mrb
,
E_ARGUMENT_ERROR
,
"invalid string for number(%s)"
,
str
);
/* not reached */
...
...
@@ -2440,7 +2450,7 @@ mrb_str_upcase(mrb_state *mrb, mrb_value self)
mrb_value
mrb_str_dump
(
mrb_state
*
mrb
,
mrb_value
str
)
{
long
len
;
mrb_int
len
;
const
char
*
p
,
*
pend
;
char
*
q
;
struct
RString
*
result
;
...
...
@@ -2542,7 +2552,7 @@ mrb_str_dump(mrb_state *mrb, mrb_value str)
}
mrb_value
mrb_str_cat
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
,
long
len
)
mrb_str_cat
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
,
mrb_int
len
)
{
if
(
len
<
0
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"negative string size (or size too big)"
);
...
...
@@ -2554,7 +2564,14 @@ mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, long len)
mrb_value
mrb_str_cat2
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
)
{
return
mrb_str_cat
(
mrb
,
str
,
ptr
,
strlen
(
ptr
));
size_t
len
;
len
=
strlen
(
ptr
);
if
(
len
>
MRB_INT_MAX
)
{
len
=
MRB_INT_MAX
;
}
return
mrb_str_cat
(
mrb
,
str
,
ptr
,
len
);
}
mrb_value
...
...
src/variable.c
View file @
b67fb972
...
...
@@ -548,6 +548,7 @@ mrb_obj_iv_inspect(mrb_state *mrb, struct RObject *obj)
mrb_value
str
=
mrb_sprintf
(
mrb
,
"-<%s:%p"
,
cn
,
(
void
*
)
obj
);
iv_foreach
(
mrb
,
t
,
inspect_i
,
&
str
);
mrb_str_cat
(
mrb
,
str
,
">"
,
1
);
return
str
;
}
return
mrb_any_to_s
(
mrb
,
mrb_obj_value
(
obj
));
...
...
test/driver.c
View file @
b67fb972
...
...
@@ -17,7 +17,8 @@ void
mrb_init_mrbtest
(
mrb_state
*
);
/* Print a short remark for the user */
void
print_hint
(
void
)
static
void
print_hint
(
void
)
{
printf
(
"mrbtest - Embeddable Ruby Test
\n
"
);
printf
(
"
\n
This is a very early version, please test and report errors.
\n
"
);
...
...
tools/mirb/mirb.c
View file @
b67fb972
...
...
@@ -132,7 +132,8 @@ is_code_block_open(struct mrb_parser_state *parser)
}
/* Print a short remark for the user */
void
print_hint
(
void
)
static
void
print_hint
(
void
)
{
printf
(
"mirb - Embeddable Interactive Ruby Shell
\n
"
);
printf
(
"
\n
This is a very early version, please test and report errors.
\n
"
);
...
...
tools/mruby/mruby.c
View file @
b67fb972
...
...
@@ -52,7 +52,7 @@ usage(const char *name)
printf
(
"Usage: %s [switches] programfile
\n
"
,
name
);
while
(
*
p
)
printf
(
" %s
\n
"
,
*
p
++
);
printf
(
" %s
\n
"
,
*
p
++
);
}
static
int
...
...
@@ -125,7 +125,6 @@ append_cmdline:
exit
(
0
);
}
else
return
-
3
;
return
0
;
default:
return
-
4
;
}
...
...
@@ -189,14 +188,14 @@ showcallinfo(mrb_state *mrb)
if
(
irep
->
filename
!=
NULL
)
filename
=
irep
->
filename
;
if
(
irep
->
lines
!=
NULL
)
{
mrb_code
*
pc
;
mrb_code
*
pc
;
if
(
i
+
1
<=
ciidx
)
{
pc
=
mrb
->
cibase
[
i
+
1
].
pc
;
}
else
{
pc
=
(
mrb_code
*
)
mrb_voidp
(
mrb_obj_iv_get
(
mrb
,
mrb
->
exc
,
mrb_intern
(
mrb
,
"lastpc"
)));
}
if
(
i
+
1
<=
ciidx
)
{
pc
=
mrb
->
cibase
[
i
+
1
].
pc
;
}
else
{
pc
=
(
mrb_code
*
)
mrb_voidp
(
mrb_obj_iv_get
(
mrb
,
mrb
->
exc
,
mrb_intern
(
mrb
,
"lastpc"
)));
}
if
(
irep
->
iseq
<=
pc
&&
pc
<
irep
->
iseq
+
irep
->
ilen
)
{
line
=
irep
->
lines
[
pc
-
irep
->
iseq
-
1
];
}
...
...
@@ -211,19 +210,16 @@ showcallinfo(mrb_state *mrb)
method
=
mrb_sym2name
(
mrb
,
ci
->
mid
);
if
(
method
)
{
const
char
*
cn
=
mrb_class_name
(
mrb
,
ci
->
proc
->
target_class
);
if
(
cn
)
{
printf
(
"
\t
[%d] %s:%d:in %s%s%s
\n
"
,
i
,
filename
,
line
,
cn
,
sep
,
method
);
printf
(
"
\t
[%d] %s:%d:in %s%s%s
\n
"
,
i
,
filename
,
line
,
cn
,
sep
,
method
);
}
else
{
printf
(
"
\t
[%d] %s:%d:in %s
\n
"
,
i
,
filename
,
line
,
method
);
printf
(
"
\t
[%d] %s:%d:in %s
\n
"
,
i
,
filename
,
line
,
method
);
}
}
else
{
printf
(
"
\t
[%d] %s:%d
\n
"
,
i
,
filename
,
line
);
printf
(
"
\t
[%d] %s:%d
\n
"
,
i
,
filename
,
line
);
}
}
}
...
...
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