From 585ffb1025fc81007ca6a15908ec16f2cdbfbf13 Mon Sep 17 00:00:00 2001 From: Vincent Gariepy Date: Sat, 19 Apr 2014 21:55:29 -0400 Subject: [PATCH] neth: use streams for inputs --- neth/main.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/neth/main.cpp b/neth/main.cpp index ff10365fe..cb974acda 100644 --- a/neth/main.cpp +++ b/neth/main.cpp @@ -564,9 +564,18 @@ int main(int argc, char** argv) fields[4].erase(std::remove(fields[4].begin(), fields[4].end(), ' '), fields[4].end()); fields[5].erase(std::find_if(fields[5].rbegin(), fields[5].rend(), std::bind1st(std::not_equal_to(), ' ')).base(), fields[5].end()); int size = fields[0].length(); - u256 amount = atoll(fields[1].c_str()); - u256 gasPrice = atoll(fields[2].c_str()); - u256 gas = atoll(fields[3].c_str()); + u256 amount; + u256 gasPrice; + u256 gas; + stringstream ssa; + ssa << fields[1]; + ssa >> amount; + stringstream ssg; + ssg << fields[3]; + ssg >> gas; + stringstream ssp; + ssp << fields[2]; + ssp >> gasPrice; string sechex = fields[4]; string sdata = fields[5]; cnote << "Data:"; @@ -623,7 +632,10 @@ int main(int argc, char** argv) { fields[0].erase(std::remove(fields[0].begin(), fields[0].end(), ' '), fields[0].end()); int size = fields[0].length(); - u256 amount = atoll(fields[1].c_str()); + u256 amount; + stringstream sss; + sss << fields[1]; + sss >> amount; if (size < 40) { if (size > 0) @@ -661,9 +673,18 @@ int main(int argc, char** argv) } else { - u256 endowment = atoll(fields[0].c_str()); - u256 gas = atoll(fields[2].c_str()); - u256 gasPrice = atoll(fields[1].c_str()); + u256 endowment; + u256 gas; + u256 gasPrice; + stringstream sse; + sse << fields[0]; + sse >> endowment; + stringstream ssg; + ssg << fields[2]; + ssg >> gas; + stringstream ssp; + ssp << fields[1]; + ssp >> gasPrice; if (endowment < 0) cwarn << "Invalid endowment"; else if (gasPrice < c_minGasPrice)