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
c79172df
Commit
c79172df
authored
Apr 20, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
put spaces after if/while
parent
2acf7245
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
47 additions
and
47 deletions
+47
-47
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
+2
-2
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
+1
-1
src/array.c
src/array.c
+10
-10
src/class.c
src/class.c
+1
-1
src/dump.c
src/dump.c
+8
-8
src/load.c
src/load.c
+17
-17
src/string.c
src/string.c
+1
-1
src/vm.c
src/vm.c
+2
-2
tasks/mrbgems_test.rake
tasks/mrbgems_test.rake
+3
-3
tools/mrbc/mrbc.c
tools/mrbc/mrbc.c
+2
-2
No files found.
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
View file @
c79172df
...
...
@@ -156,7 +156,7 @@ usage(const char *name)
const
char
*
const
*
p
=
usage_msg
;
printf
(
"Usage: %s [switches]
\n
"
,
name
);
while
(
*
p
)
while
(
*
p
)
printf
(
" %s
\n
"
,
*
p
++
);
}
...
...
@@ -281,7 +281,7 @@ main(int argc, char **argv)
last_code_line
[
char_index
]
=
'\0'
;
#else
char
*
line
=
readline
(
code_block_open
?
"* "
:
"> "
);
if
(
line
==
NULL
)
{
if
(
line
==
NULL
)
{
printf
(
"
\n
"
);
break
;
}
...
...
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
View file @
c79172df
...
...
@@ -52,7 +52,7 @@ usage(const char *name)
const
char
*
const
*
p
=
usage_msg
;
printf
(
"Usage: %s [switches] programfile
\n
"
,
name
);
while
(
*
p
)
while
(
*
p
)
printf
(
" %s
\n
"
,
*
p
++
);
}
...
...
src/array.c
View file @
c79172df
...
...
@@ -104,7 +104,7 @@ ary_fill_with_nil(mrb_value *ptr, mrb_int size)
{
mrb_value
nil
=
mrb_nil_value
();
while
((
int
)(
size
--
))
{
while
((
int
)(
size
--
))
{
*
ptr
++
=
nil
;
}
}
...
...
@@ -166,7 +166,7 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, mrb_int len)
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"array size too big"
);
}
while
(
capa
<
len
)
{
while
(
capa
<
len
)
{
if
(
capa
==
0
)
{
capa
=
ARY_DEFAULT_LEN
;
}
...
...
@@ -180,7 +180,7 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, mrb_int len)
if
(
capa
>
a
->
aux
.
capa
)
{
mrb_value
*
expanded_ptr
=
(
mrb_value
*
)
mrb_realloc
(
mrb
,
a
->
ptr
,
sizeof
(
mrb_value
)
*
capa
);
if
(
!
expanded_ptr
)
{
if
(
!
expanded_ptr
)
{
mrb_raise
(
mrb
,
E_RUNTIME_ERROR
,
"out of memory"
);
}
...
...
@@ -203,7 +203,7 @@ ary_shrink_capa(mrb_state *mrb, struct RArray *a)
capa
=
ARY_DEFAULT_LEN
;
break
;
}
}
while
(
capa
>
a
->
len
*
ARY_SHRINK_RATIO
);
}
while
(
capa
>
a
->
len
*
ARY_SHRINK_RATIO
);
if
(
capa
>
a
->
len
&&
capa
<
a
->
aux
.
capa
)
{
a
->
aux
.
capa
=
capa
;
...
...
@@ -366,7 +366,7 @@ mrb_ary_times(mrb_state *mrb, mrb_value self)
ary
=
mrb_ary_new_capa
(
mrb
,
a1
->
len
*
times
);
a2
=
mrb_ary_ptr
(
ary
);
ptr
=
a2
->
ptr
;
while
(
times
--
)
{
while
(
times
--
)
{
array_copy
(
ptr
,
a1
->
ptr
,
a1
->
len
);
ptr
+=
a1
->
len
;
a2
->
len
+=
a1
->
len
;
...
...
@@ -387,7 +387,7 @@ mrb_ary_reverse_bang(mrb_state *mrb, mrb_value self)
p1
=
a
->
ptr
;
p2
=
a
->
ptr
+
a
->
len
-
1
;
while
(
p1
<
p2
)
{
while
(
p1
<
p2
)
{
mrb_value
tmp
=
*
p1
;
*
p1
++
=
*
p2
;
*
p2
--
=
tmp
;
...
...
@@ -410,7 +410,7 @@ mrb_ary_reverse(mrb_state *mrb, mrb_value self)
p1
=
a
->
ptr
;
e
=
p1
+
a
->
len
;
p2
=
b
->
ptr
+
a
->
len
-
1
;
while
(
p1
<
e
)
{
while
(
p1
<
e
)
{
*
p2
--
=
*
p1
++
;
}
b
->
len
=
a
->
len
;
...
...
@@ -451,7 +451,7 @@ mrb_ary_push_m(mrb_state *mrb, mrb_value self)
int
len
;
mrb_get_args
(
mrb
,
"*"
,
&
argv
,
&
len
);
while
(
len
--
)
{
while
(
len
--
)
{
mrb_ary_push
(
mrb
,
self
,
*
argv
++
);
}
...
...
@@ -492,7 +492,7 @@ mrb_ary_shift(mrb_state *mrb, mrb_value self)
mrb_int
size
=
a
->
len
;
val
=
*
ptr
;
while
((
int
)(
--
size
))
{
while
((
int
)(
--
size
))
{
*
ptr
=
*
(
ptr
+
1
);
++
ptr
;
}
...
...
@@ -753,7 +753,7 @@ mrb_ary_delete_at(mrb_state *mrb, mrb_value self)
ptr
=
a
->
ptr
+
index
;
len
=
a
->
len
-
index
;
while
((
int
)(
--
len
))
{
while
((
int
)(
--
len
))
{
*
ptr
=
*
(
ptr
+
1
);
++
ptr
;
}
...
...
src/class.c
View file @
c79172df
...
...
@@ -686,7 +686,7 @@ mrb_include_module(mrb_state *mrb, struct RClass *c, struct RClass *m)
struct
RClass
*
p
=
c
,
*
ic
;
int
superclass_seen
=
0
;
while
(
p
)
{
while
(
p
)
{
if
(
c
!=
p
&&
p
->
tt
==
MRB_TT_CLASS
)
{
superclass_seen
=
1
;
}
...
...
src/dump.c
View file @
c79172df
...
...
@@ -320,11 +320,11 @@ get_debug_record_size(mrb_state *mrb, mrb_irep *irep)
size
+=
sizeof
(
uint32_t
);
// record size
size
+=
sizeof
(
uint16_t
);
// filename size
if
(
irep
->
filename
)
{
if
(
irep
->
filename
)
{
size
+=
strlen
(
irep
->
filename
);
// filename
}
size
+=
sizeof
(
uint32_t
);
// niseq
if
(
irep
->
lines
)
{
if
(
irep
->
lines
)
{
size
+=
sizeof
(
uint16_t
)
*
irep
->
ilen
;
// lineno
}
...
...
@@ -340,17 +340,17 @@ write_lineno_record(mrb_state *mrb, mrb_irep *irep, uint8_t* bin)
cur
+=
sizeof
(
uint32_t
);
/* record size */
if
(
irep
->
filename
)
{
if
(
irep
->
filename
)
{
filename_len
=
strlen
(
irep
->
filename
);
}
cur
+=
uint16_to_bin
(
filename_len
,
cur
);
/* filename size */
if
(
filename_len
)
{
if
(
filename_len
)
{
memcpy
(
cur
,
irep
->
filename
,
filename_len
);
cur
+=
filename_len
;
/* filename */
}
if
(
irep
->
lines
)
{
if
(
irep
->
lines
)
{
cur
+=
uint32_to_bin
(
irep
->
ilen
,
cur
);
/* niseq */
for
(
iseq_no
=
0
;
iseq_no
<
irep
->
ilen
;
iseq_no
++
)
{
cur
+=
uint16_to_bin
(
irep
->
lines
[
iseq_no
],
cur
);
/* opcode */
...
...
@@ -432,7 +432,7 @@ mrb_dump_irep(mrb_state *mrb, size_t start_index, int debug_info, uint8_t **bin,
section_size
+=
section_irep_size
;
/* DEBUG section size */
if
(
debug_info
)
{
if
(
debug_info
)
{
section_lineno_size
+=
sizeof
(
struct
rite_section_lineno_header
);
for
(
irep_no
=
start_index
;
irep_no
<
mrb
->
irep_len
;
irep_no
++
)
{
section_lineno_size
+=
get_debug_record_size
(
mrb
,
mrb
->
irep
[
irep_no
]);
...
...
@@ -442,7 +442,7 @@ mrb_dump_irep(mrb_state *mrb, size_t start_index, int debug_info, uint8_t **bin,
*
bin_size
+=
sizeof
(
struct
rite_binary_header
)
+
section_size
+
sizeof
(
struct
rite_binary_footer
);
cur
=
*
bin
=
(
uint8_t
*
)
mrb_malloc
(
mrb
,
*
bin_size
);
if
(
cur
==
NULL
)
{
if
(
cur
==
NULL
)
{
goto
error_exit
;
}
...
...
@@ -456,7 +456,7 @@ mrb_dump_irep(mrb_state *mrb, size_t start_index, int debug_info, uint8_t **bin,
cur
+=
section_irep_size
;
/* write DEBUG section */
if
(
debug_info
)
{
if
(
debug_info
)
{
result
=
mrb_write_section_lineno
(
mrb
,
start_index
,
cur
);
if
(
result
!=
MRB_DUMP_OK
)
{
goto
error_exit
;
...
...
src/load.c
View file @
c79172df
...
...
@@ -271,11 +271,11 @@ read_rite_binary_header(const uint8_t *bin, size_t *bin_size, uint16_t *crc)
{
const
struct
rite_binary_header
*
header
=
(
const
struct
rite_binary_header
*
)
bin
;
if
(
memcmp
(
header
->
binary_identify
,
RITE_BINARY_IDENFIFIER
,
sizeof
(
header
->
binary_identify
))
!=
0
)
{
if
(
memcmp
(
header
->
binary_identify
,
RITE_BINARY_IDENFIFIER
,
sizeof
(
header
->
binary_identify
))
!=
0
)
{
return
MRB_DUMP_INVALID_FILE_HEADER
;
}
if
(
memcmp
(
header
->
binary_version
,
RITE_BINARY_FORMAT_VER
,
sizeof
(
header
->
binary_version
))
!=
0
)
{
if
(
memcmp
(
header
->
binary_version
,
RITE_BINARY_FORMAT_VER
,
sizeof
(
header
->
binary_version
))
!=
0
)
{
return
MRB_DUMP_INVALID_FILE_HEADER
;
}
...
...
@@ -303,12 +303,12 @@ mrb_read_irep(mrb_state *mrb, const uint8_t *bin)
}
result
=
read_rite_binary_header
(
bin
,
&
bin_size
,
&
crc
);
if
(
result
!=
MRB_DUMP_OK
)
{
if
(
result
!=
MRB_DUMP_OK
)
{
return
result
;
}
n
=
offset_crc_body
();
if
(
crc
!=
calc_crc_16_ccitt
(
bin
+
n
,
bin_size
-
n
,
0
))
{
if
(
crc
!=
calc_crc_16_ccitt
(
bin
+
n
,
bin_size
-
n
,
0
))
{
return
MRB_DUMP_INVALID_FILE_HEADER
;
}
...
...
@@ -317,21 +317,21 @@ mrb_read_irep(mrb_state *mrb, const uint8_t *bin)
do
{
section_header
=
(
const
struct
rite_section_header
*
)
bin
;
if
(
memcmp
(
section_header
->
section_identify
,
RITE_SECTION_IREP_IDENTIFIER
,
sizeof
(
section_header
->
section_identify
))
==
0
)
{
if
(
memcmp
(
section_header
->
section_identify
,
RITE_SECTION_IREP_IDENTIFIER
,
sizeof
(
section_header
->
section_identify
))
==
0
)
{
result
=
read_rite_section_irep
(
mrb
,
bin
);
if
(
result
<
MRB_DUMP_OK
)
{
if
(
result
<
MRB_DUMP_OK
)
{
return
result
;
}
total_nirep
+=
result
;
}
else
if
(
memcmp
(
section_header
->
section_identify
,
RITE_SECTION_LIENO_IDENTIFIER
,
sizeof
(
section_header
->
section_identify
))
==
0
)
{
else
if
(
memcmp
(
section_header
->
section_identify
,
RITE_SECTION_LIENO_IDENTIFIER
,
sizeof
(
section_header
->
section_identify
))
==
0
)
{
result
=
read_rite_section_lineno
(
mrb
,
bin
,
sirep
);
if
(
result
<
MRB_DUMP_OK
)
{
if
(
result
<
MRB_DUMP_OK
)
{
return
result
;
}
}
bin
+=
bin_to_uint32
(
section_header
->
section_size
);
}
while
(
memcmp
(
section_header
->
section_identify
,
RITE_BINARY_EOF
,
sizeof
(
section_header
->
section_identify
))
!=
0
);
}
while
(
memcmp
(
section_header
->
section_identify
,
RITE_BINARY_EOF
,
sizeof
(
section_header
->
section_identify
))
!=
0
);
return
total_nirep
;
}
...
...
@@ -509,7 +509,7 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
}
result
=
read_rite_binary_header
(
buf
,
NULL
,
&
crc
);
mrb_free
(
mrb
,
buf
);
if
(
result
!=
MRB_DUMP_OK
)
{
if
(
result
!=
MRB_DUMP_OK
)
{
return
result
;
}
...
...
@@ -517,14 +517,14 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
fpos
=
ftell
(
fp
);
buf
=
mrb_malloc
(
mrb
,
block_size
);
fseek
(
fp
,
offset_crc_body
(),
SEEK_SET
);
while
((
nbytes
=
fread
(
buf
,
1
,
block_size
,
fp
))
>
0
)
{
while
((
nbytes
=
fread
(
buf
,
1
,
block_size
,
fp
))
>
0
)
{
crcwk
=
calc_crc_16_ccitt
(
buf
,
nbytes
,
crcwk
);
}
mrb_free
(
mrb
,
buf
);
if
(
nbytes
==
0
&&
ferror
(
fp
))
{
return
MRB_DUMP_READ_FAULT
;
}
if
(
crcwk
!=
crc
)
{
if
(
crcwk
!=
crc
)
{
return
MRB_DUMP_INVALID_FILE_HEADER
;
}
fseek
(
fp
,
fpos
+
section_size
,
SEEK_SET
);
...
...
@@ -538,24 +538,24 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
}
section_size
=
bin_to_uint32
(
section_header
.
section_size
);
if
(
memcmp
(
section_header
.
section_identify
,
RITE_SECTION_IREP_IDENTIFIER
,
sizeof
(
section_header
.
section_identify
))
==
0
)
{
if
(
memcmp
(
section_header
.
section_identify
,
RITE_SECTION_IREP_IDENTIFIER
,
sizeof
(
section_header
.
section_identify
))
==
0
)
{
fseek
(
fp
,
fpos
,
SEEK_SET
);
result
=
read_rite_section_irep_file
(
mrb
,
fp
);
if
(
result
<
MRB_DUMP_OK
)
{
if
(
result
<
MRB_DUMP_OK
)
{
return
result
;
}
total_nirep
+=
result
;
}
else
if
(
memcmp
(
section_header
.
section_identify
,
RITE_SECTION_LIENO_IDENTIFIER
,
sizeof
(
section_header
.
section_identify
))
==
0
)
{
else
if
(
memcmp
(
section_header
.
section_identify
,
RITE_SECTION_LIENO_IDENTIFIER
,
sizeof
(
section_header
.
section_identify
))
==
0
)
{
fseek
(
fp
,
fpos
,
SEEK_SET
);
result
=
read_rite_section_lineno_file
(
mrb
,
fp
,
sirep
);
if
(
result
<
MRB_DUMP_OK
)
{
if
(
result
<
MRB_DUMP_OK
)
{
return
result
;
}
}
fseek
(
fp
,
fpos
+
section_size
,
SEEK_SET
);
}
while
(
memcmp
(
section_header
.
section_identify
,
RITE_BINARY_EOF
,
sizeof
(
section_header
.
section_identify
))
!=
0
);
}
while
(
memcmp
(
section_header
.
section_identify
,
RITE_BINARY_EOF
,
sizeof
(
section_header
.
section_identify
))
!=
0
);
return
total_nirep
;
}
...
...
src/string.c
View file @
c79172df
...
...
@@ -30,7 +30,7 @@ static mrb_value mrb_str_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_
#define RESIZE_CAPA(s,capacity) do {\
s->ptr = (char *)mrb_realloc(mrb, s->ptr, (capacity)+1);\
s->aux.capa = capacity;\
} while
(0)
} while(0)
void
mrb_str_decref
(
mrb_state
*
mrb
,
mrb_shared_string
*
shared
)
...
...
src/vm.c
View file @
c79172df
...
...
@@ -63,7 +63,7 @@ stack_clear(mrb_value *from, size_t count)
{
const
mrb_value
mrb_value_zero
=
{
{
0
}
};
while
(
count
--
>
0
)
{
while
(
count
--
>
0
)
{
*
from
++
=
mrb_value_zero
;
}
}
...
...
@@ -1659,7 +1659,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
default:\
goto L_SEND;\
}\
} while
(0)
} while(0)
CASE
(
OP_EQ
)
{
/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:==,C=1)*/
...
...
tasks/mrbgems_test.rake
View file @
c79172df
...
...
@@ -59,18 +59,18 @@ MRuby.each_target do
%w(ok_test ko_test kill_test)
.
each
do
|
vname
|
f
.
puts
%Q[ val2 = mrb_gv_get(mrb2, mrb_intern(mrb2, "$
#{
vname
}
"));]
f
.
puts
%Q[ if(mrb_fixnum_p(val2)) {]
f
.
puts
%Q[ if
(mrb_fixnum_p(val2)) {]
f
.
puts
%Q[ val1 = mrb_gv_get(mrb, mrb_intern(mrb, "$
#{
vname
}
"));]
f
.
puts
%Q[ mrb_gv_set(mrb, mrb_intern(mrb, "$
#{
vname
}
"), mrb_fixnum_value(mrb_fixnum(val1) + mrb_fixnum(val2)));]
f
.
puts
%Q[ }
\n
]
end
f
.
puts
%Q[ ary2 = mrb_gv_get(mrb2, mrb_intern(mrb2, "$asserts"));]
f
.
puts
%Q[ if(mrb_test(ary2)) {]
f
.
puts
%Q[ if
(mrb_test(ary2)) {]
f
.
puts
%Q[ ary1 = mrb_gv_get(mrb, mrb_intern(mrb, "$asserts"));]
f
.
puts
%Q[ val2 = mrb_ary_shift(mrb2, ary2);]
f
.
puts
%Q[ ]
f
.
puts
%Q[ while(mrb_test(val2)) {]
f
.
puts
%Q[ while
(mrb_test(val2)) {]
f
.
puts
%Q[ char *str = mrb_string_value_cstr(mrb2, &val2);]
f
.
puts
%Q[ mrb_ary_push(mrb, ary1, mrb_str_new_cstr(mrb, str));]
f
.
puts
%Q[ val2 = mrb_ary_shift(mrb2, ary2);]
...
...
tools/mrbc/mrbc.c
View file @
c79172df
...
...
@@ -43,7 +43,7 @@ usage(const char *name)
const
char
*
const
*
p
=
usage_msg
;
printf
(
"Usage: %s [switches] programfile
\n
"
,
name
);
while
(
*
p
)
while
(
*
p
)
printf
(
" %s
\n
"
,
*
p
++
);
}
...
...
@@ -107,7 +107,7 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
args
->
check_syntax
=
1
;
break
;
case
'v'
:
if
(
!
args
->
verbose
)
mrb_show_version
(
mrb
);
if
(
!
args
->
verbose
)
mrb_show_version
(
mrb
);
args
->
verbose
=
1
;
break
;
case
'g'
:
...
...
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