-- cgit v0.12 From 0219b700b196373b550711d430ce8e1106869b7d Mon Sep 17 00:00:00 2001 From: pooryorick Date: Mon, 30 Jan 2023 19:37:35 +0000 Subject: Update code comments for Tcl_UniCharToUtf(). --- generic/tclUtf.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/generic/tclUtf.c b/generic/tclUtf.c index ab27f1b..0c16f27 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -182,25 +182,22 @@ Invalid( * * Tcl_UniCharToUtf -- * - * Store the given Tcl_UniChar as a sequence of UTF-8 bytes in the - * provided buffer. Equivalent to Plan 9 runetochar(). + * Stores the given Tcl_UniChar as a sequence of UTF-8 bytes in the provided + * buffer. Equivalent to Plan 9 runetochar(). * - * Special handling of Surrogate pairs is handled as follows: - * When this function is called for ch being a high surrogate, - * the first byte of the 4-byte UTF-8 sequence is produced and + * When this function is called and ch is a high surrogate, + * the first byte of the 4-byte UTF-8 sequence is produced, and * the function returns 1. Calling the function again with a * low surrogate, the remaining 3 bytes of the 4-byte UTF-8 * sequence is produced, and the function returns 3. The buffer * is used to remember the high surrogate between the two calls. * - * If no low surrogate follows the high surrogate (which is actually - * illegal), this can be handled reasonably by calling Tcl_UniCharToUtf - * again with ch = -1. This will produce a 3-byte UTF-8 sequence - * representing the high surrogate. + * If no low surrogate follows the high surrogate (which is actually illegal), + * calling Tcl_UniCharToUtf again with ch being -1 produces a 3-byte UTF-8 + * sequence representing the high surrogate. * * Results: - * The return values is the number of bytes in the buffer that were - * consumed. + * Returns the number of bytes populated in the buffer. * * Side effects: * None. @@ -211,12 +208,13 @@ Invalid( #undef Tcl_UniCharToUtf size_t Tcl_UniCharToUtf( - int ch, /* The Tcl_UniChar to be stored in the - * buffer. Can be or'ed with flag TCL_COMBINE */ - char *buf) /* Buffer in which the UTF-8 representation of - * the Tcl_UniChar is stored. Buffer must be - * large enough to hold the UTF-8 character - * (at most 4 bytes). */ + int ch, /* The Tcl_UniChar to be stored in the + * buffer. Can be or'ed with flag TCL_COMBINE + */ + char *buf) /* Buffer in which the UTF-8 representation of + * ch is stored. Must be large enough to hold the UTF-8 + * character (at most 4 bytes). + */ { #if TCL_UTF_MAX > 3 int flags = ch; @@ -253,7 +251,12 @@ Tcl_UniCharToUtf( /* Previous Tcl_UniChar was not a high surrogate, so just output */ } else { /* High surrogate */ + + /* Add 0x10000 to the raw number encoded in the surrogate + * pair in order to get the code point. + */ ch += 0x40; + /* Fill buffer with specific 3-byte (invalid) byte combination, so following low surrogate can recognize it and combine */ buf[2] = (char) ( 0x03 & ch); -- cgit v0.12 From 7f3849495af70609d977a45ab829c6bc9291b965 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Wed, 22 Mar 2023 20:15:47 +0000 Subject: Merge core-8-branch 7fde86610c: New script used in the "valgrind_each" target in Makefile.in. --- tools/valgrind_check_success | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tools/valgrind_check_success diff --git a/tools/valgrind_check_success b/tools/valgrind_check_success new file mode 100644 index 0000000..24830d5 --- /dev/null +++ b/tools/valgrind_check_success @@ -0,0 +1,30 @@ +#! /usr/bin/env tclsh + + +proc main {sourcetype source} { + switch $sourcetype { + file { + set chan [open $source] + try { + set data [read $chan] + } finally { + close $chan + } + } + string { + set data $source + } + default { + error [list {wrong # args}] + } + } + set found [regexp -inline -all {blocks are\ + (?:(?:(?:definitely|indirectly|possibly) lost)|still reachable)} $data] + if {[llength $found]} { + puts 0 + } else { + puts 1 + } + flush stdout +} +main {*}$argv -- cgit v0.12 From 9d432523a6f04ed087547fa81ea1c502314bcd37 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Wed, 22 Mar 2023 20:26:05 +0000 Subject: Merge core-8-branch 3082cb9e80: Make valgrind_foreach target in Makefile.in properly handle interrupted tests. --- unix/Makefile.in | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/unix/Makefile.in b/unix/Makefile.in index 93c3abd..1bf5814 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -956,6 +956,27 @@ valgrind: ${TCL_EXE} ${TCLTEST_EXE} $(TOP_DIR)/tests/all.tcl -singleproc 1 -constraints valgrind \ $(TESTFLAGS) +testresults/valgrind/%.result: ${TCL_EXE} ${TCLTEST_EXE} + @mkdir -p testresults/valgrind + $(SHELL_ENV) $(VALGRIND) $(VALGRINDARGS) ./${TCLTEST_EXE} \ + $(TOP_DIR)/tests/all.tcl -singleproc 1 -constraints valgrind \ + -file $(basename $(notdir $@)) > $@.tmp 2>&1 + @mv $@.tmp $@ +.PRECIOUS: testresults/valgrind/%.result + + +testresults/valgrind/%.success: testresults/valgrind/%.result + @printf '%s' valgrind >&2 + @printf ' %s' $(basename $(notdir $@)) >&2 + @printf '\n >&2' + @status=$$(./${TCLTEST_EXE} $(TOP_DIR)/tools/valgrind_check_success \ + file $(basename $@).result); \ + if [ "$$status" -eq 1 ]; then touch $@; exit 0; else exit 1; fi + +valgrind_each: $(addprefix testresults/valgrind/,$(addsuffix .success,$(notdir\ + $(wildcard $(TOP_DIR)/tests/*.test)))) + + valgrindshell: ${TCL_EXE} $(SHELL_ENV) $(VALGRIND) $(VALGRINDARGS) ./${TCL_EXE} $(SCRIPT) -- cgit v0.12