Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36 #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/strings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/strings.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.5.0;

import 'ds-test/test.sol';
import './strings.sol';
Expand All @@ -17,15 +17,15 @@ 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));
}

function assertEq0(strings.slice memory a, strings.slice memory b) internal {
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);
}

Expand Down