1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-28 11:09:54 +00:00

Fix #505 - bat int64 parsing.

Fixes an off-by-1 error.

Also makes windows testing hopefully a bit less flaky.
This commit is contained in:
Calvin Rose 2020-11-25 09:45:46 -06:00
parent a3f98091c4
commit a3e812b86d
4 changed files with 12 additions and 2 deletions

View File

@ -1642,7 +1642,7 @@ int janet_make_pipe(JanetHandle handles[2]) {
rhandle = CreateNamedPipeA( rhandle = CreateNamedPipeA(
PipeNameBuffer, PipeNameBuffer,
PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_WAIT, PIPE_TYPE_BYTE | PIPE_NOWAIT,
1, /* Number of pipes */ 1, /* Number of pipes */
4096, /* Out buffer size */ 4096, /* Out buffer size */
4096, /* In buffer size */ 4096, /* In buffer size */

View File

@ -447,7 +447,7 @@ int janet_scan_int64(const uint8_t *str, int32_t len, int64_t *out) {
int neg; int neg;
uint64_t bi; uint64_t bi;
if (scan_uint64(str, len, &bi, &neg)) { if (scan_uint64(str, len, &bi, &neg)) {
if (neg && bi <= (UINT64_MAX / 2)) { if (neg && bi <= ((UINT64_MAX / 2) + 1)) {
if (bi > INT64_MAX) { if (bi > INT64_MAX) {
*out = INT64_MIN; *out = INT64_MIN;
} else { } else {

View File

@ -36,6 +36,12 @@
(def s (net/server "127.0.0.1" "8000" handler)) (def s (net/server "127.0.0.1" "8000" handler))
(assert s "made server 1") (assert s "made server 1")
# We need some sleep for windows to let the server stabilize
# or else the first read can fail. Might be a strange windows
# "bug", but needs further investigating. Otherwise, `build_win test`
# can sometimes fail on windows, leading to flaky testing.
(ev/sleep 0.2)
(defn test-echo [msg] (defn test-echo [msg]
(with [conn (net/connect "127.0.0.1" "8000")] (with [conn (net/connect "127.0.0.1" "8000")]
(:write conn msg) (:write conn msg)

View File

@ -65,4 +65,8 @@
(assert (= :brackets (tuple/type (postwalk identity '[]))) "walk square brackets 1") (assert (= :brackets (tuple/type (postwalk identity '[]))) "walk square brackets 1")
(assert (= :brackets (tuple/type (walk identity '[]))) "walk square brackets 2") (assert (= :brackets (tuple/type (walk identity '[]))) "walk square brackets 2")
# # off by 1 error in inttypes
(assert (= (int/s64 "-0x8000_0000_0000_0000") (+ (int/s64 "0x7FFF_FFFF_FFFF_FFFF") 1)) "int types wrap around")
(end-suite) (end-suite)