diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-10-04 11:05:13 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-10-04 11:05:13 +0300 |
commit | 8111eca142100dd5a9e9fc11a29e750b0ccbe31a (patch) | |
tree | 31b600703dc306cc095359fc900ebb78691a0fbe /command.y | |
parent | 6d5c1e1d38f71fdfc1794b5b3723a6e476ffddf4 (diff) | |
parent | 97c4e427ab48d4e45889ca74abb0701a049d7606 (diff) | |
download | egawk-8111eca142100dd5a9e9fc11a29e750b0ccbe31a.tar.gz egawk-8111eca142100dd5a9e9fc11a29e750b0ccbe31a.tar.bz2 egawk-8111eca142100dd5a9e9fc11a29e750b0ccbe31a.zip |
Merge branch 'feature/zOS-try2' into gawk-4.1-stable
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 |