Cumulative season's silent-bug hunting (~62 fixes) across the FiveSql2 SQL engine, the Five compiler/runtime, and the hbrdd RDD layer. Saved as a single checkpoint before refactoring the parser to delegate xBase command translation to the preprocessor. Highlights: FiveSql2 engine (_FiveSql2/src/) - prefix-glob index attach -> explicit convention (<table>_pk.ntx, <table>_uq.ntx, <table>.cdx) — fixes silent multi-row INSERT row-drop - DROP/CREATE TABLE FErase chain extended (.cdx, .fsc, .fsv, .dbt, .fpt) - COUNT(DISTINCT col) parsed + aggregated via hSeen hash - UNION column-count mismatch returns SQL_ERR_GRAMMAR (was silent) - DISTINCT + ORDER BY hidden-col leak fixed (trim before DISTINCT) - Derived table FROM (SELECT...) + JOIN right-side derived - Self-FK CASCADE depth 2+ via SqlGetSingleColPK pre-collect - LAG/LEAD default arg uses SqlEvalRowExpr (handles -N const exprs) - DATE literal round-trip validation (Feb 29 non-leap rejected) - CREATE OR REPLACE VIEW; CREATE VIEW errors on already-exists - AlterTable type dispatcher comma-wrapped (1-char type "A" no longer matches CHARACTER) Compiler / runtime - gengo: HB_ -> FV_ prefix on emitted Go function names (Five identity) - gengo split: emit_block.go, emit_stmt.go, folding.go extracted - parser/stmtreg.go nudges - hbrt: debug TUI/CLI restructure (debugcmd, debugkey, termios_*), windows debug stubs collapsed - thread/vm/value/class/pcinterp tightening from panic traces RDD layer (hbrdd/) - dbf: null bitmap support (null.go + null_test.go), mmap split (mmap_posix.go / mmap_windows.go), byte-level numeric parse - ntx/cdx: windows mmap parity - workarea + mem RDD: cross-area state-bleed fixes RTL (hbrtl/) - errorlog rewrite with platform-specific FD (errorlog_fd_unix / errorlog_fd_other) - sqlscan, sqlhelpers, indexrtl, datetime extensions Gates green at checkpoint: - go test ./... : PASS - FiveSql2 SQL:1999 : 43/43 - Harbour compat : 56/56 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
80 lines
2.3 KiB
Go
80 lines
2.3 KiB
Go
// Copyright (c) 2026 Charles KWON OhJun (charleskwonohjun@gmail.com)
|
|
// All rights reserved.
|
|
|
|
//go:build linux
|
|
|
|
// Termios ioctl helpers for the debugger — Linux uses TCGETS/TCSETS.
|
|
// Kept in a tiny shim so debugcli/debugtui stay platform-neutral.
|
|
|
|
package hbrt
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
const (
|
|
ioctlGetTermios = syscall.TCGETS
|
|
ioctlSetTermios = syscall.TCSETS
|
|
)
|
|
|
|
var (
|
|
savedTermios syscall.Termios
|
|
termSaved bool
|
|
)
|
|
|
|
func restoreCooked() {
|
|
fd := int(os.Stdin.Fd())
|
|
var t syscall.Termios
|
|
syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlGetTermios, uintptr(unsafe.Pointer(&t)), 0, 0, 0)
|
|
if !termSaved {
|
|
savedTermios = t
|
|
termSaved = true
|
|
}
|
|
t.Lflag |= syscall.ICANON | syscall.ECHO
|
|
t.Oflag |= syscall.OPOST
|
|
syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlSetTermios, uintptr(unsafe.Pointer(&t)), 0, 0, 0)
|
|
}
|
|
|
|
func reenterRaw() {
|
|
fd := int(os.Stdin.Fd())
|
|
var t syscall.Termios
|
|
syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlGetTermios, uintptr(unsafe.Pointer(&t)), 0, 0, 0)
|
|
t.Lflag &^= syscall.ICANON | syscall.ECHO | syscall.ISIG
|
|
t.Oflag &^= syscall.OPOST
|
|
t.Cc[syscall.VMIN] = 1
|
|
t.Cc[syscall.VTIME] = 0
|
|
syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlSetTermios, uintptr(unsafe.Pointer(&t)), 0, 0, 0)
|
|
}
|
|
|
|
func termSize() (int, int) {
|
|
type winsize struct {
|
|
Row, Col, Xpixel, Ypixel uint16
|
|
}
|
|
var ws winsize
|
|
_, _, _ = syscall.Syscall(syscall.SYS_IOCTL, uintptr(1),
|
|
uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&ws)))
|
|
return int(ws.Row), int(ws.Col)
|
|
}
|
|
|
|
// readDebugKey puts stdin into raw mode just long enough to consume
|
|
// one keystroke / ANSI escape sequence, then restores the previous
|
|
// termios. The cross-platform decoder in debugkey.go turns the bytes
|
|
// into a logical key code.
|
|
func readDebugKey() int {
|
|
fd := int(os.Stdin.Fd())
|
|
var t syscall.Termios
|
|
syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlGetTermios, uintptr(unsafe.Pointer(&t)), 0, 0, 0)
|
|
raw := t
|
|
raw.Lflag &^= syscall.ICANON | syscall.ECHO
|
|
raw.Cc[syscall.VMIN] = 1
|
|
raw.Cc[syscall.VTIME] = 0
|
|
syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlSetTermios, uintptr(unsafe.Pointer(&raw)), 0, 0, 0)
|
|
defer syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlSetTermios, uintptr(unsafe.Pointer(&t)), 0, 0, 0)
|
|
|
|
buf := make([]byte, 8)
|
|
n, _ := syscall.Read(fd, buf)
|
|
return decodeDebugKey(buf, n)
|
|
}
|