mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 16:58:30 +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
24
third_party/linenoise/linenoise.c
vendored
24
third_party/linenoise/linenoise.c
vendored
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue