summaryrefslogtreecommitdiff
path: root/support/dktools/dk4tsp32.ctr
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-09-20 03:03:26 +0000
committerNorbert Preining <norbert@preining.info>2020-09-20 03:03:26 +0000
commit1f457376b478257b88d4a857f5ec1b6155442dd7 (patch)
tree2a06a60551dea362cf8cb0cb0ba66c78608717c4 /support/dktools/dk4tsp32.ctr
parentac690ca29ad5bf8a5203a65fd6252f7b564f4727 (diff)
CTAN sync 202009200303
Diffstat (limited to 'support/dktools/dk4tsp32.ctr')
-rw-r--r--support/dktools/dk4tsp32.ctr86
1 files changed, 81 insertions, 5 deletions
diff --git a/support/dktools/dk4tsp32.ctr b/support/dktools/dk4tsp32.ctr
index 3c1211c62c..498570ddc8 100644
--- a/support/dktools/dk4tsp32.ctr
+++ b/support/dktools/dk4tsp32.ctr
@@ -2,7 +2,7 @@
copyright owner = Dirk Krause
copyright year = 2015-xxxx
-license = bsd
+SPDX-License-Identifier: BSD-3-Clause
@@ -15,35 +15,67 @@ license = bsd
*/
#ifndef DK4CONF_H_INCLUDED
+#if DK4_BUILDING_DKTOOLS4
#include "dk4conf.h"
+#else
+#include <dktools-4/dk4conf.h>
+#endif
#endif
#ifndef DK4TYPES_H_INCLUDED
+#if DK4_BUILDING_DKTOOLS4
#include "dk4types.h"
+#else
+#include <dktools-4/dk4types.h>
+#endif
#endif
#ifndef DK4ERROR_H_INCLUDED
+#if DK4_BUILDING_DKTOOLS4
#include "dk4error.h"
+#else
+#include <dktools-4/dk4error.h>
+#endif
#endif
#ifndef DK4BOM_H_INCLUDED
+#if DK4_BUILDING_DKTOOLS4
#include "dk4bom.h"
+#else
+#include <dktools-4/dk4bom.h>
+#endif
#endif
#ifndef DK4TSP_H_INCLUDED
+#if DK4_BUILDING_DKTOOLS4
#include "dk4tsp.h"
+#else
+#include <dktools-4/dk4tsp.h>
+#endif
#endif
#ifndef DK4UTF8_H_INCLUDED
+#if DK4_BUILDING_DKTOOLS4
#include "dk4utf8.h"
+#else
+#include <dktools-4/dk4utf8.h>
+#endif
#endif
#ifndef DK4UTF16_H_INCLUDED
+#if DK4_BUILDING_DKTOOLS4
#include "dk4utf16.h"
+#else
+#include <dktools-4/dk4utf16.h>
+#endif
#endif
#ifndef DK4C32_H_INCLUDED
+#if DK4_BUILDING_DKTOOLS4
#include "dk4c32.h"
+#else
+#include <dktools-4/dk4c32.h>
+#endif
#endif
/** Handler function for single characters.
@@ -203,7 +235,7 @@ dk4tsp32_finish(dk4_tsp32_t *tsp);
@param tsp Text stream processor to retrieve errors from.
*/
void
-dk4tsp32_get_errors(dk4_er_t *er_en, dk4_er_t *er_pr, dk4_tsp32_t *tsp);
+dk4tsp32_get_errors(dk4_er_t *er_en, dk4_er_t *er_pr, dk4_tsp32_t const *tsp);
#ifdef __cplusplus
}
@@ -213,6 +245,7 @@ dk4tsp32_get_errors(dk4_er_t *er_en, dk4_er_t *er_pr, dk4_tsp32_t *tsp);
%% module
+#include "dk4conf.h"
#include "dk4tsp32.h"
#include "dk4enc.h"
#include "dk4mem.h"
@@ -221,6 +254,12 @@ dk4tsp32_get_errors(dk4_er_t *er_en, dk4_er_t *er_pr, dk4_tsp32_t *tsp);
#include "dk4utf16.h"
#include "dk4c32.h"
+#if DK4_HAVE_ASSERT_H
+#ifndef ASSERT_H_INCLUDED
+#include <assert.h>
+#define ASSERT_H_INCLUDED 1
+#endif
+#endif
$!trace-include
@@ -235,6 +274,9 @@ static
void
dk4tsp32_init(dk4_tsp32_t *tsp, int eie)
{
+#if DK4_USE_ASSERT
+ assert(NULL != tsp);
+#endif
DK4_MEMRES(tsp, sizeof(dk4_tsp32_t));
dk4bom_detect_init(&(tsp->bomd), eie);
dk4error_init(&(tsp->er_en));
@@ -273,6 +315,9 @@ dk4tsp32_process_character(
{
int back = DK4_TSP_RES_FATAL;
$? "+ dk4tsp32_process_character"
+#if DK4_USE_ASSERT
+ assert(NULL != tsp);
+#endif
/* Increase position */
(tsp->pos).chars += (dk4_um_t)1UL;
(tsp->pos).charil += (dk4_um_t)1UL;
@@ -345,12 +390,15 @@ dk4tsp32_process_byte(
int back = DK4_TSP_RES_FATAL; /* Function result */
int cuc32 = 0; /* Flag: Have 32 bit char */
int res = 0; /* Operation result */
+#if DK4_USE_ASSERT
+ assert(NULL != tsp);
+#endif
switch (tsp->ief) {
- case DK4_FILE_ENCODING_ASCII: {
+ case DK4_FILE_ENCODING_PLAIN: {
c32 = (dk4_c32_t)inbyte;
cuc32 = 1;
} break;
- case DK4_FILE_ENCODING_ANSI: {
+ case DK4_FILE_ENCODING_WIN1252: {
if (0 != dk4ansi_decode(&c32, inbyte)) {
cuc32 = 1;
} else {
@@ -480,6 +528,9 @@ static
void
dk4tsp32_initialize_decoder(dk4_tsp32_t *tsp)
{
+#if DK4_USE_ASSERT
+ assert(NULL != tsp);
+#endif
switch (tsp->ief) {
case DK4_FILE_ENCODING_UTF8: {
dk4utf8_init(&((tsp->dec).u08));
@@ -528,6 +579,9 @@ dk4tsp32_i_add_one_byte(
int res; /* Operation result */
unsigned char uc; /* Current unused byte */
$? "+ dk4tsp32_i_add_one_byte index=%lu '%!8c' 0x%02x", byte_number++, inbyte, (unsigned)inbyte
+#if DK4_USE_ASSERT
+ assert(NULL != tsp);
+#endif
(tsp->pos).bytes += (dk4_um_t)1UL;
switch (tsp->pst) {
case 0: {
@@ -588,6 +642,9 @@ dk4tsp32_setup_char(
)
{
int back = 0;
+#if DK4_USE_ASSERT
+ assert(NULL != tsp);
+#endif
if (NULL != tsp) {
dk4tsp32_init(tsp, eie);
if (NULL != fct) {
@@ -621,6 +678,11 @@ dk4tsp32_setup_line(
)
{
int back = 0;
+#if DK4_USE_ASSERT
+ assert(NULL != tsp);
+ assert(NULL != inbuf);
+ assert(0 < szin);
+#endif
if (NULL != tsp) {
dk4tsp32_init(tsp, eie);
if ((NULL != fct) && (NULL != inbuf) && (0 < szin)) {
@@ -653,6 +715,9 @@ dk4tsp32_add_one_byte(
{
int back = DK4_TSP_RES_FATAL;
$? "+ dk4tsp32_add_one_byte"
+#if DK4_USE_ASSERT
+ assert(NULL != tsp);
+#endif
if (NULL != tsp) {
if (2 > tsp->pst) {
back = dk4tsp32_i_add_one_byte(tsp, inbyte);
@@ -674,6 +739,11 @@ dk4tsp32_add_bytes(
int back = DK4_TSP_RES_FATAL; /* Function result */
int res; /* Processing result */
$? "+ dk4tsp32_add_bytes"
+#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;
@@ -707,6 +777,9 @@ dk4tsp32_finish(dk4_tsp32_t *tsp)
int res; /* Operation result */
unsigned char uc; /* Current unused byte */
$? "+ dk4tsp32_finish"
+#if DK4_USE_ASSERT
+ assert(NULL != tsp);
+#endif
if (NULL != tsp) {
/* Flush all unprocessed output
1. If there are unprocessed bytes in the BOM detector as BOM
@@ -774,8 +847,11 @@ dk4tsp32_finish(dk4_tsp32_t *tsp)
void
-dk4tsp32_get_errors(dk4_er_t *er_en, dk4_er_t *er_pr, dk4_tsp32_t *tsp)
+dk4tsp32_get_errors(dk4_er_t *er_en, dk4_er_t *er_pr, dk4_tsp32_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));