Skip to main content

convbase_underscore

Function convbase_underscore 

Source
pub fn convbase_underscore(val: i64, base: i32, underscore: i32) -> String
Expand description

Convert integer to string with underscores for readability Port of convbase_underscore(char *s, zlong v, int base, int underscore) from Src/params.c:5646.

base is i32 not u32 because zsh uses NEGATIVE base values (set by [##N]) to mean “emit N-radix digits WITHOUT the N# prefix” — convbase_ptr at params.rs:7435-7451 handles the sign: positive b produces b#NNN, negative b produces bare NNN (absolute value of b is the actual radix).

Previous Rust signature base: u32 silently dropped the sign, so $(([##16] 255)) (outputradix=-16) ended up as convbase(255, 16) = "16#FF" instead of "FF". WARNING: param names don’t match C — Rust=(val, base, underscore) vs C=(s, v, base, underscore)