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-t2h.c | |
parent | ac690ca29ad5bf8a5203a65fd6252f7b564f4727 (diff) |
CTAN sync 202009200303
Diffstat (limited to 'support/dktools/dk-t2h.c')
-rw-r--r-- | support/dktools/dk-t2h.c | 234 |
1 files changed, 131 insertions, 103 deletions
diff --git a/support/dktools/dk-t2h.c b/support/dktools/dk-t2h.c index 89c0b64e03..b5e2f81146 100644 --- a/support/dktools/dk-t2h.c +++ b/support/dktools/dk-t2h.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-t2h.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-t2h.ctr */ @@ -124,12 +102,16 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "dk4mpl.h" #include "dk4strd.h" #include "dk4pathd.h" +#include "dk4unused.h" +#ifndef DK4WMAIN_H_INCLUDED +#include "dk4wmain.h" +#endif -#line 102 "dk-t2h.ctr" +#line 106 "dk-t2h.ctr" @@ -154,12 +136,12 @@ 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-t2h/"), dkT(""), NULL -#line 130 "dk-t2h.ctr" +#line 134 "dk-t2h.ctr" }; @@ -172,7 +154,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."), @@ -199,27 +182,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(""), @@ -293,7 +276,7 @@ dkT(""), NULL -#line 262 "dk-t2h.ctr" +#line 267 "dk-t2h.ctr" }; @@ -325,7 +308,7 @@ dkT("verbose"), NULL -#line 299 "dk-t2h.ctr" +#line 304 "dk-t2h.ctr" }; @@ -417,7 +400,7 @@ dkT("Further processing failures!"), NULL -#line 374 "dk-t2h.ctr" +#line 379 "dk-t2h.ctr" }; @@ -435,7 +418,7 @@ static const char * const dk_t2h_kw8[] = { "<head>\n", /* 3 */ -"<meta name=\"generator\" content=\"dk-t2h, see http://dktools.sourceforge.net\">\n", +"<meta name=\"generator\" content=\"dk-t2h, see http://sourceforge.net/p/dktools/wiki/dk-t2h/\">\n", /* 4 */ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=us-ascii\">\n", @@ -569,7 +552,7 @@ static const char * const dk_t2h_kw8[] = { NULL -#line 457 "dk-t2h.ctr" +#line 462 "dk-t2h.ctr" }; @@ -924,13 +907,25 @@ static int dk_t2h_code = 0; /** Input encoding expected when processing stdin. */ -static int dk_t2h_i_std = DK4_FILE_ENCODING_ASCII; +static int dk_t2h_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_t2h_i_file = DK4_FILE_ENCODING_ASCII; +static int dk_t2h_i_file = +#if DK4_ON_WINDOWS + DK4_FILE_ENCODING_WIN1252 +#else + DK4_FILE_ENCODING_PLAIN +#endif +; @@ -1016,8 +1011,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 @@ -1027,8 +1023,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; } @@ -1037,8 +1034,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; } @@ -1062,10 +1060,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; } } @@ -1119,7 +1125,7 @@ dk_t2h_process_options(void) } } else { -#line 1005 "dk-t2h.ctr" +#line 1033 "dk-t2h.ctr" /* ERROR: Failed to obtain option argument, bug! */ } } @@ -1168,16 +1174,16 @@ dk_t2h_c32_after_cr_nl_check( int done = 0; -#line 1052 "dk-t2h.ctr" +#line 1080 "dk-t2h.ctr" if (dkC32(0x0A) == c) { -#line 1053 "dk-t2h.ctr" +#line 1081 "dk-t2h.ctr" /* Newline, finish line and write newline to output. */ if (0 != dk_t2h_code) { -#line 1057 "dk-t2h.ctr" +#line 1085 "dk-t2h.ctr" if (0 == dk_t2h_lhtx) { if (EOF == fputs(dk_t2h_kw8[42], stdout)) { output_error = 1; } res = dk4ma_write_c8_decimal_unsigned( @@ -1195,26 +1201,26 @@ dk_t2h_c32_after_cr_nl_check( } if (0 != dk_t2h_lhtx) { -#line 1073 "dk-t2h.ctr" +#line 1101 "dk-t2h.ctr" if (EOF == fputs(dk_t2h_kw8[44], stdout)) { output_error = 1; } } else { -#line 1075 "dk-t2h.ctr" +#line 1103 "dk-t2h.ctr" } } else { -#line 1077 "dk-t2h.ctr" +#line 1105 "dk-t2h.ctr" } if (EOF == fputc('\n', stdout)) { output_error = 1; } } else { -#line 1080 "dk-t2h.ctr" +#line 1108 "dk-t2h.ctr" if (0 != dk_t2h_code) { -#line 1081 "dk-t2h.ctr" +#line 1109 "dk-t2h.ctr" if (0 == dk_t2h_lhtx) { -#line 1082 "dk-t2h.ctr" +#line 1110 "dk-t2h.ctr" /* Start new line. */ @@ -1233,11 +1239,11 @@ dk_t2h_c32_after_cr_nl_check( dk_t2h_lhtx = 1; } else { -#line 1099 "dk-t2h.ctr" +#line 1127 "dk-t2h.ctr" } } else { -#line 1101 "dk-t2h.ctr" +#line 1129 "dk-t2h.ctr" } /* Write character to output. @@ -1272,7 +1278,7 @@ dk_t2h_c32_after_cr_nl_check( } } -#line 1134 "dk-t2h.ctr" +#line 1162 "dk-t2h.ctr" return back; } @@ -1457,7 +1463,7 @@ dk_t2h_output_dkstring(const dkChar *str) case DK4_FILE_ENCODING_UTF8 : { dk_t2h_output_utf8(str); } break; - case DK4_FILE_ENCODING_ANSI : { + case DK4_FILE_ENCODING_WIN1252 : { dk_t2h_output_ansi(str); } break; default : { @@ -1522,7 +1528,7 @@ dk_t2h_output_start_file(void) { -#line 1382 "dk-t2h.ctr" +#line 1410 "dk-t2h.ctr" /* No errors in this file yet. */ dk_t2h_dec_err = 0; @@ -1535,20 +1541,20 @@ dk_t2h_output_start_file(void) dk4app_set_log_source_line(app, dk_t2h_lineno); if (0 != dk_t2h_full) { -#line 1393 "dk-t2h.ctr" +#line 1421 "dk-t2h.ctr" if (0 != dk_t2h_code) { -#line 1394 "dk-t2h.ctr" +#line 1422 "dk-t2h.ctr" if (EOF == fputs(dk_t2h_kw8[40], stdout)) { output_error = 1; } } else { -#line 1396 "dk-t2h.ctr" +#line 1424 "dk-t2h.ctr" if (EOF == fputs(dk_t2h_kw8[38], stdout)) { output_error = 1; } } } -#line 1400 "dk-t2h.ctr" +#line 1428 "dk-t2h.ctr" } @@ -1561,23 +1567,23 @@ dk_t2h_output_finish_file(void) { -#line 1411 "dk-t2h.ctr" +#line 1439 "dk-t2h.ctr" if (0 != dk_t2h_full) { -#line 1412 "dk-t2h.ctr" +#line 1440 "dk-t2h.ctr" if (0 != dk_t2h_code) { -#line 1413 "dk-t2h.ctr" +#line 1441 "dk-t2h.ctr" if (EOF == fputs(dk_t2h_kw8[41], stdout)) { output_error = 1; } } else { -#line 1415 "dk-t2h.ctr" +#line 1443 "dk-t2h.ctr" if (EOF == fputs(dk_t2h_kw8[39], stdout)) { output_error = 1; } } } -#line 1419 "dk-t2h.ctr" +#line 1447 "dk-t2h.ctr" } @@ -1596,13 +1602,17 @@ dk_t2h_output_finish_file(void) static int dk_t2h_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. @@ -2261,19 +2271,35 @@ int wmain(int argc, wchar_t *argv[]) int main(int argc, char *argv[]) #endif { + int silent = 0; int shp; -#line 2104 "dk-t2h.ctr" +#line 2137 "dk-t2h.ctr" -#line 2105 "dk-t2h.ctr" +#line 2138 "dk-t2h.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_t2h_options, dk_t2h_sz_options, - dk_t2h_kwnl[0], DKT_VERSION_DK, - dk_t2h_kwnl[1], dk_t2h_help_text, dk_t2h_license_text - ); +#endif + if (0 != silent) { + app = dk4app_open_silent( + argc, argv, dk_t2h_options, dk_t2h_sz_options, + dk_t2h_kwnl[0], DKT_VERSION_DK, + dk_t2h_kwnl[1], dk_t2h_help_text, dk_t2h_license_text + ); + } + else { + app = dk4app_open_cmd( + argc, argv, dk_t2h_options, dk_t2h_sz_options, + dk_t2h_kwnl[0], DKT_VERSION_DK, + dk_t2h_kwnl[1], dk_t2h_help_text, dk_t2h_license_text + ); + } if (NULL != app) { dk_t2h_i_std = dk4app_get_stdin_encoding(app); dk_t2h_i_file = dk4app_get_file_in_encoding(app); @@ -2328,14 +2354,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 2168 "dk-t2h.ctr" +#line 2218 "dk-t2h.ctr" -#line 2169 "dk-t2h.ctr" +#line 2219 "dk-t2h.ctr" exit(exval); return exval; } |