Skip to main content

zsh/ported/
mod.rs

1//! Ported subsystems — every submodule here is a faithful 1:1 port of
2//! a corresponding upstream zsh C source file under `src/zsh/Src/`.
3//!
4//! Companion / opposite of `src/extensions/`. See `docs/PORT.md` for the
5//! full ruleset. `tests/port_purity.rs` enforces:
6//!   - Every `.rs` file under this directory has a matching `.c` file
7//!     under `src/zsh/Src/` (byte-for-byte identical stem).
8//!   - Every top-level `fn` carries a doc comment matching the PORT.md
9//!     template: `/// Port of NAME() from Src/STEM.c:NNNN`.
10//!   - No file may carry the `WARNING: THIS IS ADHOC IMPLEMENTATION`
11//!     marker.
12//!
13//! The crate root re-exports every submodule (`pub use ported::*;` in
14//! `src/lib.rs`) so historical call sites that reference
15//! `crate::exec::`, `crate::subst::`, `crate::zle::`, etc. continue
16//! to resolve unchanged.
17
18pub mod compat;
19pub mod cond;
20pub mod context;
21// `exec` was moved to crate root (src/exec.rs) — it isn't a port of
22// Src/exec.c (C zsh's wordcode VM; zshrs uses fusevm instead). Keep `crate::ported::exec` as a path alias so
23// the many existing `crate::ported::exec::*` call-sites still work.
24pub use crate::exec;
25pub mod glob;
26pub mod hashnameddir;
27pub mod hashtable;
28pub mod hashtable_h;
29pub mod hist;
30pub mod init;
31pub mod input;
32pub mod jobs;
33pub mod linklist;
34pub mod r#loop;
35pub mod math;
36pub mod mem;
37pub mod modentry;
38pub mod module;
39pub mod modules;
40pub mod openssh_bsd_setres_id;
41pub mod options;
42pub mod params;
43pub mod pattern;
44pub mod prompt;
45pub mod signals;
46pub mod sort;
47pub mod string;
48pub mod subst;
49pub mod text;
50pub mod utils;
51
52pub mod builtin;
53pub mod builtins;
54pub mod zle;
55pub mod zsh_h;
56pub mod zsh_system_h;
57pub mod ztype_h;
58mod prototypes_h;
59pub mod patchlevel;
60pub mod signals_h;
61pub mod config_h;
62pub mod lex;
63pub mod parse;
64
65#[cfg(test)]
66mod tests {
67    use super::*;
68
69    /// The crate's `META` byte (0x83) is the metacharacter sentinel
70    /// embedded in every metafied buffer. Three independent modules
71    /// re-declare it (input.rs:472, utils.rs:4747, zsh_h.rs); the
72    /// invariant is that the THREE constants are EQUAL. If anything
73    /// drifts, lex/quote/unmeta semantics fracture across the codebase.
74    #[test]
75    fn meta_sentinel_consistent_across_modules() {
76        assert_eq!(input::META as u8, zsh_h::META as u8);
77        assert_eq!(utils::Meta,        zsh_h::META as u8);
78        assert_eq!(input::META as u8, 0x83);
79    }
80}