/* Copyright (C) 2015-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* 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: dk4tsp08.ctr */ /** @file dk4tsp08.c The dk4tsp08 module. */ #line 286 "dk4tsp08.ctr" #include "dk4conf.h" #include "dk4tsp.h" #include "dk4tsp08.h" #include "dk4mem.h" #include "dk4enc.h" #include "dk4ansi.h" #include "dk4utf8.h" #include "dk4utf16.h" #include "dk4c32.h" #include "dk4bom.h" #include "dk4rec26.h" #if DK4_HAVE_ASSERT_H #ifndef ASSERT_H_INCLUDED #include #define ASSERT_H_INCLUDED 1 #endif #endif #line 308 "dk4tsp08.ctr" /** Initialize text stream processor structure. @param tsp Text stream processor to set up. @param eie Expected input encoding. */ static void dk4tsp08_init(dk4_tsp08_t *tsp, int eie) { #line 320 "dk4tsp08.ctr" #if DK4_USE_ASSERT assert(NULL != tsp); #endif DK4_MEMRES(tsp, sizeof(dk4_tsp08_t)); dk4bom_detect_init(&(tsp->bomd), eie); dk4error_init(&(tsp->er_en)); dk4error_init(&(tsp->er_pr)); tsp->inbuf = NULL; tsp->obj = NULL; tsp->in_sz = 0; tsp->in_us = 0; tsp->ief = eie; tsp->iee = eie; tsp->upt = 0; tsp->pen = 0; #line 335 "dk4tsp08.ctr" tsp->pst = 0; tsp->pth = 0; (tsp->pos).bytes = (dk4_um_t)0UL; (tsp->pos).chars = (dk4_um_t)1UL; #line 339 "dk4tsp08.ctr" (tsp->pos).lineno = (dk4_um_t)1UL; (tsp->pos).charil = (dk4_um_t)1UL; #line 342 "dk4tsp08.ctr" } /** Initialize decoder for found input encoding. @param tsp Text stream processor. */ static void dk4tsp08_initialize_decoder(dk4_tsp08_t *tsp) { #line 354 "dk4tsp08.ctr" #if DK4_USE_ASSERT assert(NULL != tsp); #endif if (0 == tsp->pth) { switch (tsp->ief) { case DK4_FILE_ENCODING_UTF8: { dk4utf8_init(&((tsp->dec).u08)); } break; case DK4_FILE_ENCODING_UTF16_LE: { dk4utf16_byte_init(&((tsp->dec).u16), 0); } break; case DK4_FILE_ENCODING_UTF16_BE: { dk4utf16_byte_init(&((tsp->dec).u16), 1); } break; case DK4_FILE_ENCODING_32_LE: { dk4c32_decoder_init(&((tsp->dec).c32), 0); } break; case DK4_FILE_ENCODING_32_BE: { dk4c32_decoder_init(&((tsp->dec).c32), 1); } break; } } #line 376 "dk4tsp08.ctr" } /** Process group of characters (one UTF-8 encoded 32 bit character). @param tsp Text stream processor. @param buf Buffer containing characters to process. @param sz Number of characters in buffer. @return DK4_TSP_RES_OK if the characters were processed successfully, DK4_TSP_RES_ERROR if there was an error but we can continue, DK4_TSP_RES_FATAL if there was a fatal error so we should abort processing. */ static int dk4tsp08_process_group(dk4_tsp08_t *tsp, char *buf, size_t sz) { size_t i; int back = DK4_TSP_RES_FATAL; int res; #line 399 "dk4tsp08.ctr" #if DK4_USE_ASSERT assert(NULL != tsp); assert(NULL != buf); assert(0 < sz); #endif /* Increase character numbers */ (tsp->pos).chars += (dk4_um_t)1UL; #line 407 "dk4tsp08.ctr" (tsp->pos).charil += (dk4_um_t)1UL; /* Decide between line by line or char by char processing */ if ((NULL != tsp->inbuf) && (0 < tsp->in_sz) && (NULL != (tsp->fct).lh)) { /* Line processing */ if (sz < tsp->in_sz) { if ((tsp->in_sz - sz) > tsp->in_us) { back = DK4_TSP_RES_OK; DK4_MEMCPY( &((tsp->inbuf)[tsp->in_us]), buf, sz ); tsp->in_us += sz; if ((1 == sz) && ('\n' == buf[0])) { back = DK4_TSP_RES_FATAL; if (tsp->in_us < tsp->in_sz) { (tsp->inbuf)[tsp->in_us] = '\0'; back = (*((tsp->fct).lh))( tsp->obj,tsp->inbuf,(tsp->pos).lineno,&(tsp->er_pr) ); } else { /* ERROR: Line too long! */ dk4error_set_with_position( &(tsp->er_en), DK4_E_BUFFER_TOO_SMALL, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } tsp->in_us = 0; } } else { /* ERROR: Line too long! */ dk4error_set_with_position( &(tsp->er_en), DK4_E_BUFFER_TOO_SMALL, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } } else { /* ERROR: Line too long! */ dk4error_set_with_position( &(tsp->er_en), DK4_E_BUFFER_TOO_SMALL, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } } else { /* Direct char processing */ if (NULL != (tsp->fct).ch) { back = DK4_TSP_RES_OK; for (i = 0; i < sz; i++) { res = (*((tsp->fct).ch))(tsp->obj, buf[i], &(tsp->pos), &(tsp->er_pr)); switch (res) { case DK4_TSP_RES_FATAL: { back = DK4_TSP_RES_FATAL; } break; case DK4_TSP_RES_ERROR: { if (DK4_TSP_RES_OK == back) { back = DK4_TSP_RES_ERROR; } } break; } } } else { dk4error_set_with_position( &(tsp->er_en), DK4_E_INVALID_ARGUMENTS, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } } /* After newline correct line number and position in line */ if (1 == sz) { if ('\n' == buf[0]) { (tsp->pos).lineno += (dk4_um_t)1UL; (tsp->pos).charil = (dk4_um_t)1UL; } } #line 480 "dk4tsp08.ctr" return back; } /** Normal processing for one byte. @param tsp Text stream processor. @param inbyte Byte to process. @return Operation result, one from DK4_TSP_RES_OK, DK4_TSP_RES_ERROR or DK4_TSP_RES_FATAL. */ static int dk4tsp08_process_byte( dk4_tsp08_t *tsp, unsigned char inbyte ) { unsigned char buf[8]; dk4_c32_t c32 = dkC32(0); size_t sz; int back = DK4_TSP_RES_FATAL; int cuc32 = 0; int res = 0; unsigned char uc = '\0'; char c08; #line 506 "dk4tsp08.ctr" #if DK4_USE_ASSERT assert(NULL != tsp); #endif if (0 != tsp->pth) { #line 510 "dk4tsp08.ctr" back = dk4tsp08_process_group(tsp, (char *)(&inbyte), 1); } else { #line 512 "dk4tsp08.ctr" /* Decode and process */ switch (tsp->ief) { case DK4_FILE_ENCODING_PLAIN: { #line 515 "dk4tsp08.ctr" c32 = (dk4_c32_t)inbyte; cuc32 = 1; } break; case DK4_FILE_ENCODING_WIN1252: { #line 519 "dk4tsp08.ctr" if (0 != dk4ansi_decode(&c32, inbyte)) { cuc32 = 1; } else { #line 522 "dk4tsp08.ctr" dk4error_set_with_position( &(tsp->er_en), DK4_E_DECODING_FAILED, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } } break; case DK4_FILE_ENCODING_UTF8: { #line 530 "dk4tsp08.ctr" res = dk4utf8_add(&((tsp->dec).u08), inbyte); switch (res) { case DK4_EDSTM_ERROR: { #line 533 "dk4tsp08.ctr" /* Decoding error */ dk4error_set_with_position( &(tsp->er_en), DK4_E_DECODING_FAILED, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } break; case DK4_EDSTM_FINISHED: { c32 = dk4utf8_get(&((tsp->dec).u08)); cuc32 = 1; dk4utf8_init(&((tsp->dec).u08)); } break; case DK4_EDSTM_ACCEPT: { back = DK4_TSP_RES_OK; } break; } } break; case DK4_FILE_ENCODING_UTF16_LE: { #line 551 "dk4tsp08.ctr" res = dk4utf16_byte_add(&((tsp->dec).u16), inbyte); switch (res) { case DK4_EDSTM_ERROR: { #line 554 "dk4tsp08.ctr" /* Decoding error */ dk4error_set_with_position( &(tsp->er_en), DK4_E_DECODING_FAILED, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } break; case DK4_EDSTM_FINISHED: { c32 = dk4utf16_byte_get(&((tsp->dec).u16)); cuc32 = 1; dk4utf16_byte_init(&((tsp->dec).u16), 0); } break; case DK4_EDSTM_ACCEPT: { back = DK4_TSP_RES_OK; } break; } } break; case DK4_FILE_ENCODING_UTF16_BE: { #line 572 "dk4tsp08.ctr" res = dk4utf16_byte_add(&((tsp->dec).u16), inbyte); switch (res) { case DK4_EDSTM_ERROR: { #line 575 "dk4tsp08.ctr" /* Decoding error */ dk4error_set_with_position( &(tsp->er_en), DK4_E_DECODING_FAILED, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } break; case DK4_EDSTM_FINISHED: { c32 = dk4utf16_byte_get(&((tsp->dec).u16)); cuc32 = 1; dk4utf16_byte_init(&((tsp->dec).u16), 1); } break; case DK4_EDSTM_ACCEPT: { back = DK4_TSP_RES_OK; } break; } } break; case DK4_FILE_ENCODING_32_LE: { #line 593 "dk4tsp08.ctr" res = dk4c32_decoder_add(&((tsp->dec).c32), inbyte); switch (res) { case DK4_EDSTM_ERROR: { #line 596 "dk4tsp08.ctr" /* Decoding error */ dk4error_set_with_position( &(tsp->er_en), DK4_E_DECODING_FAILED, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } break; case DK4_EDSTM_FINISHED: { c32 = dk4c32_decoder_get(&((tsp->dec).c32)); cuc32 = 1; dk4c32_decoder_init(&((tsp->dec).c32), 0); } break; case DK4_EDSTM_ACCEPT: { back = DK4_TSP_RES_OK; } break; } } break; case DK4_FILE_ENCODING_32_BE: { #line 614 "dk4tsp08.ctr" res = dk4c32_decoder_add(&((tsp->dec).c32), inbyte); switch (res) { case DK4_EDSTM_ERROR: { #line 617 "dk4tsp08.ctr" /* Decoding error */ dk4error_set_with_position( &(tsp->er_en), DK4_E_DECODING_FAILED, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } break; case DK4_EDSTM_FINISHED: { c32 = dk4c32_decoder_get(&((tsp->dec).c32)); cuc32 = 1; dk4c32_decoder_init(&((tsp->dec).c32), 1); } break; case DK4_EDSTM_ACCEPT: { back = DK4_TSP_RES_OK; } break; } } break; } if (0 != cuc32) { switch (tsp->pen) { case DK4_ENCODING_PLAIN: { #line 638 "dk4tsp08.ctr" if (dkC32(0x00000100) > c32) { c08 = (char)c32; back = dk4tsp08_process_group(tsp, &c08, 1); } else { #line 642 "dk4tsp08.ctr" /* Encoding error */ dk4error_set_with_position( &(tsp->er_en), DK4_E_ENCODING_FAILED, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } } break; case DK4_ENCODING_WIN1252: { #line 651 "dk4tsp08.ctr" if (0 != dk4ansi_encode(&uc, c32)) { c08 = (char)uc; back = dk4tsp08_process_group(tsp, &c08, 1); } else { #line 655 "dk4tsp08.ctr" /* Encoding error */ dk4error_set_with_position( &(tsp->er_en), DK4_E_ENCODING_FAILED, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } } break; case DK4_ENCODING_UTF8: { #line 664 "dk4tsp08.ctr" sz = sizeof(buf); if (0 != dk4utf8_encode(buf, &sz, c32, NULL)) { back = dk4tsp08_process_group(tsp, (char *)buf, sz); } else { #line 668 "dk4tsp08.ctr" /* Encoding error */ dk4error_set_with_position( &(tsp->er_en), DK4_E_ENCODING_FAILED, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } } break; } } } if (DK4_TSP_RES_FATAL == back) { tsp->pst = 2; } #line 683 "dk4tsp08.ctr" return back; } /** Add one byte to internal data structures (BOM detection and/or normal processing). @param tsp Text stream processor. @param inbyte Byte to add. @return Operation result, one from DK4_TSP_RES_OK, DK4_TSP_RES_ERROR or DK4_TSP_RES_FATAL. */ static int dk4tsp08_i_add_one_byte( dk4_tsp08_t *tsp, unsigned char inbyte ) { size_t nrej = 0; size_t i = 0; int back = DK4_TSP_RES_FATAL; int res; unsigned char uc; #line 708 "dk4tsp08.ctr" #if DK4_USE_ASSERT assert(NULL != tsp); #endif (tsp->pos).bytes += (dk4_um_t)1UL; switch (tsp->pst) { case 0: { /* BOM detection */ #line 715 "dk4tsp08.ctr" res = dk4bom_detect_add(&(tsp->bomd), inbyte); switch (res) { case DK4_EDSTM_ACCEPT: { back = DK4_TSP_RES_OK; } break; case DK4_EDSTM_FINISHED: case DK4_EDSTM_FINISHED_WITH_UNUSED: { #line 723 "dk4tsp08.ctr" /* This result is ok. */ back = DK4_TSP_RES_OK; /* Retrieve found encoding */ tsp->ief = dk4bom_detect_get_encoding(&(tsp->bomd)); /* Check whether we can pass through data unchanged */ if (tsp->ief == tsp->pen) { switch (tsp->ief) { #if VERSION_BEFORE_20150321 /* 2015-30-21 We do not hard-code the decision whether or not to enable pass-through for UTF-8 encoded bytes, better use a run-time decision. */ case DK4_ENCODING_PLAIN: case DK4_ENCODING_WIN1252: #if 0 /* 2014-12-01 We must make sure to process the complete UTF-8 representation of a glyph completely. */ case DK4_ENCODING_UTF8: #endif { tsp->pth = 1; #line 748 "dk4tsp08.ctr" } break; #endif case DK4_ENCODING_PLAIN : case DK4_ENCODING_WIN1252 : { tsp->pth = 1; } break; case DK4_ENCODING_UTF8 : { if (0 != tsp->upt) { tsp->pth = 1; } } break; } } /* If necessary, initialize decoder */ dk4tsp08_initialize_decoder(tsp); /* Switch to normal processing */ tsp->pst = 1; /* Process bytes stored in BOM detector */ if (DK4_EDSTM_FINISHED_WITH_UNUSED == res) { nrej = dk4bom_detect_num_unused_bytes(&(tsp->bomd)); if (0 < nrej) { #line 769 "dk4tsp08.ctr" for (i = 0; ((i < nrej) && (DK4_TSP_RES_FATAL != back)); i++) { uc = dk4bom_detect_unused_byte(&(tsp->bomd), i); #line 772 "dk4tsp08.ctr" switch (dk4tsp08_process_byte(tsp, uc)) { case DK4_TSP_RES_FATAL: { #line 774 "dk4tsp08.ctr" back = DK4_TSP_RES_FATAL; } break; case DK4_TSP_RES_ERROR: { if (DK4_TSP_RES_OK == back) { #line 778 "dk4tsp08.ctr" back = DK4_TSP_RES_ERROR; } } break; } } } } } break; case DK4_EDSTM_ERROR: { #line 787 "dk4tsp08.ctr" } break; } } break; case 1: { /* Normal processing */ #line 792 "dk4tsp08.ctr" back = dk4tsp08_process_byte(tsp, inbyte); } break; /* Processing stage 2 indicates there was a serious error before, we must skip further processing. This situation is covered by the initialization value DK4_TSP_RES_FATAL, so we do not need a case branch here. */ } #line 802 "dk4tsp08.ctr" return back; } int dk4tsp08_setup_char( dk4_tsp08_t *tsp, void *obj, dk4_c8_handler_t *fct, int pre, int eie, dk4_er_t *erp ) { int back = 0; #line 819 "dk4tsp08.ctr" #if DK4_USE_ASSERT assert(NULL != tsp); #endif if (NULL != tsp) { #line 823 "dk4tsp08.ctr" dk4tsp08_init(tsp, eie); if (NULL != fct) { #line 825 "dk4tsp08.ctr" switch (pre) { case DK4_ENCODING_PLAIN: case DK4_ENCODING_WIN1252: case DK4_ENCODING_UTF8: { tsp->obj = obj; (tsp->fct).ch = fct; tsp->pen = pre; tsp->iee = eie; #line 834 "dk4tsp08.ctr" tsp->ief = eie; back = 1; } break; default: { #line 838 "dk4tsp08.ctr" dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); tsp->pst = 2; } break; } } else { #line 843 "dk4tsp08.ctr" dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); tsp->pst = 2; } } else { #line 847 "dk4tsp08.ctr" dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } #line 849 "dk4tsp08.ctr" return back; } int dk4tsp08_setup_line( dk4_tsp08_t *tsp, void *obj, dk4_c8_line_handler_t *fct, char *inbuf, size_t szin, int pre, int eie, dk4_er_t *erp ) { int back = 0; #line 867 "dk4tsp08.ctr" #if DK4_USE_ASSERT assert(NULL != tsp); assert(NULL != inbuf); assert(0 < szin); #endif if (NULL != tsp) { #line 873 "dk4tsp08.ctr" dk4tsp08_init(tsp, eie); if ((NULL != fct) && (NULL != inbuf) && (0 < szin)) { #line 876 "dk4tsp08.ctr" switch (pre) { case DK4_ENCODING_PLAIN: case DK4_ENCODING_WIN1252: case DK4_ENCODING_UTF8: { tsp->obj = obj; (tsp->fct).lh = fct; tsp->inbuf = inbuf; tsp->in_sz = szin; tsp->in_us = 0; tsp->pen = pre; tsp->iee = eie; tsp->ief = eie; back = 1; } break; default: { #line 892 "dk4tsp08.ctr" dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); tsp->pst = 2; } break; } } else { #line 897 "dk4tsp08.ctr" dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); tsp->pst = 2; } } else { #line 901 "dk4tsp08.ctr" dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } #line 903 "dk4tsp08.ctr" return back; } int dk4tsp08_add_one_byte( dk4_tsp08_t *tsp, unsigned char inbyte ) { int back = DK4_TSP_RES_FATAL; #line 916 "dk4tsp08.ctr" #if DK4_USE_ASSERT assert(NULL != tsp); #endif if (NULL != tsp) { if (2 > tsp->pst) { back = dk4tsp08_i_add_one_byte(tsp, inbyte); } } #line 924 "dk4tsp08.ctr" return back; } int dk4tsp08_add_bytes( dk4_tsp08_t *tsp, const unsigned char *buffer, size_t sz ) { int back = DK4_TSP_RES_FATAL; int res; #line 939 "dk4tsp08.ctr" #if DK4_USE_ASSERT assert(NULL != tsp); assert(NULL != buffer); assert(0 < sz); #endif if ((NULL != tsp) && (NULL != buffer) && (0 < sz)) { if (2 > tsp->pst) { back = DK4_TSP_RES_OK; while((sz--) && (2 > tsp->pst)) { res = dk4tsp08_i_add_one_byte(tsp, *(buffer++)); switch (res) { case DK4_TSP_RES_FATAL: { #line 951 "dk4tsp08.ctr" back = DK4_TSP_RES_FATAL; } break; case DK4_TSP_RES_ERROR: { if (DK4_TSP_RES_OK == back) { #line 955 "dk4tsp08.ctr" back = DK4_TSP_RES_ERROR; } } break; } } } } #line 962 "dk4tsp08.ctr" return back; } int dk4tsp08_finish(dk4_tsp08_t *tsp) { size_t nrej = 0; size_t i = 0; int back = DK4_TSP_RES_FATAL; int res; unsigned char uc; #line 976 "dk4tsp08.ctr" #if DK4_USE_ASSERT assert(NULL != tsp); #endif if (NULL != tsp) { /* Retrieve rejected bytes from BOM detector */ back = DK4_TSP_RES_OK; if (0 == tsp->pst) { #line 983 "dk4tsp08.ctr" tsp->pst = 1; nrej = dk4bom_detect_num_unused_bytes(&(tsp->bomd)); if (0 < nrej) { dk4tsp08_initialize_decoder(tsp); for (i = 0; ((i < nrej) && (2 > tsp->pst)); i++) { uc = dk4bom_detect_unused_byte(&(tsp->bomd), i); #line 990 "dk4tsp08.ctr" switch (dk4tsp08_process_byte(tsp, uc)) { case DK4_TSP_RES_FATAL: { #line 992 "dk4tsp08.ctr" back = DK4_TSP_RES_FATAL; tsp->pst = 2; } break; case DK4_TSP_RES_ERROR: { #line 996 "dk4tsp08.ctr" if (DK4_TSP_RES_OK == back) { back = DK4_TSP_RES_ERROR; } } break; } } } } else { #line 1002 "dk4tsp08.ctr" } /* Process final line */ if ((NULL != tsp->inbuf) && (0 < tsp->in_sz) && (NULL != (tsp->fct).lh)) { if (0 < tsp->in_us) { #line 1007 "dk4tsp08.ctr" if (2 > tsp->pst) { if (tsp->in_us < tsp->in_sz) { #line 1009 "dk4tsp08.ctr" (tsp->inbuf)[tsp->in_us] = '\0'; #line 1010 "dk4tsp08.ctr" res = (*((tsp->fct).lh))( tsp->obj,tsp->inbuf,(tsp->pos).lineno,&(tsp->er_pr) ); switch (res) { case DK4_TSP_RES_FATAL: { #line 1016 "dk4tsp08.ctr" back = DK4_TSP_RES_FATAL; tsp->pst = 2; } break; case DK4_TSP_RES_ERROR: { #line 1020 "dk4tsp08.ctr" if (DK4_TSP_RES_OK == back) { back = DK4_TSP_RES_ERROR; } } break; } } else { #line 1024 "dk4tsp08.ctr" back = DK4_TSP_RES_FATAL; tsp->pst = 2; /* ERROR: Line too long! */ dk4error_set_with_position( &(tsp->er_en), DK4_E_BUFFER_TOO_SMALL, (tsp->pos).bytes, (tsp->pos).lineno, (tsp->pos).chars, (tsp->pos).charil ); } } else { #line 1034 "dk4tsp08.ctr" } } } } #line 1039 "dk4tsp08.ctr" return back; } void dk4tsp08_get_errors(dk4_er_t *er_en, dk4_er_t *er_pr, dk4_tsp08_t const *tsp) { #if DK4_USE_ASSERT assert(NULL != tsp); #endif if (NULL != tsp) { if (NULL != er_en) { DK4_MEMCPY(er_en, &(tsp->er_en), sizeof(dk4_er_t)); } if (NULL != er_pr) { DK4_MEMCPY(er_pr, &(tsp->er_pr), sizeof(dk4_er_t)); } } } void dk4tsp08_enable_utf8_pass_through(dk4_tsp08_t *tsp, int fl) { #if DK4_USE_ASSERT assert(NULL != tsp); #endif if (NULL != tsp) { tsp->upt = ((0 != fl) ? 1 : 0); } }