Created
March 13, 2017 08:27
nibtools bitshifter.c patch for macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: bitshifter.c | |
=================================================================== | |
--- bitshifter.c (revision 637) | |
+++ bitshifter.c (working copy) | |
@@ -439,13 +439,25 @@ | |
// > 0 <= C <= 7 (see above) | |
// > *b = Next bit position to be copied from 'db' (1 <= B <= 8) | |
// > [ ((Q << C) & 0xff00) + new bits from db ] >> C | |
- **q = ( ( (__int32)((**q) >> (8-*c)) << 8) | (((__int32)db << (*b-1)) & 0xff) ) >> *c; | |
+ **q = ( ( (int32_t)((**q) >> (8-*c)) << 8) | (((int32_t)db << (*b-1)) & 0xff) ) >> *c; | |
+ | |
// Determine number 'd' of copied bits (lowest value of following): | |
// - At most (8-*c) free bits in Q were filled | |
// - At most (9-*b) bits could be copied from db | |
// - At most NumDataBits were left to be copied | |
- d = min(min(8-*c, 9-*b), NumDataBits); | |
+ BYTE mina; | |
+ if (8-*c < 9-*b) { | |
+ mina = 8-*c; | |
+ } else { | |
+ mina = 9-*c; | |
+ } | |
+ | |
+ if (mina < NumDataBits) { | |
+ d = mina; | |
+ } else { | |
+ d = NumDataBits; | |
+ } | |
// Now: 1 <= d <= 8 | |
// Update source position P.B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment