netcat-0.7.1-signed-bit-counting.patch 1000 B

123456789101112131415161718192021222324252627282930
  1. # Fix the endian-specific bit-counting code so that it works.
  2. # SF:1068324 "netcat_flag_count() fix"
  3. # http://sourceforge.net/tracker/?func=detail&aid=1205729&group_id=52204&atid=466046
  4. # SF:1205729 "doen't work on arm linux platform":
  5. # http://sourceforge.net/tracker/?func=detail&aid=1068324&group_id=52204&atid=466046
  6. Index: netcat-0.7.1/src/flagset.c
  7. ===================================================================
  8. --- netcat-0.7.1.orig/src/flagset.c 2010-07-19 13:51:46.000000000 +0100
  9. +++ netcat-0.7.1/src/flagset.c 2010-07-19 13:52:27.000000000 +0100
  10. @@ -134,7 +134,7 @@
  11. int netcat_flag_count(void)
  12. {
  13. - register char c;
  14. + register unsigned char c;
  15. register int i;
  16. int ret = 0;
  17. @@ -154,8 +154,8 @@
  18. Assumed that the bit number 1 is the sign, and that we will shift the
  19. bit 1 (or the bit that takes its place later) until the the most right,
  20. WHY it has to keep the wrong sign? */
  21. - ret -= (c >> 7);
  22. - c <<= 1;
  23. + ret += c&1;
  24. + c>>=1;
  25. }
  26. }