refactor(3p/nix/libutil): Replace string2Int & trim functions

Replaces these functions with corresponding functions from Abseil,
namely absl::StripAsciiWhitespace and absl::SimpleAtoi.

In the course of doing this some minor things I encountered along the
way were also refactored.

This also changes the signatures of the various custom readFile
functions to use absl::string_view types.
This commit is contained in:
Vincent Ambo 2020-05-25 01:19:02 +01:00
parent b371821db5
commit 98299da0fd
19 changed files with 84 additions and 72 deletions

View file

@ -3,6 +3,7 @@
#include <future>
#include <utility>
#include <absl/strings/numbers.h>
#include <glog/logging.h>
#include "crypto.hh"
@ -718,7 +719,7 @@ ValidPathInfo decodeValidPathInfo(std::istream& str, bool hashGiven) {
getline(str, s);
info.narHash = Hash(s, htSHA256);
getline(str, s);
if (!string2Int(s, info.narSize)) {
if (!absl::SimpleAtoi(s, &info.narSize)) {
throw Error("number expected");
}
}
@ -726,7 +727,7 @@ ValidPathInfo decodeValidPathInfo(std::istream& str, bool hashGiven) {
std::string s;
int n;
getline(str, s);
if (!string2Int(s, n)) {
if (!absl::SimpleAtoi(s, &n)) {
throw Error("number expected");
}
while ((n--) != 0) {