Bug 1655319 - missing binary number format token
Summary: missing binary number format token
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: indent
Version: 29
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Petr Pisar
QA Contact: Fedora Extras Quality Assurance
URL: http://lists.gnu.org/archive/html/bug...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-12-02 17:49 UTC by Josef Kubin
Modified: 2019-02-12 02:55 UTC (History)
1 user (show)

Fixed In Version: indent-2.2.12-3.fc30 indent-2.2.11-25.fc28 indent-2.2.11-27.fc29
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-02-12 01:26:13 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
binary number format token (802 bytes, patch)
2018-12-02 17:49 UTC, Josef Kubin
no flags Details | Diff
A proposed patch with the tests (4.12 KB, patch)
2018-12-03 13:13 UTC, Petr Pisar
no flags Details | Diff
A proposed patch with the tests (4.13 KB, patch)
2018-12-03 13:32 UTC, Petr Pisar
no flags Details | Diff

Description Josef Kubin 2018-12-02 17:49:45 UTC
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!

Comment 1 Petr Pisar 2018-12-03 13:12:59 UTC
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.

Comment 2 Petr Pisar 2018-12-03 13:13:58 UTC
Created attachment 1510910 [details]
A proposed patch with the tests

Comment 3 Petr Pisar 2018-12-03 13:32:32 UTC
Created attachment 1510918 [details]
A proposed patch with the tests

A correction in exponents.

Comment 4 Josef Kubin 2018-12-03 13:58:58 UTC
The only my objection is increased complexity of resulting code.

Anyway thanks for your work!

Comment 5 Josef Kubin 2018-12-03 15:28:52 UTC
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.

Comment 6 Petr Pisar 2018-12-03 16:07:04 UTC
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>.

Comment 7 Petr Pisar 2019-02-01 07:31:01 UTC
No response from the upstream as expected. I'm going to apply the patch for all Fedoras now.

Comment 8 Fedora Update System 2019-02-01 08:16:55 UTC
indent-2.2.11-27.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-94aadebb72

Comment 9 Fedora Update System 2019-02-01 08:24:38 UTC
indent-2.2.11-25.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2019-ee46877ad3

Comment 10 Fedora Update System 2019-02-02 02:57:33 UTC
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

Comment 11 Fedora Update System 2019-02-02 03:36:31 UTC
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

Comment 12 Fedora Update System 2019-02-12 01:26:13 UTC
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.

Comment 13 Fedora Update System 2019-02-12 02:55:26 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.