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
a6d7de5d
Commit
a6d7de5d
authored
Feb 23, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #875 from monaka/pr-enable-building-libmruby-with-DISABLE_STDIO-macro
Fix errors caused by stdio.h dependent code.
parents
231be7c2
2bfb8882
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
6 deletions
+36
-6
include/mruby/dump.h
include/mruby/dump.h
+10
-4
src/dump.c
src/dump.c
+4
-0
src/load.c
src/load.c
+22
-2
No files found.
include/mruby/dump.h
View file @
a6d7de5d
...
...
@@ -12,16 +12,22 @@ extern "C" {
#endif
#include "mruby.h"
#ifdef ENABLE_STDIO
#include <stdio.h>
#endif
#include <stdint.h>
#ifdef ENABLE_STDIO
int
mrb_dump_irep
(
mrb_state
*
,
int
,
FILE
*
);
int
mrb_read_irep
(
mrb_state
*
,
const
char
*
);
int
mrb_bdump_irep
(
mrb_state
*
mrb
,
int
n
,
FILE
*
f
,
const
char
*
initname
);
int
mrb_read_irep_file
(
mrb_state
*
,
FILE
*
);
/* mrb_value mrb_load_irep(mrb_state*,const char*); */
/* declared in <irep.h> */
mrb_value
mrb_load_irep_file
(
mrb_state
*
,
FILE
*
);
#endif
int
mrb_read_irep
(
mrb_state
*
,
const
char
*
);
int
mrb_bdump_irep
(
mrb_state
*
mrb
,
int
n
,
FILE
*
f
,
const
char
*
initname
);
#ifdef ENABLE_STDIO
mrb_value
mrb_load_irep_file
(
mrb_state
*
,
FILE
*
);
#endif
/* dump type */
#define DUMP_TYPE_CODE 0
...
...
src/dump.c
View file @
a6d7de5d
...
...
@@ -50,6 +50,8 @@ enum {
DUMP_SECTION_NUM
,
};
#ifdef ENABLE_STDIO
uint16_t
calc_crc_16_ccitt
(
unsigned
char
*
,
int
);
static
inline
int
uint8_dump
(
uint8_t
,
char
*
,
int
);
static
inline
int
uint16_dump
(
uint16_t
,
char
*
,
int
);
...
...
@@ -741,3 +743,5 @@ mrb_bdump_irep(mrb_state *mrb, int n, FILE *f,const char *initname)
return
rc
;
}
#endif
/* ENABLE_STDIO */
src/load.c
View file @
a6d7de5d
...
...
@@ -11,6 +11,7 @@
#include "mruby/proc.h"
#include "mruby/irep.h"
#ifdef ENABLE_STDIO
typedef
struct
_RiteFILE
{
FILE
*
fp
;
...
...
@@ -18,6 +19,7 @@ typedef struct _RiteFILE
int
cnt
;
int
readlen
;
}
RiteFILE
;
#endif
const
char
hex2bin
[
256
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
//00-0f
...
...
@@ -38,15 +40,18 @@ static uint16_t hex_to_uint16(unsigned char*);
static
uint32_t
hex_to_uint32
(
unsigned
char
*
);
static
char
*
hex_to_str
(
char
*
,
char
*
,
uint16_t
*
);
uint16_t
calc_crc_16_ccitt
(
unsigned
char
*
,
int
);
#ifdef ENABLE_STDIO
static
unsigned
char
rite_fgetcSub
(
RiteFILE
*
);
static
unsigned
char
rite_fgetc
(
RiteFILE
*
,
int
);
static
unsigned
char
*
rite_fgets
(
RiteFILE
*
,
unsigned
char
*
,
int
,
int
);
static
int
load_rite_header
(
FILE
*
,
rite_binary_header
*
,
unsigned
char
*
);
static
int
load_rite_irep_record
(
mrb_state
*
,
RiteFILE
*
,
unsigned
char
*
,
uint32_t
*
);
#endif
static
int
read_rite_header
(
mrb_state
*
,
unsigned
char
*
,
rite_binary_header
*
);
static
int
read_rite_irep_record
(
mrb_state
*
,
unsigned
char
*
,
uint32_t
*
);
#ifdef ENABLE_STDIO
static
unsigned
char
rite_fgetcSub
(
RiteFILE
*
rfp
)
{
...
...
@@ -65,7 +70,9 @@ rite_fgetcSub(RiteFILE* rfp)
}
return
rfp
->
buf
[(
rfp
->
cnt
)
++
];
}
#endif
/* ENABLE_STDIO */
#ifdef ENABLE_STDIO
static
unsigned
char
rite_fgetc
(
RiteFILE
*
rfp
,
int
ignorecomment
)
{
...
...
@@ -87,7 +94,9 @@ rite_fgetc(RiteFILE* rfp, int ignorecomment)
}
}
}
#endif
/* ENABLE_STDIO */
#ifdef ENABLE_STDIO
static
unsigned
char
*
rite_fgets
(
RiteFILE
*
rfp
,
unsigned
char
*
dst
,
int
len
,
int
ignorecomment
)
{
...
...
@@ -100,7 +109,9 @@ rite_fgets(RiteFILE* rfp, unsigned char* dst, int len, int ignorecomment)
}
return
dst
;
}
#endif
/* ENABLE_STDIO */
#ifdef ENABLE_STDIO
static
int
load_rite_header
(
FILE
*
fp
,
rite_binary_header
*
bin_header
,
unsigned
char
*
hcrc
)
{
...
...
@@ -128,7 +139,9 @@ load_rite_header(FILE* fp, rite_binary_header* bin_header, unsigned char* hcrc)
return
MRB_DUMP_OK
;
}
#endif
/* ENABLE_STDIO */
#ifdef ENABLE_STDIO
static
int
load_rite_irep_record
(
mrb_state
*
mrb
,
RiteFILE
*
rfp
,
unsigned
char
*
dst
,
uint32_t
*
len
)
{
...
...
@@ -152,8 +165,10 @@ load_rite_irep_record(mrb_state *mrb, RiteFILE* rfp, unsigned char* dst, uint32_
//IREP HEADER BLOCK
*
dst
=
rite_fgetc
(
rfp
,
TRUE
);
//record identifier
if
(
*
dst
!=
RITE_IREP_IDENFIFIER
)
return
MRB_DUMP_INVALID_IREP
;
if
(
*
dst
!=
RITE_IREP_IDENFIFIER
)
{
result
=
MRB_DUMP_INVALID_IREP
;
goto
error_exit
;
}
dst
+=
sizeof
(
unsigned
char
);
*
dst
=
rite_fgetc
(
rfp
,
TRUE
);
//class or module
dst
+=
sizeof
(
unsigned
char
);
...
...
@@ -247,7 +262,9 @@ error_exit:
return
result
;
}
#endif
/* ENABLE_STDIO */
#ifdef ENABLE_STDIO
int
mrb_read_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
{
...
...
@@ -306,6 +323,7 @@ error_exit:
return
ret
;
}
#endif
/* ENABLE_STDIO */
static
int
read_rite_header
(
mrb_state
*
mrb
,
unsigned
char
*
bin
,
rite_binary_header
*
bin_header
)
...
...
@@ -668,6 +686,7 @@ irep_error(mrb_state *mrb, int n)
mrb
->
exc
=
(
struct
RObject
*
)
mrb_object
(
mrb_exc_new
(
mrb
,
E_SCRIPT_ERROR
,
msg
,
sizeof
(
msg
)
-
1
));
}
#ifdef ENABLE_STDIO
mrb_value
mrb_load_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
{
...
...
@@ -679,6 +698,7 @@ mrb_load_irep_file(mrb_state *mrb, FILE* fp)
}
return
mrb_run
(
mrb
,
mrb_proc_new
(
mrb
,
mrb
->
irep
[
n
]),
mrb_top_self
(
mrb
));
}
#endif
mrb_value
mrb_load_irep
(
mrb_state
*
mrb
,
const
char
*
bin
)
...
...
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