diff options
author | dgp <dgp@users.sourceforge.net> | 2020-03-06 21:33:24 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2020-03-06 21:33:24 (GMT) |
commit | c4a1ea568ee92b0d890bb012f44b345c80f25fa8 (patch) | |
tree | 5c9b8cae89263c6d99738a15d02d2113274f66e4 /generic/tclEncoding.c | |
parent | 1e155ca6690f927989e3afaa7559109019361d0d (diff) | |
parent | 81e31a16d82ff906b74f9b726637a3f146b77a4d (diff) | |
download | tcl-c4a1ea568ee92b0d890bb012f44b345c80f25fa8.zip tcl-c4a1ea568ee92b0d890bb012f44b345c80f25fa8.tar.gz tcl-c4a1ea568ee92b0d890bb012f44b345c80f25fa8.tar.bz2 |
merge 8.7
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r-- | generic/tclEncoding.c | 185 |
1 files changed, 50 insertions, 135 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 418ac0f..1cbd26f 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -195,85 +195,41 @@ static unsigned short emptyPage[256]; * Functions used only in this module. */ -static int BinaryProc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); -static void DupEncodingIntRep(Tcl_Obj *srcPtr, Tcl_Obj *dupPtr); -static void EscapeFreeProc(ClientData clientData); -static int EscapeFromUtfProc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); -static int EscapeToUtfProc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); -static void FillEncodingFileMap(void); -static void FreeEncoding(Tcl_Encoding encoding); -static void FreeEncodingIntRep(Tcl_Obj *objPtr); -static Encoding * GetTableEncoding(EscapeEncodingData *dataPtr, - int state); -static Tcl_Encoding LoadEncodingFile(Tcl_Interp *interp, const char *name); -static Tcl_Encoding LoadTableEncoding(const char *name, int type, - Tcl_Channel chan); -static Tcl_Encoding LoadEscapeEncoding(const char *name, Tcl_Channel chan); -static Tcl_Channel OpenEncodingFileChannel(Tcl_Interp *interp, - const char *name); -static void TableFreeProc(ClientData clientData); -static int TableFromUtfProc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); -static int TableToUtfProc(ClientData clientData, const char *src, - int srcLen, int flags, Tcl_EncodingState *statePtr, - char *dst, int dstLen, int *srcReadPtr, - int *dstWrotePtr, int *dstCharsPtr); -static size_t unilen(const char *src); -static int Utf16ToUtfProc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); -static int UtfToUtf16Proc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); -static int UtfToUcs2Proc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); -static int UtfToUtfProc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr, int pureNullMode); -static int UtfIntToUtfExtProc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); -static int UtfExtToUtfIntProc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); -static int Iso88591FromUtfProc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, int dstLen, - int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); -static int Iso88591ToUtfProc(ClientData clientData, - const char *src, int srcLen, int flags, - Tcl_EncodingState *statePtr, char *dst, - int dstLen, int *srcReadPtr, int *dstWrotePtr, - int *dstCharsPtr); +static Tcl_EncodingConvertProc BinaryProc; +static Tcl_DupInternalRepProc DupEncodingIntRep; +static Tcl_EncodingFreeProc EscapeFreeProc; +static Tcl_EncodingConvertProc EscapeFromUtfProc; +static Tcl_EncodingConvertProc EscapeToUtfProc; +static void FillEncodingFileMap(void); +static void FreeEncoding(Tcl_Encoding encoding); +static Tcl_FreeInternalRepProc FreeEncodingIntRep; +static Encoding * GetTableEncoding(EscapeEncodingData *dataPtr, + int state); +static Tcl_Encoding LoadEncodingFile(Tcl_Interp *interp, + const char *name); +static Tcl_Encoding LoadTableEncoding(const char *name, int type, + Tcl_Channel chan); +static Tcl_Encoding LoadEscapeEncoding(const char *name, + Tcl_Channel chan); +static Tcl_Channel OpenEncodingFileChannel(Tcl_Interp *interp, + const char *name); +static Tcl_EncodingFreeProc TableFreeProc; +static Tcl_EncodingConvertProc TableFromUtfProc; +static Tcl_EncodingConvertProc TableToUtfProc; +static size_t unilen(const char *src); +static Tcl_EncodingConvertProc Utf16ToUtfProc; +static Tcl_EncodingConvertProc UtfToUtf16Proc; +static Tcl_EncodingConvertProc UtfToUcs2Proc; +static int UtfToUtfProc(ClientData clientData, + const char *src, int srcLen, int flags, + Tcl_EncodingState *statePtr, char *dst, + int dstLen, int *srcReadPtr, + int *dstWrotePtr, int *dstCharsPtr, + int pureNullMode); +static Tcl_EncodingConvertProc UtfIntToUtfExtProc; +static Tcl_EncodingConvertProc UtfExtToUtfIntProc; +static Tcl_EncodingConvertProc Iso88591FromUtfProc; +static Tcl_EncodingConvertProc Iso88591ToUtfProc; /* * A Tcl_ObjType for holding a cached Tcl_Encoding in the twoPtrValue.ptr1 field @@ -1163,7 +1119,7 @@ Tcl_ExternalToUtfDString( int Tcl_ExternalToUtf( - Tcl_Interp *dummy, /* Interp for error return, if not NULL. */ + TCL_UNUSED(Tcl_Interp *), /* TODO: Re-examine this. */ Tcl_Encoding encoding, /* The encoding for the source string, or NULL * for the default system encoding. */ const char *src, /* Source string in specified encoding. */ @@ -1197,7 +1153,6 @@ Tcl_ExternalToUtf( int charLimited = (flags & TCL_ENCODING_CHAR_LIMIT) && dstCharsPtr; int maxChars = INT_MAX; Tcl_EncodingState state; - (void)dummy; if (encoding == NULL) { encoding = systemEncoding; @@ -1356,7 +1311,7 @@ Tcl_UtfToExternalDString( int Tcl_UtfToExternal( - Tcl_Interp *dummy, /* Interp for error return, if not NULL. */ + TCL_UNUSED(Tcl_Interp *), /* TODO: Re-examine this. */ Tcl_Encoding encoding, /* The encoding for the converted string, or * NULL for the default system encoding. */ const char *src, /* Source string in UTF-8. */ @@ -1387,7 +1342,6 @@ Tcl_UtfToExternal( const Encoding *encodingPtr; int result, srcRead, dstWrote, dstChars; Tcl_EncodingState state; - (void)dummy; if (encoding == NULL) { encoding = systemEncoding; @@ -2095,15 +2049,11 @@ LoadEscapeEncoding( static int BinaryProc( - ClientData clientData, /* Not used. */ + TCL_UNUSED(ClientData), const char *src, /* Source string (unknown encoding). */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ - Tcl_EncodingState *statePtr,/* Place for conversion routine to store state - * information used during a piecewise - * conversion. Contents of statePtr are - * initialized and/or reset by conversion - * routine under control of flags argument. */ + TCL_UNUSED(Tcl_EncodingState *), char *dst, /* Output buffer in which converted string is * stored. */ int dstLen, /* The maximum length of output buffer in @@ -2118,8 +2068,6 @@ BinaryProc( * output buffer. */ { int result; - (void)clientData; - (void)statePtr; result = TCL_OK; dstLen -= TCL_UTF_MAX - 1; @@ -2161,7 +2109,7 @@ BinaryProc( static int UtfIntToUtfExtProc( - ClientData clientData, /* Not used. */ + ClientData clientData, const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ @@ -2210,7 +2158,7 @@ UtfIntToUtfExtProc( static int UtfExtToUtfIntProc( - ClientData clientData, /* Not used. */ + ClientData clientData, const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ @@ -2259,7 +2207,7 @@ UtfExtToUtfIntProc( static int UtfToUtfProc( - ClientData clientData, /* Not used. */ + TCL_UNUSED(ClientData), const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ @@ -2291,7 +2239,6 @@ UtfToUtfProc( const char *dstStart, *dstEnd; int result, numChars, charLimit = INT_MAX; Tcl_UniChar *chPtr = (Tcl_UniChar *) statePtr; - (void)clientData; if (flags & TCL_ENCODING_START) { *statePtr = 0; @@ -2398,11 +2345,7 @@ Utf16ToUtfProc( const char *src, /* Source string in Unicode. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ - Tcl_EncodingState *statePtr,/* Place for conversion routine to store state - * information used during a piecewise - * conversion. Contents of statePtr are - * initialized and/or reset by conversion - * routine under control of flags argument. */ + TCL_UNUSED(Tcl_EncodingState *), char *dst, /* Output buffer in which converted string is * stored. */ int dstLen, /* The maximum length of output buffer in @@ -2423,7 +2366,6 @@ Utf16ToUtfProc( const char *dstEnd, *dstStart; int result, numChars, charLimit = INT_MAX; unsigned short ch; - (void)statePtr; if (flags & TCL_ENCODING_CHAR_LIMIT) { charLimit = *dstCharsPtr; @@ -2618,11 +2560,7 @@ UtfToUcs2Proc( const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ - Tcl_EncodingState *statePtr,/* Place for conversion routine to store state - * information used during a piecewise - * conversion. Contents of statePtr are - * initialized and/or reset by conversion - * routine under control of flags argument. */ + TCL_UNUSED(Tcl_EncodingState *), char *dst, /* Output buffer in which converted string is * stored. */ int dstLen, /* The maximum length of output buffer in @@ -2645,7 +2583,6 @@ UtfToUcs2Proc( int len; #endif Tcl_UniChar ch = 0; - (void)statePtr; srcStart = src; srcEnd = src + srcLen; @@ -2728,11 +2665,7 @@ TableToUtfProc( const char *src, /* Source string in specified encoding. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ - Tcl_EncodingState *statePtr,/* Place for conversion routine to store state - * information used during a piecewise - * conversion. Contents of statePtr are - * initialized and/or reset by conversion - * routine under control of flags argument. */ + TCL_UNUSED(Tcl_EncodingState *), char *dst, /* Output buffer in which converted string is * stored. */ int dstLen, /* The maximum length of output buffer in @@ -2756,7 +2689,6 @@ TableToUtfProc( const unsigned short *const *toUnicode; const unsigned short *pageZero; TableEncodingData *dataPtr = (TableEncodingData *)clientData; - (void)statePtr; if (flags & TCL_ENCODING_CHAR_LIMIT) { charLimit = *dstCharsPtr; @@ -2842,11 +2774,7 @@ TableFromUtfProc( const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ - Tcl_EncodingState *statePtr,/* Place for conversion routine to store state - * information used during a piecewise - * conversion. Contents of statePtr are - * initialized and/or reset by conversion - * routine under control of flags argument. */ + TCL_UNUSED(Tcl_EncodingState *), char *dst, /* Output buffer in which converted string is * stored. */ int dstLen, /* The maximum length of output buffer in @@ -2869,7 +2797,6 @@ TableFromUtfProc( int result, len, word, numChars; TableEncodingData *dataPtr = (TableEncodingData *)clientData; const unsigned short *const *fromUnicode; - (void)statePtr; result = TCL_OK; @@ -2964,15 +2891,11 @@ TableFromUtfProc( static int Iso88591ToUtfProc( - ClientData clientData, /* Ignored. */ + TCL_UNUSED(ClientData), const char *src, /* Source string in specified encoding. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ - Tcl_EncodingState *statePtr,/* Place for conversion routine to store state - * information used during a piecewise - * conversion. Contents of statePtr are - * initialized and/or reset by conversion - * routine under control of flags argument. */ + TCL_UNUSED(Tcl_EncodingState *), char *dst, /* Output buffer in which converted string is * stored. */ int dstLen, /* The maximum length of output buffer in @@ -2992,8 +2915,6 @@ Iso88591ToUtfProc( const char *srcStart, *srcEnd; const char *dstEnd, *dstStart; int result, numChars, charLimit = INT_MAX; - (void)clientData; - (void)statePtr; if (flags & TCL_ENCODING_CHAR_LIMIT) { charLimit = *dstCharsPtr; @@ -3050,15 +2971,11 @@ Iso88591ToUtfProc( static int Iso88591FromUtfProc( - ClientData clientData, /* Ignored. */ + TCL_UNUSED(ClientData), const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ - Tcl_EncodingState *statePtr,/* Place for conversion routine to store state - * information used during a piecewise - * conversion. Contents of statePtr are - * initialized and/or reset by conversion - * routine under control of flags argument. */ + TCL_UNUSED(Tcl_EncodingState *), char *dst, /* Output buffer in which converted string is * stored. */ int dstLen, /* The maximum length of output buffer in @@ -3079,8 +2996,6 @@ Iso88591FromUtfProc( const char *dstStart, *dstEnd; int result = TCL_OK, numChars; Tcl_UniChar ch = 0; - (void)clientData; - (void)statePtr; srcStart = src; srcEnd = src + srcLen; |