* 3.0.4 bug: wrong character in hungetc() @ 1997-07-24 12:19 Geoff Wing 1997-07-24 13:30 ` Andrej Borsenkow 1997-07-29 6:42 ` Zoltan Hidvegi 0 siblings, 2 replies; 5+ messages in thread From: Geoff Wing @ 1997-07-24 12:19 UTC (permalink / raw) To: zsh-workers 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() -- Geoff Wing [mason@primenet.com.au] Phone : +61-3-9818 2977 Technical Manager: PrimeNet Computer Consultants Facsimile: +61-3-9819 3788 Web: <URL:http://www.primenet.com.au/> Mobile : 0412 162 441 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 3.0.4 bug: wrong character in hungetc() 1997-07-24 12:19 3.0.4 bug: wrong character in hungetc() Geoff Wing @ 1997-07-24 13:30 ` Andrej Borsenkow 1997-07-24 14:40 ` Geoff Wing 1997-07-29 6:42 ` Zoltan Hidvegi 1 sibling, 1 reply; 5+ messages in thread From: Andrej Borsenkow @ 1997-07-24 13:30 UTC (permalink / raw) To: Geoff Wing; +Cc: zsh-workers On 24 Jul 1997, Geoff Wing wrote: > 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() > Hmmm ... My ZSH 3.0.4 doesn't say "BUG: wrong character in hungetc()", but acts somewhat strange: bor@itsmx1:~%> while ( [[ $I bug 10 ]] ) ; do ; done zsh: condition expected: bug Now UpArrow and bor@itsmx1:~%> while ( [[ $I bug 1 ^ where is the rest of string? I don't recall to use any patches for 3.0.4 greetings ------------------------------------------------------------------------- Andrej Borsenkow Fax: +7 (095) 252 01 05 SNI ITS Moscow Tel: +7 (095) 252 13 88 NERV: borsenkow.msk E-Mail: borsenkow.msk@sni.de ------------------------------------------------------------------------- ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 3.0.4 bug: wrong character in hungetc() 1997-07-24 13:30 ` Andrej Borsenkow @ 1997-07-24 14:40 ` Geoff Wing 0 siblings, 0 replies; 5+ messages in thread From: Geoff Wing @ 1997-07-24 14:40 UTC (permalink / raw) To: borsenkow.msk; +Cc: zsh-workers Andrej Borsenkow wrote about Re: 3.0.4 bug: wrong character in hungetc(): :On 24 Jul 1997, Geoff Wing wrote: :> 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() :Hmmm ... My ZSH 3.0.4 doesn't say "BUG: wrong character in hungetc()", but :acts somewhat strange: : :bor@itsmx1:~%> while ( [[ $I bug 10 ]] ) ; do ; done :zsh: condition expected: bug : Now UpArrow and :bor@itsmx1:~%> while ( [[ $I bug 1 : ^ where is the rest of string? One of the things I like least, and would probably require a big patch, is that when parsing fails or gets interrupted, eg. CTRL-C during spelling confirmation, the line only gets stored in history up to (approximately) where it got up to. :I don't recall to use any patches for 3.0.4 You're getting the same bug. "BUG:" lines don't appear unless you have the right debug define set, eg. via configure, and I presumed that most of us working on it would, like me, define them all. But it's good that you get reproduce it. It'll mean that most other people probably can too, which means we'll let them fix it :-) -- Geoff Wing [mason@primenet.com.au] Phone : +61-3-9818 2977 Technical Manager: PrimeNet Computer Consultants Facsimile: +61-3-9819 3788 Web: <URL:http://www.primenet.com.au/> Mobile : 0412 162 441 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 3.0.4 bug: wrong character in hungetc() 1997-07-24 12:19 3.0.4 bug: wrong character in hungetc() Geoff Wing 1997-07-24 13:30 ` Andrej Borsenkow @ 1997-07-29 6:42 ` Zoltan Hidvegi 1997-07-29 7:30 ` Zoltan Hidvegi 1 sibling, 1 reply; 5+ messages in thread From: Zoltan Hidvegi @ 1997-07-29 6:42 UTC (permalink / raw) To: mason; +Cc: zsh-workers > 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. Zoltan *** Src/lex.c 1997/06/06 06:13:24 3.1.3.1 --- Src/lex.c 1997/07/29 06:38:21 *************** *** 175,180 **** --- 175,183 ---- void yylex(void) { + if (errflag) + tok = LEXERR; + if (tok == LEXERR) return; do ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 3.0.4 bug: wrong character in hungetc() 1997-07-29 6:42 ` Zoltan Hidvegi @ 1997-07-29 7:30 ` Zoltan Hidvegi 0 siblings, 0 replies; 5+ messages in thread From: Zoltan Hidvegi @ 1997-07-29 7:30 UTC (permalink / raw) To: Zoltan Hidvegi; +Cc: mason, zsh-workers > > 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; } /**/ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1997-07-29 7:41 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1997-07-24 12:19 3.0.4 bug: wrong character in hungetc() 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
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).