mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-08 12:18:31 +00:00
Make fixes and improvements
- Polyfill UTIME_OMIT on XNU - Refactor Lua build code so it's better - Add unix module to lua.com (Discord request) - Add unix.utimensat() and unix.futimens() to redbean - Avoid creating double slash path in linenoise (#428) - Remove double slashes in NT paths automatically (#428) - Make strerror() smarter about showing NT errors (#428) Fixes #428
This commit is contained in:
parent
67b28b9af1
commit
c1cfca8ae1
18 changed files with 569 additions and 194 deletions
|
@ -34,16 +34,18 @@
|
|||
privileged int strerror_wr(int err, uint32_t winerr, char *buf, size_t size) {
|
||||
/* kprintf() weakly depends on this function */
|
||||
int c, n;
|
||||
bool wanting;
|
||||
char16_t winmsg[256];
|
||||
const char *sym, *msg;
|
||||
sym = firstnonnull(strerrno(err), "EUNKNOWN");
|
||||
msg = firstnonnull(strerdoc(err), "No error information");
|
||||
wanting = false;
|
||||
sym = firstnonnull(strerrno(err), (wanting = true, "EUNKNOWN"));
|
||||
msg = firstnonnull(strerdoc(err), (wanting = true, "No error information"));
|
||||
if (IsTiny()) {
|
||||
if (!sym) sym = "EUNKNOWN";
|
||||
for (; (c = *sym++); --size)
|
||||
if (size > 1) *buf++ = c;
|
||||
if (size) *buf = 0;
|
||||
} else if (!IsWindows() || err == winerr || !winerr) {
|
||||
} else if (!IsWindows() || ((err == winerr || !winerr) && !wanting)) {
|
||||
ksnprintf(buf, size, "%s/%d/%s", sym, err, msg);
|
||||
} else {
|
||||
if ((n = FormatMessage(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue