Merge pull request #1046 from monaka/pr-add-configuration-macro-MRB_PARSER_BUF_SIZE

Add configuration macro MRB_PARSER_BUF_SIZE.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2013-03-22 19:00:37 -07:00
3 changed files with 9 additions and 3 deletions
+2
View File
@@ -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 */
+5 -1
View File
@@ -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
View File
@@ -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';