From 7d1613ac75f237ba9375c3cf93b2755f8f193402 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 1 Apr 2023 07:27:28 +0000 Subject: Improve tcltest package: Don't use 'scan' for printable characters, and don't print lf as \x0A any more (as in Tcl 8.6) --- library/tcltest/tcltest.tcl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 278a4e0..6a161a3 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -1152,15 +1152,14 @@ proc tcltest::SafeFetch {n1 n2 op} { proc tcltest::Asciify {s} { set print "" foreach c [split $s ""] { - set i [scan $c %c] - if {[string is print $c] && ($i <= 127)} { + if {[string is print $c] && (($c <= "\x7E") || ($c == "\n"))} { append print $c - } elseif {$i <= 0xFF} { - append print \\x[format %02X $i] - } elseif {$i <= 0xFFFF} { - append print \\u[format %04X $i] + } elseif {$c <= "\xFF"} { + append print \\x[format %02X [scan $c %c]] + } elseif {$c <= "\xFFFF"} { + append print \\u[format %04X [scan $c %c]] } else { - append print \\U[format %08X $i] + append print \\U[format %08X [scan $c %c]] } } return $print -- cgit v0.12 From 0726ae90dbb3936ca4f841850bf791bc9a9b07ab Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 1 Apr 2023 07:45:22 +0000 Subject: New "pkgt" for testing TIP #627 --- unix/dltest/Makefile.in | 13 +++++- unix/dltest/pkgt.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 unix/dltest/pkgt.c diff --git a/unix/dltest/Makefile.in b/unix/dltest/Makefile.in index 500bf97..a99fd0b 100644 --- a/unix/dltest/Makefile.in +++ b/unix/dltest/Makefile.in @@ -25,11 +25,11 @@ LDFLAGS = @LDFLAGS_DEFAULT@ @LDFLAGS@ CC_SWITCHES = $(CFLAGS) -I${SRC_DIR}/../../generic -DTCL_MEM_DEBUG \ ${SHLIB_CFLAGS} -DUSE_TCL_STUBS ${AC_FLAGS} -all: pkga${SHLIB_SUFFIX} pkgb${SHLIB_SUFFIX} pkgc${SHLIB_SUFFIX} pkgd${SHLIB_SUFFIX} pkge${SHLIB_SUFFIX} pkgua${SHLIB_SUFFIX} pkgooa${SHLIB_SUFFIX} +all: pkga${SHLIB_SUFFIX} pkgb${SHLIB_SUFFIX} pkgc${SHLIB_SUFFIX} pkgd${SHLIB_SUFFIX} pkge${SHLIB_SUFFIX} pkgt${SHLIB_SUFFIX} pkgua${SHLIB_SUFFIX} pkgooa${SHLIB_SUFFIX} @if test -n "$(DLTEST_SUFFIX)"; then $(MAKE) dltest_suffix; fi @touch ../dltest.marker -dltest_suffix: pkga${DLTEST_SUFFIX} pkgb${DLTEST_SUFFIX} pkgc${DLTEST_SUFFIX} pkgd${DLTEST_SUFFIX} pkge${DLTEST_SUFFIX} pkgua${DLTEST_SUFFIX} pkgooa${DLTEST_SUFFIX} +dltest_suffix: pkga${DLTEST_SUFFIX} pkgb${DLTEST_SUFFIX} pkgc${DLTEST_SUFFIX} pkgd${DLTEST_SUFFIX} pkge${DLTEST_SUFFIX} pkgt${DLTEST_SUFFIX} pkgua${DLTEST_SUFFIX} pkgooa${DLTEST_SUFFIX} @touch ../dltest.marker pkga.o: $(SRC_DIR)/pkga.c @@ -47,6 +47,9 @@ pkgd.o: $(SRC_DIR)/pkgd.c pkge.o: $(SRC_DIR)/pkge.c $(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkge.c +pkgt.o: $(SRC_DIR)/pkgt.c + $(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgt.c + pkgua.o: $(SRC_DIR)/pkgua.c $(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgua.c @@ -68,6 +71,9 @@ pkgd${SHLIB_SUFFIX}: pkgd.o pkge${SHLIB_SUFFIX}: pkge.o ${SHLIB_LD} -o pkge${SHLIB_SUFFIX} pkge.o ${SHLIB_LD_LIBS} +pkgt${SHLIB_SUFFIX}: pkgt.o + ${SHLIB_LD} -o pkgt${SHLIB_SUFFIX} pkgt.o ${SHLIB_LD_LIBS} + pkgua${SHLIB_SUFFIX}: pkgua.o ${SHLIB_LD} -o pkgua${SHLIB_SUFFIX} pkgua.o ${SHLIB_LD_LIBS} @@ -89,6 +95,9 @@ pkgd${DLTEST_SUFFIX}: pkgd.o pkge${DLTEST_SUFFIX}: pkge.o ${DLTEST_LD} -o pkge${DLTEST_SUFFIX} pkge.o ${SHLIB_LD_LIBS} +pkgt${DLTEST_SUFFIX}: pkgt.o + ${DLTEST_LD} -o pkgt${DLTEST_SUFFIX} pkgt.o ${SHLIB_LD_LIBS} + pkgua${DLTEST_SUFFIX}: pkgua.o ${DLTEST_LD} -o pkgua${DLTEST_SUFFIX} pkgua.o ${SHLIB_LD_LIBS} diff --git a/unix/dltest/pkgt.c b/unix/dltest/pkgt.c new file mode 100644 index 0000000..4a02665 --- /dev/null +++ b/unix/dltest/pkgt.c @@ -0,0 +1,108 @@ +/* + * pkgt.c -- + * + * This file contains a simple Tcl package "pkgt" that is intended for + * testing the Tcl dynamic loading facilities. + * + * Copyright © 1995 Sun Microsystems, Inc. + * + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. + */ + +#undef STATIC_BUILD +#include "tcl.h" + +static int TraceProc2 ( + void *clientData, + Tcl_Interp *interp, + size_t level, + const char *command, + Tcl_Command commandInfo, + size_t objc, + struct Tcl_Obj *const *objv) +{ + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * Pkgt_EqObjCmd2 -- + * + * This procedure is invoked to process the "pkgt_eq" Tcl command. It + * expects two arguments and returns 1 if they are the same, 0 if they + * are different. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * See the user documentation. + * + *---------------------------------------------------------------------- + */ + +static int +Pkgt_EqObjCmd2( + void *dummy, /* Not used. */ + Tcl_Interp *interp, /* Current interpreter. */ + size_t objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument objects. */ +{ + Tcl_WideInt result; + const char *str1, *str2; + size_t len1, len2; + (void)dummy; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "string1 string2"); + return TCL_ERROR; + } + + str1 = Tcl_GetStringFromObj(objv[1], &len1); + str2 = Tcl_GetStringFromObj(objv[2], &len2); + if (len1 == len2) { + result = (Tcl_UtfNcmp(str1, str2, len1) == 0); + } else { + result = 0; + } + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(result)); + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * Pkgt_Init -- + * + * This is a package initialization procedure, which is called by Tcl + * when this package is to be added to an interpreter. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +DLLEXPORT int +Pkgt_Init( + Tcl_Interp *interp) /* Interpreter in which the package is to be + * made available. */ +{ + int code; + + if (Tcl_InitStubs(interp, "8.7-", 0) == NULL) { + return TCL_ERROR; + } + code = Tcl_PkgProvide(interp, "pkgt", "1.0"); + if (code != TCL_OK) { + return code; + } + Tcl_CreateObjCommand2(interp, "pkgt_eq", Pkgt_EqObjCmd2, NULL, NULL); + Tcl_CreateObjTrace2(interp, 0, 0, TraceProc2, NULL, NULL); + return TCL_OK; +} -- cgit v0.12