diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-09-12 07:53:46 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-09-12 07:58:57 +0900 |
| commit | 9e86d204e54eb0824cbb681027c729fbc8ab82a7 (patch) | |
| tree | 764603f422d7f323cbb1e04cf5ac237f2d4d3359 /mrbgems/mruby-compiler/core/parse.y | |
| parent | e1a865f272ae84c817036e6b6c723dc47b9d81b2 (diff) | |
| download | mruby-9e86d204e54eb0824cbb681027c729fbc8ab82a7.tar.gz mruby-9e86d204e54eb0824cbb681027c729fbc8ab82a7.zip | |
parse.y: avoid adding zero length strings.
Diffstat (limited to 'mrbgems/mruby-compiler/core/parse.y')
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 6e6dff533..cb1ad9427 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -3305,7 +3305,11 @@ string_fragment : tCHAR } | tSTRING_BEG string_rep tSTRING { - $$ = new_dstr(p, push($2, $3)); + node *n = $2; + if (nint($3->cdr->cdr) > 0) { + n = push(n, $3); + } + $$ = new_dstr(p, n); } ; @@ -3347,7 +3351,11 @@ xstring : tXSTRING_BEG tXSTRING } | tXSTRING_BEG string_rep tXSTRING { - $$ = new_dxstr(p, push($2, $3)); + node *n = $2; + if (nint($3->cdr->cdr) > 0) { + n = push(n, $3); + } + $$ = new_dxstr(p, n); } ; @@ -3410,7 +3418,11 @@ words : tWORDS_BEG tSTRING } | tWORDS_BEG string_rep tSTRING { - $$ = new_words(p, push($2, $3)); + node *n = $2; + if (nint($3->cdr->cdr) > 0) { + n = push(n, $3); + } + $$ = new_words(p, n); } ; @@ -3422,8 +3434,12 @@ symbol : basic_symbol } | tSYMBEG tSTRING_BEG string_rep tSTRING { + node *n = $3; p->lstate = EXPR_ENDARG; - $$ = new_dsym(p, new_dstr(p, push($3, $4))); + if (nint($4->cdr->cdr) > 0) { + n = push(n, $4); + } + $$ = new_dsym(p, new_dstr(p, n)); } ; |
