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:
Justine Tunney 2022-06-18 01:10:29 -07:00
parent 67b28b9af1
commit c1cfca8ae1
18 changed files with 569 additions and 194 deletions

View file

@ -2289,16 +2289,18 @@ int linenoiseHistorySave(const char *filename) {
int j;
FILE *fp;
mode_t old_umask;
old_umask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
fp = fopen(filename, "w");
umask(old_umask);
if (!fp) return -1;
chmod(filename, S_IRUSR | S_IWUSR);
for (j = 0; j < historylen; j++) {
fputs(history[j], fp);
fputc('\n', fp);
if (filename) {
old_umask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
fp = fopen(filename, "w");
umask(old_umask);
if (!fp) return -1;
chmod(filename, S_IRUSR | S_IWUSR);
for (j = 0; j < historylen; j++) {
fputs(history[j], fp);
fputc('\n', fp);
}
fclose(fp);
}
fclose(fp);
return 0;
}
@ -2378,7 +2380,9 @@ char *linenoiseGetHistoryPath(const char *prog) {
if (*a) {
abAppends(&path, a);
abAppends(&path, b);
abAppendw(&path, '/');
if (!endswith(path.b, "/") && !endswith(path.b, "\\")) {
abAppendw(&path, '/');
}
}
abAppendw(&path, '.');
abAppends(&path, prog);