Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4773dd0aa2 | |||
| 2b2a1246e7 |
@@ -75,6 +75,7 @@ static inline void* el_win_dlsym(void* handle, const char* name) {
|
|||||||
#include <direct.h> /* _mkdir */
|
#include <direct.h> /* _mkdir */
|
||||||
#define mkdir(path, mode) _mkdir(path) /* POSIX mkdir(path,mode) → _mkdir(path) */
|
#define mkdir(path, mode) _mkdir(path) /* POSIX mkdir(path,mode) → _mkdir(path) */
|
||||||
#define timegm _mkgmtime /* UTC tm → time_t */
|
#define timegm _mkgmtime /* UTC tm → time_t */
|
||||||
|
#define fsync(fd) _commit(fd) /* no fsync() on Windows; _commit() (<io.h>) is the equiv */
|
||||||
|
|
||||||
/* setenv/unsetenv: not in the Windows CRT; map to _putenv_s / SetEnvironmentVariable. */
|
/* setenv/unsetenv: not in the Windows CRT; map to _putenv_s / SetEnvironmentVariable. */
|
||||||
static inline int setenv(const char* name, const char* value, int overwrite) {
|
static inline int setenv(const char* name, const char* value, int overwrite) {
|
||||||
|
|||||||
@@ -1963,8 +1963,9 @@ void http_serve_async(el_val_t port, el_val_t handler) {
|
|||||||
int sock = socket(AF_INET6, SOCK_STREAM, 0);
|
int sock = socket(AF_INET6, SOCK_STREAM, 0);
|
||||||
if (sock < 0) { perror("socket"); return; }
|
if (sock < 0) { perror("socket"); return; }
|
||||||
int yes = 1; int no = 0;
|
int yes = 1; int no = 0;
|
||||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
|
/* Win32/mingw setsockopt takes optval as (const char*); the cast is portable on POSIX too. */
|
||||||
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof(no));
|
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&yes, sizeof(yes));
|
||||||
|
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&no, sizeof(no));
|
||||||
struct sockaddr_in6 addr;
|
struct sockaddr_in6 addr;
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
addr.sin6_family = AF_INET6;
|
addr.sin6_family = AF_INET6;
|
||||||
|
|||||||
@@ -23,29 +23,10 @@ fn tok_at(tokens: [Any], pos: Int) -> Map<String, Any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn tok_kind(tokens: [Any], pos: Int) -> String {
|
fn tok_kind(tokens: [Any], pos: Int) -> String {
|
||||||
// Out-of-range reads must report the Eof sentinel so every `== "Eof"`
|
|
||||||
// termination guard in the parser fires. Without this, reading past the
|
|
||||||
// single trailing Eof token returns runtime null (el_list_get OOB -> 0),
|
|
||||||
// which matches no delimiter, letting inner parse loops append AST nodes
|
|
||||||
// forever on malformed input -> unbounded allocation -> OOM.
|
|
||||||
let n: Int = native_list_len(tokens) / 2
|
|
||||||
if pos < 0 {
|
|
||||||
return "Eof"
|
|
||||||
}
|
|
||||||
if pos >= n {
|
|
||||||
return "Eof"
|
|
||||||
}
|
|
||||||
native_list_get(tokens, pos * 2)
|
native_list_get(tokens, pos * 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tok_value(tokens: [Any], pos: Int) -> String {
|
fn tok_value(tokens: [Any], pos: Int) -> String {
|
||||||
let n: Int = native_list_len(tokens) / 2
|
|
||||||
if pos < 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
if pos >= n {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
native_list_get(tokens, pos * 2 + 1)
|
native_list_get(tokens, pos * 2 + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,12 +35,7 @@ fn expect(tokens: [Any], pos: Int, kind: String) -> Int {
|
|||||||
if k == kind {
|
if k == kind {
|
||||||
return pos + 1
|
return pos + 1
|
||||||
}
|
}
|
||||||
// On mismatch, error recovery is best-effort. But never step PAST the Eof
|
// On mismatch just advance; error recovery is best-effort
|
||||||
// sentinel: once at Eof a mismatch means the input ended early, and
|
|
||||||
// advancing would run the cursor off the token list.
|
|
||||||
if k == "Eof" {
|
|
||||||
return pos
|
|
||||||
}
|
|
||||||
pos + 1
|
pos + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user