|
| 1 | +$NetBSD: patch-src_utils.h,v 1.1 2024/11/26 23:07:02 riastradh Exp $ |
| 2 | + |
| 3 | +Fix ctype abuse. |
| 4 | +https://github.com/ledger/ledger/pull/2341 |
| 5 | + |
| 6 | +Fix build with boost>=1.86, which broke API compatibility. |
| 7 | +https://github.com/ledger/ledger/issues/2378 |
| 8 | + |
| 9 | +--- src/utils.h.orig 2020-05-18 05:30:10.000000000 +0000 |
| 10 | ++++ src/utils.h |
| 11 | +@@ -542,7 +542,7 @@ inline char * next_element(char * buf, b |
| 12 | + |
| 13 | + inline char peek_next_nonws(std::istream& in) { |
| 14 | + char c = static_cast<char>(in.peek()); |
| 15 | +- while (in.good() && ! in.eof() && std::isspace(c)) { |
| 16 | ++ while (in.good() && ! in.eof() && std::isspace(static_cast<unsigned char>(c))) { |
| 17 | + in.get(c); |
| 18 | + c = static_cast<char>(in.peek()); |
| 19 | + } |
| 20 | +@@ -607,14 +607,14 @@ inline char peek_next_nonws(std::istream |
| 21 | + *_p = '\0'; \ |
| 22 | + } |
| 23 | + |
| 24 | +-inline string to_hex(unsigned int * message_digest, const int len = 1) |
| 25 | ++inline string to_hex(unsigned char * message_digest, const int len = 4) |
| 26 | + { |
| 27 | + std::ostringstream buf; |
| 28 | + |
| 29 | +- for(int i = 0; i < 5 ; i++) { |
| 30 | +- buf.width(8); |
| 31 | ++ for(int i = 0; i < 20 ; i++) { |
| 32 | ++ buf.width(2); |
| 33 | + buf.fill('0'); |
| 34 | +- buf << std::hex << message_digest[i]; |
| 35 | ++ buf << std::hex << (int)message_digest[i]; |
| 36 | + if (i + 1 >= len) |
| 37 | + break; // only output the first LEN dwords |
| 38 | + } |
| 39 | +@@ -627,9 +627,9 @@ inline string sha1sum(const string& str) |
| 40 | + |
| 41 | + sha.process_bytes(str.c_str(), str.length()); |
| 42 | + |
| 43 | +- unsigned int message_digest[5]; |
| 44 | ++ unsigned char message_digest[20]; |
| 45 | + sha.get_digest(message_digest); |
| 46 | +- return to_hex(message_digest, 5); |
| 47 | ++ return to_hex(message_digest, 20); |
| 48 | + } |
| 49 | + |
| 50 | + extern const string version; |
0 commit comments