mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 08:48:29 +00:00
Make improvements
- Improved async signal safety of read() particularly for longjmp() - Started adding cancel cleanup handlers for locks / etc on Windows - Make /dev/tty work better particularly for uses like `foo | less` - Eagerly read console input into a linked list, so poll can signal - Fix some libc definitional bugs, which configure scripts detected
This commit is contained in:
parent
d6c2830850
commit
0c5dd7b342
85 changed files with 1062 additions and 671 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
|
@ -145,6 +146,12 @@ static abi wontreturn void WinInit(const char16_t *cmdline) {
|
|||
}
|
||||
}
|
||||
|
||||
// avoid programs like emacs nagging the user to define this
|
||||
char16_t var[8];
|
||||
if (!__imp_GetEnvironmentVariableW(u"TERM", var, 8)) {
|
||||
__imp_SetEnvironmentVariableW(u"TERM", u"xterm-256color");
|
||||
}
|
||||
|
||||
// allocate memory for stack and argument block
|
||||
_Static_assert(sizeof(struct WinArgs) % FRAMESIZE == 0, "");
|
||||
_mmi.p = _mmi.s;
|
||||
|
@ -173,6 +180,21 @@ static abi wontreturn void WinInit(const char16_t *cmdline) {
|
|||
int count = GetDosArgv(cmdline, wa->argblock, ARRAYLEN(wa->argblock),
|
||||
wa->argv, ARRAYLEN(wa->argv));
|
||||
|
||||
// normalize executable path
|
||||
if (wa->argv[0] && !WinFileExists(wa->argv[0])) {
|
||||
unsigned i, n = 0;
|
||||
while (wa->argv[0][n]) ++n;
|
||||
if (n + 4 < sizeof(wa->argv0buf)) {
|
||||
for (i = 0; i < n; ++i) {
|
||||
wa->argv0buf[i] = wa->argv[0][i];
|
||||
}
|
||||
WRITE32LE(wa->argv0buf + i, READ32LE(".com"));
|
||||
if (WinFileExists(wa->argv0buf)) {
|
||||
wa->argv[0] = wa->argv0buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// munge argv so dos paths become cosmo paths
|
||||
for (int i = 0; wa->argv[i]; ++i) {
|
||||
if (wa->argv[i][0] == '\\' && //
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue