use std::sync::atomic::AtomicI32;
use std::sync::atomic::Ordering;
#[inline]
#[allow(non_snake_case)]
pub fn minimum<T: PartialOrd>(a: T, b: T) -> T {
if a < b {
a
} else {
b
}
}
#[allow(non_camel_case_types)]
pub type zlong = i64;
#[allow(non_camel_case_types)]
pub type zulong = u64;
pub const ZLONG_MAX: zlong = i64::MAX;
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy)] pub struct mnumber {
pub l: i64, pub d: f64, pub type_: u32, }
pub const MN_INTEGER: u32 = 1; pub const MN_FLOAT: u32 = 2; pub const MN_UNSET: u32 = 4;
pub type MathFunc = Box<mathfunc>;
pub type NumMathFunc = fn(name: &str, argc: i32, argv: &[mnumber], id: i32) -> mnumber;
pub type StrMathFunc = fn(name: &str, arg: &str, id: i32) -> mnumber;
#[allow(non_camel_case_types)]
pub struct mathfunc {
pub next: Option<Box<mathfunc>>, pub name: String, pub flags: i32, pub nfunc: Option<NumMathFunc>, pub sfunc: Option<StrMathFunc>, pub module: Option<String>, pub minargs: i32, pub maxargs: i32, pub funcid: i32, }
pub const MFF_STR: i32 = 1; pub const MFF_ADDED: i32 = 2; pub const MFF_USERFUNC: i32 = 4; pub const MFF_AUTOALL: i32 = 8;
pub const META: char = '\u{83}'; pub const DEFAULT_IFS: &str = " \t\n\u{83} "; pub const DEFAULT_IFS_SH: &str = " \t\n";
#[allow(non_upper_case_globals)] pub const Pound: char = '\u{84}'; pub const Stringg: char = '\u{85}'; #[allow(non_upper_case_globals)] pub const Hat: char = '\u{86}'; #[allow(non_upper_case_globals)] pub const Star: char = '\u{87}'; #[allow(non_upper_case_globals)] pub const Inpar: char = '\u{88}'; #[allow(non_upper_case_globals)] pub const Inparmath: char = '\u{89}'; #[allow(non_upper_case_globals)] pub const Outpar: char = '\u{8a}'; #[allow(non_upper_case_globals)] pub const Outparmath: char = '\u{8b}'; #[allow(non_upper_case_globals)] pub const Qstring: char = '\u{8c}'; #[allow(non_upper_case_globals)] pub const Equals: char = '\u{8d}'; #[allow(non_upper_case_globals)] pub const Bar: char = '\u{8e}'; #[allow(non_upper_case_globals)] pub const Inbrace: char = '\u{8f}'; #[allow(non_upper_case_globals)] pub const Outbrace: char = '\u{90}'; #[allow(non_upper_case_globals)] pub const Inbrack: char = '\u{91}'; #[allow(non_upper_case_globals)] pub const Outbrack: char = '\u{92}'; #[allow(non_upper_case_globals)] pub const Tick: char = '\u{93}'; #[allow(non_upper_case_globals)] pub const Inang: char = '\u{94}'; #[allow(non_upper_case_globals)] pub const Outang: char = '\u{95}'; #[allow(non_upper_case_globals)] pub const OutangProc: char = '\u{96}'; #[allow(non_upper_case_globals)] pub const Quest: char = '\u{97}'; #[allow(non_upper_case_globals)] pub const Tilde: char = '\u{98}'; #[allow(non_upper_case_globals)] pub const Qtick: char = '\u{99}'; #[allow(non_upper_case_globals)] pub const Comma: char = '\u{9a}'; #[allow(non_upper_case_globals)] pub const Dash: char = '\u{9b}'; #[allow(non_upper_case_globals)] pub const Bang: char = '\u{9c}'; pub const LAST_NORMAL_TOK: char = Bang;
#[allow(non_upper_case_globals)] pub const Snull: char = '\u{9d}'; #[allow(non_upper_case_globals)] pub const Dnull: char = '\u{9e}'; #[allow(non_upper_case_globals)] pub const Bnull: char = '\u{9f}'; #[allow(non_upper_case_globals)] pub const Bnullkeep: char = '\u{a0}'; #[allow(non_upper_case_globals)] pub const Nularg: char = '\u{a1}'; #[allow(non_upper_case_globals)] pub const Marker: char = '\u{a2}';
pub const SPECCHARS: &str = "#$^*()=|{}[]`<>?~;&\n\t \\\'\""; pub const PATCHARS: &str = "#^*()|[]<>?~\\";
#[inline]
#[allow(non_snake_case)]
pub fn IS_DASH(x: char) -> bool {
x == '-' || x == Dash
}
pub const QT_NONE: i32 = 0; pub const QT_BACKSLASH: i32 = 1; pub const QT_SINGLE: i32 = 2; pub const QT_DOUBLE: i32 = 3; pub const QT_DOLLARS: i32 = 4; pub const QT_BACKTICK: i32 = 5; pub const QT_SINGLE_OPTIONAL: i32 = 6; pub const QT_BACKSLASH_PATTERN: i32 = 7; pub const QT_BACKSLASH_SHOWNULL: i32 = 8; pub const QT_QUOTEDZPUTS: i32 = 9;
#[inline]
#[allow(non_snake_case)]
pub fn QT_IS_SINGLE(x: i32) -> bool {
x == QT_SINGLE || x == QT_SINGLE_OPTIONAL
}
#[allow(non_camel_case_types)]
pub type lextok = i32;
pub const NULLTOK: lextok = 0; pub const SEPER: lextok = 1;
pub const NEWLIN: lextok = 2;
pub const SEMI: lextok = 3;
pub const DSEMI: lextok = 4;
pub const AMPER: lextok = 5;
pub const INPAR_TOK: lextok = 6; pub const OUTPAR_TOK: lextok = 7;
pub const DBAR: lextok = 8;
pub const DAMPER: lextok = 9;
pub const OUTANG_TOK: lextok = 10; pub const OUTANGBANG: lextok = 11;
pub const DOUTANG: lextok = 12;
pub const DOUTANGBANG: lextok = 13;
pub const INANG_TOK: lextok = 14;
pub const INOUTANG: lextok = 15;
pub const DINANG: lextok = 16;
pub const DINANGDASH: lextok = 17;
pub const INANGAMP: lextok = 18;
pub const OUTANGAMP: lextok = 19;
pub const AMPOUTANG: lextok = 20;
pub const OUTANGAMPBANG: lextok = 21;
pub const DOUTANGAMP: lextok = 22;
pub const DOUTANGAMPBANG: lextok = 23;
pub const TRINANG: lextok = 24;
pub const BAR_TOK: lextok = 25;
pub const BARAMP: lextok = 26;
pub const INOUTPAR: lextok = 27;
pub const DINPAR: lextok = 28;
pub const DOUTPAR: lextok = 29;
pub const AMPERBANG: lextok = 30;
pub const SEMIAMP: lextok = 31;
pub const SEMIBAR: lextok = 32;
pub const DOUTBRACK: lextok = 33;
pub const STRING_LEX: lextok = 34;
pub const ENVSTRING: lextok = 35;
pub const ENVARRAY: lextok = 36;
pub const ENDINPUT: lextok = 37;
pub const LEXERR: lextok = 38;
pub const BANG_TOK: lextok = 39; pub const DINBRACK: lextok = 40;
pub const INBRACE_TOK: lextok = 41;
pub const OUTBRACE_TOK: lextok = 42;
pub const CASE: lextok = 43;
pub const COPROC: lextok = 44;
pub const DOLOOP: lextok = 45;
pub const DONE: lextok = 46;
pub const ELIF: lextok = 47;
pub const ELSE: lextok = 48;
pub const ZEND: lextok = 49;
pub const ESAC: lextok = 50;
pub const FI: lextok = 51;
pub const FOR: lextok = 52;
pub const FOREACH: lextok = 53;
pub const FUNC: lextok = 54;
pub const IF: lextok = 55;
pub const NOCORRECT: lextok = 56;
pub const REPEAT: lextok = 57;
pub const SELECT: lextok = 58;
pub const THEN: lextok = 59;
pub const TIME: lextok = 60;
pub const UNTIL: lextok = 61;
pub const WHILE: lextok = 62;
pub const TYPESET: lextok = 63;
pub const REDIR_WRITE: i32 = 0;
pub const REDIR_WRITENOW: i32 = 1;
pub const REDIR_APP: i32 = 2;
pub const REDIR_APPNOW: i32 = 3;
pub const REDIR_ERRWRITE: i32 = 4;
pub const REDIR_ERRWRITENOW: i32 = 5;
pub const REDIR_ERRAPP: i32 = 6;
pub const REDIR_ERRAPPNOW: i32 = 7;
pub const REDIR_READWRITE: i32 = 8;
pub const REDIR_READ: i32 = 9;
pub const REDIR_HEREDOC: i32 = 10;
pub const REDIR_HEREDOCDASH: i32 = 11;
pub const REDIR_HERESTR: i32 = 12;
pub const REDIR_MERGEIN: i32 = 13;
pub const REDIR_MERGEOUT: i32 = 14;
pub const REDIR_CLOSE: i32 = 15;
pub const REDIR_INPIPE: i32 = 16;
pub const REDIR_OUTPIPE: i32 = 17;
pub const REDIR_TYPE_MASK: i32 = 0x1f; pub const REDIR_VARID_MASK: i32 = 0x20; pub const REDIR_FROM_HEREDOC_MASK: i32 = 0x40;
#[inline]
#[allow(non_snake_case)]
pub fn IS_WRITE_FILE(x: i32) -> bool {
x >= REDIR_WRITE && x <= REDIR_READWRITE
}
#[inline]
#[allow(non_snake_case)]
pub fn IS_APPEND_REDIR(x: i32) -> bool {
IS_WRITE_FILE(x) && (x & 2) != 0
}
#[inline]
#[allow(non_snake_case)]
pub fn IS_CLOBBER_REDIR(x: i32) -> bool {
IS_WRITE_FILE(x) && (x & 1) != 0
}
#[inline]
#[allow(non_snake_case)]
pub fn IS_ERROR_REDIR(x: i32) -> bool {
x >= REDIR_ERRWRITE && x <= REDIR_ERRAPPNOW
}
#[inline]
#[allow(non_snake_case)]
pub fn IS_READFD(x: i32) -> bool {
(x >= REDIR_READWRITE && x <= REDIR_MERGEIN) || x == REDIR_INPIPE
}
#[inline]
#[allow(non_snake_case)]
pub fn IS_REDIROP(x: lextok) -> bool {
x >= OUTANG_TOK && x <= TRINANG
}
pub const FDT_UNUSED: i32 = 0; pub const FDT_INTERNAL: i32 = 1; pub const FDT_EXTERNAL: i32 = 2; pub const FDT_MODULE: i32 = 3; pub const FDT_XTRACE: i32 = 4; pub const FDT_FLOCK: i32 = 5; pub const FDT_FLOCK_EXEC: i32 = 6; pub const FDT_PROC_SUBST: i32 = 7; pub const FDT_TYPE_MASK: i32 = 15; pub const FDT_SAVED_MASK: i32 = 16;
pub const INP_FREE: i32 = 1 << 0; pub const INP_ALIAS: i32 = 1 << 1; pub const INP_HIST: i32 = 1 << 2; pub const INP_CONT: i32 = 1 << 3; pub const INP_ALCONT: i32 = 1 << 4; pub const INP_HISTCONT: i32 = 1 << 5; pub const INP_LINENO: i32 = 1 << 6; pub const INP_APPEND: i32 = 1 << 7; pub const INP_RAW_KEEP: i32 = 1 << 8;
pub const META_REALLOC: i32 = 0; pub const META_USEHEAP: i32 = 1;
pub const META_STATIC: i32 = 2;
pub const META_DUP: i32 = 3;
pub const META_ALLOC: i32 = 4;
pub const META_NOALLOC: i32 = 5;
pub const META_HEAPDUP: i32 = 6;
pub const META_HREALLOC: i32 = 7;
pub const ZCONTEXT_HIST: i32 = 1 << 0; pub const ZCONTEXT_LEX: i32 = 1 << 1; pub const ZCONTEXT_PARSE: i32 = 1 << 2;
#[derive(Default)]
#[allow(non_camel_case_types)]
pub struct entersubsh_ret {
pub gleader: i32, pub list_pipe_job: i32, }
#[allow(non_camel_case_types)]
pub struct linknode {
pub next: Option<Box<linknode>>,
pub prev: Option<Box<linknode>>,
pub dat: usize,
}
#[allow(non_camel_case_types)]
pub struct linklist {
pub first: Option<Box<linknode>>,
pub last: Option<Box<linknode>>,
pub flags: i32,
}
pub type LinkNode = Box<linknode>; pub type LinkList = Box<linklist>;
pub type Alias = Box<alias>; pub type Asgment = Box<asgment>; pub type Builtin = Box<builtin>; pub type Cmdnam = Box<cmdnam>; pub type Complist = Box<crate::ported::glob::complist>; pub type Conddef = Box<conddef>; pub type Dirsav = Box<dirsav>; pub type Emulation_options = Box<emulation_options>; pub type Execcmd_params = Box<execcmd_params>; pub type Features = Box<features>; pub type Feature_enables = Box<feature_enables>; pub type Funcstack = Box<funcstack>; pub type FuncWrap = Box<funcwrap>; pub type HashNode = Box<hashnode>; pub type HashTable = Box<hashtable>; pub type Heap = Box<heap>; pub type Heapstack = Box<heapstack>; pub type Histent = Box<histent>; pub type Hookdef = Box<hookdef>; pub type Imatchdata = Box<imatchdata>; pub type Job = Box<job>; pub type Jobfile = Box<jobfile>; pub type Linkedmod = Box<linkedmod>; pub type Module = Box<module>; pub type Nameddir = Box<nameddir>; pub type Options = Box<options>; pub type Optname = Box<optname>; pub type Param = Box<param>; pub type Paramdef = Box<paramdef>; pub type Patstralloc = Box<patstralloc>; pub type Patprog = Box<patprog>; pub type Prepromptfn = Box<prepromptfn>; pub type Process = Box<process>; pub type Redir = Box<redir>; pub type Reswd = Box<reswd>; pub type Shfunc = Box<shfunc>; pub type Timedfn = Box<timedfn>; pub type Value = Box<value>;
pub type voidvoidfnptr_t = fn();
#[allow(non_camel_case_types)]
pub struct prepromptfn {
pub func: voidvoidfnptr_t,
}
#[allow(non_camel_case_types)]
pub struct timedfn {
pub func: voidvoidfnptr_t,
pub when: i64, }
pub type CondHandler = fn(args: &[String], id: i32) -> i32;
#[allow(non_camel_case_types)]
pub struct conddef {
pub next: Option<Conddef>, pub name: String, pub flags: i32, pub handler: Option<CondHandler>, pub min: i32, pub max: i32, pub condid: i32, pub module: Option<String>, }
#[allow(non_camel_case_types)]
pub struct dirsav {
pub dirfd: i32, pub level: i32, pub dirname: Option<String>, pub dev: u64, pub ino: u64, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub struct hashnode {
pub next: Option<HashNode>, pub nam: String, pub flags: i32, }
pub type VFunc = fn(usize) -> usize; pub type FreeFunc = fn(usize); pub type HashFunc = fn(name: &str) -> u32; pub type TableFunc = fn(table: &mut hashtable); pub type AddNodeFunc = fn(table: &mut hashtable, name: String, val: usize);
pub type GetNodeFunc = fn(table: &hashtable, name: &str) -> Option<HashNode>;
pub type RemoveNodeFunc = fn(table: &mut hashtable, name: &str) -> Option<HashNode>;
pub type FreeNodeFunc = fn(node: HashNode);
pub type CompareFunc = fn(a: &str, b: &str) -> i32;
pub type ScanFunc = fn(node: &HashNode, flags: i32);
pub type ScanTabFunc = fn(table: &hashtable, func: ScanFunc, flags: i32);
pub type PrintTableStats = fn(table: &hashtable);
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct hashtable {
pub hsize: i32, pub ct: i32, pub nodes: Vec<Option<HashNode>>, pub tmpdata: usize, pub hash: Option<HashFunc>, pub emptytable: Option<TableFunc>, pub filltable: Option<TableFunc>, pub cmpnodes: Option<CompareFunc>, pub addnode: Option<AddNodeFunc>, pub getnode: Option<GetNodeFunc>, pub getnode2: Option<GetNodeFunc>, pub removenode: Option<RemoveNodeFunc>, pub disablenode: Option<ScanFunc>, pub enablenode: Option<ScanFunc>, pub freenode: Option<FreeNodeFunc>, pub printnode: Option<ScanFunc>, pub scantab: Option<ScanTabFunc>, }
#[allow(non_camel_case_types)]
pub struct optname {
pub node: hashnode, pub optno: i32, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub struct reswd {
pub node: hashnode, pub token: i32, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub struct alias {
pub node: hashnode, pub text: String, pub inuse: i32, }
#[allow(non_camel_case_types)]
pub struct asgment {
pub node: linknode, pub name: String, pub flags: i32, pub scalar: Option<String>, pub array: Option<crate::ported::linklist::LinkList<String>>, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub struct cmdnam {
pub node: hashnode, pub name: Option<Vec<String>>, pub cmd: Option<String>, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub struct shfunc {
pub node: hashnode, pub filename: Option<String>, pub lineno: i64, pub funcdef: Option<Eprog>, pub redir: Option<Eprog>, pub sticky: Option<Emulation_options>, pub body: Option<String>,
}
#[allow(non_camel_case_types)]
#[derive(Clone, Default)]
pub struct funcstack {
pub prev: Option<Funcstack>, pub name: String, pub filename: Option<String>, pub caller: Option<String>, pub flineno: i64, pub lineno: i64, pub tp: i32, }
pub type WrapFunc = fn(prog: Eprog, w: FuncWrap, name: &str) -> i32;
#[allow(non_camel_case_types)]
pub struct funcwrap {
pub next: Option<FuncWrap>, pub flags: i32, pub handler: Option<WrapFunc>, pub module: Option<Module>, }
#[allow(non_camel_case_types)]
pub struct builtin {
pub node: hashnode, pub handlerfunc: Option<HandlerFunc>, pub minargs: i32, pub maxargs: i32, pub funcid: i32, pub optstr: Option<String>, pub defopts: Option<String>, }
#[allow(non_camel_case_types)]
pub struct execcmd_params {
pub args: Option<LinkList>, pub redir: Option<LinkList>, pub beg: Wordcode, pub varspc: Wordcode, pub assignspc: Wordcode, pub typ: i32, pub postassigns: i32, pub htok: i32, }
#[allow(non_camel_case_types)]
#[derive(Debug)]
pub struct module {
pub node: hashnode, pub handle: Option<usize>, pub linked: Option<Linkedmod>, pub alias: Option<String>, pub autoloads: Option<crate::ported::linklist::LinkList<String>>, pub deps: Option<crate::ported::linklist::LinkList<String>>, pub wrapper: i32, }
impl module {
pub fn new(name: &str) -> Self {
Self {
node: hashnode {
next: None,
nam: name.to_string(),
flags: MOD_LINKED,
},
handle: None,
linked: None,
alias: None,
autoloads: None,
deps: None,
wrapper: 0,
}
}
pub fn is_loaded(&self) -> bool {
(self.node.flags & MOD_LINKED) != 0
&& (self.node.flags & MOD_UNLOAD) == 0
}
}
pub type Module_generic_func = fn() -> i32;
pub type Module_void_func = fn(m: &module) -> i32;
pub type Module_features_func = fn(m: &module, features: &mut Vec<String>) -> i32;
pub type Module_enables_func = fn(m: &module, enables: &mut Vec<i32>) -> i32;
#[allow(non_camel_case_types)]
#[derive(Debug)]
pub struct linkedmod {
pub name: String, pub setup: Option<Module_void_func>, pub features: Option<Module_features_func>, pub enables: Option<Module_enables_func>, pub boot: Option<Module_void_func>, pub cleanup: Option<Module_void_func>, pub finish: Option<Module_void_func>, }
#[allow(non_camel_case_types)]
pub struct features {
pub bn_list: Option<Builtin>, pub bn_size: i32, pub cd_list: Option<Conddef>, pub cd_size: i32, pub mf_list: Option<MathFunc>, pub mf_size: i32, pub pd_list: Option<Paramdef>, pub pd_size: i32, pub n_abstract: i32, }
#[allow(non_camel_case_types)]
pub struct feature_enables {
pub str: String, pub pat: Option<Patprog>, }
pub type Hookfn = fn(def: Hookdef, data: usize) -> i32;
#[allow(non_camel_case_types)]
pub struct hookdef {
pub next: Option<Hookdef>, pub name: String, pub def: Option<Hookfn>, pub flags: i32, pub funcs: Option<LinkList>, }
#[derive(Debug, Clone)]
#[allow(non_camel_case_types)]
pub struct patprog {
pub startoff: i64, pub size: i64, pub mustoff: i64, pub patmlen: i64, pub globflags: i32, pub globend: i32, pub flags: i32, pub patnpar: i32, pub patstartch: u8, }
#[allow(non_camel_case_types)]
pub struct patstralloc {
pub unmetalen: i32, pub unmetalenp: i32, pub alloced: Option<String>, pub progstrunmeta: Option<String>, pub progstrunmetalen: i32, }
#[allow(non_camel_case_types)]
pub struct zpc_disables_save {
pub next: Option<Box<zpc_disables_save>>, pub disables: u32, }
pub type Zpc_disables_save = Box<zpc_disables_save>;
#[allow(non_camel_case_types)]
pub struct imatchdata {
pub mstr: Option<String>, pub mlen: i32, pub ustr: Option<String>, pub ulen: i32, pub flags: i32, pub replstr: Option<String>, pub repllist: Option<LinkList>, }
pub type GsuScalar = Box<gsu_scalar>; pub type GsuInteger = Box<gsu_integer>; pub type GsuFloat = Box<gsu_float>; pub type GsuArray = Box<gsu_array>; pub type GsuHash = Box<gsu_hash>;
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct gsu_scalar {
pub getfn: fn(pm: ¶m) -> String, pub setfn: fn(pm: &mut param, val: String), pub unsetfn: fn(pm: &mut param, exp: i32), }
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct gsu_integer {
pub getfn: fn(pm: ¶m) -> i64,
pub setfn: fn(pm: &mut param, val: i64),
pub unsetfn: fn(pm: &mut param, exp: i32),
}
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct gsu_float {
pub getfn: fn(pm: ¶m) -> f64,
pub setfn: fn(pm: &mut param, val: f64),
pub unsetfn: fn(pm: &mut param, exp: i32),
}
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct gsu_array {
pub getfn: fn(pm: ¶m) -> Vec<String>,
pub setfn: fn(pm: &mut param, val: Vec<String>),
pub unsetfn: fn(pm: &mut param, exp: i32),
}
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct gsu_hash {
pub getfn: fn(pm: ¶m) -> Option<&HashTable>,
pub setfn: fn(pm: &mut param, val: HashTable),
pub unsetfn: fn(pm: &mut param, exp: i32),
}
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct param {
pub node: hashnode, pub u_data: usize, pub u_arr: Option<Vec<String>>, pub u_str: Option<String>, pub u_val: i64, pub u_dval: f64, pub u_hash: Option<HashTable>, pub gsu_s: Option<GsuScalar>, pub gsu_i: Option<GsuInteger>, pub gsu_f: Option<GsuFloat>, pub gsu_a: Option<GsuArray>, pub gsu_h: Option<GsuHash>, pub base: i32, pub width: i32, pub env: Option<String>, pub ename: Option<String>, pub old: Option<Param>, pub level: i32, }
#[allow(non_camel_case_types)]
pub struct tieddata {
pub arrptr: Option<Vec<String>>, pub joinchar: i32, }
#[allow(non_camel_case_types)]
pub struct repldata {
pub b: i32, pub e: i32, pub replstr: Option<String>, }
pub type Repldata = Box<repldata>;
#[allow(non_camel_case_types)]
pub struct paramdef {
pub name: String, pub flags: i32, pub var: usize, pub gsu: usize, pub getnfn: Option<GetNodeFunc>, pub scantfn: Option<ScanTabFunc>, pub pm: Option<Param>, }
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct nameddir {
pub node: hashnode, pub dir: String, pub diff: i32, }
#[allow(non_camel_case_types)]
pub struct groupmap {
pub name: String, pub gid: u32, }
pub type Groupmap = Box<groupmap>;
#[allow(non_camel_case_types)]
pub struct groupset {
pub array: Vec<groupmap>, pub num: i32, }
pub type Groupset = Box<groupset>;
#[allow(non_camel_case_types)]
pub struct histent {
pub node: hashnode, pub up: Option<Histent>, pub down: Option<Histent>, pub zle_text: Option<String>, pub stim: i64, pub ftim: i64, pub words: Vec<i16>, pub nwords: i32, pub histnum: i64, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub struct emulation_options {
pub emulation: i32, pub n_on_opts: i32, pub n_off_opts: i32, pub on_opts: Vec<OptIndex>, pub off_opts: Vec<OptIndex>, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub struct ttyinfo {
#[cfg(unix)]
pub tio: libc::termios, #[cfg(unix)]
pub winsize: libc::winsize, }
#[allow(non_camel_case_types)]
pub struct heapstack {
pub next: Option<Heapstack>, pub used: usize, }
#[allow(non_camel_case_types)]
pub struct heap {
pub next: Option<Heap>, pub size: usize, pub used: usize, pub sp: Option<Heapstack>, }
#[allow(non_camel_case_types)]
pub struct sortelt {
pub orig: String, pub cmp: String, pub origlen: i32, pub len: i32, }
pub type SortElt = Box<sortelt>;
#[allow(non_camel_case_types)]
pub struct hist_stack {
pub histactive: i32, pub histdone: i32, pub stophist: i32, pub hlinesz: i32, pub defev: i64, pub hline: Option<String>, pub hptr: Option<String>, pub chwords: Vec<i16>, pub chwordlen: i32, pub chwordpos: i32, pub csp: i32, pub hist_keep_comment: i32, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Default)]
pub struct lexbufstate {
pub ptr: Option<String>, pub siz: i32, pub len: i32, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Default)]
pub struct lex_stack {
pub dbparens: i32, pub isfirstln: i32, pub isfirstch: i32, pub lexflags: i32, pub tok: lextok, pub tokstr: Option<String>, pub zshlextext: Option<String>, pub lexbuf: lexbufstate, pub lex_add_raw: i32, pub tokstr_raw: Option<String>, pub lexbuf_raw: lexbufstate, pub lexstop: i32, pub toklineno: i64, }
#[allow(non_camel_case_types)]
pub struct parse_stack {
pub hdocs: Option<Box<heredocs>>, pub incmdpos: i32, pub aliasspaceflag: i32, pub incond: i32, pub inredir: i32, pub incasepat: i32, pub isnewlin: i32, pub infor: i32, pub inrepeat_: i32, pub intypeset: i32, pub eclen: i32, pub ecused: i32, pub ecnpats: i32, pub ecbuf: Wordcode, pub ecstrs: Option<Eccstr>, pub ecsoffs: i32, pub ecssub: i32, pub ecnfunc: i32, }
#[allow(non_camel_case_types)]
pub struct heredocs {
pub next: Option<Box<heredocs>>, pub typ: i32, pub pc: i32, pub str: Option<String>, }
#[allow(non_camel_case_types)]
pub struct execstack {
pub next: Option<Box<execstack>>, pub list_pipe_pid: i32, pub nowait: i32, pub pline_level: i32, pub list_pipe_child: i32, pub list_pipe_job: i32, pub list_pipe_text: [u8; JOBTEXTSIZE], pub lastval: i32, pub noeval: i32, pub badcshglob: i32, pub cmdoutpid: i32, pub cmdoutval: i32, pub use_cmdoutval: i32, pub procsubstpid: i32, pub trap_return: i32, pub trap_state: i32, pub trapisfunc: i32, pub traplocallevel: i32, pub noerrs: i32, pub this_noerrexit: i32, pub underscore: Option<String>, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub struct process {
pub pid: i32, pub text: String, pub status: i32, pub ti: crate::ported::zsh_h::timeinfo, pub bgtime: Option<std::time::Instant>, pub endtime: Option<std::time::Instant>, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Default)]
pub struct job {
pub gleader: i32, pub other: i32, pub stat: i32, pub pwd: Option<String>, pub procs: Vec<process>, pub auxprocs: Vec<process>, pub filelist: Vec<String>, pub stty_in_env: i32, pub ty: Option<Box<ttyinfo>>, pub text: String,
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub struct funcdump {
pub next: Option<FuncDump>, pub dev: u64, pub ino: u64, pub fd: i32, pub map: Wordcode, pub addr: Wordcode, pub len: i32, pub count: i32, pub filename: Option<String>, }
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Default)]
pub struct eprog {
pub flags: i32, pub len: i32, pub npats: i32, pub nref: i32, pub pats: Vec<Patprog>, pub prog: Wordcode, pub strs: Option<String>, pub shf: Option<Shfunc>, pub dump: Option<FuncDump>, }
#[allow(non_camel_case_types)]
pub struct estate {
pub prog: Eprog, pub pc: usize, pub strs: Option<String>, pub strs_offset: usize, }
#[allow(non_camel_case_types)]
pub struct eccstr {
pub left: Option<Eccstr>, pub right: Option<Eccstr>, pub str: Option<String>, pub offs: wordcode, pub aoffs: wordcode, pub nfunc: i32, pub hashval: u32, }
pub const Z_TIMED: i32 = 1 << 0; pub const Z_SYNC: i32 = 1 << 1; pub const Z_ASYNC: i32 = 1 << 2; pub const Z_DISOWN: i32 = 1 << 3;
pub const COND_NOT: i32 = 0;
pub const COND_AND: i32 = 1;
pub const COND_OR: i32 = 2;
pub const COND_STREQ: i32 = 3;
pub const COND_STRDEQ: i32 = 4;
pub const COND_STRNEQ: i32 = 5;
pub const COND_STRLT: i32 = 6;
pub const COND_STRGTR: i32 = 7;
pub const COND_NT: i32 = 8;
pub const COND_OT: i32 = 9;
pub const COND_EF: i32 = 10;
pub const COND_EQ: i32 = 11;
pub const COND_NE: i32 = 12;
pub const COND_LT: i32 = 13;
pub const COND_GT: i32 = 14;
pub const COND_LE: i32 = 15;
pub const COND_GE: i32 = 16;
pub const COND_REGEX: i32 = 17;
pub const COND_MOD: i32 = 18;
pub const COND_MODI: i32 = 19;
pub const CONDF_INFIX: i32 = 1; pub const CONDF_ADDED: i32 = 2; pub const CONDF_AUTOALL: i32 = 4;
pub const REDIRF_FROM_HEREDOC: i32 = 1;
#[allow(non_camel_case_types)]
pub struct redir {
pub typ: i32,
pub flags: i32,
pub fd1: i32,
pub fd2: i32,
pub name: Option<String>,
pub varid: Option<String>,
pub here_terminator: Option<String>,
pub munged_here_terminator: Option<String>,
}
pub const MULTIOUNIT: usize = 8;
#[allow(non_camel_case_types)]
pub struct multio {
pub ct: i32,
pub rflag: i32,
pub pipe: i32,
pub fds: [i32; MULTIOUNIT],
}
#[allow(non_camel_case_types)]
pub struct value {
pub pm: Option<Param>,
pub arr: Vec<String>,
pub scanflags: i32,
pub valflags: i32,
pub start: i32,
pub end: i32,
}
pub const VALFLAG_INV: i32 = 0x0001; pub const VALFLAG_EMPTY: i32 = 0x0002;
pub const VALFLAG_SUBST: i32 = 0x0004;
pub const VALFLAG_REFSLICE: i32 = 0x0008;
pub const MAX_ARRLEN: i32 = 262144;
#[allow(non_camel_case_types)]
pub type wordcode = u32; pub type Wordcode = Vec<wordcode>;
pub type FuncDump = Box<funcdump>; pub type Eprog = Box<eprog>;
pub const EF_REAL: i32 = 1; pub const EF_HEAP: i32 = 2;
pub const EF_MAP: i32 = 4;
pub const EF_RUN: i32 = 8;
pub type Estate = Box<estate>; pub type Eccstr = Box<eccstr>;
pub const EC_NODUP: i32 = 0; pub const EC_DUP: i32 = 1; pub const EC_DUPTOK: i32 = 2;
pub const WC_CODEBITS: u32 = 5; #[inline]
#[allow(non_snake_case)]
pub fn wc_code(c: wordcode) -> wordcode {
c & ((1 << WC_CODEBITS) - 1)
}
#[inline]
#[allow(non_snake_case)]
pub fn wc_data(c: wordcode) -> wordcode {
c >> WC_CODEBITS
}
#[inline]
#[allow(non_snake_case)]
pub fn wc_bdata(d: wordcode) -> wordcode {
d << WC_CODEBITS
}
#[inline]
#[allow(non_snake_case)]
pub fn wc_bld(c: wordcode, d: wordcode) -> wordcode {
c | (d << WC_CODEBITS)
}
pub const WC_END: wordcode = 0;
pub const WC_LIST: wordcode = 1;
pub const WC_SUBLIST: wordcode = 2;
pub const WC_PIPE: wordcode = 3;
pub const WC_REDIR: wordcode = 4;
pub const WC_ASSIGN: wordcode = 5;
pub const WC_SIMPLE: wordcode = 6;
pub const WC_TYPESET: wordcode = 7;
pub const WC_SUBSH: wordcode = 8;
pub const WC_CURSH: wordcode = 9;
pub const WC_TIMED: wordcode = 10;
pub const WC_FUNCDEF: wordcode = 11;
pub const WC_FOR: wordcode = 12;
pub const WC_SELECT: wordcode = 13;
pub const WC_WHILE: wordcode = 14;
pub const WC_REPEAT: wordcode = 15;
pub const WC_CASE: wordcode = 16;
pub const WC_IF: wordcode = 17;
pub const WC_COND: wordcode = 18;
pub const WC_ARITH: wordcode = 19;
pub const WC_AUTOFN: wordcode = 20;
pub const WC_TRY: wordcode = 21;
pub const WC_COUNT: wordcode = 22;
pub const Z_END: i32 = 1 << 4; pub const Z_SIMPLE: i32 = 1 << 5; pub const WC_LIST_FREE: u32 = 6;
pub const WC_SUBLIST_END: wordcode = 0;
pub const WC_SUBLIST_AND: wordcode = 1;
pub const WC_SUBLIST_OR: wordcode = 2;
pub const WC_SUBLIST_COPROC: wordcode = 4;
pub const WC_SUBLIST_NOT: wordcode = 8;
pub const WC_SUBLIST_SIMPLE: wordcode = 16;
pub const WC_SUBLIST_FREE: u32 = 5;
pub const WC_PIPE_END: wordcode = 0;
pub const WC_PIPE_MID: wordcode = 1;
pub const WC_ASSIGN_SCALAR: wordcode = 0;
pub const WC_ASSIGN_ARRAY: wordcode = 1;
pub const WC_ASSIGN_NEW: wordcode = 0;
pub const WC_ASSIGN_INC: wordcode = 1;
pub const WC_TIMED_EMPTY: wordcode = 0;
pub const WC_TIMED_PIPE: wordcode = 1;
pub const WC_FOR_PPARAM: wordcode = 0;
pub const WC_FOR_LIST: wordcode = 1;
pub const WC_FOR_COND: wordcode = 2;
pub const WC_SELECT_PPARAM: wordcode = 0;
pub const WC_SELECT_LIST: wordcode = 1;
pub const WC_WHILE_WHILE: wordcode = 0;
pub const WC_WHILE_UNTIL: wordcode = 1;
pub const WC_CASE_HEAD: wordcode = 0;
pub const WC_CASE_OR: wordcode = 1;
pub const WC_CASE_AND: wordcode = 2;
pub const WC_CASE_TESTAND: wordcode = 3;
pub const WC_CASE_FREE: u32 = 3;
pub const WC_IF_HEAD: wordcode = 0;
pub const WC_IF_IF: wordcode = 1;
pub const WC_IF_ELIF: wordcode = 2;
pub const WC_IF_ELSE: wordcode = 3;
#[inline]
#[allow(non_snake_case)]
pub fn WCB_END() -> wordcode {
wc_bld(WC_END, 0)
} #[inline]
#[allow(non_snake_case)]
pub fn WC_LIST_TYPE(c: wordcode) -> wordcode {
wc_data(c)
} #[inline]
#[allow(non_snake_case)]
pub fn WC_LIST_SKIP(c: wordcode) -> wordcode {
wc_data(c) >> WC_LIST_FREE
} #[inline]
#[allow(non_snake_case)]
pub fn WCB_LIST(t: wordcode, o: wordcode) -> wordcode {
wc_bld(WC_LIST, t | (o << WC_LIST_FREE))
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_SUBLIST_TYPE(c: wordcode) -> wordcode {
wc_data(c) & 3
} #[inline]
#[allow(non_snake_case)]
pub fn WC_SUBLIST_FLAGS(c: wordcode) -> wordcode {
wc_data(c) & 0x1c
} #[inline]
#[allow(non_snake_case)]
pub fn WC_SUBLIST_SKIP(c: wordcode) -> wordcode {
wc_data(c) >> WC_SUBLIST_FREE
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_SUBLIST(t: wordcode, f: wordcode, o: wordcode) -> wordcode {
wc_bld(WC_SUBLIST, t | f | (o << WC_SUBLIST_FREE))
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_PIPE_TYPE(c: wordcode) -> wordcode {
wc_data(c) & 1
} #[inline]
#[allow(non_snake_case)]
pub fn WC_PIPE_LINENO(c: wordcode) -> wordcode {
wc_data(c) >> 1
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_PIPE(t: wordcode, l: wordcode) -> wordcode {
wc_bld(WC_PIPE, t | (l << 1))
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_REDIR_TYPE(c: wordcode) -> i32 {
(wc_data(c) & REDIR_TYPE_MASK as u32) as i32
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_REDIR_VARID(c: wordcode) -> i32 {
(wc_data(c) & REDIR_VARID_MASK as u32) as i32
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_REDIR_FROM_HEREDOC(c: wordcode) -> i32 {
(wc_data(c) & REDIR_FROM_HEREDOC_MASK as u32) as i32
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_REDIR(t: wordcode) -> wordcode {
wc_bld(WC_REDIR, t)
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_REDIR_WORDS(c: wordcode) -> i32 {
(if WC_REDIR_VARID(c) != 0 { 4 } else { 3 })
+ (if WC_REDIR_FROM_HEREDOC(c) != 0 { 2 } else { 0 })
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_ASSIGN_TYPE(c: wordcode) -> wordcode {
wc_data(c) & 1
} #[inline]
#[allow(non_snake_case)]
pub fn WC_ASSIGN_TYPE2(c: wordcode) -> wordcode {
(wc_data(c) & 2) >> 1
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_ASSIGN_NUM(c: wordcode) -> wordcode {
wc_data(c) >> 2
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_ASSIGN(t: wordcode, a: wordcode, n: wordcode) -> wordcode {
wc_bld(WC_ASSIGN, t | (a << 1) | (n << 2))
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_SIMPLE_ARGC(c: wordcode) -> wordcode {
wc_data(c)
} #[inline]
#[allow(non_snake_case)]
pub fn WCB_SIMPLE(n: wordcode) -> wordcode {
wc_bld(WC_SIMPLE, n)
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_TYPESET_ARGC(c: wordcode) -> wordcode {
wc_data(c)
} #[inline]
#[allow(non_snake_case)]
pub fn WCB_TYPESET(n: wordcode) -> wordcode {
wc_bld(WC_TYPESET, n)
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_SUBSH_SKIP(c: wordcode) -> wordcode {
wc_data(c)
} #[inline]
#[allow(non_snake_case)]
pub fn WCB_SUBSH(o: wordcode) -> wordcode {
wc_bld(WC_SUBSH, o)
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_CURSH_SKIP(c: wordcode) -> wordcode {
wc_data(c)
} #[inline]
#[allow(non_snake_case)]
pub fn WCB_CURSH(o: wordcode) -> wordcode {
wc_bld(WC_CURSH, o)
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_TIMED_TYPE(c: wordcode) -> wordcode {
wc_data(c)
} #[inline]
#[allow(non_snake_case)]
pub fn WCB_TIMED(t: wordcode) -> wordcode {
wc_bld(WC_TIMED, t)
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_FUNCDEF_SKIP(c: wordcode) -> wordcode {
wc_data(c)
} #[inline]
#[allow(non_snake_case)]
pub fn WCB_FUNCDEF(o: wordcode) -> wordcode {
wc_bld(WC_FUNCDEF, o)
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_FOR_TYPE(c: wordcode) -> wordcode {
wc_data(c) & 3
} #[inline]
#[allow(non_snake_case)]
pub fn WC_FOR_SKIP(c: wordcode) -> wordcode {
wc_data(c) >> 2
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_FOR(t: wordcode, o: wordcode) -> wordcode {
wc_bld(WC_FOR, t | (o << 2))
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_SELECT_TYPE(c: wordcode) -> wordcode {
wc_data(c) & 1
} #[inline]
#[allow(non_snake_case)]
pub fn WC_SELECT_SKIP(c: wordcode) -> wordcode {
wc_data(c) >> 1
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_SELECT(t: wordcode, o: wordcode) -> wordcode {
wc_bld(WC_SELECT, t | (o << 1))
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_WHILE_TYPE(c: wordcode) -> wordcode {
wc_data(c) & 1
} #[inline]
#[allow(non_snake_case)]
pub fn WC_WHILE_SKIP(c: wordcode) -> wordcode {
wc_data(c) >> 1
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_WHILE(t: wordcode, o: wordcode) -> wordcode {
wc_bld(WC_WHILE, t | (o << 1))
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_REPEAT_SKIP(c: wordcode) -> wordcode {
wc_data(c)
} #[inline]
#[allow(non_snake_case)]
pub fn WCB_REPEAT(o: wordcode) -> wordcode {
wc_bld(WC_REPEAT, o)
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_TRY_SKIP(c: wordcode) -> wordcode {
wc_data(c)
} #[inline]
#[allow(non_snake_case)]
pub fn WCB_TRY(o: wordcode) -> wordcode {
wc_bld(WC_TRY, o)
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_CASE_TYPE(c: wordcode) -> wordcode {
wc_data(c) & 7
} #[inline]
#[allow(non_snake_case)]
pub fn WC_CASE_SKIP(c: wordcode) -> wordcode {
wc_data(c) >> WC_CASE_FREE
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_CASE(t: wordcode, o: wordcode) -> wordcode {
wc_bld(WC_CASE, t | (o << WC_CASE_FREE))
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_IF_TYPE(c: wordcode) -> wordcode {
wc_data(c) & 3
} #[inline]
#[allow(non_snake_case)]
pub fn WC_IF_SKIP(c: wordcode) -> wordcode {
wc_data(c) >> 2
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_IF(t: wordcode, o: wordcode) -> wordcode {
wc_bld(WC_IF, t | (o << 2))
}
#[inline]
#[allow(non_snake_case)]
pub fn WC_COND_TYPE(c: wordcode) -> wordcode {
wc_data(c) & 127
} #[inline]
#[allow(non_snake_case)]
pub fn WC_COND_SKIP(c: wordcode) -> wordcode {
wc_data(c) >> 7
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_COND(t: wordcode, o: wordcode) -> wordcode {
wc_bld(WC_COND, t | (o << 7))
}
#[inline]
#[allow(non_snake_case)]
pub fn WCB_ARITH() -> wordcode {
wc_bld(WC_ARITH, 0)
} #[inline]
#[allow(non_snake_case)]
pub fn WCB_AUTOFN() -> wordcode {
wc_bld(WC_AUTOFN, 0)
}
pub const NULLBINCMD: Option<HandlerFunc> = None;
#[inline]
#[allow(non_snake_case)]
pub fn EMULATION(x: i32) -> bool { let emul = crate::ported::options::emulation
.load(std::sync::atomic::Ordering::Relaxed);
(emul & x) != 0
}
#[inline]
#[allow(non_snake_case)]
pub fn SHELL_EMULATION() -> i32 { let emul = crate::ported::options::emulation
.load(std::sync::atomic::Ordering::Relaxed);
emul & ((1 << 5) - 1)
}
#[inline]
#[allow(non_snake_case)]
pub fn IN_EVAL_TRAP() -> bool { crate::ported::signals::intrap.load(Ordering::Relaxed) != 0
&& crate::ported::signals::trapisfunc.load(Ordering::Relaxed) == 0
&& crate::ported::signals::traplocallevel.load(Ordering::Relaxed)
== crate::ported::params::locallevel.load(Ordering::Relaxed)
}
#[inline]
#[allow(non_snake_case)]
pub fn ASG_ARRAYP(asg: &asgment) -> bool {
(asg.flags & ASG_ARRAY) != 0
}
#[inline]
#[allow(non_snake_case)]
pub fn ASG_VALUEP(asg: &asgment) -> bool {
ASG_ARRAYP(asg) || asg.scalar.is_some()
}
#[inline]
#[allow(non_snake_case)]
pub fn MB_METASTRLEN2END(s: &str, widthp: bool, eptr: usize) -> usize {
let truncated = if eptr <= s.len() { &s[..eptr] } else { s };
MB_METASTRLEN2(truncated, widthp)
}
pub const EXITHOOK_OFFSET: usize = 0; pub const BEFORETRAPHOOK_OFFSET: usize = 1; pub const AFTERTRAPHOOK_OFFSET: usize = 2; pub const GETCOLORATTR_OFFSET: usize = 3;
pub const STOPHIST_DELTA: i32 = 4; pub const ALLOWHIST_DELTA: i32 = -4;
pub const STOPHIST: i32 = STOPHIST_DELTA;
pub const ALLOWHIST: i32 = ALLOWHIST_DELTA;
pub const EXITHOOK: usize = EXITHOOK_OFFSET;
pub const BEFORETRAPHOOK: usize = BEFORETRAPHOOK_OFFSET;
pub const AFTERTRAPHOOK: usize = AFTERTRAPHOOK_OFFSET;
pub const GETCOLORATTR: usize = GETCOLORATTR_OFFSET;
#[inline]
#[allow(non_snake_case)]
pub const fn ZLONG_CONST(x: i64) -> zlong {
x
}
#[macro_export]
macro_rules! STRINGIFY_LITERAL {
($x:tt) => {
stringify!($x)
};
}
#[macro_export]
macro_rules! STRINGIFY {
($x:tt) => {
$crate::STRINGIFY_LITERAL!($x)
};
}
#[macro_export]
macro_rules! ERRMSG {
($msg:expr) => {
concat!(file!(), ":", line!(), ": ", $msg)
};
}
pub const HEAPID_FMT: &str = "{:x}";
#[macro_export]
macro_rules! HEAP_ERROR {
($heap_id:expr) => {
eprintln!(
"{}:{}: HEAP DEBUG: invalid heap: {:x}.",
file!(),
line!(),
$heap_id
)
};
}
pub const SGTTYFLAG_NAME: &str = "tio.c_oflag";
pub const SGTTYFLAG: &str = SGTTYFLAG_NAME;
#[cfg(target_os = "linux")]
pub const SGTABTYPE: u32 = libc::XTABS;
#[cfg(not(target_os = "linux"))]
pub const SGTABTYPE: u32 = 0;
#[inline]
#[allow(non_snake_case)]
pub fn ZWS(s: &str) -> &str {
s
}
#[inline]
#[allow(non_snake_case)]
pub fn BUILTIN(
name: &str,
flags: i32,
handler: Option<HandlerFunc>,
min: i32,
max: i32,
funcid: i32,
optstr: Option<&str>,
defopts: Option<&str>,
) -> builtin {
builtin {
node: hashnode {
next: None,
nam: name.to_string(),
flags,
},
handlerfunc: handler,
minargs: min,
maxargs: max,
funcid,
optstr: optstr.map(|s| s.to_string()),
defopts: defopts.map(|s| s.to_string()),
}
}
#[inline]
#[allow(non_snake_case)]
pub fn BIN_PREFIX(name: &str, flags: i32) -> builtin {
BUILTIN(
name,
flags | BINF_PREFIX as i32,
NULLBINCMD,
0,
0,
0,
None,
None,
)
}
#[inline]
#[allow(non_snake_case)]
pub fn CONDDEF(
name: &str,
flags: i32,
handler: CondHandler,
min: i32,
max: i32,
condid: i32,
) -> conddef {
conddef {
next: None,
name: name.to_string(),
flags,
handler: Some(handler),
min,
max,
condid,
module: None,
}
}
#[inline]
#[allow(non_snake_case)]
pub fn HOOKDEF(name: &str, func: Hookfn, flags: i32) -> hookdef {
hookdef {
next: None,
name: name.to_string(),
def: Some(func),
flags,
funcs: None,
}
}
#[inline]
#[allow(non_snake_case)]
pub fn NUMMATHFUNC(name: &str, func: NumMathFunc, min: i32, max: i32, id: i32) -> mathfunc {
mathfunc {
next: None,
name: name.to_string(),
flags: 0,
nfunc: Some(func),
sfunc: None,
module: None,
minargs: min,
maxargs: max,
funcid: id,
}
}
#[inline]
#[allow(non_snake_case)]
pub fn STRMATHFUNC(name: &str, func: StrMathFunc, id: i32) -> mathfunc {
mathfunc {
next: None,
name: name.to_string(),
flags: MFF_STR,
nfunc: None,
sfunc: Some(func),
module: None,
minargs: 0,
maxargs: 0,
funcid: id,
}
}
#[inline]
#[allow(non_snake_case)]
pub fn PARAMDEF(name: &str, flags: i32, var: usize, gsu: usize) -> paramdef {
paramdef {
name: name.to_string(),
flags,
var,
gsu,
getnfn: None,
scantfn: None,
pm: None,
}
}
#[inline]
#[allow(non_snake_case)]
pub fn INTPARAMDEF(name: &str, var: usize) -> paramdef {
PARAMDEF(name, PM_INTEGER as i32, var, 0)
}
#[inline]
#[allow(non_snake_case)]
pub fn STRPARAMDEF(name: &str, var: usize) -> paramdef {
PARAMDEF(name, PM_SCALAR as i32, var, 0)
}
#[inline]
#[allow(non_snake_case)]
pub fn ARRPARAMDEF(name: &str, var: usize) -> paramdef {
PARAMDEF(name, PM_ARRAY as i32, var, 0)
}
#[inline]
#[allow(non_snake_case)]
pub fn SPECIALPMDEF(
name: &str,
flags: i32,
gsufn: usize,
getfn: Option<GetNodeFunc>,
scanfn: Option<ScanTabFunc>,
) -> paramdef {
paramdef {
name: name.to_string(),
flags: flags | (PM_SPECIAL | PM_HIDE | PM_HIDEVAL) as i32,
var: 0,
gsu: gsufn,
getnfn: getfn,
scantfn: scanfn,
pm: None,
}
}
#[inline]
#[allow(non_snake_case)]
pub fn WRAPDEF(func: WrapFunc) -> funcwrap {
funcwrap {
next: None,
flags: 0,
handler: Some(func),
module: None,
}
}
#[allow(non_camel_case_types)]
pub struct jobfile {
pub name: Option<String>,
pub fd: i32,
pub is_fd: i32,
}
pub const STAT_CHANGED: i32 = 0x0001; pub const STAT_STOPPED: i32 = 0x0002;
pub const STAT_TIMED: i32 = 0x0004;
pub const STAT_DONE: i32 = 0x0008;
pub const STAT_LOCKED: i32 = 0x0010;
pub const STAT_NOPRINT: i32 = 0x0020;
pub const STAT_INUSE: i32 = 0x0040;
pub const STAT_SUPERJOB: i32 = 0x0080;
pub const STAT_SUBJOB: i32 = 0x0100;
pub const STAT_WASSUPER: i32 = 0x0200;
pub const STAT_CURSH: i32 = 0x0400;
pub const STAT_NOSTTY: i32 = 0x0800;
pub const STAT_ATTACH: i32 = 0x1000;
pub const STAT_SUBLEADER: i32 = 0x2000;
pub const STAT_BUILTIN: i32 = 0x4000;
pub const STAT_SUBJOB_ORPHANED: i32 = 0x8000;
pub const STAT_DISOWN: i32 = 0x10000;
pub const SP_RUNNING: i32 = -1;
pub const JOBTEXTSIZE: usize = 80; pub const MAXJOBS_ALLOC: i32 = 50; pub const MAX_PIPESTATS: usize = 256;
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Default)]
pub struct timeinfo {
pub ut: i64,
pub st: i64,
}
impl timeinfo {
pub fn user_dur(&self) -> std::time::Duration { std::time::Duration::from_micros(self.ut as u64) }
pub fn sys_dur(&self) -> std::time::Duration { std::time::Duration::from_micros(self.st as u64) }
}
pub const DISABLED: i32 = 1 << 0;
pub const HASHED: i32 = 1 << 1; pub const ALIAS_GLOBAL: i32 = 1 << 1; pub const ALIAS_SUFFIX: i32 = 1 << 2;
pub const ASG_ARRAY: i32 = 1; pub const ASG_KEY_VALUE: i32 = 2;
pub const SFC_NONE: i32 = 0; pub const SFC_DIRECT: i32 = 1;
pub const SFC_SIGNAL: i32 = 2;
pub const SFC_HOOK: i32 = 3;
pub const SFC_WIDGET: i32 = 4;
pub const SFC_COMPLETE: i32 = 5;
pub const SFC_CWIDGET: i32 = 6;
pub const SFC_SUBST: i32 = 7;
pub const FS_SOURCE: i32 = 0; pub const FS_FUNC: i32 = 1;
pub const FS_EVAL: i32 = 2;
pub const WRAPF_ADDED: i32 = 1;
pub const HOOK_SUFFIX: &str = "_functions"; pub const HOOK_SUFFIX_LEN: usize = 11;
pub const MAX_OPS: usize = 128;
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct options {
pub ind: [u8; MAX_OPS],
pub args: Vec<String>,
pub argscount: i32,
pub argsalloc: i32,
}
pub const PARSEARGS_TOPLEVEL: i32 = 0x1; pub const PARSEARGS_LOGIN: i32 = 0x2;
#[inline]
#[allow(non_snake_case)]
pub fn OPT_MINUS(ops: &options, c: u8) -> bool {
(ops.ind[c as usize] & 1) != 0
}
#[inline]
#[allow(non_snake_case)]
pub fn OPT_PLUS(ops: &options, c: u8) -> bool {
(ops.ind[c as usize] & 2) != 0
}
#[inline]
#[allow(non_snake_case)]
pub fn OPT_ISSET(ops: &options, c: u8) -> bool {
ops.ind[c as usize] != 0
}
#[inline]
#[allow(non_snake_case)]
pub fn OPT_HASARG(ops: &options, c: u8) -> bool {
ops.ind[c as usize] > 3
}
pub type HandlerFunc = fn(name: &str, args: &[String], ops: &options, funcid: i32) -> i32;
pub const BINF_PLUSOPTS: u32 = 1 << 1; pub const BINF_PRINTOPTS: u32 = 1 << 2; pub const BINF_ADDED: u32 = 1 << 3; pub const BINF_MAGICEQUALS: u32 = 1 << 4; pub const BINF_PREFIX: u32 = 1 << 5; pub const BINF_DASH: u32 = 1 << 6; pub const BINF_BUILTIN: u32 = 1 << 7; pub const BINF_COMMAND: u32 = 1 << 8; pub const BINF_EXEC: u32 = 1 << 9; pub const BINF_NOGLOB: u32 = 1 << 10; pub const BINF_PSPECIAL: u32 = 1 << 11; pub const BINF_SKIPINVALID: u32 = 1 << 12; pub const BINF_KEEPNUM: u32 = 1 << 13; pub const BINF_SKIPDASH: u32 = 1 << 14; pub const BINF_DASHDASHVALID: u32 = 1 << 15; pub const BINF_CLEARENV: u32 = 1 << 16; pub const BINF_AUTOALL: u32 = 1 << 17; pub const BINF_HANDLES_OPTS: u32 = 1 << 18; pub const BINF_ASSIGN: u32 = 1 << 19;
pub const MOD_BUSY: i32 = 1 << 0; pub const MOD_UNLOAD: i32 = 1 << 1; pub const MOD_SETUP: i32 = 1 << 2; pub const MOD_LINKED: i32 = 1 << 3; pub const MOD_INIT_S: i32 = 1 << 4; pub const MOD_INIT_B: i32 = 1 << 5; pub const MOD_ALIAS: i32 = 1 << 6;
pub const HOOKF_ALL: i32 = 1;
pub const PAT_HEAPDUP: i32 = 0x0000; pub const PAT_FILE: i32 = 0x0001;
pub const PAT_FILET: i32 = 0x0002;
pub const PAT_ANY: i32 = 0x0004;
pub const PAT_NOANCH: i32 = 0x0008;
pub const PAT_NOGLD: i32 = 0x0010;
pub const PAT_PURES: i32 = 0x0020;
pub const PAT_STATIC: i32 = 0x0040;
pub const PAT_SCAN: i32 = 0x0080;
pub const PAT_ZDUP: i32 = 0x0100;
pub const PAT_NOTSTART: i32 = 0x0200;
pub const PAT_NOTEND: i32 = 0x0400;
pub const PAT_HAS_EXCLUDP: i32 = 0x0800;
pub const PAT_LCMATCHUC: i32 = 0x1000;
pub const ZPC_SLASH: i32 = 0;
pub const ZPC_NULL: i32 = 1;
pub const ZPC_BAR: i32 = 2;
pub const ZPC_OUTPAR: i32 = 3;
pub const ZPC_TILDE: i32 = 4;
pub const ZPC_SEG_COUNT: i32 = 5;
pub const ZPC_INPAR: i32 = ZPC_SEG_COUNT;
pub const ZPC_QUEST: i32 = ZPC_SEG_COUNT + 1;
pub const ZPC_STAR: i32 = ZPC_SEG_COUNT + 2;
pub const ZPC_INBRACK: i32 = ZPC_SEG_COUNT + 3;
pub const ZPC_INANG: i32 = ZPC_SEG_COUNT + 4;
pub const ZPC_HAT: i32 = ZPC_SEG_COUNT + 5;
pub const ZPC_HASH: i32 = ZPC_SEG_COUNT + 6;
pub const ZPC_BNULLKEEP: i32 = ZPC_SEG_COUNT + 7;
pub const ZPC_NO_KSH_GLOB: i32 = ZPC_SEG_COUNT + 8;
pub const ZPC_KSH_QUEST: i32 = ZPC_NO_KSH_GLOB;
pub const ZPC_KSH_STAR: i32 = ZPC_NO_KSH_GLOB + 1;
pub const ZPC_KSH_PLUS: i32 = ZPC_NO_KSH_GLOB + 2;
pub const ZPC_KSH_BANG: i32 = ZPC_NO_KSH_GLOB + 3;
pub const ZPC_KSH_BANG2: i32 = ZPC_NO_KSH_GLOB + 4;
pub const ZPC_KSH_AT: i32 = ZPC_NO_KSH_GLOB + 5;
pub const ZPC_COUNT: i32 = ZPC_NO_KSH_GLOB + 6;
pub const PP_FIRST: i32 = 1;
pub const PP_ALPHA: i32 = 1;
pub const PP_ALNUM: i32 = 2;
pub const PP_ASCII: i32 = 3;
pub const PP_BLANK: i32 = 4;
pub const PP_CNTRL: i32 = 5;
pub const PP_DIGIT: i32 = 6;
pub const PP_GRAPH: i32 = 7;
pub const PP_LOWER: i32 = 8;
pub const PP_PRINT: i32 = 9;
pub const PP_PUNCT: i32 = 10;
pub const PP_SPACE: i32 = 11;
pub const PP_UPPER: i32 = 12;
pub const PP_XDIGIT: i32 = 13;
pub const PP_IDENT: i32 = 14;
pub const PP_IFS: i32 = 15;
pub const PP_IFSSPACE: i32 = 16;
pub const PP_WORD: i32 = 17;
pub const PP_INCOMPLETE: i32 = 18;
pub const PP_INVALID: i32 = 19;
pub const PP_LAST: i32 = 19;
pub const PP_UNKWN: i32 = 20;
pub const PP_RANGE: i32 = 21;
pub const GF_LCMATCHUC: i32 = 0x0100;
pub const GF_IGNCASE: i32 = 0x0200;
pub const GF_BACKREF: i32 = 0x0400;
pub const GF_MATCHREF: i32 = 0x0800;
pub const GF_MULTIBYTE: i32 = 0x1000;
pub const ZMB_VALID: i32 = 0;
pub const ZMB_INCOMPLETE: i32 = 1;
pub const ZMB_INVALID: i32 = 2;
pub const PM_SCALAR: u32 = 0;
pub const PM_ARRAY: u32 = 1 << 0;
pub const PM_INTEGER: u32 = 1 << 1;
pub const PM_EFLOAT: u32 = 1 << 2;
pub const PM_FFLOAT: u32 = 1 << 3;
pub const PM_HASHED: u32 = 1 << 4;
pub const PM_LEFT: u32 = 1 << 5;
pub const PM_RIGHT_B: u32 = 1 << 6;
pub const PM_RIGHT_Z: u32 = 1 << 7;
pub const PM_LOWER: u32 = 1 << 8;
pub const PM_UPPER: u32 = 1 << 9;
pub const PM_UNDEFINED: u32 = 1 << 9;
pub const PM_READONLY: u32 = 1 << 10;
pub const PM_TAGGED: u32 = 1 << 11;
pub const PM_EXPORTED: u32 = 1 << 12;
pub const PM_ABSPATH_USED: u32 = 1 << 12;
pub const PM_UNIQUE: u32 = 1 << 13;
pub const PM_UNALIASED: u32 = 1 << 13;
pub const PM_HIDE: u32 = 1 << 14;
pub const PM_CUR_FPATH: u32 = 1 << 14;
pub const PM_HIDEVAL: u32 = 1 << 15;
pub const PM_WARNNESTED: u32 = 1 << 15;
pub const PM_TIED: u32 = 1 << 16;
pub const PM_TAGGED_LOCAL: u32 = 1 << 16;
pub const PM_DONTIMPORT_SUID: u32 = 1 << 17;
pub const PM_LOADDIR: u32 = 1 << 17;
pub const PM_SINGLE: u32 = 1 << 18;
pub const PM_ANONYMOUS: u32 = 1 << 18;
pub const PM_LOCAL: u32 = 1 << 19;
pub const PM_KSHSTORED: u32 = 1 << 19;
pub const PM_SPECIAL: u32 = 1 << 20;
pub const PM_ZSHSTORED: u32 = 1 << 20;
pub const PM_RO_BY_DESIGN: u32 = 1 << 21;
pub const PM_READONLY_SPECIAL: u32 = PM_SPECIAL | PM_READONLY | PM_RO_BY_DESIGN;
pub const PM_DONTIMPORT: u32 = 1 << 22;
pub const PM_DECLARED: u32 = 1 << 22;
pub const PM_RESTRICTED: u32 = 1 << 23;
pub const PM_UNSET: u32 = 1 << 24;
pub const PM_DEFAULTED: u32 = PM_DECLARED | PM_UNSET;
pub const PM_REMOVABLE: u32 = 1 << 25;
pub const PM_AUTOLOAD: u32 = 1 << 26;
pub const PM_NORESTORE: u32 = 1 << 27;
pub const PM_AUTOALL: u32 = 1 << 27;
pub const PM_HASHELEM: u32 = 1 << 28;
pub const PM_NAMEDDIR: u32 = 1 << 29;
pub const PM_NAMEREF: u32 = 1 << 30;
#[inline]
#[allow(non_snake_case)]
pub const fn PM_TYPE(x: u32) -> u32 {
x & (PM_SCALAR | PM_INTEGER | PM_EFLOAT | PM_FFLOAT | PM_ARRAY | PM_HASHED | PM_NAMEREF)
}
pub const TYPESET_OPTSTR: &str = "aiEFALRZlurtxUhHT"; pub const TYPESET_OPTNUM: &str = "LRZiEF";
pub const SCANPM_WANTVALS: u32 = 1 << 0;
pub const SCANPM_WANTKEYS: u32 = 1 << 1;
pub const SCANPM_WANTINDEX: u32 = 1 << 2;
pub const SCANPM_MATCHKEY: u32 = 1 << 3;
pub const SCANPM_MATCHVAL: u32 = 1 << 4;
pub const SCANPM_MATCHMANY: u32 = 1 << 5;
pub const SCANPM_ASSIGNING: u32 = 1 << 6;
pub const SCANPM_KEYMATCH: u32 = 1 << 7;
pub const SCANPM_DQUOTED: u32 = 1 << 8;
pub const SCANPM_ARRONLY: u32 = 1 << 9;
pub const SCANPM_CHECKING: u32 = 1 << 10;
pub const SCANPM_NOEXEC: u32 = 1 << 11;
pub const SCANPM_NONAMESPC: u32 = 1 << 12;
pub const SCANPM_NONAMEREF: u32 = 1 << 13;
pub const SCANPM_ISVAR_AT: u32 = 1 << 14;
pub const SUB_END: i32 = 0x0001;
pub const SUB_LONG: i32 = 0x0002;
pub const SUB_SUBSTR: i32 = 0x0004;
pub const SUB_MATCH: i32 = 0x0008;
pub const SUB_REST: i32 = 0x0010;
pub const SUB_BIND: i32 = 0x0020;
pub const SUB_EIND: i32 = 0x0040;
pub const SUB_LEN: i32 = 0x0080;
pub const SUB_ALL: i32 = 0x0100;
pub const SUB_GLOBAL: i32 = 0x0200;
pub const SUB_DOSUBST: i32 = 0x0400;
pub const SUB_RETFAIL: i32 = 0x0800;
pub const SUB_START: i32 = 0x1000;
pub const SUB_LIST: i32 = 0x2000;
pub const SUB_EGLOB: i32 = 0x4000;
pub const ZSHTOK_SUBST: i32 = 0x0001;
pub const ZSHTOK_SHGLOB: i32 = 0x0002;
pub const PREFORK_TYPESET: i32 = 0x01;
pub const PREFORK_ASSIGN: i32 = 0x02;
pub const PREFORK_SINGLE: i32 = 0x04;
pub const PREFORK_SPLIT: i32 = 0x08;
pub const PREFORK_SHWORDSPLIT: i32 = 0x10;
pub const PREFORK_NOSHWORDSPLIT: i32 = 0x20;
pub const PREFORK_SUBEXP: i32 = 0x40;
pub const PREFORK_KEY_VALUE: i32 = 0x80;
pub const PREFORK_NO_UNTOK: i32 = 0x100;
pub const MULTSUB_WS_AT_START: i32 = 1;
pub const MULTSUB_WS_AT_END: i32 = 2;
pub const MULTSUB_PARAM_NAME: i32 = 4;
pub const ASSPM_AUGMENT: i32 = 1 << 0;
pub const ASSPM_WARN_CREATE: i32 = 1 << 1;
pub const ASSPM_WARN_NESTED: i32 = 1 << 2;
pub const ASSPM_WARN: i32 = ASSPM_WARN_CREATE | ASSPM_WARN_NESTED;
pub const ASSPM_ENV_IMPORT: i32 = 1 << 3;
pub const ASSPM_KEY_VALUE: i32 = 1 << 4;
pub const ND_USERNAME: i32 = 1 << 1; pub const ND_NOABBREV: i32 = 1 << 2;
pub const PRINT_NAMEONLY: i32 = 1 << 0; pub const PRINT_TYPE: i32 = 1 << 1;
pub const PRINT_LIST: i32 = 1 << 2;
pub const PRINT_KV_PAIR: i32 = 1 << 3;
pub const PRINT_INCLUDEVALUE: i32 = 1 << 4;
pub const PRINT_TYPESET: i32 = 1 << 5;
pub const PRINT_LINE: i32 = 1 << 6;
pub const PRINT_POSIX_EXPORT: i32 = 1 << 7;
pub const PRINT_POSIX_READONLY: i32 = 1 << 8;
pub const PRINT_WITH_NAMESPACE: i32 = 1 << 9;
pub const PRINT_WHENCE_CSH: i32 = 1 << 7; pub const PRINT_WHENCE_VERBOSE: i32 = 1 << 8;
pub const PRINT_WHENCE_SIMPLE: i32 = 1 << 9;
pub const PRINT_WHENCE_FUNCDEF: i32 = 1 << 10;
pub const PRINT_WHENCE_WORD: i32 = 1 << 11;
pub const LOOP_OK: i32 = 0; pub const LOOP_EMPTY: i32 = 1;
pub const LOOP_ERROR: i32 = 2;
pub const SOURCE_OK: i32 = 0; pub const SOURCE_NOT_FOUND: i32 = 1;
pub const SOURCE_ERROR: i32 = 2;
pub const NOERREXIT_EXIT: i32 = 1; pub const NOERREXIT_RETURN: i32 = 2;
pub const NOERREXIT_SIGNAL: i32 = 8;
pub const HIST_MAKEUNIQUE: u32 = 0x00000001; pub const HIST_OLD: u32 = 0x00000002;
pub const HIST_READ: u32 = 0x00000004;
pub const HIST_DUP: u32 = 0x00000008;
pub const HIST_FOREIGN: u32 = 0x00000010;
pub const HIST_TMPSTORE: u32 = 0x00000020;
pub const HIST_NOWRITE: u32 = 0x00000040;
pub const GETHIST_UPWARD: i32 = -1;
pub const GETHIST_DOWNWARD: i32 = 1;
pub const GETHIST_EXACT: i32 = 0;
pub const HISTFLAG_DONE: i32 = 1; pub const HISTFLAG_NOEXEC: i32 = 2;
pub const HISTFLAG_RECALL: i32 = 4;
pub const HISTFLAG_SETTY: i32 = 8;
pub const HFILE_APPEND: u32 = 0x0001;
pub const HFILE_SKIPOLD: u32 = 0x0002;
pub const HFILE_SKIPDUPS: u32 = 0x0004;
pub const HFILE_SKIPFOREIGN: u32 = 0x0008;
pub const HFILE_FAST: u32 = 0x0010;
pub const HFILE_NO_REWRITE: u32 = 0x0020;
pub const HFILE_USE_OPTIONS: u32 = 0x8000;
pub const LEXFLAGS_ACTIVE: i32 = 0x0001;
pub const LEXFLAGS_ZLE: i32 = 0x0002;
pub const LEXFLAGS_COMMENTS_KEEP: i32 = 0x0004;
pub const LEXFLAGS_COMMENTS_STRIP: i32 = 0x0008;
pub const LEXFLAGS_COMMENTS: i32 = LEXFLAGS_COMMENTS_KEEP | LEXFLAGS_COMMENTS_STRIP;
pub const LEXFLAGS_NEWLINE: i32 = 0x0010;
pub const IN_NOTHING: i32 = 0;
pub const IN_CMD: i32 = 1;
pub const IN_MATH: i32 = 2;
pub const IN_COND: i32 = 3;
pub const IN_ENV: i32 = 4;
pub const IN_PAR: i32 = 5;
pub const EMULATE_CSH: i32 = 1 << 1; pub const EMULATE_KSH: i32 = 1 << 2;
pub const EMULATE_SH: i32 = 1 << 3;
pub const EMULATE_ZSH: i32 = 1 << 4;
pub const EMULATE_FULLY: i32 = 1 << 5;
pub const EMULATE_UNUSED: i32 = 1 << 6;
pub const OPT_INVALID: i32 = 0;
pub const ALIASESOPT: i32 = 1;
pub const ALIASFUNCDEF: i32 = 2;
pub const ALLEXPORT: i32 = 3;
pub const ALWAYSLASTPROMPT: i32 = 4;
pub const ALWAYSTOEND: i32 = 5;
pub const APPENDHISTORY: i32 = 6;
pub const AUTOCD: i32 = 7;
pub const AUTOCONTINUE: i32 = 8;
pub const AUTOLIST: i32 = 9;
pub const AUTOMENU: i32 = 10;
pub const AUTONAMEDIRS: i32 = 11;
pub const AUTOPARAMKEYS: i32 = 12;
pub const AUTOPARAMSLASH: i32 = 13;
pub const AUTOPUSHD: i32 = 14;
pub const AUTOREMOVESLASH: i32 = 15;
pub const AUTORESUME: i32 = 16;
pub const BADPATTERN: i32 = 17;
pub const BANGHIST: i32 = 18;
pub const BAREGLOBQUAL: i32 = 19;
pub const BASHAUTOLIST: i32 = 20;
pub const BASHREMATCH: i32 = 21;
pub const BEEP: i32 = 22;
pub const BGNICE: i32 = 23;
pub const BRACECCL: i32 = 24;
pub const BSDECHO: i32 = 25;
pub const CASEGLOB: i32 = 26;
pub const CASEMATCH: i32 = 27;
pub const CASEPATHS: i32 = 28;
pub const CBASES: i32 = 29;
pub const CDABLEVARS: i32 = 30;
pub const CDSILENT: i32 = 31;
pub const CHASEDOTS: i32 = 32;
pub const CHASELINKS: i32 = 33;
pub const CHECKJOBS: i32 = 34;
pub const CHECKRUNNINGJOBS: i32 = 35;
pub const CLOBBER: i32 = 36;
pub const CLOBBEREMPTY: i32 = 37;
pub const APPENDCREATE: i32 = 38;
pub const COMBININGCHARS: i32 = 39;
pub const COMPLETEALIASES: i32 = 40;
pub const COMPLETEINWORD: i32 = 41;
pub const CORRECT: i32 = 42;
pub const CORRECTALL: i32 = 43;
pub const CONTINUEONERROR: i32 = 44;
pub const CPRECEDENCES: i32 = 45;
pub const CSHJUNKIEHISTORY: i32 = 46;
pub const CSHJUNKIELOOPS: i32 = 47;
pub const CSHJUNKIEQUOTES: i32 = 48;
pub const CSHNULLCMD: i32 = 49;
pub const CSHNULLGLOB: i32 = 50;
pub const DEBUGBEFORECMD: i32 = 51;
pub const EMACSMODE: i32 = 52;
pub const EQUALSOPT: i32 = 53; pub const ERREXIT: i32 = 54;
pub const ERRRETURN: i32 = 55;
pub const EXECOPT: i32 = 56;
pub const EXTENDEDGLOB: i32 = 57;
pub const EXTENDEDHISTORY: i32 = 58;
pub const EVALLINENO: i32 = 59;
pub const FLOWCONTROL: i32 = 60;
pub const FORCEFLOAT: i32 = 61;
pub const FUNCTIONARGZERO: i32 = 62;
pub const GLOBOPT: i32 = 63;
pub const GLOBALEXPORT: i32 = 64;
pub const GLOBALRCS: i32 = 65;
pub const GLOBASSIGN: i32 = 66;
pub const GLOBCOMPLETE: i32 = 67;
pub const GLOBDOTS: i32 = 68;
pub const GLOBSTARSHORT: i32 = 69;
pub const GLOBSUBST: i32 = 70;
pub const HASHCMDS: i32 = 71;
pub const HASHDIRS: i32 = 72;
pub const HASHEXECUTABLESONLY: i32 = 73;
pub const HASHLISTALL: i32 = 74;
pub const HISTALLOWCLOBBER: i32 = 75;
pub const HISTBEEP: i32 = 76;
pub const HISTEXPIREDUPSFIRST: i32 = 77;
pub const HISTFCNTLLOCK: i32 = 78;
pub const HISTFINDNODUPS: i32 = 79;
pub const HISTIGNOREALLDUPS: i32 = 80;
pub const HISTIGNOREDUPS: i32 = 81;
pub const HISTIGNORESPACE: i32 = 82;
pub const HISTLEXWORDS: i32 = 83;
pub const HISTNOFUNCTIONS: i32 = 84;
pub const HISTNOSTORE: i32 = 85;
pub const HISTREDUCEBLANKS: i32 = 86;
pub const HISTSAVEBYCOPY: i32 = 87;
pub const HISTSAVENODUPS: i32 = 88;
pub const HISTSUBSTPATTERN: i32 = 89;
pub const HISTVERIFY: i32 = 90;
pub const HUP: i32 = 91;
pub const IGNOREBRACES: i32 = 92;
pub const IGNORECLOSEBRACES: i32 = 93;
pub const IGNOREEOF: i32 = 94;
pub const INCAPPENDHISTORY: i32 = 95;
pub const INCAPPENDHISTORYTIME: i32 = 96;
pub const INTERACTIVE: i32 = 97;
pub const INTERACTIVECOMMENTS: i32 = 98;
pub const KSHARRAYS: i32 = 99;
pub const KSHAUTOLOAD: i32 = 100;
pub const KSHGLOB: i32 = 101;
pub const KSHOPTIONPRINT: i32 = 102;
pub const KSHTYPESET: i32 = 103;
pub const KSHZEROSUBSCRIPT: i32 = 104;
pub const LISTAMBIGUOUS: i32 = 105;
pub const LISTBEEP: i32 = 106;
pub const LISTPACKED: i32 = 107;
pub const LISTROWSFIRST: i32 = 108;
pub const LISTTYPES: i32 = 109;
pub const LOCALLOOPS: i32 = 110;
pub const LOCALOPTIONS: i32 = 111;
pub const LOCALPATTERNS: i32 = 112;
pub const LOCALTRAPS: i32 = 113;
pub const LOGINSHELL: i32 = 114;
pub const LONGLISTJOBS: i32 = 115;
pub const MAGICEQUALSUBST: i32 = 116;
pub const MAILWARNING: i32 = 117;
pub const MARKDIRS: i32 = 118;
pub const MENUCOMPLETE: i32 = 119;
pub const MONITOR: i32 = 120;
pub const MULTIBYTE: i32 = 121;
pub const MULTIFUNCDEF: i32 = 122;
pub const MULTIOS: i32 = 123;
pub const NOMATCH: i32 = 124;
pub const NOTIFY: i32 = 125;
pub const NULLGLOB: i32 = 126;
pub const NUMERICGLOBSORT: i32 = 127;
pub const OCTALZEROES: i32 = 128;
pub const OVERSTRIKE: i32 = 129;
pub const PATHDIRS: i32 = 130;
pub const PATHSCRIPT: i32 = 131;
pub const PIPEFAIL: i32 = 132;
pub const POSIXALIASES: i32 = 133;
pub const POSIXARGZERO: i32 = 134;
pub const POSIXBUILTINS: i32 = 135;
pub const POSIXCD: i32 = 136;
pub const POSIXIDENTIFIERS: i32 = 137;
pub const POSIXJOBS: i32 = 138;
pub const POSIXSTRINGS: i32 = 139;
pub const POSIXTRAPS: i32 = 140;
pub const PRINTEIGHTBIT: i32 = 141;
pub const PRINTEXITVALUE: i32 = 142;
pub const PRIVILEGED: i32 = 143;
pub const PROMPTBANG: i32 = 144;
pub const PROMPTCR: i32 = 145;
pub const PROMPTPERCENT: i32 = 146;
pub const PROMPTSP: i32 = 147;
pub const PROMPTSUBST: i32 = 148;
pub const PUSHDIGNOREDUPS: i32 = 149;
pub const PUSHDMINUS: i32 = 150;
pub const PUSHDSILENT: i32 = 151;
pub const PUSHDTOHOME: i32 = 152;
pub const RCEXPANDPARAM: i32 = 153;
pub const RCQUOTES: i32 = 154;
pub const RCS: i32 = 155;
pub const RECEXACT: i32 = 156;
pub const REMATCHPCRE: i32 = 157;
pub const RESTRICTED: i32 = 158;
pub const RMSTARSILENT: i32 = 159;
pub const RMSTARWAIT: i32 = 160;
pub const SHAREHISTORY: i32 = 161;
pub const SHFILEEXPANSION: i32 = 162;
pub const SHGLOB: i32 = 163;
pub const SHINSTDIN: i32 = 164;
pub const SHNULLCMD: i32 = 165;
pub const SHOPTIONLETTERS: i32 = 166;
pub const SHORTLOOPS: i32 = 167;
pub const SHORTREPEAT: i32 = 168;
pub const SHWORDSPLIT: i32 = 169;
pub const SINGLECOMMAND: i32 = 170;
pub const SINGLELINEZLE: i32 = 171;
pub const SOURCETRACE: i32 = 172;
pub const SUNKEYBOARDHACK: i32 = 173;
pub const TRANSIENTRPROMPT: i32 = 174;
pub const TRAPSASYNC: i32 = 175;
pub const TYPESETSILENT: i32 = 176;
pub const TYPESETTOUNSET: i32 = 177;
pub const UNSET: i32 = 178;
pub const VERBOSE: i32 = 179;
pub const VIMODE: i32 = 180;
pub const WARNCREATEGLOBAL: i32 = 181;
pub const WARNNESTEDVAR: i32 = 182;
pub const XTRACE: i32 = 183;
pub const USEZLE: i32 = 184;
pub const DVORAK: i32 = 185;
pub const OPT_SIZE: i32 = 186;
pub type OptIndex = u8;
#[inline]
pub fn isset(opt: i32) -> bool {
crate::ported::options::opt_state_get(&opt_name(opt)).unwrap_or(false)
}
#[inline]
pub fn unset(opt: i32) -> bool {
!isset(opt)
}
#[inline]
pub fn interact() -> bool {
isset(INTERACTIVE)
}
#[inline]
pub fn jobbing() -> bool {
isset(MONITOR)
}
#[inline]
pub fn islogin() -> bool {
isset(LOGINSHELL)
}
pub fn opt_name(opt: i32) -> &'static str {
match opt {
x if x == ALLEXPORT => "allexport",
x if x == ALWAYSLASTPROMPT => "alwayslastprompt",
x if x == ALWAYSTOEND => "alwaystoend",
x if x == APPENDHISTORY => "appendhistory",
x if x == AUTOCD => "autocd",
x if x == AUTOCONTINUE => "autocontinue",
x if x == AUTOLIST => "autolist",
x if x == AUTOMENU => "automenu",
x if x == AUTONAMEDIRS => "autonamedirs",
x if x == AUTOPARAMKEYS => "autoparamkeys",
x if x == AUTOPARAMSLASH => "autoparamslash",
x if x == AUTOPUSHD => "autopushd",
x if x == AUTOREMOVESLASH => "autoremoveslash",
x if x == AUTORESUME => "autoresume",
x if x == BADPATTERN => "badpattern",
x if x == BANGHIST => "banghist",
x if x == BAREGLOBQUAL => "bareglobqual",
x if x == BASHAUTOLIST => "bashautolist",
x if x == BASHREMATCH => "bashrematch",
x if x == BEEP => "beep",
x if x == BGNICE => "bgnice",
x if x == BRACECCL => "braceccl",
x if x == BSDECHO => "bsdecho",
x if x == CASEGLOB => "caseglob",
x if x == CASEMATCH => "casematch",
x if x == CBASES => "cbases",
x if x == CDABLEVARS => "cdablevars",
x if x == CDSILENT => "cdsilent",
x if x == CHASEDOTS => "chasedots",
x if x == CHASELINKS => "chaselinks",
x if x == CHECKJOBS => "checkjobs",
x if x == CHECKRUNNINGJOBS => "checkrunningjobs",
x if x == CLOBBER => "clobber",
x if x == COMBININGCHARS => "combiningchars",
x if x == COMPLETEALIASES => "completealiases",
x if x == COMPLETEINWORD => "completeinword",
x if x == CORRECT => "correct",
x if x == CORRECTALL => "correctall",
x if x == CPRECEDENCES => "cprecedences",
x if x == CSHJUNKIEHISTORY => "cshjunkiehistory",
x if x == CSHJUNKIELOOPS => "cshjunkieloops",
x if x == CSHJUNKIEQUOTES => "cshjunkiequotes",
x if x == CSHNULLCMD => "cshnullcmd",
x if x == CSHNULLGLOB => "cshnullglob",
x if x == DEBUGBEFORECMD => "debugbeforecmd",
x if x == EMACSMODE => "emacs",
x if x == EQUALSOPT => "equals",
x if x == ERREXIT => "errexit",
x if x == ERRRETURN => "errreturn",
x if x == EXECOPT => "exec",
x if x == EXTENDEDGLOB => "extendedglob",
x if x == EXTENDEDHISTORY => "extendedhistory",
x if x == EVALLINENO => "evallineno",
x if x == FLOWCONTROL => "flowcontrol",
x if x == FORCEFLOAT => "forcefloat",
x if x == FUNCTIONARGZERO => "functionargzero",
x if x == GLOBOPT => "glob",
x if x == GLOBALEXPORT => "globalexport",
x if x == GLOBALRCS => "globalrcs",
x if x == GLOBASSIGN => "globassign",
x if x == GLOBCOMPLETE => "globcomplete",
x if x == GLOBDOTS => "globdots",
x if x == GLOBSTARSHORT => "globstarshort",
x if x == GLOBSUBST => "globsubst",
x if x == HASHCMDS => "hashcmds",
x if x == HASHDIRS => "hashdirs",
x if x == HASHEXECUTABLESONLY => "hashexecutablesonly",
x if x == HASHLISTALL => "hashlistall",
x if x == HISTALLOWCLOBBER => "histallowclobber",
x if x == HISTBEEP => "histbeep",
x if x == HISTEXPIREDUPSFIRST => "histexpiredupsfirst",
x if x == HISTFCNTLLOCK => "histfcntllock",
x if x == HISTFINDNODUPS => "histfindnodups",
x if x == HISTIGNOREALLDUPS => "histignorealldups",
x if x == HISTIGNOREDUPS => "histignoredups",
x if x == HISTIGNORESPACE => "histignorespace",
x if x == HISTLEXWORDS => "histlexwords",
x if x == HISTNOFUNCTIONS => "histnofunctions",
x if x == HISTNOSTORE => "histnostore",
x if x == HISTREDUCEBLANKS => "histreduceblanks",
x if x == HISTSAVEBYCOPY => "histsavebycopy",
x if x == HISTSAVENODUPS => "histsavenodups",
x if x == HISTSUBSTPATTERN => "histsubstpattern",
x if x == HISTVERIFY => "histverify",
x if x == HUP => "hup",
x if x == IGNOREBRACES => "ignorebraces",
x if x == IGNORECLOSEBRACES => "ignoreclosebraces",
x if x == IGNOREEOF => "ignoreeof",
x if x == INCAPPENDHISTORY => "incappendhistory",
x if x == INCAPPENDHISTORYTIME => "incappendhistorytime",
x if x == INTERACTIVE => "interactive",
x if x == INTERACTIVECOMMENTS => "interactivecomments",
x if x == KSHARRAYS => "ksharrays",
x if x == KSHAUTOLOAD => "kshautoload",
x if x == KSHGLOB => "kshglob",
x if x == KSHOPTIONPRINT => "kshoptionprint",
x if x == KSHTYPESET => "kshtypeset",
x if x == KSHZEROSUBSCRIPT => "kshzerosubscript",
x if x == LISTAMBIGUOUS => "listambiguous",
x if x == LISTBEEP => "listbeep",
x if x == LISTPACKED => "listpacked",
x if x == LISTROWSFIRST => "listrowsfirst",
x if x == LISTTYPES => "listtypes",
x if x == LOCALOPTIONS => "localoptions",
x if x == LOCALLOOPS => "localloops",
x if x == LOCALPATTERNS => "localpatterns",
x if x == LOCALTRAPS => "localtraps",
x if x == LOGINSHELL => "loginshell",
x if x == LONGLISTJOBS => "longlistjobs",
x if x == MAGICEQUALSUBST => "magicequalsubst",
x if x == MAILWARNING => "mailwarning",
x if x == MARKDIRS => "markdirs",
x if x == MENUCOMPLETE => "menucomplete",
x if x == MONITOR => "monitor",
x if x == MULTIBYTE => "multibyte",
x if x == MULTIFUNCDEF => "multifuncdef",
x if x == MULTIOS => "multios",
x if x == NOMATCH => "nomatch",
x if x == NOTIFY => "notify",
x if x == NULLGLOB => "nullglob",
x if x == NUMERICGLOBSORT => "numericglobsort",
x if x == OCTALZEROES => "octalzeroes",
x if x == OVERSTRIKE => "overstrike",
x if x == PATHDIRS => "pathdirs",
x if x == PATHSCRIPT => "pathscript",
x if x == PIPEFAIL => "pipefail",
x if x == POSIXALIASES => "posixaliases",
x if x == POSIXARGZERO => "posixargzero",
x if x == POSIXBUILTINS => "posixbuiltins",
x if x == POSIXCD => "posixcd",
x if x == POSIXIDENTIFIERS => "posixidentifiers",
x if x == POSIXJOBS => "posixjobs",
x if x == POSIXSTRINGS => "posixstrings",
x if x == POSIXTRAPS => "posixtraps",
x if x == PRINTEIGHTBIT => "printeightbit",
x if x == PRINTEXITVALUE => "printexitvalue",
x if x == PRIVILEGED => "privileged",
x if x == PROMPTBANG => "promptbang",
x if x == PROMPTCR => "promptcr",
x if x == PROMPTPERCENT => "promptpercent",
x if x == PROMPTSP => "promptsp",
x if x == PROMPTSUBST => "promptsubst",
x if x == PUSHDIGNOREDUPS => "pushdignoredups",
x if x == PUSHDMINUS => "pushdminus",
x if x == PUSHDSILENT => "pushdsilent",
x if x == PUSHDTOHOME => "pushdtohome",
x if x == RCEXPANDPARAM => "rcexpandparam",
x if x == RCQUOTES => "rcquotes",
x if x == RCS => "rcs",
x if x == RECEXACT => "recexact",
x if x == REMATCHPCRE => "rematchpcre",
x if x == RESTRICTED => "restricted",
x if x == RMSTARSILENT => "rmstarsilent",
x if x == RMSTARWAIT => "rmstarwait",
x if x == SHAREHISTORY => "sharehistory",
x if x == SHFILEEXPANSION => "shfileexpansion",
x if x == SHGLOB => "shglob",
x if x == SHINSTDIN => "shinstdin",
x if x == SHNULLCMD => "shnullcmd",
x if x == SHOPTIONLETTERS => "shoptionletters",
x if x == SHORTLOOPS => "shortloops",
x if x == SHORTREPEAT => "shortrepeat",
x if x == SHWORDSPLIT => "shwordsplit",
x if x == SINGLECOMMAND => "singlecommand",
x if x == SINGLELINEZLE => "singlelinezle",
x if x == SOURCETRACE => "sourcetrace",
x if x == SUNKEYBOARDHACK => "sunkeyboardhack",
x if x == TRANSIENTRPROMPT => "transientrprompt",
x if x == TRAPSASYNC => "trapsasync",
x if x == TYPESETSILENT => "typesetsilent",
x if x == UNSET => "unset",
x if x == VERBOSE => "verbose",
x if x == ALIASESOPT => "aliases",
x if x == WARNCREATEGLOBAL => "warncreateglobal",
x if x == WARNNESTEDVAR => "warnnestedvar",
x if x == XTRACE => "xtrace",
x if x == USEZLE => "zle",
x if x == DVORAK => "dvorak",
_ => "",
}
}
pub const TERM_BAD: i32 = 0x01;
pub const TERM_UNKNOWN: i32 = 0x02;
pub const TERM_NOUP: i32 = 0x04;
pub const TERM_SHORT: i32 = 0x08;
pub const TERM_NARROW: i32 = 0x10;
pub const TCCLEARSCREEN: i32 = 0;
pub const TCLEFT: i32 = 1;
pub const TCMULTLEFT: i32 = 2;
pub const TCRIGHT: i32 = 3;
pub const TCMULTRIGHT: i32 = 4;
pub const TCUP: i32 = 5;
pub const TCMULTUP: i32 = 6;
pub const TCDOWN: i32 = 7;
pub const TCMULTDOWN: i32 = 8;
pub const TCDEL: i32 = 9;
pub const TCMULTDEL: i32 = 10;
pub const TCINS: i32 = 11;
pub const TCMULTINS: i32 = 12;
pub const TCCLEAREOD: i32 = 13;
pub const TCCLEAREOL: i32 = 14;
pub const TCINSLINE: i32 = 15;
pub const TCDELLINE: i32 = 16;
pub const TCNEXTTAB: i32 = 17;
pub const TCBOLDFACEBEG: i32 = 18;
pub const TCFAINTBEG: i32 = 19;
pub const TCSTANDOUTBEG: i32 = 20;
pub const TCUNDERLINEBEG: i32 = 21;
pub const TCITALICSBEG: i32 = 22;
pub const TCALLATTRSOFF: i32 = 23;
pub const TCSTANDOUTEND: i32 = 24;
pub const TCUNDERLINEEND: i32 = 25;
pub const TCITALICSEND: i32 = 26;
pub const TCHORIZPOS: i32 = 27;
pub const TCUPCURSOR: i32 = 28;
pub const TCDOWNCURSOR: i32 = 29;
pub const TCLEFTCURSOR: i32 = 30;
pub const TCRIGHTCURSOR: i32 = 31;
pub const TCSAVECURSOR: i32 = 32;
pub const TCRESTRCURSOR: i32 = 33;
pub const TCBACKSPACE: i32 = 34;
pub const TCFGCOLOUR: i32 = 35;
pub const TCBGCOLOUR: i32 = 36;
pub const TCCURINV: i32 = 37;
pub const TCCURVIS: i32 = 38;
pub const TC_COUNT: i32 = 39;
pub type zattr = u64;
pub const TXTBOLDFACE: zattr = 0x0001;
pub const TXTFAINT: zattr = 0x0002;
pub const TXTSTANDOUT: zattr = 0x0004;
pub const TXTUNDERLINE: zattr = 0x0008;
pub const TXTITALIC: zattr = 0x0010;
pub const TXTFGCOLOUR: zattr = 0x0020;
pub const TXTBGCOLOUR: zattr = 0x0040;
pub const TXT_ATTR_ALL: zattr = 0x007F;
pub const TXT_MULTIWORD_MASK: zattr = 0x0400;
pub const TXT_ERROR: zattr = 0xF00000F000000003;
pub const TXT_ATTR_FONT_WEIGHT: zattr = TXTBOLDFACE | TXTFAINT;
pub const TXT_ATTR_FG_COL_MASK: zattr = 0x000000FFFFFF0000;
pub const TXT_ATTR_FG_COL_SHIFT: u32 = 16;
pub const TXT_ATTR_BG_COL_MASK: zattr = 0xFFFFFF0000000000;
pub const TXT_ATTR_BG_COL_SHIFT: u32 = 40;
pub const TXT_ATTR_FG_24BIT: zattr = 0x4000;
pub const TXT_ATTR_BG_24BIT: zattr = 0x8000;
pub const TXT_ATTR_FG_MASK: zattr = TXTFGCOLOUR | TXT_ATTR_FG_COL_MASK | TXT_ATTR_FG_24BIT;
pub const TXT_ATTR_BG_MASK: zattr = TXTBGCOLOUR | TXT_ATTR_BG_COL_MASK | TXT_ATTR_BG_24BIT;
pub const TXT_ATTR_COLOUR_MASK: zattr = TXT_ATTR_FG_MASK | TXT_ATTR_BG_MASK;
pub const COL_SEQ_FG: i32 = 0;
pub const COL_SEQ_BG: i32 = 1;
#[allow(non_camel_case_types)]
pub struct color_rgb {
pub red: u32,
pub green: u32,
pub blue: u32,
}
pub type Color_rgb = Box<color_rgb>;
pub const TSC_RAW: i32 = 0x0001; pub const TSC_PROMPT: i32 = 0x0002;
pub const CMDSTACKSZ: usize = 256;
pub const CS_FOR: i32 = 0;
pub const CS_WHILE: i32 = 1;
pub const CS_REPEAT: i32 = 2;
pub const CS_SELECT: i32 = 3;
pub const CS_UNTIL: i32 = 4;
pub const CS_IF: i32 = 5;
pub const CS_IFTHEN: i32 = 6;
pub const CS_ELSE: i32 = 7;
pub const CS_ELIF: i32 = 8;
pub const CS_MATH: i32 = 9;
pub const CS_COND: i32 = 10;
pub const CS_CMDOR: i32 = 11;
pub const CS_CMDAND: i32 = 12;
pub const CS_PIPE: i32 = 13;
pub const CS_ERRPIPE: i32 = 14;
pub const CS_FOREACH: i32 = 15;
pub const CS_CASE: i32 = 16;
pub const CS_FUNCDEF: i32 = 17;
pub const CS_SUBSH: i32 = 18;
pub const CS_CURSH: i32 = 19;
pub const CS_ARRAY: i32 = 20;
pub const CS_QUOTE: i32 = 21;
pub const CS_DQUOTE: i32 = 22;
pub const CS_BQUOTE: i32 = 23;
pub const CS_CMDSUBST: i32 = 24;
pub const CS_MATHSUBST: i32 = 25;
pub const CS_ELIFTHEN: i32 = 26;
pub const CS_HEREDOC: i32 = 27;
pub const CS_HEREDOCD: i32 = 28;
pub const CS_BRACE: i32 = 29;
pub const CS_BRACEPAR: i32 = 30;
pub const CS_ALWAYS: i32 = 31;
pub const CS_COUNT: i32 = 32;
pub type Heapid = u32;
pub const HEAPID_PERMANENT: Heapid = u32::MAX;
pub const HDV_PUSH: i32 = 0x01;
pub const HDV_POP: i32 = 0x02;
pub const HDV_CREATE: i32 = 0x04;
pub const HDV_FREE: i32 = 0x08;
pub const HDV_NEW: i32 = 0x10;
pub const HDV_OLD: i32 = 0x20;
pub const HDV_SWITCH: i32 = 0x40;
pub const HDV_ALLOC: i32 = 0x80;
pub const ZSIG_TRAPPED: i32 = 1 << 0;
pub const ZSIG_IGNORED: i32 = 1 << 1;
pub const ZSIG_FUNC: i32 = 1 << 2;
pub const ZSIG_MASK: i32 = ZSIG_TRAPPED | ZSIG_IGNORED | ZSIG_FUNC;
pub const ZSIG_ALIAS: i32 = 1 << 3;
pub const ZSIG_SHIFT: i32 = 4;
pub const TRAP_STATE_INACTIVE: i32 = 0;
pub const TRAP_STATE_PRIMED: i32 = 1;
pub const TRAP_STATE_FORCE_RETURN: i32 = 2;
pub const ERRFLAG_ERROR: i32 = 1;
pub const ERRFLAG_INT: i32 = 2;
pub const ERRFLAG_HARD: i32 = 4;
pub const SORTIT_ANYOLDHOW: i32 = 0;
pub const SORTIT_IGNORING_CASE: i32 = 1;
pub const SORTIT_NUMERICALLY: i32 = 2;
pub const SORTIT_NUMERICALLY_SIGNED: i32 = 4;
pub const SORTIT_BACKWARDS: i32 = 8;
pub const SORTIT_IGNORING_BACKSLASHES: i32 = 16;
pub const SORTIT_SOMEHOW: i32 = 32;
pub const CASMOD_NONE: i32 = 0;
pub const CASMOD_UPPER: i32 = 1;
pub const CASMOD_LOWER: i32 = 2;
pub const CASMOD_CAPS: i32 = 3;
pub const GETKEY_OCTAL_ESC: i32 = 1 << 0;
pub const GETKEY_EMACS: i32 = 1 << 1;
pub const GETKEY_CTRL: i32 = 1 << 2;
pub const GETKEY_BACKSLASH_C: i32 = 1 << 3;
pub const GETKEY_DOLLAR_QUOTE: i32 = 1 << 4;
pub const GETKEY_BACKSLASH_MINUS: i32 = 1 << 5;
pub const GETKEY_SINGLE_CHAR: i32 = 1 << 6;
pub const GETKEY_UPDATE_OFFSET: i32 = 1 << 7;
pub const GETKEY_PRINTF_PERCENT: i32 = 1 << 8;
pub const GETKEYS_ECHO: i32 = GETKEY_BACKSLASH_C;
pub const GETKEYS_PRINTF_FMT: i32 = GETKEY_OCTAL_ESC | GETKEY_BACKSLASH_C | GETKEY_PRINTF_PERCENT;
pub const GETKEYS_PRINTF_ARG: i32 = GETKEY_BACKSLASH_C;
pub const GETKEYS_PRINT: i32 = GETKEY_OCTAL_ESC | GETKEY_BACKSLASH_C | GETKEY_EMACS;
pub const GETKEYS_BINDKEY: i32 = GETKEY_OCTAL_ESC | GETKEY_EMACS | GETKEY_CTRL;
pub const GETKEYS_DOLLARS_QUOTE: i32 = GETKEY_OCTAL_ESC | GETKEY_EMACS | GETKEY_DOLLAR_QUOTE;
pub const GETKEYS_MATH: i32 = GETKEY_OCTAL_ESC | GETKEY_EMACS | GETKEY_CTRL | GETKEY_SINGLE_CHAR;
pub const GETKEYS_SEP: i32 = GETKEY_OCTAL_ESC | GETKEY_EMACS;
pub const GETKEYS_SUFFIX: i32 =
GETKEY_OCTAL_ESC | GETKEY_EMACS | GETKEY_CTRL | GETKEY_BACKSLASH_MINUS;
pub const ZLRF_HISTORY: i32 = 0x01;
pub const ZLRF_NOSETTY: i32 = 0x02;
pub const ZLRF_IGNOREEOF: i32 = 0x04;
pub const ZLCON_LINE_START: i32 = 0;
pub const ZLCON_LINE_CONT: i32 = 1;
pub const ZLCON_SELECT: i32 = 2;
pub const ZLCON_VARED: i32 = 3;
pub const ZLE_CMD_GET_LINE: i32 = 0;
pub const ZLE_CMD_READ: i32 = 1;
pub const ZLE_CMD_ADD_TO_LINE: i32 = 2;
pub const ZLE_CMD_TRASH: i32 = 3;
pub const ZLE_CMD_RESET_PROMPT: i32 = 4;
pub const ZLE_CMD_REFRESH: i32 = 5;
pub const ZLE_CMD_SET_KEYMAP: i32 = 6;
pub const ZLE_CMD_GET_KEY: i32 = 7;
pub const ZLE_CMD_SET_HIST_LINE: i32 = 8;
pub const ZLE_CMD_PREEXEC: i32 = 9;
pub const ZLE_CMD_POSTEXEC: i32 = 10;
pub const ZLE_CMD_CHPWD: i32 = 11;
pub const ZEXIT_NORMAL: i32 = 0;
pub const ZEXIT_SIGNAL: i32 = 1;
pub const ZEXIT_DEFERRED: i32 = 2;
pub const NICEFLAG_HEAP: i32 = 1;
pub const NICEFLAG_QUOTE: i32 = 2;
pub const NICEFLAG_NODUP: i32 = 4;
pub type convchar_t = u32;
pub const MB_INCOMPLETE: usize = usize::MAX - 1; pub const MB_INVALID: usize = usize::MAX; pub const MB_CUR_MAX: usize = 6;
#[inline]
#[allow(non_snake_case)]
pub fn MB_METACHARINIT() {}
#[inline]
#[allow(non_snake_case)]
pub fn MB_METACHARLEN(s: &[u8]) -> usize {
if s.is_empty() {
0
} else if s[0] as char == META {
2
} else {
1
}
}
#[inline]
#[allow(non_snake_case)]
pub fn MB_METACHARLENCONV(s: &[u8]) -> (usize, Option<char>) {
if s.is_empty() {
return (0, None);
}
if s[0] as char == META && s.len() >= 2 {
let unmeta = s[1] ^ 0x20;
(2, Some(unmeta as char))
} else {
(1, Some(s[0] as char))
}
}
#[inline]
#[allow(non_snake_case)]
pub fn MB_METASTRLEN(s: &str) -> usize {
let mut n = 0;
let mut i = 0;
let bytes = s.as_bytes();
while i < bytes.len() {
if bytes[i] as char == META && i + 1 < bytes.len() {
i += 2;
} else {
i += 1;
}
n += 1;
}
n
}
#[inline]
#[allow(non_snake_case)]
pub fn MB_METASTRWIDTH(s: &str) -> usize {
MB_METASTRLEN(s)
}
#[inline]
#[allow(non_snake_case)]
pub fn MB_METASTRLEN2(s: &str, widthp: bool) -> usize {
if widthp {
MB_METASTRWIDTH(s)
} else {
MB_METASTRLEN(s)
}
}
#[inline]
#[allow(non_snake_case)]
pub fn MB_CHARINIT() {}
#[inline]
#[allow(non_snake_case)]
pub fn MB_CHARLEN(s: &[u8], len: usize) -> usize {
if len == 0 || s.is_empty() {
0
} else {
1
}
}
#[inline]
#[allow(non_snake_case)]
pub fn MB_CHARLENCONV(s: &[u8], len: usize) -> (usize, Option<char>) {
if len == 0 || s.is_empty() {
(0, None)
} else {
(1, Some(s[0] as char))
}
}
#[inline]
#[allow(non_snake_case)]
pub fn WCWIDTH(wc: char) -> i32 {
if wc as u32 == 0 {
return 0;
}
if wc.is_control() {
return 0;
}
let cp = wc as u32;
if (0x1100..=0x115F).contains(&cp)
|| (0x2E80..=0x303E).contains(&cp)
|| (0x3041..=0x33FF).contains(&cp)
|| (0x3400..=0x4DBF).contains(&cp)
|| (0x4E00..=0x9FFF).contains(&cp)
|| (0xA000..=0xA4CF).contains(&cp)
|| (0xAC00..=0xD7A3).contains(&cp)
|| (0xF900..=0xFAFF).contains(&cp)
|| (0xFE30..=0xFE4F).contains(&cp)
|| (0xFF00..=0xFF60).contains(&cp)
|| (0xFFE0..=0xFFE6).contains(&cp)
|| (0x20000..=0x2FFFD).contains(&cp)
|| (0x30000..=0x3FFFD).contains(&cp)
{
2
} else {
1
}
}
#[inline]
#[allow(non_snake_case)]
pub fn WCWIDTH_WINT(wc: char) -> i32 {
WCWIDTH(wc)
}
#[inline]
#[allow(non_snake_case)]
pub fn IS_COMBINING(wc: char) -> bool {
wc as u32 != 0 && WCWIDTH(wc) == 0
}
#[inline]
#[allow(non_snake_case)]
pub fn IS_BASECHAR(wc: char) -> bool {
!wc.is_whitespace() && !wc.is_control() && WCWIDTH(wc) > 0
}
#[inline]
#[allow(non_snake_case)]
pub const fn ZWC(c: char) -> char {
c
}
#[inline]
#[allow(non_snake_case)]
pub fn OPT_ARG<'a>(ops: &'a options, c: u8) -> Option<&'a str> {
let idx = (ops.ind[c as usize] >> 2) as usize;
if idx == 0 {
return None;
}
ops.args.get(idx - 1).map(|s| s.as_str())
}
#[inline]
#[allow(non_snake_case)]
pub fn OPT_ARG_SAFE<'a>(ops: &'a options, c: u8) -> Option<&'a str> {
if OPT_HASARG(ops, c) {
OPT_ARG(ops, c)
} else {
None
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn zlong_zulong_sizes() {
assert_eq!(std::mem::size_of::<zlong>(), 8);
assert_eq!(std::mem::size_of::<zulong>(), 8);
}
#[test]
fn meta_byte_value() {
assert_eq!(META as u32, 0x83);
}
#[test]
fn parser_tokens_correct() {
assert_eq!(Pound as u32, 0x84);
assert_eq!(Bang as u32, 0x9c);
assert_eq!(Snull as u32, 0x9d);
assert_eq!(Dnull as u32, 0x9e);
assert_eq!(Bnull as u32, 0x9f);
assert_eq!(Bnullkeep as u32, 0xa0);
assert_eq!(Nularg as u32, 0xa1);
assert_eq!(Marker as u32, 0xa2);
}
#[test]
fn pm_type_isolates_type_bits() {
assert_eq!(PM_TYPE(PM_INTEGER | PM_EXPORTED), PM_INTEGER);
assert_eq!(PM_TYPE(PM_ARRAY | PM_READONLY), PM_ARRAY);
}
#[test]
fn opt_isset_basic() {
let mut ops = options {
ind: [0u8; MAX_OPS],
args: Vec::new(),
argscount: 0,
argsalloc: 0,
};
ops.ind[b'l' as usize] = 1; assert!(OPT_ISSET(&ops, b'l'));
assert!(OPT_MINUS(&ops, b'l'));
assert!(!OPT_PLUS(&ops, b'l'));
assert!(!OPT_ISSET(&ops, b'r'));
}
#[test]
fn binf_constants_correct() {
assert_eq!(BINF_PREFIX, 1 << 5);
assert_eq!(BINF_ASSIGN, 1 << 19);
}
#[test]
fn cond_constants_correct() {
assert_eq!(COND_NOT, 0);
assert_eq!(COND_MODI, 19);
}
#[test]
fn fdt_constants_correct() {
assert_eq!(FDT_UNUSED, 0);
assert_eq!(FDT_PROC_SUBST, 7);
assert_eq!(FDT_TYPE_MASK, 15);
}
#[test]
fn redir_iswrite_classification() {
assert!(IS_WRITE_FILE(REDIR_WRITE));
assert!(IS_WRITE_FILE(REDIR_READWRITE));
assert!(!IS_WRITE_FILE(REDIR_READ));
assert!(IS_ERROR_REDIR(REDIR_ERRWRITE));
assert!(IS_ERROR_REDIR(REDIR_ERRAPPNOW));
assert!(!IS_ERROR_REDIR(REDIR_WRITE));
}
#[test]
fn wc_macros_round_trip() {
let w = wc_bld(WC_LIST, 42);
assert_eq!(wc_code(w), WC_LIST);
assert_eq!(wc_data(w), 42);
}
#[test]
fn mb_metastrlen_counts_meta_pairs() {
assert_eq!(MB_METASTRLEN("abc"), 3);
assert_eq!(MB_METASTRLEN("hello"), 5);
assert_eq!(MB_METASTRLEN(""), 0);
}
#[test]
fn mb_charlen_basic() {
assert_eq!(MB_CHARLEN(b"abc", 3), 1);
assert_eq!(MB_CHARLEN(b"", 0), 0);
}
#[test]
fn wcwidth_basic() {
assert_eq!(WCWIDTH('a'), 1);
assert_eq!(WCWIDTH('\u{0007}'), 0); assert_eq!(WCWIDTH('\u{4E2D}'), 2); }
#[test]
fn is_combining_zero_width() {
assert!(!IS_COMBINING('a')); assert!(!IS_COMBINING('\u{0000}')); assert!(IS_COMBINING('\u{0007}'));
}
#[test]
fn pat_flags_correct() {
assert_eq!(PAT_FILE, 0x0001);
assert_eq!(PAT_LCMATCHUC, 0x1000);
}
#[test]
fn sub_flags_correct() {
assert_eq!(SUB_END, 0x0001);
assert_eq!(SUB_EGLOB, 0x4000);
}
#[test]
fn pp_constants_ordered() {
assert_eq!(PP_FIRST, PP_ALPHA);
assert!(PP_LAST >= PP_ALPHA);
assert!(PP_RANGE > PP_LAST);
}
#[test]
fn typeset_optstr_constants() {
assert_eq!(TYPESET_OPTSTR, "aiEFALRZlurtxUhHT");
assert_eq!(TYPESET_OPTNUM, "LRZiEF");
}
#[test]
fn job_stat_flags_distinct() {
let all = STAT_CHANGED
| STAT_STOPPED
| STAT_TIMED
| STAT_DONE
| STAT_LOCKED
| STAT_NOPRINT
| STAT_INUSE
| STAT_SUPERJOB
| STAT_SUBJOB
| STAT_WASSUPER
| STAT_CURSH
| STAT_NOSTTY
| STAT_ATTACH
| STAT_SUBLEADER
| STAT_BUILTIN
| STAT_SUBJOB_ORPHANED
| STAT_DISOWN;
assert_eq!(all.count_ones(), 17);
}
#[test]
fn opt_size_at_186() {
assert_eq!(OPT_SIZE, 186);
}
#[test]
fn cs_count_is_32() {
assert_eq!(CS_COUNT, 32);
}
#[test]
fn zwc_passes_through() {
assert_eq!(ZWC('a'), 'a');
}
}
#[allow(dead_code)]
const _MARKER_KEEP: AtomicI32 = AtomicI32::new(0);