From 13f5fd77bbc528862f295f9e7196f3ff709d185a Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 21 Jun 2026 21:42:12 +0200 Subject: Unicode builds now expect UTF-8 strings * They are built with `-DREGEX_UTF8` instead of `-DREGEX_WCHAR`. Functions are called reg_ucomp() and reg_uexec() instead for consistency. The library is now called libhsurex.so instead of libhswrex.so. * The `chr` type is now always `unsigned char`. As a result many other uses of the `chr` type had to be changed to pchr (which is always large enough to hold a byte or wide character). Generally we try to keep code changes as small as possible since we may have to backport changes from the Tcl codebase or contribute patches to the Tcl project. --- regalone.h | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'regalone.h') diff --git a/regalone.h b/regalone.h index 940c11d..e05fdb8 100644 --- a/regalone.h +++ b/regalone.h @@ -2,22 +2,18 @@ #include #include #include +#include #include #ifndef REGEX_STANDALONE # define REGEX_STANDALONE #endif -#ifdef REGEX_WCHAR -# include -# include - typedef wchar_t chr; - typedef chr Tcl_UniChar; -#else -# include - typedef unsigned char chr; - typedef wchar_t Tcl_UniChar; -#endif +#include +#include +// FIXME: Should better be a signed char? +typedef unsigned char chr; +//typedef wchar_t Tcl_UniChar; /* * In The standalone version we are more concerned with performance, @@ -34,7 +30,12 @@ #define ckrealloc(p,n) realloc(p,n) #define ckfree(p) free(p) -#ifdef REGEX_WCHAR +// FIXME: Perhaps get rid of these references completely. +#define Tcl_DStringInit(ds) do (void)(ds); while (0) +#define Tcl_UniCharToUtfDString(s,l,ds) ((char *)(s)) +#define Tcl_DStringFree(ds) do (void)(ds); while (0) + +#ifdef REGEX_UTF8 # define Tcl_UniCharToLower(c) towlower(c) # define Tcl_UniCharToUpper(c) towupper(c) # define Tcl_UniCharToTitle(c) towupper(c) @@ -43,9 +44,6 @@ # define Tcl_UniCharIsDigit(c) iswdigit(c) # define Tcl_UniCharIsSpace(c) iswspace(c) #else -# define Tcl_DStringInit(ds) -# define Tcl_UniCharToUtfDString(s,l,ds) (s) -# define Tcl_DStringFree(ds) # define Tcl_UniCharToLower(c) tolower(c) # define Tcl_UniCharToUpper(c) toupper(c) # define Tcl_UniCharToTitle(c) toupper(c) @@ -238,13 +236,3 @@ typedef struct Tcl_DString { #else # define EXTERN extern TCL_STORAGE_CLASS #endif - - -#ifdef REGEX_WCHAR -EXTERN void Tcl_DStringFree (Tcl_DString * dsPtr); -EXTERN void Tcl_DStringInit (Tcl_DString * dsPtr); -EXTERN char * Tcl_UniCharToUtfDString (CONST Tcl_UniChar * uniStr, - int uniLength, Tcl_DString * dsPtr); -EXTERN void Tcl_DStringSetLength (Tcl_DString * dsPtr, - int length); -#endif /* REGEX_WCHAR */ -- cgit v1.2.3