summaryrefslogtreecommitdiff
path: root/perly.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-12-07 21:53:37 -0700
committerKarl Williamson <khw@cpan.org>2014-12-09 11:43:32 -0700
commit100b2bb8398f189ce38052fd6f7138adebb1b995 (patch)
tree7f61f911e536807a22ecfde4d4ee9d82e60e808f /perly.c
parent239f83d5b3d443f78d6f2c12df7ff685f9bb7e65 (diff)
downloadperl-100b2bb8398f189ce38052fd6f7138adebb1b995.tar.gz
perly.c: Fix EBCDIC bug
The code was changing the value in a structure on EBCDIC platforms. It turns out that that structure element is used later under quite limited circumstances. The changed value is actually only needed during an array look-up, so we no longer store the change.
Diffstat (limited to 'perly.c')
-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);
}