diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-10-04 11:22:56 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-10-04 11:22:56 +0300 |
commit | 2626d04d332dd87d4e6e9effe943dd6aa3d21cac (patch) | |
tree | 705737cb3eda7b80afaec1c0b22c620491e212e0 /command.y | |
parent | b08964cd1db8da56e2a16cebde05d493d4f6ae1b (diff) | |
parent | d992c45de5c007fc28a8e0cafec81bb9308a342c (diff) | |
download | egawk-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.y | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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 |