It's hard to reproduce the issue you described: You probably mixed "+" and "-" here and you don't tell us what options you are using. It's furthermore unclear if the code you show is before or after formatting and so it's not possible to understand how your expectations differ from the results you get. You better should have provided something like this:
When formatting the following code with astyle version 3.4.14
I found that there was no padding added around + and - in the cases where the variable name ended in e which led me to the conclusion that astyle treats these expressions as floating point literals despite the missing 0x prefix that allows hexadecimal floating point literals in C99 or C++17 respectively.
Last edit: w-peuker 2024-04-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to format the following code with astyle 3.4.14:
intmain(){inta0e=10+30;floatx=a0e-30;}
via command astyle --style=java --indent=tab=4 --indent-switches --indent-namespaces --indent-preproc-block --min-conditional-indent=1 --pad-oper --pad-comma --pad-header < test.cpp > output.cpp.
The result is:
intmain(){inta0e=10+30;floatx=a0e-30;}
The operator '-' in "a0e-30" should be padded with spaces, but it's not.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's hard to reproduce the issue you described: You probably mixed
"+"
and"-"
here and you don't tell us what options you are using. It's furthermore unclear if the code you show is before or after formatting and so it's not possible to understand how your expectations differ from the results you get. You better should have provided something like this:When formatting the following code with astyle version 3.4.14
via the command line
astyle --pad-oper < test.c > test-b.c
(or
astyle --pad-oper < test.cpp > test-b.cpp
), I get this result:I found that there was no padding added around
+
and-
in the cases where the variable name ended ine
which led me to the conclusion that astyle treats these expressions as floating point literals despite the missing0x
prefix that allows hexadecimal floating point literals in C99 or C++17 respectively.Last edit: w-peuker 2024-04-25
Thank you for the clarification.
I tried to format the following code with astyle 3.4.14:
via command
astyle --style=java --indent=tab=4 --indent-switches --indent-namespaces --indent-preproc-block --min-conditional-indent=1 --pad-oper --pad-comma --pad-header < test.cpp > output.cpp
.The result is:
The operator '-' in "a0e-30" should be padded with spaces, but it's not.
Fixed in 3.4.15