aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-04-20 10:18:45 -0700
committerWladimir J. van der Laan <laanwj@gmail.com>2012-04-20 10:18:45 -0700
commit00b9c0f4b20f6eb714fa55eb00df326a6f74fd10 (patch)
tree09d89fa8f0111990b95860b440b0030a1eca29ae /src
parent3b9e6b7820bf2fa98c8c2ae296cbe5fb043f690f (diff)
parent8c8e8c2e931b26905112faffb12f527f3256f5dc (diff)
Merge pull request #1122 from dlitz/unsigned-char-fix
Unsigned char fix & fix undefined phexdigits[255]
Diffstat (limited to 'src')
-rw-r--r--src/bignum.h5
-rw-r--r--src/script.h6
-rw-r--r--src/uint256.h2
-rw-r--r--src/util.cpp10
4 files changed, 13 insertions, 10 deletions
diff --git a/src/bignum.h b/src/bignum.h
index cea8e1e357..0d57dc8a8e 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -78,7 +78,8 @@ public:
BN_clear_free(this);
}
- CBigNum(char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
+ //CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'.
+ CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
@@ -296,7 +297,7 @@ public:
psz++;
// hex string to bignum
- static char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
+ static signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
*this = 0;
while (isxdigit(*psz))
{
diff --git a/src/script.h b/src/script.h
index 524d08b3ec..1aac324f62 100644
--- a/src/script.h
+++ b/src/script.h
@@ -268,7 +268,8 @@ public:
}
- explicit CScript(char b) { operator<<(b); }
+ //explicit CScript(char b) is not portable. Use 'signed char' or 'unsigned char'.
+ explicit CScript(signed char b) { operator<<(b); }
explicit CScript(short b) { operator<<(b); }
explicit CScript(int b) { operator<<(b); }
explicit CScript(long b) { operator<<(b); }
@@ -285,7 +286,8 @@ public:
explicit CScript(const std::vector<unsigned char>& b) { operator<<(b); }
- CScript& operator<<(char b) { return push_int64(b); }
+ //CScript& operator<<(char b) is not portable. Use 'signed char' or 'unsigned char'.
+ CScript& operator<<(signed char b) { return push_int64(b); }
CScript& operator<<(short b) { return push_int64(b); }
CScript& operator<<(int b) { return push_int64(b); }
CScript& operator<<(long b) { return push_int64(b); }
diff --git a/src/uint256.h b/src/uint256.h
index bf3c55bccb..104b84970a 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -305,7 +305,7 @@ public:
psz += 2;
// hex string to uint
- static char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
+ static unsigned char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
const char* pbegin = psz;
while (phexdigit[(unsigned char)*psz] || *psz == '0')
psz++;
diff --git a/src/util.cpp b/src/util.cpp
index ac65d417b3..9f2de3449d 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -425,14 +425,14 @@ bool ParseMoney(const char* pszIn, int64& nRet)
}
-static char phexdigit[256] =
+static signed char phexdigit[256] =
{ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,
-1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1
+ -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
@@ -461,12 +461,12 @@ vector<unsigned char> ParseHex(const char* psz)
{
while (isspace(*psz))
psz++;
- char c = phexdigit[(unsigned char)*psz++];
- if (c == (char)-1)
+ signed char c = phexdigit[(unsigned char)*psz++];
+ if (c == (signed char)-1)
break;
unsigned char n = (c << 4);
c = phexdigit[(unsigned char)*psz++];
- if (c == (char)-1)
+ if (c == (signed char)-1)
break;
n |= c;
vch.push_back(n);