mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add configuration macro MRB_PARSER_BUF_SIZE.
This commit is contained in:
@@ -49,6 +49,8 @@
|
||||
/* initial minimum size for string buffer */
|
||||
//#define MRB_STR_BUF_MIN_SIZE 128
|
||||
|
||||
/* array size for parser buffer */
|
||||
//#define MRB_PARSER_BUF_SIZE 1024
|
||||
|
||||
/* -DDISABLE_XXXX to drop following features */
|
||||
//#define DISABLE_STDIO /* use of stdio */
|
||||
|
||||
@@ -91,6 +91,10 @@ struct mrb_parser_heredoc_info {
|
||||
mrb_ast_node *doc;
|
||||
};
|
||||
|
||||
#ifndef MRB_PARSER_BUF_SIZE
|
||||
# define MRB_PARSER_BUF_SIZE 1024
|
||||
#endif
|
||||
|
||||
/* parser structure */
|
||||
struct mrb_parser_state {
|
||||
mrb_state *mrb;
|
||||
@@ -113,7 +117,7 @@ struct mrb_parser_state {
|
||||
mrb_ast_node *locals;
|
||||
|
||||
mrb_ast_node *pb;
|
||||
char buf[1024];
|
||||
char buf[MRB_PARSER_BUF_SIZE];
|
||||
int bidx;
|
||||
|
||||
mrb_ast_node *heredocs; /* list of mrb_parser_heredoc_info* */
|
||||
|
||||
+2
-2
@@ -3342,7 +3342,7 @@ newtok(parser_state *p)
|
||||
static void
|
||||
tokadd(parser_state *p, int c)
|
||||
{
|
||||
if (p->bidx < 1024) {
|
||||
if (p->bidx < MRB_PARSER_BUF_SIZE) {
|
||||
p->buf[p->bidx++] = c;
|
||||
}
|
||||
}
|
||||
@@ -3356,7 +3356,7 @@ toklast(parser_state *p)
|
||||
static void
|
||||
tokfix(parser_state *p)
|
||||
{
|
||||
if (p->bidx >= 1024) {
|
||||
if (p->bidx >= MRB_PARSER_BUF_SIZE) {
|
||||
yyerror(p, "string too long (truncated)");
|
||||
}
|
||||
p->buf[p->bidx] = '\0';
|
||||
|
||||
Reference in New Issue
Block a user