# HG changeset patch # User laurent # Date 1307350907 -7200 # Node ID 29add821207d85bdec9ad09eeb8f6c2f47631d89 # Parent 8fcea60029def71cd3f9f06b9aeab4c1197f38af Fix bug when generating integer with leading zero (octal value for C compiler) diff -r 8fcea60029de -r 29add821207d stage4/generate_c/generate_c_base.cc --- a/stage4/generate_c/generate_c_base.cc Fri Jun 03 17:14:24 2011 +0100 +++ b/stage4/generate_c/generate_c_base.cc Mon Jun 06 11:01:47 2011 +0200 @@ -105,9 +105,17 @@ void *print_striped_token(token_c *token, int offset = 0) { std::string str = ""; - for (unsigned int i = offset; i < strlen(token->value); i++) - if (token->value[i] != '_') + bool leading_zero = true; + for (unsigned int i = offset; i < strlen(token->value); i++) { + if (leading_zero && + (token->value[i] != '0' || + i == strlen(token->value) - 1 || + token->value[i + 1] == '.' + )) + leading_zero = false; + if (!leading_zero && token->value[i] != '_') str += token->value[i]; + } return s4o.printupper(str); } @@ -420,7 +428,7 @@ /* SYM_TOKEN(fixed_point_c) */ -void *visit(fixed_point_c *symbol) {return print_token(symbol);} +void *visit(fixed_point_c *symbol) {return print_striped_token(symbol);} /* SYM_REF2(days_c, days, hours) */