aboutsummaryrefslogtreecommitdiffstats
path: root/command.y
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-10-04 11:22:56 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-10-04 11:22:56 +0300
commit2626d04d332dd87d4e6e9effe943dd6aa3d21cac (patch)
tree705737cb3eda7b80afaec1c0b22c620491e212e0 /command.y
parentb08964cd1db8da56e2a16cebde05d493d4f6ae1b (diff)
parentd992c45de5c007fc28a8e0cafec81bb9308a342c (diff)
downloadegawk-2626d04d332dd87d4e6e9effe943dd6aa3d21cac.tar.gz
egawk-2626d04d332dd87d4e6e9effe943dd6aa3d21cac.tar.bz2
egawk-2626d04d332dd87d4e6e9effe943dd6aa3d21cac.zip
Merge branch 'gawk-4.1-stable' (zOS updates included)
Diffstat (limited to 'command.y')
-rw-r--r--command.y37
1 files changed, 37 insertions, 0 deletions
diff --git a/command.y b/command.y
index bd5b4870..5ceec1f2 100644
--- a/command.y
+++ b/command.y
@@ -1022,7 +1022,11 @@ yyerror(const char *mesg, ...)
/* yylex --- read a command and turn it into tokens */
static int
+#ifdef USE_EBCDIC
+yylex_ebcdic(void)
+#else
yylex(void)
+#endif
{
static char *lexptr = NULL;
static char *lexend;
@@ -1298,6 +1302,39 @@ err:
return D_VARIABLE;
}
+/* Convert single-character tokens coming out of yylex() from EBCDIC to
+ ASCII values on-the-fly so that the parse tables need not be regenerated
+ for EBCDIC systems. */
+#ifdef USE_EBCDIC
+static int
+yylex(void)
+{
+ static char etoa_xlate[256];
+ static int do_etoa_init = 1;
+ int tok;
+
+ if (do_etoa_init)
+ {
+ for (tok = 0; tok < 256; tok++)
+ etoa_xlate[tok] = (char) tok;
+#ifdef HAVE___ETOA_L
+ /* IBM helpfully provides this function. */
+ __etoa_l(etoa_xlate, sizeof(etoa_xlate));
+#else
+# error "An EBCDIC-to-ASCII translation function is needed for this system"
+#endif
+ do_etoa_init = 0;
+ }
+
+ tok = yylex_ebcdic();
+
+ if (tok >= 0 && tok <= 0xFF)
+ tok = etoa_xlate[tok];
+
+ return tok;
+}
+#endif /* USE_EBCDIC */
+
/* find_argument --- find index in 'argtab' for a command option */
static int