diff --git a/src/CHANGELOG b/src/CHANGELOG index dbf2dc02e..ea3601632 100755 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -59,6 +59,11 @@ ECL 12.2.2: translate the input/output to and from the corresponding codepage. (EXPERIMENTAL) + - ECL detects the codepage that the console is using and applies it as + the appropriate external format (with :CRLF convention). + + - ECL's console stream signals EOF when Ctrl-Z is detected. + * Metaobject protocol: - Implemented CLOS:COMPUTE-APPLICABLE-METHODS-USING-CLASSES. diff --git a/src/c/alloc_2.d b/src/c/alloc_2.d old mode 100755 new mode 100644 diff --git a/src/c/file.d b/src/c/file.d old mode 100755 new mode 100644 index f30cb791d..b1f32d78a --- a/src/c/file.d +++ b/src/c/file.d @@ -3997,7 +3997,7 @@ maybe_make_windows_console_fd(cl_object fname, int desc, enum ecl_smmode smm, external_format); output->stream.eof_char = CONTROL_Z; } else { - output = ecl_make_stream_from_fd + output = ecl_make_file_stream_from_fd (fname, desc, smm, byte_size, flags, external_format); diff --git a/src/c/load.d b/src/c/load.d old mode 100755 new mode 100644 diff --git a/src/c/main.d b/src/c/main.d index 29197a461..351d11eae 100644 --- a/src/c/main.d +++ b/src/c/main.d @@ -439,6 +439,50 @@ struct cl_core_struct cl_core = { Cnil /* known_signals */ }; +#if !defined(ECL_MS_WINDOWS_HOST) +#define maybe_fix_console_stream(strm) (void)0 +#else +static void +maybe_fix_console_stream(cl_object stream) +{ + DWORD cp = GetConsoleCP(); + const char *encoding; + cl_object external_format; + int i; + static const struct { + int code; + const char *name; + } known_cp[] = { + {874, "WINDOWS-CP874"}, + {932, "WINDOWS-CP932"}, + {936, "WINDOWS-CP936"}, + {949, "WINDOWS-CP949"}, + {950, "WINDOWS-CP950"}, + {1200, "WINDOWS-CP1200"}, + {1201, "WINDOWS-CP1201"}, + {1250, "WINDOWS-CP1250"}, + {1251, "WINDOWS-CP1251"}, + {1252, "WINDOWS-CP1252"}, + {1253, "WINDOWS-CP1253"}, + {1254, "WINDOWS-CP1254"}, + {1255, "WINDOWS-CP1255"}, + {1256, "WINDOWS-CP1256"}, + {1257, "WINDOWS-CP1257"}, + {1258, "WINDOWS-CP1258"}, + {65001, "UTF8"}, + {0,"LATIN-1"} + }; + if (stream->stream.mode != smm_io_wcon) + return; + for (i = 0; known_cp[i].code && known_cp[i].code != cp; i++) + {} + external_format = cl_list(2, ecl_make_keyword(known_cp[i].name), + @':crlf'); + si_stream_external_format_set(stream, external_format); + stream->stream.eof_char = 26; +} +#endif + int cl_boot(int argc, char **argv) { @@ -727,6 +771,12 @@ cl_boot(int argc, char **argv) ecl_init_module(OBJNULL,init_lib_LSP); + if (cl_fboundp(@'ext::make-encoding') != Cnil) { + maybe_fix_console_stream(cl_core.standard_input); + maybe_fix_console_stream(cl_core.standard_output); + maybe_fix_console_stream(cl_core.error_output); + } + /* Jump to top level */ ECL_SET(@'*package*', cl_core.user_package); init_unixint(1); diff --git a/src/c/time.d b/src/c/time.d old mode 100755 new mode 100644 diff --git a/src/c/unixfsys.d b/src/c/unixfsys.d old mode 100755 new mode 100644 diff --git a/src/c/unixint.d b/src/c/unixint.d old mode 100755 new mode 100644 diff --git a/src/c/unixsys.d b/src/c/unixsys.d old mode 100755 new mode 100644