diff options
Diffstat (limited to 'Src/zsh.h')
-rw-r--r-- | Src/zsh.h | 120 |
1 files changed, 87 insertions, 33 deletions
diff --git a/Src/zsh.h b/Src/zsh.h index fe88efe69..7df5add86 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -238,6 +238,16 @@ struct mathfunc { #define PATCHARS "#^*()|[]<>?~\\" /* + * Check for a possibly tokenized dash. + * + * A dash only needs to be a token in a character range, [a-z], but + * it's difficult in general to ensure that. So it's turned into + * a token at the usual point in the lexer. However, we need + * to check for a literal dash at many points. + */ +#define IS_DASH(x) ((x) == '-' || (x) == Dash) + +/* * Types of quote. This is used in various places, so care needs * to be taken when changing them. (Oooh, don't you look surprised.) * - Passed to quotestring() to indicate style. This is the ultimate @@ -489,6 +499,7 @@ typedef struct complist *Complist; typedef struct conddef *Conddef; typedef struct dirsav *Dirsav; typedef struct emulation_options *Emulation_options; +typedef struct execcmd_params *Execcmd_params; typedef struct features *Features; typedef struct feature_enables *Feature_enables; typedef struct funcstack *Funcstack; @@ -622,27 +633,34 @@ struct timedfn { /* (1<<4) is used for Z_END, see the wordcode definitions */ /* (1<<5) is used for Z_SIMPLE, see the wordcode definitions */ -/* Condition types. */ +/* + * Condition types. + * + * Careful when changing these: both cond_binary_ops in text.c and + * condstr in cond.c depend on these. (The zsh motto is "two instances + * are better than one". Or something.) + */ #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 +#define COND_STRDEQ 4 +#define COND_STRNEQ 5 +#define COND_STRLT 6 +#define COND_STRGTR 7 +#define COND_NT 8 +#define COND_OT 9 +#define COND_EF 10 +#define COND_EQ 11 +#define COND_NE 12 +#define COND_LT 13 +#define COND_GT 14 +#define COND_LE 15 +#define COND_GE 16 +#define COND_REGEX 17 +#define COND_MOD 18 +#define COND_MODI 19 typedef int (*CondHandler) _((char **, int)); @@ -976,7 +994,8 @@ struct jobfile { struct job { pid_t gleader; /* process group leader of this job */ - pid_t other; /* subjob id or subshell pid */ + pid_t other; /* subjob id (SUPERJOB) + * or subshell pid (SUBJOB) */ int stat; /* see STATs below */ char *pwd; /* current working dir of shell when * * this job was spawned */ @@ -1008,6 +1027,8 @@ struct job { #define STAT_SUBLEADER (0x2000) /* is super-job, but leader is sub-shell */ #define STAT_BUILTIN (0x4000) /* job at tail of pipeline is a builtin */ +#define STAT_SUBJOB_ORPHANED (0x8000) + /* STAT_SUBJOB with STAT_SUPERJOB exited */ #define SP_RUNNING -1 /* fake status for jobs currently running */ @@ -1059,6 +1080,7 @@ struct execstack { int trapisfunc; int traplocallevel; int noerrs; + int this_noerrexit; char *underscore; }; @@ -1221,7 +1243,9 @@ struct cmdnam { struct shfunc { struct hashnode node; - char *filename; /* Name of file located in */ + char *filename; /* Name of file located in. + For not yet autoloaded file, name + of explicit directory, if not NULL. */ zlong lineno; /* line number in above file */ Eprog funcdef; /* function definition */ Eprog redir; /* redirections to apply */ @@ -1381,6 +1405,21 @@ struct builtin { */ #define BINF_ASSIGN (1<<19) +/** + * Parameters passed to execcmd(). + * These are not opaque --- they are also used by the pipeline manager. + */ +struct execcmd_params { + LinkList args; /* All command prefixes, arguments & options */ + LinkList redir; /* Redirections */ + Wordcode beg; /* The code at the start of the command */ + Wordcode varspc; /* The code for assignment parsed as such */ + Wordcode assignspc; /* The code for assignment parsed as typeset */ + int type; /* The WC_* type of the command */ + int postassigns; /* The number of assignspc assiguments */ + int htok; /* tokens in parameter list */ +}; + struct module { struct hashnode node; union { @@ -1502,6 +1541,7 @@ struct patstralloc { /* Flags used in pattern matchers (Patprog) and passed down to patcompile */ +#define PAT_HEAPDUP 0x0000 /* Dummy flag for default behavior */ #define PAT_FILE 0x0001 /* Pattern is a file name */ #define PAT_FILET 0x0002 /* Pattern is top level file, affects ~ */ #define PAT_ANY 0x0004 /* Match anything (cheap "*") */ @@ -1562,8 +1602,8 @@ struct zpc_disables_save { struct zpc_disables_save *next; /* * Bit vector of ZPC_COUNT disabled characters. - * We'll live dangerously and assumed ZPC_COUNT is no greater - * than the number of bits an an unsigned int. + * We'll live dangerously and assume ZPC_COUNT is no greater + * than the number of bits in an unsigned int. */ unsigned int disables; }; @@ -1778,6 +1818,7 @@ struct tieddata { #define PM_READONLY (1<<10) /* readonly */ #define PM_TAGGED (1<<11) /* tagged */ #define PM_EXPORTED (1<<12) /* exported */ +#define PM_ABSPATH_USED (1<<12) /* (function): loaded using absolute path */ /* The following are the same since they * * both represent -U option to typeset */ @@ -1785,7 +1826,9 @@ struct tieddata { #define PM_UNALIASED (1<<13) /* do not expand aliases when autoloading */ #define PM_HIDE (1<<14) /* Special behaviour hidden by local */ +#define PM_CUR_FPATH (1<<14) /* (function): can use $fpath with filename */ #define PM_HIDEVAL (1<<15) /* Value not shown in `typeset' commands */ +#define PM_WARNNESTED (1<<15) /* (function): non-recursive WARNNESTEDVAR */ #define PM_TIED (1<<16) /* array tied to colon-path or v.v. */ #define PM_TAGGED_LOCAL (1<<16) /* (function): non-recursive PM_TAGGED */ @@ -1795,6 +1838,9 @@ struct tieddata { #define PM_CHECKLEN (1<<20) /* cached length is checked */ /* Remaining flags do not correspond directly to command line arguments */ +#define PM_DONTIMPORT_SUID (1<<19) /* do not import if running setuid */ +#define PM_LOADDIR (1<<19) /* (function) filename gives load directory */ +#define PM_SINGLE (1<<20) /* special can only have a single instance */ #define PM_LOCAL (1<<21) /* this parameter will be made local */ #define PM_SPECIAL (1<<22) /* special builtin parameter */ #define PM_DONTIMPORT (1<<23) /* do not import this variable */ @@ -1986,9 +2032,15 @@ struct paramdef { * Flags for assignsparam and assignaparam. */ enum { + /* Add to rather than override value */ ASSPM_AUGMENT = 1 << 0, + /* Test for warning if creating global variable in function */ ASSPM_WARN_CREATE = 1 << 1, - ASSPM_ENV_IMPORT = 1 << 2 + /* Test for warning if using nested variable in function */ + ASSPM_WARN_NESTED = 1 << 2, + ASSPM_WARN = (ASSPM_WARN_CREATE|ASSPM_WARN_NESTED), + /* Import from environment, so exercise care evaluating value */ + ASSPM_ENV_IMPORT = 1 << 3, }; /* node for named directory hash table (nameddirtab) */ @@ -2196,6 +2248,7 @@ struct histent { enum { OPT_INVALID, ALIASESOPT, + ALIASFUNCDEF, ALLEXPORT, ALWAYSLASTPROMPT, ALWAYSTOEND, @@ -2369,6 +2422,7 @@ enum { VERBOSE, VIMODE, WARNCREATEGLOBAL, + WARNNESTEDVAR, XTRACE, USEZLE, DVORAK, @@ -2570,7 +2624,7 @@ struct ttyinfo { #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 txtchangeset(T, X, Y) ((void)(T && (*T &= ~(Y), *T |= (X)))) /* * For outputting sequences to change colour: specify foreground @@ -2802,7 +2856,14 @@ enum errflag_bits { /* * User interrupt. */ - ERRFLAG_INT = 2 + ERRFLAG_INT = 2, + /* + * Hard error --- return to top-level prompt in interactive + * shell. In non-interactive shell we'll typically already + * have exited. This is reset by "errflag = 0" in + * loop(toplevel = 1, ...). + */ + ERRFLAG_HARD = 4 }; /***********/ @@ -2873,6 +2934,7 @@ struct hist_stack { void (*addtoline) _((int)); unsigned char *cstack; int csp; + int curline_linked; }; /* @@ -3099,8 +3161,8 @@ typedef wint_t convchar_t; * much what the definition tells us. However, we happen to know this * works on MacOS which doesn't define that. */ -#if defined(BROKEN_WCWIDTH) && (defined(__STDC_ISO_10646__) || defined(__APPLE__)) -#define WCWIDTH(wc) mk_wcwidth(wc) +#ifdef ENABLE_UNICODE9 +#define WCWIDTH(wc) u9_wcwidth(wc) #else #define WCWIDTH(wc) wcwidth(wc) #endif @@ -3145,15 +3207,7 @@ typedef wint_t convchar_t; * sense throughout the shell. I am not aware of a way of * detecting the Unicode trait in standard libraries. */ -#ifdef BROKEN_WCWIDTH -/* - * We can't be quite sure the wcwidth we've provided is entirely - * in agreement with the system's, so be extra safe. - */ -#define IS_COMBINING(wc) (wc != 0 && WCWIDTH(wc) == 0 && !iswcntrl(wc)) -#else #define IS_COMBINING(wc) (wc != 0 && WCWIDTH(wc) == 0) -#endif /* * Test for the base of a combining character. * |