aboutsummaryrefslogtreecommitdiffstats
path: root/command.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-10-04 11:25:17 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-10-04 11:25:17 +0300
commitad122d8fe3acb4cde689f2995f8505eef73f0a35 (patch)
treee9f930c934fc6b32f902aa76b4d2859b0b55f21d /command.c
parent588f4f5b2808c1b3cadff6c1c26c9b1d5c70b918 (diff)
parent2626d04d332dd87d4e6e9effe943dd6aa3d21cac (diff)
downloadegawk-ad122d8fe3acb4cde689f2995f8505eef73f0a35.tar.gz
egawk-ad122d8fe3acb4cde689f2995f8505eef73f0a35.tar.bz2
egawk-ad122d8fe3acb4cde689f2995f8505eef73f0a35.zip
Merge branch 'master' into feature/cmake
Diffstat (limited to 'command.c')
-rw-r--r--command.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/command.c b/command.c
index b23b21c5..763055f0 100644
--- a/command.c
+++ b/command.c
@@ -2773,7 +2773,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;
@@ -3049,6 +3053,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