tpircher-zz / pycrc

Free, easy to use Cyclic Redundancy Check (CRC) calculator and source code generator
https://pycrc.org
MIT License
169 stars 36 forks source link

Bad-looking C code generated #1

Closed intgr closed 12 years ago

intgr commented 12 years ago

Currently pycrc generates bad-looking C code like this:

for (i = 0; i < 32; i++) {
    bit = crc & 0x80000000;        crc = (crc << 1) | 0x00;

This bug was introduced in 0.7.9. The parser eats newline characters after block delimiters, so a double-newline is necessary. This patch fixes it.

tpircher-zz commented 12 years ago

Hi intgr,

thanks for the report. I see, a958828 has introduced the regression. I'll pull your fix tonight (after figuring out how to do so...)

Cheers Th

tpircher-zz commented 12 years ago

Actually, I would prefer a different fix for this bug. The empty line could be avoided by placing the semicolon out of the macro blocks {: ... :}, something like this:

Can you rework your pull request to change this please?

Thanks a lot.

PS: yes, I know the macro language I've come up with is a bit simplistic/unflexible/crap/you-name-it, but one important goal for pycrc was that running pycrc must be as painless as possible, so I did not want to include dependencies on external code generators.

intgr commented 12 years ago

Good idea, I pushed a new commit to my fork.

(I was trying to think of prettier ways to solve the problem, but couldn't think of that)