X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=toke.c;h=dbb273a263ad9fa48afe7702deb2191007b5fe9a;hb=22239a37ce131e4f5341aee571f08aced283e16a;hp=00825b2e90c61a58beb19d0da80cbfc41d327d71;hpb=c277df42229d99fecbc76f5da53793a409ac66e1;p=p5sagit%2Fp5-mst-13.2.git diff --git a/toke.c b/toke.c index 00825b2..dbb273a 100644 --- a/toke.c +++ b/toke.c @@ -187,7 +187,7 @@ missingterm(char *s) char q; if (s) { char *nl = strrchr(s,'\n'); - if (nl) + if (nl) *nl = '\0'; } else if (multi_close < 32 || multi_close == 127) { @@ -219,6 +219,19 @@ depcom(void) deprecate("comma-less variable list"); } +#ifdef WIN32 + +static I32 +win32_textfilter(int idx, SV *sv, int maxlen) +{ + I32 count = FILTER_READ(idx+1, sv, maxlen); + if (count > 0 && !maxlen) + win32_strip_return(sv); + return count; +} +#endif + + void lex_start(SV *line) { @@ -487,7 +500,7 @@ force_next(I32 type) } static char * -force_word(register char *start, int token, int check_keyword, int allow_pack, int allow_tick) +force_word(register char *start, int token, int check_keyword, int allow_pack, int allow_initial_tick) { register char *s; STRLEN len; @@ -496,7 +509,7 @@ force_word(register char *start, int token, int check_keyword, int allow_pack, i s = start; if (isIDFIRST(*s) || (allow_pack && *s == ':') || - (allow_tick && *s == '\'') ) + (allow_initial_tick && *s == '\'') ) { s = scan_word(s, tokenbuf, sizeof tokenbuf, allow_pack, &len); if (check_keyword && keyword(tokenbuf, len)) @@ -1109,9 +1122,8 @@ filter_del(filter_t funcp) if (!rsfp_filters || AvFILL(rsfp_filters)<0) return; /* if filter is on top of stack (usual case) just pop it off */ - if (IoDIRP(FILTER_DATA(0)) == (void*)funcp){ - /* sv_free(av_pop(rsfp_filters)); */ - sv_free(av_shift(rsfp_filters)); + if (IoDIRP(FILTER_DATA(AvFILL(rsfp_filters))) == (void*)funcp){ + sv_free(av_pop(rsfp_filters)); return; } @@ -1159,6 +1171,7 @@ filter_read(int idx, SV *buf_sv, int maxlen) else return 0 ; /* end of file */ } + } return SvCUR(buf_sv); } @@ -1179,9 +1192,15 @@ filter_read(int idx, SV *buf_sv, int maxlen) return (*funcp)(idx, buf_sv, maxlen); } + static char * filter_gets(register SV *sv, register FILE *fp, STRLEN append) { +#ifdef WIN32FILTER + if (!rsfp_filters) { + filter_add(win32_textfilter,NULL); + } +#endif if (rsfp_filters) { if (!append) @@ -1193,7 +1212,6 @@ filter_gets(register SV *sv, register FILE *fp, STRLEN append) } else return (sv_gets(sv, fp, append)); - } @@ -1212,6 +1230,8 @@ yylex(void) register char *d; register I32 tmp; STRLEN len; + GV *gv = Nullgv; + GV **gvp = 0; if (pending_ident) { char pit = pending_ident; @@ -1227,10 +1247,10 @@ yylex(void) if (!strchr(tokenbuf,':')) { #ifdef USE_THREADS - /* Check for single character per-thread magicals */ + /* Check for single character per-thread SVs */ if (tokenbuf[0] == '$' && tokenbuf[2] == '\0' - && !isALPHA(tokenbuf[1]) /* Rule out obvious non-magicals */ - && (tmp = find_thread_magical(&tokenbuf[1])) != NOT_IN_PAD) + && !isALPHA(tokenbuf[1]) /* Rule out obvious non-threadsvs */ + && (tmp = find_threadsv(&tokenbuf[1])) != NOT_IN_PAD) { yylval.opval = newOP(OP_THREADSV, 0); yylval.opval->op_targ = tmp; @@ -1374,7 +1394,7 @@ yylex(void) force_next(','); #ifdef USE_THREADS nextval[nexttoke].opval = newOP(OP_THREADSV, 0); - nextval[nexttoke].opval->op_targ = find_thread_magical("\""); + nextval[nexttoke].opval->op_targ = find_threadsv("\""); force_next(PRIVATEREF); #else force_ident("\"", '$'); @@ -1724,9 +1744,11 @@ yylex(void) } goto retry; case '\r': +#ifndef WIN32CHEAT warn("Illegal character \\%03o (carriage return)", '\r'); croak( "(Maybe you didn't strip carriage returns after a network transfer?)\n"); +#endif case ' ': case '\t': case '\f': case 013: s++; goto retry; @@ -2525,8 +2547,8 @@ yylex(void) case 'z': case 'Z': keylookup: { - GV *gv = Nullgv; - GV **gvp = 0; + gv = Nullgv; + gvp = 0; bufptr = s; s = scan_word(s, tokenbuf, sizeof tokenbuf, FALSE, &len); @@ -3520,7 +3542,7 @@ yylex(void) if (*s == ';' || *s == ')') /* probably a close */ croak("sort is now a reserved word"); expect = XTERM; - s = force_word(s,WORD,TRUE,TRUE,TRUE); + s = force_word(s,WORD,TRUE,TRUE,FALSE); LOP(OP_SORT,XREF); case KEY_split: @@ -5361,3 +5383,4 @@ yyerror(char *s) return 0; } +