Skip to content

Commit

Permalink
Fix include file in the generated C89 code.
Browse files Browse the repository at this point in the history
Fixed a bug in the generated C89 code that included stdint.h.
Thanks to Frank (ftheile).
Closes issue 3454356.
  • Loading branch information
tpircher-zz committed Dec 8, 2011
1 parent 3ffd08b commit 8d104cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2011-12-08 Thomas Pircher <tehpeh@gmx.net>

* crc_symtable.py:
Fixed a bug in the generated C89 code that included stdint.h.
Thanks to Frank (ftheile).
Closes issue 3454356.

2011-11-08 Thomas Pircher <tehpeh@gmx.net>

* crc_symtable.py:
Expand Down
6 changes: 3 additions & 3 deletions crc_symtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ def __getTerminal(self, id):
#include $include_file
:}
#include "$header_filename" /* include the header file generated with pycrc */
#include <stdint.h>
#include <stdlib.h>
$if ($undefined_parameters == True or $crc_algorithm == "bit-by-bit" or $crc_algorithm == "bit-by-bit-fast") {:
$if ($c_std != C89) {:
#include <stdint.h>
$if ($undefined_parameters == True or $crc_algorithm == "bit-by-bit" or $crc_algorithm == "bit-by-bit-fast") {:
#include <stdbool.h>
:}
:}
Expand Down Expand Up @@ -577,7 +577,7 @@ def __getTerminal(self, id):
$c_bool bit;
$crc_t crc = $cfg_xor_in;
for (i = 0; i < $cfg_width; i++) {
bit = $if ($c_std == C89) {:!!(crc & 0x01);:} $else {:crc & 0x01;:}
bit = crc & 0x01;
if (bit) {
crc = ((crc ^ $cfg_poly) >> 1) | $cfg_msb_mask;
} else {
Expand Down
4 changes: 2 additions & 2 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ opt="--width 64 --poly 0x000000000000001b --reflect-in 1 --xor-in 0x0 --reflect-
teststr "$cmd" "$res"
teststr "$PYCRC $opt" "$res"
testfil "$cmd" "$res"
testbin "$opt" "$res" # don't test binaries with width 64 bits (variables not wide enough...)
testbin "$opt" "$res"

#CRC-64-jones
res="0xcaa717168609f281"
Expand All @@ -345,7 +345,7 @@ opt="--width 64 --poly 0xad93d23594c935a9 --reflect-in 1 --xor-in 0xffffffffffff
teststr "$cmd" "$res"
teststr "$PYCRC $opt" "$res"
testfil "$cmd" "$res"
testbin "$opt" "$res" # don't test binaries with width 64 bits (variables not wide enough...)
testbin "$opt" "$res"
fi


Expand Down

0 comments on commit 8d104cf

Please sign in to comment.