summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--perly.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/perly.c b/perly.c
index 44d6ce68e4..f3243d45c7 100644
--- a/perly.c
+++ b/perly.c
@@ -320,15 +320,6 @@ Perl_yyparse (pTHX_ int gramtype)
if (parser->yychar == YYEMPTY) {
YYDPRINTF ((Perl_debug_log, "Reading a token: "));
parser->yychar = yylex();
-
-/* perly.tab is shipped based on an ASCII system; if it were to be regenerated
- * on a platform that doesn't use ASCII, this translation back would need to be
- * removed */
-# ifdef EBCDIC
- if (parser->yychar >= 0) {
- parser->yychar = NATIVE_TO_UNI(parser->yychar);
- }
-# endif
}
if (parser->yychar <= YYEOF) {
@@ -336,7 +327,16 @@ Perl_yyparse (pTHX_ int gramtype)
YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
}
else {
- yytoken = YYTRANSLATE (parser->yychar);
+ /* perly.tab is shipped based on an ASCII system, so need to index it
+ * with characters translated to ASCII. Although it's not designed for
+ * this purpose, we can use NATIVE_TO_UNI here. It returns its
+ * argument on ASCII platforms, and on EBCDIC translates native to
+ * ascii in the 0-255 range, leaving everything else unchanged. This
+ * jibes with yylex() returning some bare characters in that range, but
+ * all tokens it returns are either 0, or above 255. There could be a
+ * problem if NULs weren't 0, or were ever returned as raw chars by
+ * yylex() */
+ yytoken = YYTRANSLATE (NATIVE_TO_UNI(parser->yychar));
YYDSYMPRINTF ("Next token is", yytoken, &parser->yylval);
}