summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/mrbconf.h2
-rw-r--r--include/mruby/compile.h6
-rw-r--r--src/parse.y4
3 files changed, 9 insertions, 3 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h
index 030e00c9f..a6914cdb4 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -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 */
diff --git a/include/mruby/compile.h b/include/mruby/compile.h
index 0df0d3d0a..26f8a597f 100644
--- a/include/mruby/compile.h
+++ b/include/mruby/compile.h
@@ -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* */
diff --git a/src/parse.y b/src/parse.y
index 90a0eeb3b..7694644a9 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -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';