mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-10 12:40:58 +02:00
lexsave/lexrestore lexflags
add new LEXFLAGS_ZLE
This commit is contained in:
parent
eab4f9a83c
commit
ebcead7543
7 changed files with 33 additions and 23 deletions
|
@ -1,5 +1,10 @@
|
||||||
2010-12-14 Peter Stephenson <pws@csr.com>
|
2010-12-14 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 28529: Src/hist.c, Src/lex.c, Src/zsh.h, Src/Zle/compcore.c,
|
||||||
|
Src/Zle/compctl.c, Src/Zle/zle_tricky.c: save and restore
|
||||||
|
lexflags and separate out special word logic for ZLE by
|
||||||
|
adding new flag LEXFLAGS_ZLE.
|
||||||
|
|
||||||
* 28528: Doc/Zsh/expn.yo, Src/hist.c, Src/lex.c, Src/subst.c,
|
* 28528: Doc/Zsh/expn.yo, Src/hist.c, Src/lex.c, Src/subst.c,
|
||||||
Src/zsh.h, Src/Zle/compcore.c, Src/Zle/compctl.c,
|
Src/zsh.h, Src/Zle/compcore.c, Src/Zle/compctl.c,
|
||||||
Src/Zle/zle_tricky.c, Test/D04parameter.ztst: clear up use of
|
Src/Zle/zle_tricky.c, Test/D04parameter.ztst: clear up use of
|
||||||
|
@ -13950,5 +13955,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.5149 $
|
* $Revision: 1.5150 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
@ -1481,13 +1481,13 @@ set_comp_sep(void)
|
||||||
|
|
||||||
/* Put the string in the lexer buffer and call the lexer to *
|
/* Put the string in the lexer buffer and call the lexer to *
|
||||||
* get the words we have to expand. */
|
* get the words we have to expand. */
|
||||||
lexflags = LEXFLAGS_ACTIVE;
|
|
||||||
ocs = zlemetacs;
|
ocs = zlemetacs;
|
||||||
oll = zlemetall;
|
oll = zlemetall;
|
||||||
ol = zlemetaline;
|
ol = zlemetaline;
|
||||||
addedx = 1;
|
addedx = 1;
|
||||||
noerrs = 1;
|
noerrs = 1;
|
||||||
lexsave();
|
lexsave();
|
||||||
|
lexflags = LEXFLAGS_ZLE;
|
||||||
/*
|
/*
|
||||||
* tl is the length of the temporary string including
|
* tl is the length of the temporary string including
|
||||||
* the space at the start and the x at the cursor position,
|
* the space at the start and the x at the cursor position,
|
||||||
|
@ -1634,7 +1634,7 @@ set_comp_sep(void)
|
||||||
noaliases = ona;
|
noaliases = ona;
|
||||||
strinend();
|
strinend();
|
||||||
inpop();
|
inpop();
|
||||||
errflag = lexflags = 0;
|
errflag = 0;
|
||||||
noerrs = ne;
|
noerrs = ne;
|
||||||
lexrestore();
|
lexrestore();
|
||||||
wb = owb;
|
wb = owb;
|
||||||
|
|
|
@ -2789,10 +2789,10 @@ sep_comp_string(char *ss, char *s, int noffs)
|
||||||
|
|
||||||
/* Put the string in the lexer buffer and call the lexer to *
|
/* Put the string in the lexer buffer and call the lexer to *
|
||||||
* get the words we have to expand. */
|
* get the words we have to expand. */
|
||||||
lexflags = LEXFLAGS_ACTIVE;
|
|
||||||
addedx = 1;
|
addedx = 1;
|
||||||
noerrs = 1;
|
noerrs = 1;
|
||||||
lexsave();
|
lexsave();
|
||||||
|
lexflags = LEXFLAGS_ZLE;
|
||||||
tmp = (char *) zhalloc(tl = sl + 3 + strlen(s));
|
tmp = (char *) zhalloc(tl = sl + 3 + strlen(s));
|
||||||
strcpy(tmp, ss);
|
strcpy(tmp, ss);
|
||||||
tmp[sl] = ' ';
|
tmp[sl] = ' ';
|
||||||
|
@ -2843,7 +2843,7 @@ sep_comp_string(char *ss, char *s, int noffs)
|
||||||
noaliases = ona;
|
noaliases = ona;
|
||||||
strinend();
|
strinend();
|
||||||
inpop();
|
inpop();
|
||||||
errflag = lexflags = 0;
|
errflag = 0;
|
||||||
noerrs = ne;
|
noerrs = ne;
|
||||||
lexrestore();
|
lexrestore();
|
||||||
wb = owb;
|
wb = owb;
|
||||||
|
@ -3703,8 +3703,8 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
|
||||||
|
|
||||||
/* Put the string in the lexer buffer and call the lexer to *
|
/* Put the string in the lexer buffer and call the lexer to *
|
||||||
* get the words we have to expand. */
|
* get the words we have to expand. */
|
||||||
lexflags = LEXFLAGS_ACTIVE;
|
|
||||||
lexsave();
|
lexsave();
|
||||||
|
lexflags = LEXFLAGS_ZLE;
|
||||||
tmpbuf = (char *)zhalloc(strlen(cc->str) + 5);
|
tmpbuf = (char *)zhalloc(strlen(cc->str) + 5);
|
||||||
sprintf(tmpbuf, "foo %s", cc->str); /* KLUDGE! */
|
sprintf(tmpbuf, "foo %s", cc->str); /* KLUDGE! */
|
||||||
inpush(tmpbuf, 0, NULL);
|
inpush(tmpbuf, 0, NULL);
|
||||||
|
@ -3721,7 +3721,7 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
|
||||||
noaliases = ona;
|
noaliases = ona;
|
||||||
strinend();
|
strinend();
|
||||||
inpop();
|
inpop();
|
||||||
errflag = lexflags = 0;
|
errflag = 0;
|
||||||
lexrestore();
|
lexrestore();
|
||||||
/* Fine, now do full expansion. */
|
/* Fine, now do full expansion. */
|
||||||
prefork(foo, 0);
|
prefork(foo, 0);
|
||||||
|
|
|
@ -1140,9 +1140,9 @@ get_comp_string(void)
|
||||||
zsfree(varname);
|
zsfree(varname);
|
||||||
varname = NULL;
|
varname = NULL;
|
||||||
insubscr = 0;
|
insubscr = 0;
|
||||||
lexflags = LEXFLAGS_ACTIVE;
|
|
||||||
clwpos = -1;
|
clwpos = -1;
|
||||||
lexsave();
|
lexsave();
|
||||||
|
lexflags = LEXFLAGS_ZLE;
|
||||||
inpush(dupstrspace(linptr), 0, NULL);
|
inpush(dupstrspace(linptr), 0, NULL);
|
||||||
strinbeg(0);
|
strinbeg(0);
|
||||||
wordpos = tt0 = cp = rd = ins = oins = linarr = parct = ia = redirpos = 0;
|
wordpos = tt0 = cp = rd = ins = oins = linarr = parct = ia = redirpos = 0;
|
||||||
|
@ -2707,7 +2707,6 @@ doexpandhist(void)
|
||||||
noaliases = ona;
|
noaliases = ona;
|
||||||
strinend();
|
strinend();
|
||||||
inpop();
|
inpop();
|
||||||
lexflags = 0;
|
|
||||||
lexrestore();
|
lexrestore();
|
||||||
expanding = 0;
|
expanding = 0;
|
||||||
|
|
||||||
|
@ -2807,8 +2806,8 @@ getcurcmd(void)
|
||||||
int curlincmd;
|
int curlincmd;
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
|
|
||||||
lexflags = LEXFLAGS_ACTIVE;
|
|
||||||
lexsave();
|
lexsave();
|
||||||
|
lexflags = LEXFLAGS_ZLE;
|
||||||
metafy_line();
|
metafy_line();
|
||||||
inpush(dupstrspace(zlemetaline), 0, NULL);
|
inpush(dupstrspace(zlemetaline), 0, NULL);
|
||||||
strinbeg(1);
|
strinbeg(1);
|
||||||
|
@ -2829,7 +2828,7 @@ getcurcmd(void)
|
||||||
popheap();
|
popheap();
|
||||||
strinend();
|
strinend();
|
||||||
inpop();
|
inpop();
|
||||||
errflag = lexflags = 0;
|
errflag = 0;
|
||||||
unmetafy_line();
|
unmetafy_line();
|
||||||
lexrestore();
|
lexrestore();
|
||||||
|
|
||||||
|
|
11
Src/hist.c
11
Src/hist.c
|
@ -2897,11 +2897,9 @@ histfileIsLocked(void)
|
||||||
* If index is non-NULL, and input is from a string in ZLE, *index
|
* If index is non-NULL, and input is from a string in ZLE, *index
|
||||||
* is set to the position of the end of the current editor word.
|
* is set to the position of the end of the current editor word.
|
||||||
*
|
*
|
||||||
* comments is used if buf is non-NULL (i.e. this is not a string
|
* flags is passed directly to lexflags, see lex.c, except that
|
||||||
* from ZLE).
|
* we 'or' in the bit LEXFLAGS_ACTIVE to make sure the variable
|
||||||
* If it is 0, comments are not parsed; they are treated as ordinary words.
|
* is set.
|
||||||
* If it is 1, comments are treated as single strings, one per line.
|
|
||||||
* If it is 2, comments are removed.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -2909,7 +2907,7 @@ mod_export LinkList
|
||||||
bufferwords(LinkList list, char *buf, int *index, int flags)
|
bufferwords(LinkList list, char *buf, int *index, int flags)
|
||||||
{
|
{
|
||||||
int num = 0, cur = -1, got = 0, ne = noerrs;
|
int num = 0, cur = -1, got = 0, ne = noerrs;
|
||||||
int owb = wb, owe = we, oadx = addedx, ozp = lexflags, onc = nocomments;
|
int owb = wb, owe = we, oadx = addedx, onc = nocomments;
|
||||||
int ona = noaliases, ocs = zlemetacs, oll = zlemetall;
|
int ona = noaliases, ocs = zlemetacs, oll = zlemetall;
|
||||||
int forloop = 0, rcquotes = opts[RCQUOTES];
|
int forloop = 0, rcquotes = opts[RCQUOTES];
|
||||||
char *p, *addedspaceptr;
|
char *p, *addedspaceptr;
|
||||||
|
@ -3120,7 +3118,6 @@ bufferwords(LinkList list, char *buf, int *index, int flags)
|
||||||
strinend();
|
strinend();
|
||||||
inpop();
|
inpop();
|
||||||
errflag = 0;
|
errflag = 0;
|
||||||
lexflags = ozp;
|
|
||||||
nocomments = onc;
|
nocomments = onc;
|
||||||
noerrs = ne;
|
noerrs = ne;
|
||||||
lexrestore();
|
lexrestore();
|
||||||
|
|
|
@ -126,7 +126,7 @@ mod_export int noaliases;
|
||||||
* Note that although it is passed into the lexer as an input, the
|
* Note that although it is passed into the lexer as an input, the
|
||||||
* lexer can set it to zero after finding the word it's searching for.
|
* lexer can set it to zero after finding the word it's searching for.
|
||||||
* This only happens if the line being parsed actually does come from
|
* This only happens if the line being parsed actually does come from
|
||||||
* ZLE.
|
* ZLE, and hence the bit LEXFLAGS_ZLE is set.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -202,6 +202,7 @@ struct lexstack {
|
||||||
int isfirstch;
|
int isfirstch;
|
||||||
int histactive;
|
int histactive;
|
||||||
int histdone;
|
int histdone;
|
||||||
|
int lexflags;
|
||||||
int stophist;
|
int stophist;
|
||||||
int hlinesz;
|
int hlinesz;
|
||||||
char *hline;
|
char *hline;
|
||||||
|
@ -258,6 +259,7 @@ lexsave(void)
|
||||||
ls->isfirstch = isfirstch;
|
ls->isfirstch = isfirstch;
|
||||||
ls->histactive = histactive;
|
ls->histactive = histactive;
|
||||||
ls->histdone = histdone;
|
ls->histdone = histdone;
|
||||||
|
ls->lexflags = lexflags;
|
||||||
ls->stophist = stophist;
|
ls->stophist = stophist;
|
||||||
stophist = 0;
|
stophist = 0;
|
||||||
if (!lstack) {
|
if (!lstack) {
|
||||||
|
@ -332,6 +334,7 @@ lexrestore(void)
|
||||||
isfirstch = lstack->isfirstch;
|
isfirstch = lstack->isfirstch;
|
||||||
histactive = lstack->histactive;
|
histactive = lstack->histactive;
|
||||||
histdone = lstack->histdone;
|
histdone = lstack->histdone;
|
||||||
|
lexflags = lstack->lexflags;
|
||||||
stophist = lstack->stophist;
|
stophist = lstack->stophist;
|
||||||
chline = lstack->hline;
|
chline = lstack->hline;
|
||||||
hptr = lstack->hptr;
|
hptr = lstack->hptr;
|
||||||
|
@ -1804,7 +1807,7 @@ exalias(void)
|
||||||
} else
|
} else
|
||||||
zshlextext = tokstr;
|
zshlextext = tokstr;
|
||||||
|
|
||||||
if (lexflags && !(inbufflags & INP_ALIAS)) {
|
if ((lexflags & LEXFLAGS_ZLE) && !(inbufflags & INP_ALIAS)) {
|
||||||
int zp = lexflags;
|
int zp = lexflags;
|
||||||
|
|
||||||
gotword();
|
gotword();
|
||||||
|
|
12
Src/zsh.h
12
Src/zsh.h
|
@ -1834,14 +1834,20 @@ struct histent {
|
||||||
* has otherwise all the default effects.
|
* has otherwise all the default effects.
|
||||||
*/
|
*/
|
||||||
#define LEXFLAGS_ACTIVE 0x0001
|
#define LEXFLAGS_ACTIVE 0x0001
|
||||||
|
/*
|
||||||
|
* Being used from zle. This is slightly more intrusive
|
||||||
|
* (=> grotesquely non-modular) than use from within
|
||||||
|
* the main shell, so it's a separate flag.
|
||||||
|
*/
|
||||||
|
#define LEXFLAGS_ZLE 0x0002
|
||||||
/*
|
/*
|
||||||
* Parse comments and treat each comment as a single string
|
* Parse comments and treat each comment as a single string
|
||||||
*/
|
*/
|
||||||
#define LEXFLAGS_COMMENTS_KEEP 0x0002
|
#define LEXFLAGS_COMMENTS_KEEP 0x0004
|
||||||
/*
|
/*
|
||||||
* Parse comments and strip them.
|
* Parse comments and strip them.
|
||||||
*/
|
*/
|
||||||
#define LEXFLAGS_COMMENTS_STRIP 0x0004
|
#define LEXFLAGS_COMMENTS_STRIP 0x0008
|
||||||
/*
|
/*
|
||||||
* Either of the above
|
* Either of the above
|
||||||
*/
|
*/
|
||||||
|
@ -1849,7 +1855,7 @@ struct histent {
|
||||||
/*
|
/*
|
||||||
* Treat newlines as whitespace
|
* Treat newlines as whitespace
|
||||||
*/
|
*/
|
||||||
#define LEXFLAGS_NEWLINE 0x0008
|
#define LEXFLAGS_NEWLINE 0x0010
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* Definitions for programable completion */
|
/* Definitions for programable completion */
|
||||||
|
|
Loading…
Reference in a new issue