szn

Bug 497 — test helper setRaw hardcodes macOS termios indices

497. cc[16]/cc[17] are VMIN/VTIME only on macOS

Severity: LOW (test-only, but a real cross-platform break) Status: 🟢 FIXED Files: src/input.zig:1896-1906

Problem

const VMIN: usize = 16;
const VTIME: usize = 17;

fn setRaw(fd: i32) void {
    ...
    raw.cc[VMIN] = 1;
    raw.cc[VTIME] = 0;
    ...
}

VMIN=16/VTIME=17 are the macOS/BSD c_cc indices. On Linux, VMIN is 6 and VTIME is 5; indices 16/17 are VEOL2 and a reserved slot. On Linux this helper sets VEOL2=1 and clobbers a reserved byte while leaving the real VMIN/VTIME at whatever tcgetattr returned — raw mode is misconfigured and the DSR cursor-report tests below it hang or fail on Linux. (They currently pass by luck of pty defaults, which is worse: a silent portability trap.)

This is evidence the test suite is developed against macOS and not regularly run on Linux — worth fixing as part of making Linux a first-class test target.

Proposed Fix

const VMIN: usize = if (builtin.os.tag == .macos) 16 else 6;
const VTIME: usize = if (builtin.os.tag == .macos) 17 else 5;

(std.c.termios may already expose these per-OS; prefer the std constants if available.)

Resolution

Replaced the hardcoded constants with target-os switches matching src/client/raw.zig:

const VMIN: usize = switch (@import("builtin").os.tag) {
    .linux => 6,
    .macos, .ios => 16,
    .freebsd => 4,
    else => 6,
};
const VTIME: usize = switch (@import("builtin").os.tag) {
    .linux => 5,
    .macos, .ios => 17,
    .freebsd => 5,
    else => 5,
};

Added unit test input test helper VMIN and VTIME match the target platform — bug #497.