diff options
author | Norbert Preining <norbert@preining.info> | 2020-09-20 03:03:26 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-09-20 03:03:26 +0000 |
commit | 1f457376b478257b88d4a857f5ec1b6155442dd7 (patch) | |
tree | 2a06a60551dea362cf8cb0cb0ba66c78608717c4 /support/dktools/dk-t2l.c | |
parent | ac690ca29ad5bf8a5203a65fd6252f7b564f4727 (diff) |
CTAN sync 202009200303
Diffstat (limited to 'support/dktools/dk-t2l.c')
-rw-r--r-- | support/dktools/dk-t2l.c | 286 |
1 files changed, 175 insertions, 111 deletions
diff --git a/support/dktools/dk-t2l.c b/support/dktools/dk-t2l.c index 52ae36a00e..c064ca8124 100644 --- a/support/dktools/dk-t2l.c +++ b/support/dktools/dk-t2l.c @@ -1,36 +1,14 @@ /* - WARNING: This file was generated by dkct. - Changes you make here will be lost if dkct is run again! - You should modify the original source and run dkct on it. - Original source: dk-t2l.ctr +Copyright (C) 2015-2020, Dirk Krause +SPDX-License-Identifier: BSD-3-Clause */ /* -Copyright (C) 2015-2017, Dirk Krause - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above opyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. -* Neither the name of the author nor the names of contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + WARNING: This file was generated by the dkct program (see + http://dktools.sourceforge.net/ for details). + Changes you make here will be lost if dkct is run again! + You should modify the original source and run dkct on it. + Original source: dk-t2l.ctr */ @@ -111,6 +89,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "dk4vers.h" #include "dk4tsp32.h" #include "dk4uc2l.h" +#include "dk4uc2la.h" #include "dk4maidhdu.h" #include "dk4maidddu.h" #include "dk4maodh.h" @@ -118,6 +97,11 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "dk4mpl.h" #include "dk4strd.h" #include "dk4pathd.h" +#include "dk4strm.h" +#include "dk4strmf.h" +#include "dk4strmo32.h" + + #if DK4_CHAR_SIZE > 1 #if DK4_CHAR_SIZE == 2 @@ -127,12 +111,16 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "dk4ansi.h" #include "dk4utf8.h" #endif +#include "dk4unused.h" +#ifndef DK4WMAIN_H_INCLUDED +#include "dk4wmain.h" +#endif -#line 105 "dk-t2l.ctr" +#line 115 "dk-t2l.ctr" @@ -156,18 +144,19 @@ dkT("-l\t\t--line-feed\t\t\tWrite \\\\ sequence for newline."), dkT("-t\t\t--tabulator\t\t\tWrite LaTeX sequence for"), dkT("\t\t\t\t\t\ttabulators"), dkT("\t\t--verbose\t\t\tShow error message on SIGPIPE."), +dkT("\t\t--check\t\t\t\tSyntax check for all data files."), dkT(""), dkT("--help\t\t\t\t\t\tShow this short help text."), dkT("--manual\t\t\t\t\t*** SHOW FULL MANUAL. ***"), dkT("--version\t\t\t\t\tShow version information."), dkT("--license\t\t\t\t\tShow license information."), dkT(""), -dkT("http://dktools.sourceforge.net"), +dkT("http://sourceforge.net/p/dktools/wiki/dk-t2l/"), dkT(""), NULL -#line 138 "dk-t2l.ctr" +#line 149 "dk-t2l.ctr" }; @@ -180,7 +169,8 @@ dkT("This software uses code from the following projects, either directly or as" dkT("a library:"), dkT(""), dkT("dktools\t\tDirk Krause's tools and libraries."), -dkT("\t\tSee http://dktools.sourceforge.net/ for more information."), +dkT("\t\tSee http://sourceforge.net/p/dktools/wiki/Home/"), +dkT("\t\tfor more information."), #if DK4_HAVE_ZLIB_H dkT(""), dkT("zlib\t\tData compression library."), @@ -207,27 +197,27 @@ dkT(""), dkT("Redistribution and use in source and binary forms, with or without"), dkT("modification, are permitted provided that the following conditions are met:"), dkT(""), -dkT("* Redistributions of source code must retain the above copyright notice,"), -dkT(" this list of conditions and the following disclaimer."), -dkT("* Redistributions in binary form must reproduce the above copyright"), -dkT(" notice, this list of conditions and the following disclaimer in the"), -dkT(" documentation and/or other materials provided with the distribution."), -dkT("* Neither the name of the Dirk Krause nor the names of contributors may be"), -dkT(" used to endorse or promote products derived from this software without"), -dkT(" specific prior written permission."), +dkT("1. Redistributions of source code must retain the above copyright notice,"), +dkT(" this list of conditions and the following disclaimer."), +dkT("2. Redistributions in binary form must reproduce the above copyright"), +dkT(" notice, this list of conditions and the following disclaimer in the"), +dkT(" documentation and/or other materials provided with the distribution."), +dkT("3. Neither the name of the copyright holder nor the names of its"), +dkT(" contributors may be used to endorse or promote products derived from"), +dkT(" this software without specific prior written permission."), dkT(""), -dkT("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\""), -dkT("AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE"), -dkT("IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE"), -dkT("ARE DISCLAIMED."), -dkT(""), -dkT("IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,"), -dkT("INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,"), -dkT("BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,"), -dkT("DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY"), -dkT("OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING"), -dkT("NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,"), -dkT("EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."), +dkT("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"), +dkT("``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT"), +dkT("LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR"), +dkT("A PARTICULAR PURPOSE ARE DISCLAIMED."), +dkT("IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY"), +dkT("DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES"), +dkT("(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR"), +dkT("SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER"), +dkT("CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT"), +dkT("LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY"), +dkT("OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF"), +dkT("SUCH DAMAGE."), #if DK4_HAVE_ZLIB_H dkT(""), dkT(""), @@ -301,7 +291,7 @@ dkT(""), NULL -#line 270 "dk-t2l.ctr" +#line 282 "dk-t2l.ctr" }; @@ -321,7 +311,7 @@ static const char * const dk_t2l_kw8[] = { NULL -#line 288 "dk-t2l.ctr" +#line 300 "dk-t2l.ctr" }; @@ -350,10 +340,13 @@ dkT("\\"), /* 6 */ dkT("verbose"), +/* 7 */ +dkT("check"), + NULL -#line 325 "dk-t2l.ctr" +#line 341 "dk-t2l.ctr" }; @@ -460,7 +453,7 @@ dkT("\"!"), NULL -#line 405 "dk-t2l.ctr" +#line 421 "dk-t2l.ctr" }; @@ -483,7 +476,7 @@ static const dk4_option_specification_t dk_t2l_options[] = { /* Command line arguments are hexadecimal character numbers. */ - { dkT('x'), dkT("hex"), DK4_OPT_ARG_NONE }, + { dkT('h'), dkT("hex"), DK4_OPT_ARG_NONE }, /* Write recommendations about font encodings and packages. */ @@ -499,7 +492,11 @@ static const dk4_option_specification_t dk_t2l_options[] = { /* Verbose output. */ - { dkT('\0'), dkT("verbose"), DK4_OPT_ARG_NONE } + { dkT('\0'), dkT("verbose"), DK4_OPT_ARG_NONE }, + + /* Immediately load all data files for syntax check. + */ + { dkT('\0'), dkT("check"), DK4_OPT_ARG_NONE } }; @@ -576,13 +573,25 @@ static int dk_t2l_numeric = 0; /** Input encoding expected when processing stdin. */ -static int dk_t2l_i_std = DK4_FILE_ENCODING_ASCII; +static int dk_t2l_i_std = +#if DK4_ON_WINDOWS + DK4_FILE_ENCODING_WIN1252 +#else + DK4_FILE_ENCODING_PLAIN +#endif +; /** Input encoding expected when processing files. */ -static int dk_t2l_i_file = DK4_FILE_ENCODING_ASCII; +static int dk_t2l_i_file = +#if DK4_ON_WINDOWS + DK4_FILE_ENCODING_WIN1252 +#else + DK4_FILE_ENCODING_PLAIN +#endif +; @@ -639,6 +648,11 @@ static int dk_t2l_tabs = 0; static int dk_t2l_linef = 0; +/** Flag: Syntax check on all data files. +*/ +static int dk_t2l_synchk = 0; + + #ifdef SIGPIPE /** Indicator: SIGPIPE signal received. @@ -685,8 +699,9 @@ sig_pass_pointer(DK4_VOLATILE dk4_sig_atomic_t *ptr) */ static void -sig_handler_pipe(int signo) +sig_handler_pipe(int DK4_ARG_UNUSED(signo) ) { + DK4_UNUSED_ARG(signo) *sig_pass_pointer(&sig_had_pipe) = 1; } #endif @@ -696,8 +711,9 @@ sig_handler_pipe(int signo) */ static void -sig_handler_int(int signo) +sig_handler_int(int DK4_ARG_UNUSED(signo) ) { + DK4_UNUSED_ARG(signo) *sig_pass_pointer(&sig_had_int) = 1; } @@ -706,8 +722,9 @@ sig_handler_int(int signo) */ static void -sig_handler_term(int signo) +sig_handler_term(int DK4_ARG_UNUSED(signo) ) { + DK4_UNUSED_ARG(signo) *sig_pass_pointer(&sig_had_term) = 1; } @@ -731,10 +748,18 @@ sig_read_atomic(DK4_VOLATILE dk4_sig_atomic_t *ap) */ static int -sig_can_continue(int check_pipe) +sig_can_continue( +#ifdef SIGPIPE + int check_pipe +#else + int DK4_ARG_UNUSED(check_pipe) +#endif +) { int back = 1; -#ifdef SIGPIPE +#ifndef SIGPIPE + DK4_UNUSED_ARG(check_pipe) +#else if (0 != check_pipe) { if (0 != sig_read_atomic(&sig_had_pipe)) { back = 0; } } @@ -795,7 +820,7 @@ dk_t2l_process_options(void) } } else { -#line 738 "dk-t2l.ctr" +#line 786 "dk-t2l.ctr" /* ERROR: Failed to obtain option argument, bug! */ } } @@ -806,11 +831,14 @@ dk_t2l_process_options(void) dk_t2l_echo = 1; dk_t2l_numeric = 1; } - if (0 != dk4app_opt_is_set_short(app, dkT('x'), NULL)) { + if (0 != dk4app_opt_is_set_short(app, dkT('h'), NULL)) { dk_t2l_echo = 1; dk_t2l_numeric = 2; } - uc2l = dk4uc2l_open_from_app(app); + if (0 != dk4app_opt_is_set_long(app, dk_t2l_kwnl[7], NULL)) { + dk_t2l_synchk = 1; + } + uc2l = dk4uc2l_open_from_app_ex1(app, dk_t2l_synchk); if (NULL == uc2l) { back = 0; } @@ -914,9 +942,7 @@ dk_t2l_end_math_mode(void) static int dk_t2l_c32_after_cr_nl_check( - dk4_c32_t c, - dk4_text_stream_position_t *pos, - dk4_er_t *erp + dk4_c32_t c ) { dkChar buf[16*sizeof(dk4_um_t)]; @@ -946,12 +972,12 @@ dk_t2l_c32_after_cr_nl_check( dk_t2l_end_math_mode(); if (EOF == fputc(' ', stdout)) { output_error = 1; } } else { - lseq = dk4uc2l_find(uc2l, c, 0, app); + lseq = dk4uc2l_find_app(uc2l, c, 0, app); if (NULL != lseq) { dk_t2l_end_math_mode(); if (EOF == fputs(lseq, stdout)) { output_error = 1; } } else { - lseq = dk4uc2l_find(uc2l, c, 1, app); + lseq = dk4uc2l_find_app(uc2l, c, 1, app); if (NULL != lseq) { dk_t2l_begin_math_mode(); if (EOF == fputs(lseq, stdout)) { output_error = 1; } @@ -987,18 +1013,21 @@ dk_t2l_c32_after_cr_nl_check( static int dk_t2l_c32_handler( - void *obj, + void * DK4_ARG_UNUSED(obj), dk4_c32_t c, - dk4_text_stream_position_t *pos, - dk4_er_t *erp + dk4_text_stream_position_t * DK4_ARG_UNUSED(pos), + dk4_er_t * DK4_ARG_UNUSED(erp) ) { int back = DK4_TSP_RES_OK; + DK4_UNUSED_ARG(obj) + DK4_UNUSED_ARG(pos) + DK4_UNUSED_ARG(erp) if (dkC32(0x0A) == c) { /* For a newline clear CR and TXT flag, set NL flag. */ - back = dk_t2l_c32_after_cr_nl_check(c, pos, erp); + back = dk_t2l_c32_after_cr_nl_check(c); dk_t2l_lineno++; if ((dk4_um_t)0UL == dk_t2l_lineno) { /* ERROR: Overflow in line number counting */ @@ -1016,7 +1045,7 @@ dk_t2l_c32_handler( Otherwise simply set CR flag. */ if (0 != dk_t2l_last_cr) { - back = dk_t2l_c32_after_cr_nl_check(dkC32(0x0D), pos, erp); + back = dk_t2l_c32_after_cr_nl_check(dkC32(0x0D)); dk_t2l_lhtx = 1; dk_t2l_last_nl = 0; } else { @@ -1030,8 +1059,8 @@ dk_t2l_c32_handler( Reset NL and CR flag, set TXT flag. */ if (0 != dk_t2l_last_cr) { - back = dk_t2l_c32_after_cr_nl_check(dkC32(0x0D), pos, erp); - switch (dk_t2l_c32_after_cr_nl_check(c, pos, erp)) { + back = dk_t2l_c32_after_cr_nl_check(dkC32(0x0D)); + switch (dk_t2l_c32_after_cr_nl_check(c)) { case DK4_TSP_RES_FATAL: { back = DK4_TSP_RES_FATAL; } break; @@ -1042,7 +1071,7 @@ dk_t2l_c32_handler( } break; } } else { - back = dk_t2l_c32_after_cr_nl_check(c, pos, erp); + back = dk_t2l_c32_after_cr_nl_check(c); } dk_t2l_lhtx = 1; dk_t2l_last_nl = 0; @@ -1175,7 +1204,7 @@ dk_t2l_report_errors(dk4_er_t *er_en, dk4_er_t *er_pr) static void -dk_t2l_echo_hex(const dkChar *txt, int argno) +dk_t2l_echo_hex(const dkChar *txt) { const dkChar *endptr = NULL; dk4_um_t um = (dk4_um_t)0UL; @@ -1190,7 +1219,7 @@ dk_t2l_echo_hex(const dkChar *txt, int argno) ); if (0 != res) { if ((dk4_um_t)0xFFFFFFFFUL >= um) { - (void)dk_t2l_c32_after_cr_nl_check((dk4_c32_t)um, NULL, NULL); + (void)dk_t2l_c32_after_cr_nl_check((dk4_c32_t)um); } else { dk4app_log_3(app, dk_t2l_msg, dk_t2l_sz_msg, DK4_LL_ERROR, 28, 29, txt); } @@ -1204,7 +1233,7 @@ dk_t2l_echo_hex(const dkChar *txt, int argno) static void -dk_t2l_echo_numeric(const dkChar *txt, int argno) +dk_t2l_echo_numeric(const dkChar *txt) { const dkChar *endptr = NULL; dk4_um_t um = (dk4_um_t)0UL; @@ -1222,7 +1251,7 @@ dk_t2l_echo_numeric(const dkChar *txt, int argno) ); if (0 != res) { if ((dk4_um_t)0xFFFFFFFFUL >= um) { - (void)dk_t2l_c32_after_cr_nl_check((dk4_c32_t)um, NULL, NULL); + (void)dk_t2l_c32_after_cr_nl_check((dk4_c32_t)um); } else { dk4app_log_3(app, dk_t2l_msg, dk_t2l_sz_msg, DK4_LL_ERROR, 28, 29, txt); } @@ -1231,7 +1260,7 @@ dk_t2l_echo_numeric(const dkChar *txt, int argno) dk4app_log_3(app, dk_t2l_msg, dk_t2l_sz_msg, DK4_LL_ERROR, 30, 31, txt); } } else { - dk_t2l_echo_hex(&(txt[2]), argno); + dk_t2l_echo_hex(&(txt[2])); } } @@ -1253,7 +1282,7 @@ dk_t2l_echo_c32(const dkChar *txt, int argno) if (EOF == fputc(' ', stdout)) { output_error = 1; } } isfirst = 0; - (void)dk_t2l_c32_after_cr_nl_check(*(txt++), NULL, NULL); + (void)dk_t2l_c32_after_cr_nl_check(*(txt++)); } } @@ -1284,7 +1313,7 @@ dk_t2l_echo_utf16(const dkChar *txt, int argno) if (EOF == fputc(' ', stdout)) { output_error = 1; } } isfirst = 0; - (void)dk_t2l_c32_after_cr_nl_check(dk4utf16_get(&dec), NULL, NULL); + (void)dk_t2l_c32_after_cr_nl_check(dk4utf16_get(&dec)); } break; } } else { @@ -1319,7 +1348,7 @@ dk_t2l_echo_ascii(const dkChar *txt, int argno) } isfirst = 0; c32 = dkC32(0xFF) & ((dk4_c32_t)((unsigned char)(*(txt++)))); - (void)dk_t2l_c32_after_cr_nl_check(c32, NULL, NULL); + (void)dk_t2l_c32_after_cr_nl_check(c32); } } @@ -1349,7 +1378,7 @@ dk_t2l_echo_utf8(const dkChar *txt, int argno) if (EOF == fputc(' ', stdout)) { output_error = 1; } } isfirst = 0; - (void)dk_t2l_c32_after_cr_nl_check(dk4utf8_get(&dec), NULL, NULL); + (void)dk_t2l_c32_after_cr_nl_check(dk4utf8_get(&dec)); } break; } } else { @@ -1382,7 +1411,7 @@ dk_t2l_echo_ansi(const dkChar *txt, int argno) if (EOF == fputc(' ', stdout)) { output_error = 1; } } isfirst = 0; - (void)dk_t2l_c32_after_cr_nl_check(c32, NULL, NULL); + (void)dk_t2l_c32_after_cr_nl_check(c32); } else { /* !!!!! ERROR: Decoding */ exval = EXIT_FAILURE; @@ -1413,7 +1442,7 @@ dk_t2l_echo_text(const dkChar *txt, int argno) case DK4_ENCODING_UTF8 : { dk_t2l_echo_utf8(txt, argno); } break; - case DK4_ENCODING_ANSI : { + case DK4_ENCODING_WIN1252 : { dk_t2l_echo_ansi(txt, argno); } break; default : { @@ -1444,7 +1473,7 @@ dk_t2l_process_cmdline(void) for (i = 0; i < argc; i++) { xargv = dk4app_get_argv(app, i); if (NULL != xargv) { - dk_t2l_echo_hex(xargv, i); + dk_t2l_echo_hex(xargv); } } dk_t2l_end_math_mode(); @@ -1453,7 +1482,7 @@ dk_t2l_process_cmdline(void) for (i = 0; i < argc; i++) { xargv = dk4app_get_argv(app, i); if (NULL != xargv) { - dk_t2l_echo_numeric(xargv, i); + dk_t2l_echo_numeric(xargv); } } dk_t2l_end_math_mode(); @@ -1710,8 +1739,10 @@ static void dk_t2l_normal_run(void) { - int argc; - int i; + dk4_er_t er; + dk4_stream_t *wstrm; + int argc; + int i; if (0 != dk_t2l_process_options()) { exval = EXIT_SUCCESS; dk_t2l_output_start_page(); @@ -1724,16 +1755,31 @@ dk_t2l_normal_run(void) dk_t2l_process_filename(dk4app_get_argv(app, i)); } } else { - dk_t2l_process_stdin(); + if (0 == dk_t2l_synchk) { + dk_t2l_process_stdin(); + } } } dk_t2l_output_finish_page(); if (0 != dk4app_opt_is_set_short(app, dkT('r'), NULL)) { - dk4uc2l_recommendations(uc2l, stdout); + dk4error_init(&er); + wstrm = dk4stream_open_for_file(stdout, DK4_STREAM_WRITE, 0, 0, &er); + if (NULL != wstrm) { + dk4stream_set_output_encoding(wstrm, DK4_FILE_ENCODING_PLAIN); + dk4uc2l_recommendations(uc2l, wstrm, &er); + if (0 == dk4stream_close(wstrm, NULL)) { + /* ERROR: Incomplete output */ + dk4app_log_base1(app, DK4_LL_ERROR, 128); + } + } + else { + /* ERROR: Failed to create stream writer */ + dk4app_log_base1(app, DK4_LL_ERROR, 90); + } } if (0 != dk4uc2l_retrieve_errors(uc2l)) { -#line 1674 "dk-t2l.ctr" +#line 1743 "dk-t2l.ctr" /* ERROR: Probably incorrect output due to problems */ dk4app_log_1(app, dk_t2l_msg, dk_t2l_sz_msg, DK4_LL_ERROR, 11); exval = EXIT_FAILURE; @@ -1945,19 +1991,35 @@ int wmain(int argc, wchar_t *argv[]) int main(int argc, char *argv[]) #endif { + int silent = 0; int shp; -#line 1887 "dk-t2l.ctr" +#line 1957 "dk-t2l.ctr" -#line 1888 "dk-t2l.ctr" +#line 1958 "dk-t2l.ctr" +#if DK4_CHAR_SIZE > 1 + if (NULL != getenv("VIM")) { silent = 1; } + if (NULL != getenv("VIMRUNTIME")) { silent = 1; } +#endif +#if 0 dk4fput_initialize_stderr(); - app = dk4app_open_cmd( - argc, argv, dk_t2l_options, dk_t2l_sz_options, - dk_t2l_kwnl[0], DKT_VERSION_DK, - dk_t2l_kwnl[1], dk_t2l_help_text, dk_t2l_license_text - ); +#endif + if (0 != silent) { + app = dk4app_open_silent( + argc, argv, dk_t2l_options, dk_t2l_sz_options, + dk_t2l_kwnl[0], DKT_VERSION_DK, + dk_t2l_kwnl[1], dk_t2l_help_text, dk_t2l_license_text + ); + } + else { + app = dk4app_open_cmd( + argc, argv, dk_t2l_options, dk_t2l_sz_options, + dk_t2l_kwnl[0], DKT_VERSION_DK, + dk_t2l_kwnl[1], dk_t2l_help_text, dk_t2l_license_text + ); + } if (NULL != app) { dk_t2l_i_std = dk4app_get_stdin_encoding(app); dk_t2l_i_file = dk4app_get_file_in_encoding(app); @@ -2012,14 +2074,16 @@ int main(int argc, char *argv[]) if (0 != sig_read_atomic(&sig_had_pipe)) { exval = EXIT_FAILURE; } #endif if (0 != output_error) { exval = EXIT_FAILURE; } - fflush(stderr); - dk4fput_cleanup_stderr(); + if (0 == silent) { + fflush(stderr); + dk4fput_cleanup_stderr(); + } -#line 1951 "dk-t2l.ctr" +#line 2038 "dk-t2l.ctr" -#line 1952 "dk-t2l.ctr" +#line 2039 "dk-t2l.ctr" exit(exval); return exval; } |