| 28 | #ifdef HAVE_UN |
| 29 | |
| 30 | static std::string |
| 31 | LocalAddressToString(std::string_view raw) noexcept |
| 32 | { |
| 33 | if (raw.empty()) |
| 34 | return "local"; |
| 35 | |
| 36 | if (raw.front() != '\0' && raw.back() == '\0') |
| 37 | /* don't convert the null terminator of a non-abstract socket |
| 38 | to a '@' */ |
| 39 | raw.remove_suffix(1); |
| 40 | |
| 41 | std::string result{raw}; |
| 42 | |
| 43 | /* replace all null bytes with '@'; this also handles abstract |
| 44 | addresses (Linux specific) */ |
| 45 | std::replace(result.begin(), result.end(), '\0', '@'); |
| 46 | |
| 47 | return result; |
| 48 | } |
| 49 | |
| 50 | #endif |
| 51 |
no test coverage detected