#define minimum(a,b) ((a) < (b) ? (a) : (b))
#ifdef ZSH_64_BIT_TYPE
typedef ZSH_64_BIT_TYPE zlong;
#ifdef ZSH_64_BIT_UTYPE
typedef ZSH_64_BIT_UTYPE zulong;
#else
typedef unsigned zlong zulong;
#endif
#else
typedef long zlong;
typedef unsigned long zulong;
#endif
#ifndef LONG_IS_64_BIT
# define PAD_64_BIT 1
#endif
typedef struct {
union {
zlong l;
double d;
} u;
int type;
} mnumber;
#define MN_INTEGER 1
#define MN_FLOAT 2
#define MN_UNSET 4
typedef struct mathfunc *MathFunc;
typedef mnumber (*NumMathFunc)(char *, int, mnumber *, int);
typedef mnumber (*StrMathFunc)(char *, char *, int);
struct mathfunc {
MathFunc next;
char *name;
int flags;
NumMathFunc nfunc;
StrMathFunc sfunc;
char *module;
int minargs;
int maxargs;
int funcid;
};
#define MFF_STR 1
#define MFF_ADDED 2
#define MFF_USERFUNC 4
#define MFF_AUTOALL 8
#define NUMMATHFUNC(name, func, min, max, id) \
{ NULL, name, 0, func, NULL, NULL, min, max, id }
#define STRMATHFUNC(name, func, id) \
{ NULL, name, MFF_STR, NULL, func, NULL, 0, 0, id }
#ifdef BROKEN_SIGNED_TO_UNSIGNED_CASTING
# define STOUC(X) ((unsigned char)(unsigned short)(X))
#else
# define STOUC(X) ((unsigned char)(X))
#endif
#define Meta ((char) 0x83)
#define DEFAULT_IFS " \t\n\203 "
#define DEFAULT_IFS_SH " \t\n"
#define Pound ((char) 0x84)
#define String ((char) 0x85)
#define Hat ((char) 0x86)
#define Star ((char) 0x87)
#define Inpar ((char) 0x88)
#define Outpar ((char) 0x89)
#define Qstring ((char) 0x8a)
#define Equals ((char) 0x8b)
#define Bar ((char) 0x8c)
#define Inbrace ((char) 0x8d)
#define Outbrace ((char) 0x8e)
#define Inbrack ((char) 0x8f)
#define Outbrack ((char) 0x90)
#define Tick ((char) 0x91)
#define Inang ((char) 0x92)
#define Outang ((char) 0x93)
#define OutangProc ((char) 0x94)
#define Quest ((char) 0x95)
#define Tilde ((char) 0x96)
#define Qtick ((char) 0x97)
#define Comma ((char) 0x98)
#define Snull ((char) 0x99)
#define Dnull ((char) 0x9a)
#define Bnull ((char) 0x9b)
#define Bnullkeep ((char) 0x9c)
#define Nularg ((char) 0x9d)
#define Marker ((char) 0xa0)
#define SPECCHARS "#$^*()=|{}[]`<>?~;&\n\t \\\'\""
enum {
QT_NONE,
QT_BACKSLASH,
QT_SINGLE,
QT_DOUBLE,
QT_DOLLARS,
QT_BACKTICK,
QT_SINGLE_OPTIONAL,
QT_BACKSLASH_SHOWNULL
};
#define QT_IS_SINGLE(x) ((x) == QT_SINGLE || (x) == QT_SINGLE_OPTIONAL)
enum {
NULLTOK,
SEPER,
NEWLIN,
SEMI,
DSEMI,
AMPER,
INPAR,
OUTPAR,
DBAR,
DAMPER,
OUTANG,
OUTANGBANG,
DOUTANG,
DOUTANGBANG,
INANG,
INOUTANG,
DINANG,
DINANGDASH,
INANGAMP,
OUTANGAMP,
AMPOUTANG,
OUTANGAMPBANG,
DOUTANGAMP,
DOUTANGAMPBANG,
TRINANG,
BAR,
BARAMP,
INOUTPAR,
DINPAR,
DOUTPAR,
AMPERBANG,
SEMIAMP,
SEMIBAR,
DOUTBRACK,
STRING,
ENVSTRING,
ENVARRAY,
ENDINPUT,
LEXERR,
BANG,
DINBRACK,
INBRACE,
OUTBRACE,
CASE,
COPROC,
DOLOOP,
DONE,
ELIF,
ELSE,
ZEND,
ESAC,
FI,
FOR,
FOREACH,
FUNC,
IF,
NOCORRECT,
REPEAT,
SELECT,
THEN,
TIME,
UNTIL,
WHILE
};
enum {
REDIR_WRITE,
REDIR_WRITENOW,
REDIR_APP,
REDIR_APPNOW,
REDIR_ERRWRITE,
REDIR_ERRWRITENOW,
REDIR_ERRAPP,
REDIR_ERRAPPNOW,
REDIR_READWRITE,
REDIR_READ,
REDIR_HEREDOC,
REDIR_HEREDOCDASH,
REDIR_HERESTR,
REDIR_MERGEIN,
REDIR_MERGEOUT,
REDIR_CLOSE,
REDIR_INPIPE,
REDIR_OUTPIPE
};
#define REDIR_TYPE_MASK (0x1f)
#define REDIR_VARID_MASK (0x20)
#define REDIR_FROM_HEREDOC_MASK (0x40)
#define IS_WRITE_FILE(X) ((X)>=REDIR_WRITE && (X)<=REDIR_READWRITE)
#define IS_APPEND_REDIR(X) (IS_WRITE_FILE(X) && ((X) & 2))
#define IS_CLOBBER_REDIR(X) (IS_WRITE_FILE(X) && ((X) & 1))
#define IS_ERROR_REDIR(X) ((X)>=REDIR_ERRWRITE && (X)<=REDIR_ERRAPPNOW)
#define IS_READFD(X) (((X)>=REDIR_READWRITE && (X)<=REDIR_MERGEIN) || (X)==REDIR_INPIPE)
#define IS_REDIROP(X) ((X)>=OUTANG && (X)<=TRINANG)
#define FDT_UNUSED 0
#define FDT_INTERNAL 1
#define FDT_EXTERNAL 2
#define FDT_XTRACE 3
#define FDT_FLOCK 4
#define FDT_FLOCK_EXEC 5
#ifdef PATH_DEV_FD
#define FDT_PROC_SUBST 6
#endif
#define INP_FREE (1<<0)
#define INP_ALIAS (1<<1)
#define INP_HIST (1<<2)
#define INP_CONT (1<<3)
#define INP_ALCONT (1<<4)
#define INP_LINENO (1<<5)
#define META_REALLOC 0
#define META_USEHEAP 1
#define META_STATIC 2
#define META_DUP 3
#define META_ALLOC 4
#define META_NOALLOC 5
#define META_HEAPDUP 6
#define META_HREALLOC 7
typedef struct alias *Alias;
typedef struct asgment *Asgment;
typedef struct builtin *Builtin;
typedef struct cmdnam *Cmdnam;
typedef struct complist *Complist;
typedef struct conddef *Conddef;
typedef struct dirsav *Dirsav;
typedef struct features *Features;
typedef struct feature_enables *Feature_enables;
typedef struct funcstack *Funcstack;
typedef struct funcwrap *FuncWrap;
typedef struct hashnode *HashNode;
typedef struct hashtable *HashTable;
typedef struct heap *Heap;
typedef struct heapstack *Heapstack;
typedef struct histent *Histent;
typedef struct hookdef *Hookdef;
typedef struct job *Job;
typedef struct linkedmod *Linkedmod;
typedef struct linknode *LinkNode;
typedef union linkroot *LinkList;
typedef struct module *Module;
typedef struct nameddir *Nameddir;
typedef struct options *Options;
typedef struct optname *Optname;
typedef struct param *Param;
typedef struct paramdef *Paramdef;
typedef struct patprog *Patprog;
typedef struct prepromptfn *Prepromptfn;
typedef struct process *Process;
typedef struct redir *Redir;
typedef struct reswd *Reswd;
typedef struct shfunc *Shfunc;
typedef struct timedfn *Timedfn;
typedef struct value *Value;
struct linknode {
LinkNode next;
LinkNode prev;
void *dat;
};
struct linklist {
LinkNode first;
LinkNode last;
int flags;
};
union linkroot {
struct linklist list;
struct linknode node;
};
#define firstnode(X) ((X)->list.first)
#define lastnode(X) ((X)->list.last)
#define peekfirst(X) (firstnode(X)->dat)
#define peeklast(X) (lastnode(X)->dat)
#define addlinknode(X,Y) insertlinknode(X,lastnode(X),Y)
#define zaddlinknode(X,Y) zinsertlinknode(X,lastnode(X),Y)
#define uaddlinknode(X,Y) uinsertlinknode(X,lastnode(X),Y)
#define empty(X) (firstnode(X) == NULL)
#define nonempty(X) (firstnode(X) != NULL)
#define getaddrdata(X) (&((X)->dat))
#define getdata(X) ((X)->dat)
#define setdata(X,Y) ((X)->dat = (Y))
#define nextnode(X) ((X)->next)
#define prevnode(X) ((X)->prev)
#define pushnode(X,Y) insertlinknode(X,&(X)->node,Y)
#define zpushnode(X,Y) zinsertlinknode(X,&(X)->node,Y)
#define incnode(X) (X = nextnode(X))
#define decnode(X) (X = prevnode(X))
#define firsthist() (hist_ring? hist_ring->down->histnum : curhist)
#define setsizednode(X,Y,Z) (firstnode(X)[(Y)].dat = (void *) (Z))
#define local_list0(N) union linkroot N
#define init_list0(N) \
do { \
(N).list.first = NULL; \
(N).list.last = &(N).node; \
(N).list.flags = 0; \
} while (0)
#define local_list1(N) union linkroot N; struct linknode __n0
#define init_list1(N,V0) \
do { \
(N).list.first = &__n0; \
(N).list.last = &__n0; \
(N).list.flags = 0; \
__n0.next = NULL; \
__n0.prev = &(N).node; \
__n0.dat = (void *) (V0); \
} while (0)
typedef void (*voidvoidfnptr_t) _((void));
struct prepromptfn {
voidvoidfnptr_t func;
};
struct timedfn {
voidvoidfnptr_t func;
time_t when;
};
#define Z_TIMED (1<<0)
#define Z_SYNC (1<<1)
#define Z_ASYNC (1<<2)
#define Z_DISOWN (1<<3)
#define COND_NOT 0
#define COND_AND 1
#define COND_OR 2
#define COND_STREQ 3
#define COND_STRNEQ 4
#define COND_STRLT 5
#define COND_STRGTR 6
#define COND_NT 7
#define COND_OT 8
#define COND_EF 9
#define COND_EQ 10
#define COND_NE 11
#define COND_LT 12
#define COND_GT 13
#define COND_LE 14
#define COND_GE 15
#define COND_REGEX 16
#define COND_MOD 17
#define COND_MODI 18
typedef int (*CondHandler) _((char **, int));
struct conddef {
Conddef next;
char *name;
int flags;
CondHandler handler;
int min;
int max;
int condid;
char *module;
};
#define CONDF_INFIX 1
#define CONDF_ADDED 2
#define CONDF_AUTOALL 4
#define CONDDEF(name, flags, handler, min, max, condid) \
{ NULL, name, flags, handler, min, max, condid, NULL }
enum {
REDIRF_FROM_HEREDOC = 1
};
struct redir {
int type;
int flags;
int fd1, fd2;
char *name;
char *varid;
char *here_terminator;
char *munged_here_terminator;
};
#define MULTIOUNIT 8
struct multio {
int ct;
int rflag;
int pipe;
int fds[MULTIOUNIT];
};
struct asgment {
struct asgment *next;
char *name;
char *value;
};
struct value {
int isarr;
Param pm;
int flags;
int start;
int end;
char **arr;
};
enum {
VALFLAG_INV = 0x0001,
VALFLAG_EMPTY = 0x0002,
VALFLAG_SUBST = 0x0004
};
#define MAX_ARRLEN 262144
typedef unsigned int wordcode;
typedef wordcode *Wordcode;
typedef struct funcdump *FuncDump;
typedef struct eprog *Eprog;
struct funcdump {
FuncDump next;
dev_t dev;
ino_t ino;
int fd;
Wordcode map;
Wordcode addr;
int len;
int count;
char *filename;
};
struct eprog {
int flags;
int len;
int npats;
int nref;
Patprog *pats;
Wordcode prog;
char *strs;
Shfunc shf;
FuncDump dump;
};
#define EF_REAL 1
#define EF_HEAP 2
#define EF_MAP 4
#define EF_RUN 8
typedef struct estate *Estate;
struct estate {
Eprog prog;
Wordcode pc;
char *strs;
};
typedef struct eccstr *Eccstr;
struct eccstr {
Eccstr left, right;
char *str;
wordcode offs, aoffs;
int nfunc;
};
#define EC_NODUP 0
#define EC_DUP 1
#define EC_DUPTOK 2
#define WC_CODEBITS 5
#define wc_code(C) ((C) & ((wordcode) ((1 << WC_CODEBITS) - 1)))
#define wc_data(C) ((C) >> WC_CODEBITS)
#define wc_bdata(D) ((D) << WC_CODEBITS)
#define wc_bld(C,D) (((wordcode) (C)) | (((wordcode) (D)) << WC_CODEBITS))
#define WC_END 0
#define WC_LIST 1
#define WC_SUBLIST 2
#define WC_PIPE 3
#define WC_REDIR 4
#define WC_ASSIGN 5
#define WC_SIMPLE 6
#define WC_SUBSH 7
#define WC_CURSH 8
#define WC_TIMED 9
#define WC_FUNCDEF 10
#define WC_FOR 11
#define WC_SELECT 12
#define WC_WHILE 13
#define WC_REPEAT 14
#define WC_CASE 15
#define WC_IF 16
#define WC_COND 17
#define WC_ARITH 18
#define WC_AUTOFN 19
#define WC_TRY 20
#define WC_COUNT 21
#define WCB_END() wc_bld(WC_END, 0)
#define WC_LIST_TYPE(C) wc_data(C)
#define Z_END (1<<4)
#define Z_SIMPLE (1<<5)
#define WC_LIST_FREE (6)
#define WC_LIST_SKIP(C) (wc_data(C) >> WC_LIST_FREE)
#define WCB_LIST(T,O) wc_bld(WC_LIST, ((T) | ((O) << WC_LIST_FREE)))
#define WC_SUBLIST_TYPE(C) (wc_data(C) & ((wordcode) 3))
#define WC_SUBLIST_END 0
#define WC_SUBLIST_AND 1
#define WC_SUBLIST_OR 2
#define WC_SUBLIST_FLAGS(C) (wc_data(C) & ((wordcode) 0x1c))
#define WC_SUBLIST_COPROC 4
#define WC_SUBLIST_NOT 8
#define WC_SUBLIST_SIMPLE 16
#define WC_SUBLIST_FREE (5)
#define WC_SUBLIST_SKIP(C) (wc_data(C) >> WC_SUBLIST_FREE)
#define WCB_SUBLIST(T,F,O) wc_bld(WC_SUBLIST, \
((T) | (F) | ((O) << WC_SUBLIST_FREE)))
#define WC_PIPE_TYPE(C) (wc_data(C) & ((wordcode) 1))
#define WC_PIPE_END 0
#define WC_PIPE_MID 1
#define WC_PIPE_LINENO(C) (wc_data(C) >> 1)
#define WCB_PIPE(T,L) wc_bld(WC_PIPE, ((T) | ((L) << 1)))
#define WC_REDIR_TYPE(C) ((int)(wc_data(C) & REDIR_TYPE_MASK))
#define WC_REDIR_VARID(C) ((int)(wc_data(C) & REDIR_VARID_MASK))
#define WC_REDIR_FROM_HEREDOC(C) ((int)(wc_data(C) & REDIR_FROM_HEREDOC_MASK))
#define WCB_REDIR(T) wc_bld(WC_REDIR, (T))
#define WC_REDIR_WORDS(C) \
((WC_REDIR_VARID(C) ? 4 : 3) + \
(WC_REDIR_FROM_HEREDOC(C) ? 2 : 0))
#define WC_ASSIGN_TYPE(C) (wc_data(C) & ((wordcode) 1))
#define WC_ASSIGN_TYPE2(C) ((wc_data(C) & ((wordcode) 2)) >> 1)
#define WC_ASSIGN_SCALAR 0
#define WC_ASSIGN_ARRAY 1
#define WC_ASSIGN_NEW 0
#define WC_ASSIGN_INC 1
#define WC_ASSIGN_NUM(C) (wc_data(C) >> 2)
#define WCB_ASSIGN(T,A,N) wc_bld(WC_ASSIGN, ((T) | ((A) << 1) | ((N) << 2)))
#define WC_SIMPLE_ARGC(C) wc_data(C)
#define WCB_SIMPLE(N) wc_bld(WC_SIMPLE, (N))
#define WC_SUBSH_SKIP(C) wc_data(C)
#define WCB_SUBSH(O) wc_bld(WC_SUBSH, (O))
#define WC_CURSH_SKIP(C) wc_data(C)
#define WCB_CURSH(O) wc_bld(WC_CURSH, (O))
#define WC_TIMED_TYPE(C) wc_data(C)
#define WC_TIMED_EMPTY 0
#define WC_TIMED_PIPE 1
#define WCB_TIMED(T) wc_bld(WC_TIMED, (T))
#define WC_FUNCDEF_SKIP(C) wc_data(C)
#define WCB_FUNCDEF(O) wc_bld(WC_FUNCDEF, (O))
#define WC_FOR_TYPE(C) (wc_data(C) & 3)
#define WC_FOR_PPARAM 0
#define WC_FOR_LIST 1
#define WC_FOR_COND 2
#define WC_FOR_SKIP(C) (wc_data(C) >> 2)
#define WCB_FOR(T,O) wc_bld(WC_FOR, ((T) | ((O) << 2)))
#define WC_SELECT_TYPE(C) (wc_data(C) & 1)
#define WC_SELECT_PPARAM 0
#define WC_SELECT_LIST 1
#define WC_SELECT_SKIP(C) (wc_data(C) >> 1)
#define WCB_SELECT(T,O) wc_bld(WC_SELECT, ((T) | ((O) << 1)))
#define WC_WHILE_TYPE(C) (wc_data(C) & 1)
#define WC_WHILE_WHILE 0
#define WC_WHILE_UNTIL 1
#define WC_WHILE_SKIP(C) (wc_data(C) >> 1)
#define WCB_WHILE(T,O) wc_bld(WC_WHILE, ((T) | ((O) << 1)))
#define WC_REPEAT_SKIP(C) wc_data(C)
#define WCB_REPEAT(O) wc_bld(WC_REPEAT, (O))
#define WC_TRY_SKIP(C) wc_data(C)
#define WCB_TRY(O) wc_bld(WC_TRY, (O))
#define WC_CASE_TYPE(C) (wc_data(C) & 7)
#define WC_CASE_HEAD 0
#define WC_CASE_OR 1
#define WC_CASE_AND 2
#define WC_CASE_TESTAND 3
#define WC_CASE_FREE (3)
#define WC_CASE_SKIP(C) (wc_data(C) >> WC_CASE_FREE)
#define WCB_CASE(T,O) wc_bld(WC_CASE, ((T) | ((O) << WC_CASE_FREE)))
#define WC_IF_TYPE(C) (wc_data(C) & 3)
#define WC_IF_HEAD 0
#define WC_IF_IF 1
#define WC_IF_ELIF 2
#define WC_IF_ELSE 3
#define WC_IF_SKIP(C) (wc_data(C) >> 2)
#define WCB_IF(T,O) wc_bld(WC_IF, ((T) | ((O) << 2)))
#define WC_COND_TYPE(C) (wc_data(C) & 127)
#define WC_COND_SKIP(C) (wc_data(C) >> 7)
#define WCB_COND(T,O) wc_bld(WC_COND, ((T) | ((O) << 7)))
#define WCB_ARITH() wc_bld(WC_ARITH, 0)
#define WCB_AUTOFN() wc_bld(WC_AUTOFN, 0)
struct job {
pid_t gleader;
pid_t other;
int stat;
char *pwd;
struct process *procs;
struct process *auxprocs;
LinkList filelist;
int stty_in_env;
struct ttyinfo *ty;
};
#define STAT_CHANGED (0x0001)
#define STAT_STOPPED (0x0002)
#define STAT_TIMED (0x0004)
#define STAT_DONE (0x0008)
#define STAT_LOCKED (0x0010)
#define STAT_NOPRINT (0x0020)
#define STAT_INUSE (0x0040)
#define STAT_SUPERJOB (0x0080)
#define STAT_SUBJOB (0x0100)
#define STAT_WASSUPER (0x0200)
#define STAT_CURSH (0x0400)
#define STAT_NOSTTY (0x0800)
#define STAT_ATTACH (0x1000)
#define STAT_SUBLEADER (0x2000)
#define SP_RUNNING -1
struct timeinfo {
long ut;
long st;
};
#define JOBTEXTSIZE 80
#define MAXJOBS_ALLOC (50)
#ifdef HAVE_GETRUSAGE
typedef struct rusage child_times_t;
#else
typedef struct timeinfo child_times_t;
#endif
struct process {
struct process *next;
pid_t pid;
char text[JOBTEXTSIZE];
int status;
child_times_t ti;
struct timeval bgtime;
struct timeval endtime;
};
struct execstack {
struct execstack *next;
pid_t list_pipe_pid;
int nowait;
int pline_level;
int list_pipe_child;
int list_pipe_job;
char list_pipe_text[JOBTEXTSIZE];
int lastval;
int noeval;
int badcshglob;
pid_t cmdoutpid;
int cmdoutval;
int use_cmdoutval;
int trap_return;
int trap_state;
int trapisfunc;
int traplocallevel;
int noerrs;
int subsh_close;
char *underscore;
};
struct heredocs {
struct heredocs *next;
int type;
int pc;
char *str;
};
struct dirsav {
int dirfd, level;
char *dirname;
dev_t dev;
ino_t ino;
};
#define MAX_PIPESTATS 256
typedef void *(*VFunc) _((void *));
typedef void (*FreeFunc) _((void *));
typedef unsigned (*HashFunc) _((const char *));
typedef void (*TableFunc) _((HashTable));
typedef void (*AddNodeFunc) _((HashTable, char *, void *));
typedef HashNode (*GetNodeFunc) _((HashTable, const char *));
typedef HashNode (*RemoveNodeFunc) _((HashTable, const char *));
typedef void (*FreeNodeFunc) _((HashNode));
typedef int (*CompareFunc) _((const char *, const char *));
typedef void (*ScanFunc) _((HashNode, int));
typedef void (*ScanTabFunc) _((HashTable, ScanFunc, int));
typedef void (*PrintTableStats) _((HashTable));
struct hashtable {
int hsize;
int ct;
HashNode *nodes;
void *tmpdata;
HashFunc hash;
TableFunc emptytable;
TableFunc filltable;
CompareFunc cmpnodes;
AddNodeFunc addnode;
GetNodeFunc getnode;
GetNodeFunc getnode2;
RemoveNodeFunc removenode;
ScanFunc disablenode;
ScanFunc enablenode;
FreeNodeFunc freenode;
ScanFunc printnode;
ScanTabFunc scantab;
#ifdef HASHTABLE_INTERNAL_MEMBERS
HASHTABLE_INTERNAL_MEMBERS
#endif
};
struct hashnode {
HashNode next;
char *nam;
int flags;
};
#define DISABLED (1<<0)
struct optname {
struct hashnode node;
int optno;
};
struct reswd {
struct hashnode node;
int token;
};
struct alias {
struct hashnode node;
char *text;
int inuse;
};
#define ALIAS_GLOBAL (1<<1)
#define ALIAS_SUFFIX (1<<2)
struct cmdnam {
struct hashnode node;
union {
char **name;
char *cmd;
}
u;
};
#define HASHED (1<<1)
struct shfunc {
struct hashnode node;
char *filename;
zlong lineno;
Eprog funcdef;
int emulation;
};
#define SFC_NONE 0
#define SFC_DIRECT 1
#define SFC_SIGNAL 2
#define SFC_HOOK 3
#define SFC_WIDGET 4
#define SFC_COMPLETE 5
#define SFC_CWIDGET 6
#define SFC_SUBST 7
enum {
FS_SOURCE,
FS_FUNC,
FS_EVAL
};
struct funcstack {
Funcstack prev;
char *name;
char *filename;
char *caller;
zlong flineno;
zlong lineno;
int tp;
};
typedef int (*WrapFunc) _((Eprog, FuncWrap, char *));
struct funcwrap {
FuncWrap next;
int flags;
WrapFunc handler;
Module module;
};
#define WRAPF_ADDED 1
#define WRAPDEF(func) \
{ NULL, 0, func, NULL }
#define HOOK_SUFFIX "_functions"
#define HOOK_SUFFIX_LEN 11
#define MAX_OPS 128
#define OPT_MINUS(ops,c) ((ops)->ind[c] & 1)
#define OPT_PLUS(ops,c) ((ops)->ind[c] & 2)
#define OPT_ISSET(ops,c) ((ops)->ind[c] != 0)
#define OPT_HASARG(ops,c) ((ops)->ind[c] > 3)
#define OPT_ARG(ops,c) ((ops)->args[((ops)->ind[c] >> 2) - 1])
#define OPT_ARG_SAFE(ops,c) (OPT_HASARG(ops,c) ? OPT_ARG(ops,c) : NULL)
struct options {
unsigned char ind[MAX_OPS];
char **args;
int argscount, argsalloc;
};
typedef int (*HandlerFunc) _((char *, char **, Options, int));
#define NULLBINCMD ((HandlerFunc) 0)
struct builtin {
struct hashnode node;
HandlerFunc handlerfunc;
int minargs;
int maxargs;
int funcid;
char *optstr;
char *defopts;
};
#define BUILTIN(name, flags, handler, min, max, funcid, optstr, defopts) \
{ { NULL, name, flags }, handler, min, max, funcid, optstr, defopts }
#define BIN_PREFIX(name, flags) \
BUILTIN(name, flags | BINF_PREFIX, NULLBINCMD, 0, 0, 0, NULL, NULL)
#define BINF_PLUSOPTS (1<<1)
#define BINF_PRINTOPTS (1<<2)
#define BINF_ADDED (1<<3)
#define BINF_MAGICEQUALS (1<<4)
#define BINF_PREFIX (1<<5)
#define BINF_DASH (1<<6)
#define BINF_BUILTIN (1<<7)
#define BINF_COMMAND (1<<8)
#define BINF_EXEC (1<<9)
#define BINF_NOGLOB (1<<10)
#define BINF_PSPECIAL (1<<11)
#define BINF_SKIPINVALID (1<<12)
#define BINF_KEEPNUM (1<<13)
#define BINF_SKIPDASH (1<<14)
#define BINF_DASHDASHVALID (1<<15)
#define BINF_CLEARENV (1<<16)
#define BINF_AUTOALL (1<<17)
#define BINF_HANDLES_OPTS (1<<18)
struct module {
struct hashnode node;
union {
void *handle;
Linkedmod linked;
char *alias;
} u;
LinkList autoloads;
LinkList deps;
int wrapper;
};
#define MOD_BUSY (1<<0)
#define MOD_UNLOAD (1<<1)
#define MOD_SETUP (1<<2)
#define MOD_LINKED (1<<3)
#define MOD_INIT_S (1<<4)
#define MOD_INIT_B (1<<5)
#define MOD_ALIAS (1<<6)
typedef int (*Module_generic_func) _((void));
typedef int (*Module_void_func) _((Module));
typedef int (*Module_features_func) _((Module, char ***));
typedef int (*Module_enables_func) _((Module, int **));
struct linkedmod {
char *name;
Module_void_func setup;
Module_features_func features;
Module_enables_func enables;
Module_void_func boot;
Module_void_func cleanup;
Module_void_func finish;
};
struct features {
Builtin bn_list;
int bn_size;
Conddef cd_list;
int cd_size;
MathFunc mf_list;
int mf_size;
Paramdef pd_list;
int pd_size;
int n_abstract;
};
struct feature_enables {
char *str;
Patprog pat;
};
typedef int (*Hookfn) _((Hookdef, void *));
struct hookdef {
Hookdef next;
char *name;
Hookfn def;
int flags;
LinkList funcs;
};
#define HOOKF_ALL 1
#define HOOKDEF(name, func, flags) { NULL, name, (Hookfn) func, flags, NULL }
struct patprog {
long startoff;
long size;
long mustoff;
long patmlen;
int globflags;
int globend;
int flags;
int patnpar;
char patstartch;
};
#define PAT_FILE 0x0001
#define PAT_FILET 0x0002
#define PAT_ANY 0x0004
#define PAT_NOANCH 0x0008
#define PAT_NOGLD 0x0010
#define PAT_PURES 0x0020
#define PAT_STATIC 0x0040
#define PAT_SCAN 0x0080
#define PAT_ZDUP 0x0100
#define PAT_NOTSTART 0x0200
#define PAT_NOTEND 0x0400
#define PAT_HAS_EXCLUDP 0x0800
#define PAT_LCMATCHUC 0x1000
#define PP_FIRST 1
#define PP_ALPHA 1
#define PP_ALNUM 2
#define PP_ASCII 3
#define PP_BLANK 4
#define PP_CNTRL 5
#define PP_DIGIT 6
#define PP_GRAPH 7
#define PP_LOWER 8
#define PP_PRINT 9
#define PP_PUNCT 10
#define PP_SPACE 11
#define PP_UPPER 12
#define PP_XDIGIT 13
#define PP_IDENT 14
#define PP_IFS 15
#define PP_IFSSPACE 16
#define PP_WORD 17
#define PP_LAST 17
#define PP_UNKWN 18
#define PP_RANGE 19
#define GF_LCMATCHUC 0x0100
#define GF_IGNCASE 0x0200
#define GF_BACKREF 0x0400
#define GF_MATCHREF 0x0800
#define GF_MULTIBYTE 0x1000
#define dummy_patprog1 ((Patprog) 1)
#define dummy_patprog2 ((Patprog) 2)
typedef const struct gsu_scalar *GsuScalar;
typedef const struct gsu_integer *GsuInteger;
typedef const struct gsu_float *GsuFloat;
typedef const struct gsu_array *GsuArray;
typedef const struct gsu_hash *GsuHash;
struct gsu_scalar {
char *(*getfn) _((Param));
void (*setfn) _((Param, char *));
void (*unsetfn) _((Param, int));
};
struct gsu_integer {
zlong (*getfn) _((Param));
void (*setfn) _((Param, zlong));
void (*unsetfn) _((Param, int));
};
struct gsu_float {
double (*getfn) _((Param));
void (*setfn) _((Param, double));
void (*unsetfn) _((Param, int));
};
struct gsu_array {
char **(*getfn) _((Param));
void (*setfn) _((Param, char **));
void (*unsetfn) _((Param, int));
};
struct gsu_hash {
HashTable (*getfn) _((Param));
void (*setfn) _((Param, HashTable));
void (*unsetfn) _((Param, int));
};
struct param {
struct hashnode node;
union {
void *data;
char **arr;
char *str;
zlong val;
zlong *valptr;
double dval;
HashTable hash;
} u;
union {
GsuScalar s;
GsuInteger i;
GsuFloat f;
GsuArray a;
GsuHash h;
} gsu;
int base;
int width;
char *env;
char *ename;
Param old;
int level;
};
struct tieddata {
char ***arrptr;
int joinchar;
};
#define PM_SCALAR 0
#define PM_ARRAY (1<<0)
#define PM_INTEGER (1<<1)
#define PM_EFLOAT (1<<2)
#define PM_FFLOAT (1<<3)
#define PM_HASHED (1<<4)
#define PM_TYPE(X) \
(X & (PM_SCALAR|PM_INTEGER|PM_EFLOAT|PM_FFLOAT|PM_ARRAY|PM_HASHED))
#define PM_LEFT (1<<5)
#define PM_RIGHT_B (1<<6)
#define PM_RIGHT_Z (1<<7)
#define PM_LOWER (1<<8)
#define PM_UPPER (1<<9)
#define PM_UNDEFINED (1<<9)
#define PM_READONLY (1<<10)
#define PM_TAGGED (1<<11)
#define PM_EXPORTED (1<<12)
#define PM_UNIQUE (1<<13)
#define PM_UNALIASED (1<<13)
#define PM_HIDE (1<<14)
#define PM_HIDEVAL (1<<15)
#define PM_TIED (1<<16)
#define PM_KSHSTORED (1<<17)
#define PM_ZSHSTORED (1<<18)
#define PM_LOCAL (1<<21)
#define PM_SPECIAL (1<<22)
#define PM_DONTIMPORT (1<<23)
#define PM_RESTRICTED (1<<24)
#define PM_UNSET (1<<25)
#define PM_REMOVABLE (1<<26)
#define PM_AUTOLOAD (1<<27)
#define PM_NORESTORE (1<<28)
#define PM_AUTOALL (1<<28)
#define PM_HASHELEM (1<<29)
#define PM_NAMEDDIR (1<<30)
#define TYPESET_OPTSTR "aiEFALRZlurtxUhHTkz"
#define TYPESET_OPTNUM "LRZiEF"
#define SCANPM_WANTVALS (1<<0)
#define SCANPM_WANTKEYS (1<<1)
#define SCANPM_WANTINDEX (1<<2)
#define SCANPM_MATCHKEY (1<<3)
#define SCANPM_MATCHVAL (1<<4)
#define SCANPM_MATCHMANY (1<<5)
#define SCANPM_ASSIGNING (1<<6)
#define SCANPM_KEYMATCH (1<<7)
#define SCANPM_DQUOTED (1<<8)
#define SCANPM_ARRONLY (1<<9)
#define SCANPM_ISVAR_AT ((-1)<<15)
#define SUB_END 0x0001
#define SUB_LONG 0x0002
#define SUB_SUBSTR 0x0004
#define SUB_MATCH 0x0008
#define SUB_REST 0x0010
#define SUB_BIND 0x0020
#define SUB_EIND 0x0040
#define SUB_LEN 0x0080
#define SUB_ALL 0x0100
#define SUB_GLOBAL 0x0200
#define SUB_DOSUBST 0x0400
#define SUB_RETFAIL 0x0800
#define SUB_START 0x1000
#define SUB_LIST 0x2000
struct repldata {
int b, e;
char *replstr;
};
typedef struct repldata *Repldata;
enum {
ZSHTOK_SUBST = 0x0001,
ZSHTOK_SHGLOB = 0x0002
};
#define PF_TYPESET 0x01
#define PF_ASSIGN 0x02
#define PF_SINGLE 0x04
struct paramdef {
char *name;
int flags;
void *var;
const void *gsu;
GetNodeFunc getnfn;
ScanTabFunc scantfn;
Param pm;
};
#define PARAMDEF(name, flags, var, gsu) \
{ name, flags, (void *) var, (void *) gsu, \
NULL, NULL, NULL \
}
#define INTPARAMDEF(name, var) \
{ name, PM_INTEGER, (void *) var, NULL, NULL, NULL, NULL }
#define STRPARAMDEF(name, var) \
{ name, PM_SCALAR, (void *) var, NULL, NULL, NULL, NULL }
#define ARRPARAMDEF(name, var) \
{ name, PM_ARRAY, (void *) var, NULL, NULL, NULL, NULL }
#define SPECIALPMDEF(name, flags, gsufn, getfn, scanfn) \
{ name, flags | PM_SPECIAL | PM_HIDE | PM_HIDEVAL, \
NULL, gsufn, getfn, scanfn, NULL }
#define setsparam(S,V) assignsparam(S,V,0)
#define setaparam(S,V) assignaparam(S,V,0)
enum {
ASSPM_AUGMENT = 1 << 0,
ASSPM_WARN_CREATE = 1 << 1
};
struct nameddir {
struct hashnode node;
char *dir;
int diff;
};
#define ND_USERNAME (1<<1)
#define ND_NOABBREV (1<<2)
#define PRINT_NAMEONLY (1<<0)
#define PRINT_TYPE (1<<1)
#define PRINT_LIST (1<<2)
#define PRINT_KV_PAIR (1<<3)
#define PRINT_INCLUDEVALUE (1<<4)
#define PRINT_TYPESET (1<<5)
#define PRINT_WHENCE_CSH (1<<5)
#define PRINT_WHENCE_VERBOSE (1<<6)
#define PRINT_WHENCE_SIMPLE (1<<7)
#define PRINT_WHENCE_FUNCDEF (1<<9)
#define PRINT_WHENCE_WORD (1<<10)
enum loop_return {
LOOP_OK,
LOOP_EMPTY,
LOOP_ERROR
};
enum source_return {
SOURCE_OK = 0,
SOURCE_NOT_FOUND = 1,
SOURCE_ERROR = 2
};
struct histent {
struct hashnode node;
Histent up;
Histent down;
char *zle_text;
time_t stim;
time_t ftim;
short *words;
int nwords;
zlong histnum;
};
#define HIST_MAKEUNIQUE 0x00000001
#define HIST_OLD 0x00000002
#define HIST_READ 0x00000004
#define HIST_DUP 0x00000008
#define HIST_FOREIGN 0x00000010
#define HIST_TMPSTORE 0x00000020
#define GETHIST_UPWARD (-1)
#define GETHIST_DOWNWARD 1
#define GETHIST_EXACT 0
#define STOPHIST (stophist += 4);
#define ALLOWHIST (stophist -= 4);
#define HISTFLAG_DONE 1
#define HISTFLAG_NOEXEC 2
#define HISTFLAG_RECALL 4
#define HISTFLAG_SETTY 8
#define HFILE_APPEND 0x0001
#define HFILE_SKIPOLD 0x0002
#define HFILE_SKIPDUPS 0x0004
#define HFILE_SKIPFOREIGN 0x0008
#define HFILE_FAST 0x0010
#define HFILE_NO_REWRITE 0x0020
#define HFILE_USE_OPTIONS 0x8000
#define LEXFLAGS_ACTIVE 0x0001
#define LEXFLAGS_ZLE 0x0002
#define LEXFLAGS_COMMENTS_KEEP 0x0004
#define LEXFLAGS_COMMENTS_STRIP 0x0008
#define LEXFLAGS_COMMENTS (LEXFLAGS_COMMENTS_KEEP|LEXFLAGS_COMMENTS_STRIP)
#define LEXFLAGS_NEWLINE 0x0010
#define IN_NOTHING 0
#define IN_CMD 1
#define IN_MATH 2
#define IN_COND 3
#define IN_ENV 4
#define IN_PAR 5
#define EMULATE_CSH (1<<1)
#define EMULATE_KSH (1<<2)
#define EMULATE_SH (1<<3)
#define EMULATE_ZSH (1<<4)
#define EMULATION(X) (emulation & (X))
#define SHELL_EMULATION() (emulation & ((1<<5)-1))
#define EMULATE_FULLY (1<<5)
#define EMULATE_UNUSED (1<<6)
enum {
OPT_INVALID,
ALIASESOPT,
ALLEXPORT,
ALWAYSLASTPROMPT,
ALWAYSTOEND,
APPENDHISTORY,
AUTOCD,
AUTOCONTINUE,
AUTOLIST,
AUTOMENU,
AUTONAMEDIRS,
AUTOPARAMKEYS,
AUTOPARAMSLASH,
AUTOPUSHD,
AUTOREMOVESLASH,
AUTORESUME,
BADPATTERN,
BANGHIST,
BAREGLOBQUAL,
BASHAUTOLIST,
BASHREMATCH,
BEEP,
BGNICE,
BRACECCL,
BSDECHO,
CASEGLOB,
CASEMATCH,
CBASES,
CDABLEVARS,
CHASEDOTS,
CHASELINKS,
CHECKJOBS,
CLOBBER,
COMBININGCHARS,
COMPLETEALIASES,
COMPLETEINWORD,
CORRECT,
CORRECTALL,
CPRECEDENCES,
CSHJUNKIEHISTORY,
CSHJUNKIELOOPS,
CSHJUNKIEQUOTES,
CSHNULLCMD,
CSHNULLGLOB,
DEBUGBEFORECMD,
EMACSMODE,
EQUALS,
ERREXIT,
ERRRETURN,
EXECOPT,
EXTENDEDGLOB,
EXTENDEDHISTORY,
EVALLINENO,
FLOWCONTROL,
FUNCTIONARGZERO,
GLOBOPT,
GLOBALEXPORT,
GLOBALRCS,
GLOBASSIGN,
GLOBCOMPLETE,
GLOBDOTS,
GLOBSUBST,
HASHCMDS,
HASHDIRS,
HASHLISTALL,
HISTALLOWCLOBBER,
HISTBEEP,
HISTEXPIREDUPSFIRST,
HISTFCNTLLOCK,
HISTFINDNODUPS,
HISTIGNOREALLDUPS,
HISTIGNOREDUPS,
HISTIGNORESPACE,
HISTLEXWORDS,
HISTNOFUNCTIONS,
HISTNOSTORE,
HISTREDUCEBLANKS,
HISTSAVEBYCOPY,
HISTSAVENODUPS,
HISTSUBSTPATTERN,
HISTVERIFY,
HUP,
IGNOREBRACES,
IGNOREEOF,
INCAPPENDHISTORY,
INTERACTIVE,
INTERACTIVECOMMENTS,
KSHARRAYS,
KSHAUTOLOAD,
KSHGLOB,
KSHOPTIONPRINT,
KSHTYPESET,
KSHZEROSUBSCRIPT,
LISTAMBIGUOUS,
LISTBEEP,
LISTPACKED,
LISTROWSFIRST,
LISTTYPES,
LOCALOPTIONS,
LOCALTRAPS,
LOGINSHELL,
LONGLISTJOBS,
MAGICEQUALSUBST,
MAILWARNING,
MARKDIRS,
MENUCOMPLETE,
MONITOR,
MULTIBYTE,
MULTIFUNCDEF,
MULTIOS,
NOMATCH,
NOTIFY,
NULLGLOB,
NUMERICGLOBSORT,
OCTALZEROES,
OVERSTRIKE,
PATHDIRS,
PATHSCRIPT,
POSIXALIASES,
POSIXBUILTINS,
POSIXCD,
POSIXIDENTIFIERS,
POSIXJOBS,
POSIXSTRINGS,
POSIXTRAPS,
PRINTEIGHTBIT,
PRINTEXITVALUE,
PRIVILEGED,
PROMPTBANG,
PROMPTCR,
PROMPTPERCENT,
PROMPTSP,
PROMPTSUBST,
PUSHDIGNOREDUPS,
PUSHDMINUS,
PUSHDSILENT,
PUSHDTOHOME,
RCEXPANDPARAM,
RCQUOTES,
RCS,
RECEXACT,
REMATCHPCRE,
RESTRICTED,
RMSTARSILENT,
RMSTARWAIT,
SHAREHISTORY,
SHFILEEXPANSION,
SHGLOB,
SHINSTDIN,
SHNULLCMD,
SHOPTIONLETTERS,
SHORTLOOPS,
SHWORDSPLIT,
SINGLECOMMAND,
SINGLELINEZLE,
SOURCETRACE,
SUNKEYBOARDHACK,
TRANSIENTRPROMPT,
TRAPSASYNC,
TYPESETSILENT,
UNSET,
VERBOSE,
VIMODE,
WARNCREATEGLOBAL,
XTRACE,
USEZLE,
DVORAK,
OPT_SIZE
};
#undef isset
#define isset(X) (opts[X])
#define unset(X) (!opts[X])
#define interact (isset(INTERACTIVE))
#define jobbing (isset(MONITOR))
#define islogin (isset(LOGINSHELL))
struct ttyinfo {
#ifdef HAVE_TERMIOS_H
struct termios tio;
#else
# ifdef HAVE_TERMIO_H
struct termio tio;
# else
struct sgttyb sgttyb;
int lmodes;
struct tchars tchars;
struct ltchars ltchars;
# endif
#endif
#ifdef TIOCGWINSZ
struct winsize winsize;
#endif
};
#if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H)
#define SGTTYFLAG shttyinfo.tio.c_oflag
#else
#define SGTTYFLAG shttyinfo.sgttyb.sg_flags
#endif
# ifdef TAB3
#define SGTABTYPE TAB3
# else
# ifdef OXTABS
#define SGTABTYPE OXTABS
# else
# ifdef XTABS
#define SGTABTYPE XTABS
# endif
# endif
# endif
#define TERM_BAD 0x01
#define TERM_UNKNOWN 0x02
#define TERM_NOUP 0x04
#define TERM_SHORT 0x08
#define TERM_NARROW 0x10
#define TCCLEARSCREEN 0
#define TCLEFT 1
#define TCMULTLEFT 2
#define TCRIGHT 3
#define TCMULTRIGHT 4
#define TCUP 5
#define TCMULTUP 6
#define TCDOWN 7
#define TCMULTDOWN 8
#define TCDEL 9
#define TCMULTDEL 10
#define TCINS 11
#define TCMULTINS 12
#define TCCLEAREOD 13
#define TCCLEAREOL 14
#define TCINSLINE 15
#define TCDELLINE 16
#define TCNEXTTAB 17
#define TCBOLDFACEBEG 18
#define TCSTANDOUTBEG 19
#define TCUNDERLINEBEG 20
#define TCALLATTRSOFF 21
#define TCSTANDOUTEND 22
#define TCUNDERLINEEND 23
#define TCHORIZPOS 24
#define TCUPCURSOR 25
#define TCDOWNCURSOR 26
#define TCLEFTCURSOR 27
#define TCRIGHTCURSOR 28
#define TCSAVECURSOR 29
#define TCRESTRCURSOR 30
#define TCBACKSPACE 31
#define TCFGCOLOUR 32
#define TCBGCOLOUR 33
#define TC_COUNT 34
#define tccan(X) (tclen[X])
#define TXTBOLDFACE 0x0001
#define TXTSTANDOUT 0x0002
#define TXTUNDERLINE 0x0004
#define TXTFGCOLOUR 0x0008
#define TXTBGCOLOUR 0x0010
#define TXT_ATTR_ON_MASK 0x001F
#define txtisset(X) (txtattrmask & (X))
#define txtset(X) (txtattrmask |= (X))
#define txtunset(X) (txtattrmask &= ~(X))
#define TXTNOBOLDFACE 0x0020
#define TXTNOSTANDOUT 0x0040
#define TXTNOUNDERLINE 0x0080
#define TXTNOFGCOLOUR 0x0100
#define TXTNOBGCOLOUR 0x0200
#define TXT_ATTR_OFF_MASK 0x03E0
#define TXT_ATTR_OFF_ON_SHIFT 5
#define TXT_ATTR_OFF_FROM_ON(attr) \
(((attr) & TXT_ATTR_ON_MASK) << TXT_ATTR_OFF_ON_SHIFT)
#define TXT_ATTR_ON_FROM_OFF(attr) \
(((attr) & TXT_ATTR_OFF_MASK) >> TXT_ATTR_OFF_ON_SHIFT)
#define TXT_MULTIWORD_MASK 0x0400
#define TXT_ATTR_FG_COL_MASK 0x000FF000
#define TXT_ATTR_FG_COL_SHIFT (12)
#define TXT_ATTR_BG_COL_MASK 0x0FF00000
#define TXT_ATTR_BG_COL_SHIFT (20)
#define TXT_ATTR_FG_TERMCAP 0x10000000
#define TXT_ATTR_BG_TERMCAP 0x20000000
#define TXT_ATTR_ON_VALUES_MASK \
(TXT_ATTR_ON_MASK|TXT_ATTR_FG_COL_MASK|TXT_ATTR_BG_COL_MASK|\
TXT_ATTR_FG_TERMCAP|TXT_ATTR_BG_TERMCAP)
#define TXT_ATTR_FG_ON_MASK \
(TXTFGCOLOUR|TXT_ATTR_FG_COL_MASK|TXT_ATTR_FG_TERMCAP)
#define TXT_ATTR_BG_ON_MASK \
(TXTBGCOLOUR|TXT_ATTR_BG_COL_MASK|TXT_ATTR_BG_TERMCAP)
#define TXT_ATTR_COLOUR_ON_MASK \
(TXT_ATTR_FG_ON_MASK|TXT_ATTR_BG_ON_MASK)
#define txtchangeisset(T,X) ((T) & (X))
#define txtchangeget(T,A) (((T) & A ## _MASK) >> A ## _SHIFT)
#define txtchangeset(T, X, Y) ((void)(T && (*T |= (X), *T &= ~(Y))))
#define COL_SEQ_FG (0)
#define COL_SEQ_BG (1)
#define COL_SEQ_COUNT (2)
enum {
TSC_RAW = 0x0001,
TSC_PROMPT = 0x0002,
TSC_OUTPUT_MASK = 0x0003,
TSC_DIRTY = 0x0004
};
#define CMDSTACKSZ 256
#define CS_FOR 0
#define CS_WHILE 1
#define CS_REPEAT 2
#define CS_SELECT 3
#define CS_UNTIL 4
#define CS_IF 5
#define CS_IFTHEN 6
#define CS_ELSE 7
#define CS_ELIF 8
#define CS_MATH 9
#define CS_COND 10
#define CS_CMDOR 11
#define CS_CMDAND 12
#define CS_PIPE 13
#define CS_ERRPIPE 14
#define CS_FOREACH 15
#define CS_CASE 16
#define CS_FUNCDEF 17
#define CS_SUBSH 18
#define CS_CURSH 19
#define CS_ARRAY 20
#define CS_QUOTE 21
#define CS_DQUOTE 22
#define CS_BQUOTE 23
#define CS_CMDSUBST 24
#define CS_MATHSUBST 25
#define CS_ELIFTHEN 26
#define CS_HEREDOC 27
#define CS_HEREDOCD 28
#define CS_BRACE 29
#define CS_BRACEPAR 30
#define CS_ALWAYS 31
#define CS_COUNT 32
struct heapstack {
struct heapstack *next;
size_t used;
};
struct heap {
struct heap *next;
size_t size;
size_t used;
struct heapstack *sp;
#define arena(X) ((char *) (X) + sizeof(struct heap))
}
#if defined(PAD_64_BIT) && defined(__GNUC__)
__attribute__ ((aligned (8)))
#endif
;
# define NEWHEAPS(h) do { Heap _switch_oldheaps = h = new_heaps(); do
# define OLDHEAPS while (0); old_heaps(_switch_oldheaps); } while (0);
# define SWITCHHEAPS(o, h) do { o = switch_heaps(h); do
# define SWITCHBACKHEAPS(o) while (0); switch_heaps(o); } while (0);
#ifdef DEBUG
#define STRINGIFY_LITERAL(x) # x
#define STRINGIFY(x) STRINGIFY_LITERAL(x)
#define ERRMSG(x) (__FILE__ ":" STRINGIFY(__LINE__) ": " x)
# define DPUTS(X,Y) if (!(X)) {;} else dputs(ERRMSG(Y))
# define DPUTS1(X,Y,Z1) if (!(X)) {;} else dputs(ERRMSG(Y), Z1)
# define DPUTS2(X,Y,Z1,Z2) if (!(X)) {;} else dputs(ERRMSG(Y), Z1, Z2)
# define DPUTS3(X,Y,Z1,Z2,Z3) if (!(X)) {;} else dputs(ERRMSG(Y), Z1, Z2, Z3)
#else
# define DPUTS(X,Y)
# define DPUTS1(X,Y,Z1)
# define DPUTS2(X,Y,Z1,Z2)
# define DPUTS3(X,Y,Z1,Z2,Z3)
#endif
#define ZSIG_TRAPPED (1<<0)
#define ZSIG_IGNORED (1<<1)
#define ZSIG_FUNC (1<<2)
#define ZSIG_MASK (ZSIG_TRAPPED|ZSIG_IGNORED|ZSIG_FUNC)
#define ZSIG_ALIAS (1<<3)
#define ZSIG_SHIFT 4
enum trap_state {
TRAP_STATE_INACTIVE,
TRAP_STATE_PRIMED,
TRAP_STATE_FORCE_RETURN
};
#define IN_EVAL_TRAP() \
(intrap && !trapisfunc && traplocallevel == locallevel)
typedef int (*CompareFn) _((const void *, const void *));
enum {
SORTIT_ANYOLDHOW = 0,
SORTIT_IGNORING_CASE = 1,
SORTIT_NUMERICALLY = 2,
SORTIT_BACKWARDS = 4,
SORTIT_IGNORING_BACKSLASHES = 8,
SORTIT_SOMEHOW = 16,
};
struct sortelt {
char *orig;
const char *cmp;
int origlen;
int len;
};
typedef struct sortelt *SortElt;
enum {
CASMOD_NONE,
CASMOD_UPPER,
CASMOD_LOWER,
CASMOD_CAPS
};
enum {
GETKEY_OCTAL_ESC = (1 << 0),
GETKEY_EMACS = (1 << 1),
GETKEY_CTRL = (1 << 2),
GETKEY_BACKSLASH_C = (1 << 3),
GETKEY_DOLLAR_QUOTE = (1 << 4),
GETKEY_BACKSLASH_MINUS = (1 << 5),
GETKEY_SINGLE_CHAR = (1 << 6),
GETKEY_UPDATE_OFFSET = (1 << 7)
};
#define GETKEYS_ECHO (GETKEY_BACKSLASH_C)
#define GETKEYS_PRINTF_FMT (GETKEY_OCTAL_ESC|GETKEY_BACKSLASH_C)
#define GETKEYS_PRINTF_ARG (GETKEY_BACKSLASH_C)
#define GETKEYS_PRINT (GETKEY_OCTAL_ESC|GETKEY_BACKSLASH_C|GETKEY_EMACS)
#define GETKEYS_BINDKEY (GETKEY_OCTAL_ESC|GETKEY_EMACS|GETKEY_CTRL)
#define GETKEYS_DOLLARS_QUOTE (GETKEY_OCTAL_ESC|GETKEY_EMACS|GETKEY_DOLLAR_QUOTE)
#define GETKEYS_MATH \
(GETKEY_OCTAL_ESC|GETKEY_EMACS|GETKEY_CTRL|GETKEY_SINGLE_CHAR)
#define GETKEYS_SEP (GETKEY_OCTAL_ESC|GETKEY_EMACS)
#define GETKEYS_SUFFIX \
(GETKEY_OCTAL_ESC|GETKEY_EMACS|GETKEY_CTRL|GETKEY_BACKSLASH_MINUS)
#define ZLRF_HISTORY 0x01
#define ZLRF_NOSETTY 0x02
#define ZLRF_IGNOREEOF 0x04
enum {
ZLCON_LINE_START,
ZLCON_LINE_CONT,
ZLCON_SELECT,
ZLCON_VARED
};
typedef int (*CompctlReadFn) _((char *, char **, Options, char *));
typedef char * (*ZleEntryPoint)(int cmd, va_list ap);
enum {
ZLE_CMD_GET_LINE,
ZLE_CMD_READ,
ZLE_CMD_ADD_TO_LINE,
ZLE_CMD_TRASH,
ZLE_CMD_RESET_PROMPT,
ZLE_CMD_REFRESH,
ZLE_CMD_SET_KEYMAP,
ZLE_CMD_GET_KEY
};
#define EXITHOOK (zshhooks + 0)
#define BEFORETRAPHOOK (zshhooks + 1)
#define AFTERTRAPHOOK (zshhooks + 2)
#ifdef MULTIBYTE_SUPPORT
#define nicezputs(str, outs) (void)mb_niceformat((str), (outs), NULL, 0)
#define MB_METACHARINIT() mb_metacharinit()
typedef wint_t convchar_t;
#define MB_METACHARLENCONV(str, cp) mb_metacharlenconv((str), (cp))
#define MB_METACHARLEN(str) mb_metacharlenconv(str, NULL)
#define MB_METASTRLEN(str) mb_metastrlen(str, 0)
#define MB_METASTRWIDTH(str) mb_metastrlen(str, 1)
#define MB_METASTRLEN2(str, widthp) mb_metastrlen(str, widthp)
#ifdef BROKEN_WCWIDTH
#define WCWIDTH(wc) mk_wcwidth(wc)
#else
#define WCWIDTH(wc) wcwidth(wc)
#endif
#define WCWIDTH_WINT(wc) zwcwidth(wc)
#define MB_INCOMPLETE ((size_t)-2)
#define MB_INVALID ((size_t)-1)
#ifndef MB_CUR_MAX
#define MB_CUR_MAX 6
#endif
#define ZWC(c) L ## c
#define ZWS(s) L ## s
#ifdef BROKEN_WCWIDTH
#define IS_COMBINING(wc) (WCWIDTH(wc) == 0 && !iswcntrl(wc))
#else
#define IS_COMBINING(wc) (WCWIDTH(wc) == 0)
#endif
#define IS_BASECHAR(wc) (iswgraph(wc) && WCWIDTH(wc) > 0)
#else
#define MB_METACHARINIT()
typedef int convchar_t;
#define MB_METACHARLENCONV(str, cp) metacharlenconv((str), (cp))
#define MB_METACHARLEN(str) (*(str) == Meta ? 2 : 1)
#define MB_METASTRLEN(str) ztrlen(str)
#define MB_METASTRWIDTH(str) ztrlen(str)
#define MB_METASTRLEN2(str, widthp) ztrlen(str)
#define WCWIDTH_WINT(c) (1)
#define ZWC(c) c
#define ZWS(s) s
#endif