From e4079e164753d90370a31ca70021f3d4f624e4bb Mon Sep 17 00:00:00 2001 From: Chirag Mahaveer Parmar Date: Fri, 1 Mar 2019 14:00:31 +0100 Subject: [PATCH 1/2] Fixes #36 --- src/strings.sol | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/strings.sol b/src/strings.sol index b449645a..272db832 100644 --- a/src/strings.sol +++ b/src/strings.sol @@ -34,7 +34,7 @@ * corresponding to the left and right parts of the string. */ -pragma solidity ^0.4.14; +pragma solidity ^0.5.0; library strings { struct slice { @@ -83,23 +83,23 @@ library strings { uint ret; if (self == 0) return 0; - if (self & 0xffffffffffffffffffffffffffffffff == 0) { + if (uint(self) & 0xffffffffffffffffffffffffffffffff == 0) { ret += 16; self = bytes32(uint(self) / 0x100000000000000000000000000000000); } - if (self & 0xffffffffffffffff == 0) { + if (uint(self) & 0xffffffffffffffff == 0) { ret += 8; self = bytes32(uint(self) / 0x10000000000000000); } - if (self & 0xffffffff == 0) { + if (uint(self) & 0xffffffff == 0) { ret += 4; self = bytes32(uint(self) / 0x100000000); } - if (self & 0xffff == 0) { + if (uint(self) & 0xffff == 0) { ret += 2; self = bytes32(uint(self) / 0x10000); } - if (self & 0xff == 0) { + if (uint(self) & 0xff == 0) { ret += 1; } return 32 - ret; @@ -702,7 +702,7 @@ library strings { uint retptr; assembly { retptr := add(ret, 32) } - for(i = 0; i < parts.length; i++) { + for(uint i = 0; i < parts.length; i++) { memcpy(retptr, parts[i]._ptr, parts[i]._len); retptr += parts[i]._len; if (i < parts.length - 1) { From cb55e93beb952bcf083c749a2cfe8f92facdf1e1 Mon Sep 17 00:00:00 2001 From: Chirag Mahaveer Parmar Date: Tue, 14 May 2019 10:05:42 +0200 Subject: [PATCH 2/2] test support --- src/strings.t.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/strings.t.sol b/src/strings.t.sol index a78bd8a3..0b7834e5 100644 --- a/src/strings.t.sol +++ b/src/strings.t.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.21; +pragma solidity ^0.5.0; import 'ds-test/test.sol'; import './strings.sol'; @@ -17,7 +17,7 @@ contract StringsTest is DSTest { return x == 0 ? int(0) : (x < 0 ? -1 : int(1)); } - function assertEq0(string a, string b) internal { + function assertEq0(string memory a, string memory b) internal { assertEq0(bytes(a), bytes(b)); } @@ -25,7 +25,7 @@ contract StringsTest is DSTest { assertEq0(a.toString(), b.toString()); } - function assertEq0(strings.slice memory a, string b) internal { + function assertEq0(strings.slice memory a, string memory b) internal { assertEq0(a.toString(), b); }