From 9695d17df1538460aad11500f56071500d9e4c80 Mon Sep 17 00:00:00 2001 Message-ID: <9695d17df1538460aad11500f56071500d9e4c80.1733510219.git.janneke@gnu.org> From: Janneke Nieuwenhuizen Date: Mon, 18 Nov 2024 00:16:56 +0100 Subject: [PATCH] REMOVEME: stoi: add some debugging. Change-Id: I114025c43cd2404a00dc65af7def06a312a31ca3 --- nix/libstore/local-store.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nix/libstore/local-store.cc b/nix/libstore/local-store.cc index 0883a4bbce..e98bf04392 100644 --- a/nix/libstore/local-store.cc +++ b/nix/libstore/local-store.cc @@ -1164,9 +1164,9 @@ static std::shared_ptr authenticationAgent() static int readInteger(int fd) { string str; + char ch; while (1) { - char ch; ssize_t rd = read(fd, &ch, 1); if (rd == -1) { if (errno != EINTR) @@ -1177,11 +1177,20 @@ static int readInteger(int fd) if (isdigit(ch)) { str += ch; } else { - break; + std::cerr << "00 nondigit: `" << ch << "' [" << (int) ch << "]" << std::endl; + std::cerr << "01 read until now: >>>" << str << "<<<" << std::endl; + break; } } } + if (str.empty()) { + std::cerr << "02 nondigit: `" << ch << "' [" << (int) ch << "]" << std::endl; + str += ch; + str += readLine(fd); + std::cerr << "03 nondigit: >>>" << str << "<<<" << std::endl; + throw EndOfFile("unexpected non-digit reading an integer"); + } return stoi(str); } base-commit: 889c396cc5fd948d2c874c2d4a51115f82591964 -- 2.46.0