Created attachment 1510658 [details] binary number format token Description of problem: $ echo '0b11110000' | indent 0 b11110000 Version-Release number of selected component (if applicable): indent-2.2.12 How reproducible: always Expected results: $ echo '0b11110000' | indent 0b11110000 Additional info: see my patch to add binary number format token Binary number format is frequently used in embedded world for MCU registers. Thank you for adding the token!
I cannot find this format in ISO C11 specification. I only found a GCC extension <https://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html>. Am I correct the binary constants are not part of any standard? GCC actually supports both lower-cased and upper-cased 'B' notation. It also supports long and unsigned binary constants. None of them are accepted by your patch. I reworked your patch to utilize the floating number code. I will forward that patch to the indent upstream to obtain a feedback. I will also attach my patch here so you can test it. If upstream does not reject it, I will apply it to Fedora's indent package.
Created attachment 1510910 [details] A proposed patch with the tests
Created attachment 1510918 [details] A proposed patch with the tests A correction in exponents.
The only my objection is increased complexity of resulting code. Anyway thanks for your work!
I have found several crazy corner cases in your state machine: $ ./indent <<< '0b10ululul' 0b10ululul $ ./indent <<< '0b10lllll' 0b10lllll $ ./indent <<< '0b10uuuuuu' 0b10uuuuuu $ ./indent <<< '0b10f' 0b10f $ ./indent <<< '0b10df' 0b10df $ ./indent <<< '0b10dd' 0b10dd $ ./indent <<< '0b10df' 0b10df ... It is not a problem because the compiler captures these cases. I would rather prefer code decomposition to another automaton for integers because of KISS and maintenance.
I know about them. This is how current code works even for non-binary constants. indent is not a validator and it deals correctly only with a valid C code. If you want to help with developing indent, please send your suggestions and patches to <bug-indent>.
No response from the upstream as expected. I'm going to apply the patch for all Fedoras now.
indent-2.2.11-27.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-94aadebb72
indent-2.2.11-25.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2019-ee46877ad3
indent-2.2.11-27.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-94aadebb72
indent-2.2.11-25.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-ee46877ad3
indent-2.2.11-25.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.
indent-2.2.11-27.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.