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