Skip to content

Commit

Permalink
[ re #242 ] some relaxations to not worry about 1-off bugs
Browse files Browse the repository at this point in the history
I sleep better if I do not have to worry about the corner cases which
have not been verified by a theorem prover or static analysis.
  • Loading branch information
andreasabel committed Nov 4, 2018
1 parent a4ae2a4 commit a065117
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions source/src/BNFC/Backend/CPP/PrettyPrinter.hs
Expand Up @@ -106,14 +106,17 @@ mkHFile useStl inPackage cf groups = unlines
] ++ [" void visit" ++ t ++ "(String s);" | t <- tokenNames cf] ++
[
" protected:",
" char *buf_;",
" int cur_, buf_size;",
"",
" void inline bufAppend(const char *s)",
" {",
" int len = strlen(s);",
" while (cur_ + len > buf_size)",
" while (cur_ + len >= buf_size)",
" {",
" buf_size *= 2; /* Double the buffer size */",
" resizeBuffer();",
" }",
" resizeBuffer();",
" for(int n = 0; n < len; n++)",
" {",
" buf_[cur_ + n] = s[n];",
Expand All @@ -124,7 +127,7 @@ mkHFile useStl inPackage cf groups = unlines
"",
" void inline bufAppend(const char c)",
" {",
" if (cur_ == buf_size)",
" if (cur_ >= buf_size)",
" {",
" buf_size *= 2; /* Double the buffer size */",
" resizeBuffer();",
Expand Down Expand Up @@ -163,8 +166,6 @@ mkHFile useStl inPackage cf groups = unlines
" }",
" buf_ = temp;",
" }",
" char *buf_;",
" int cur_, buf_size;",
"};",
""
]
Expand Down

0 comments on commit a065117

Please sign in to comment.