From: Zoltan Hidvegi <hzoli@frontiernet.net>
To: hzoli@frontiernet.net (Zoltan Hidvegi)
Cc: mason@primenet.com.au, zsh-workers@math.gatech.edu
Subject: Re: 3.0.4 bug: wrong character in hungetc()
Date: Tue, 29 Jul 1997 03:30:49 -0400 (EDT) [thread overview]
Message-ID: <199707290730.DAA03258@hzoli.home> (raw)
In-Reply-To: <199707290642.CAA02532@hzoli.home> from Zoltan Hidvegi at "Jul 29, 97 02:42:02 am"
> > Heyla,
> > I might have missed this previously. Has this bug been dealt with?
> >
> > % while ( [[ $I bug 10 ]] ) ; do ; done
> > zsh: condition expected: bug
> > BUG: wrong character in hungetc()
> > BUG: wrong character in hungetc()
> > BUG: wrong character in hungetc()
>
> Here is the fix.
Well, this does not get the history right. Forget this lex.c patch, and
try this one instead.
Zoltan
*** Src/parse.c 1997/06/05 04:44:57 3.1.3.0
--- Src/parse.c 1997/07/29 07:29:47
***************
*** 34,39 ****
--- 34,40 ----
#define YYERROR { tok = LEXERR; return NULL; }
#define YYERRORV { tok = LEXERR; return; }
+ #define COND_ERROR(X,Y) do{zerr(X,Y,0);discard_input();YYERROR}while(0)
#define make_list() allocnode(N_LIST)
#define make_sublist() allocnode(N_SUBLIST)
***************
*** 104,121 ****
return NULL;
}
yyerror();
! errflag = 0;
! if (isnewlin <= 0) {
! /* Discard remaining stuff after a parse error. */
! int c;
!
! hwbegin(0);
! while ((c = hgetc()) != '\n' && !lexstop);
! if (c == '\n')
! hungetc('\n');
! hwend();
! }
! errflag = 1;
return NULL;
} else {
l->right = par_event();
--- 105,111 ----
return NULL;
}
yyerror();
! discard_input();
return NULL;
} else {
l->right = par_event();
***************
*** 1268,1277 ****
{
Cond n = (Cond) make_cond();
! if (a[0] != '-' || !a[1] || a[2]) {
! zerr("parse error: condition expected: %s", a, 0);
! return NULL;
! }
n->left = (void *) b;
n->type = a[1];
n->ntype = NT_SET(N_COND, 1, NT_STR, NT_STR, 0, 0);
--- 1258,1265 ----
{
Cond n = (Cond) make_cond();
! if (a[0] != '-' || !a[1] || a[2])
! COND_ERROR("parse error: condition expected: %s", a);
n->left = (void *) b;
n->type = a[1];
n->ntype = NT_SET(N_COND, 1, NT_STR, NT_STR, 0, 0);
***************
*** 1310,1322 ****
if ((t0 = get_cond_num(b + 1)) > -1)
n->type = t0 + COND_NT;
else
! zerr("unrecognized condition: %s", b, 0);
} else
! zerr("condition expected: %s", b, 0);
n->left = (void *) a;
n->right = (void *) c;
n->ntype = NT_SET(N_COND, 1, NT_STR, NT_STR, 0, 0);
return n;
}
/**/
--- 1298,1328 ----
if ((t0 = get_cond_num(b + 1)) > -1)
n->type = t0 + COND_NT;
else
! COND_ERROR("unrecognized condition: %s", b);
} else
! COND_ERROR("condition expected: %s", b);
n->left = (void *) a;
n->right = (void *) c;
n->ntype = NT_SET(N_COND, 1, NT_STR, NT_STR, 0, 0);
return n;
+ }
+
+ /**/
+ static void
+ discard_input(void)
+ {
+ errflag = 0;
+ if (isnewlin <= 0) {
+ /* Discard remaining stuff after a parse error. */
+ int c;
+
+ hwbegin(0);
+ while ((c = hgetc()) != '\n' && !lexstop);
+ if (c == '\n')
+ hungetc('\n');
+ hwend();
+ }
+ errflag = 1;
}
/**/
prev parent reply other threads:[~1997-07-29 7:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-07-24 12:19 Geoff Wing
1997-07-24 13:30 ` Andrej Borsenkow
1997-07-24 14:40 ` Geoff Wing
1997-07-29 6:42 ` Zoltan Hidvegi
1997-07-29 7:30 ` Zoltan Hidvegi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199707290730.DAA03258@hzoli.home \
--to=hzoli@frontiernet.net \
--cc=mason@primenet.com.au \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).