summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2024-06-12 20:24:40 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2024-06-12 20:24:40 (GMT)
commit73267eb55f525b707d0fdcefd762a8fee30db37c (patch)
treec7674bb24c32f4a953dcf76bb4e3450cadcf6f23
parent27863f91869e8509ed1616633b505ab8d71585c6 (diff)
downloadtcl-73267eb55f525b707d0fdcefd762a8fee30db37c.zip
tcl-73267eb55f525b707d0fdcefd762a8fee30db37c.tar.gz
tcl-73267eb55f525b707d0fdcefd762a8fee30db37c.tar.bz2
Fix some indentation/wrapping for style
-rw-r--r--generic/tclEncoding.c280
1 files changed, 153 insertions, 127 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 129ca51..624705d 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -34,9 +34,9 @@ typedef struct {
Tcl_EncodingFreeProc *freeProc;
/* If non-NULL, function to call when this
* encoding is deleted. */
- void *clientData; /* Arbitrary value associated with encoding
+ void *clientData; /* Arbitrary value associated with encoding
* type. Passed to conversion functions. */
- Tcl_Size nullSize; /* Number of 0x00 bytes that signify
+ Tcl_Size nullSize; /* Number of 0x00 bytes that signify
* end-of-string in this encoding. This number
* is used to determine the source string
* length when the srcLen argument is
@@ -119,7 +119,8 @@ typedef struct {
* entry in this array is 1, otherwise it is
* 0. */
int numSubTables; /* Length of following array. */
- EscapeSubTable subTables[TCLFLEXARRAY];/* Information about each EscapeSubTable used
+ EscapeSubTable subTables[TCLFLEXARRAY];
+ /* Information about each EscapeSubTable used
* by this encoding type. The actual size is
* as large as necessary to hold all
* EscapeSubTables. */
@@ -201,19 +202,19 @@ static const struct TclEncodingProfiles {
{"tcl8", TCL_ENCODING_PROFILE_TCL8},
};
-#define PROFILE_TCL8(flags_) \
+#define PROFILE_TCL8(flags_) \
(ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_TCL8)
-#define PROFILE_REPLACE(flags_) \
+#define PROFILE_REPLACE(flags_) \
(ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_REPLACE)
-#define PROFILE_STRICT(flags_) \
+#define PROFILE_STRICT(flags_) \
(!PROFILE_TCL8(flags_) && !PROFILE_REPLACE(flags_))
#define UNICODE_REPLACE_CHAR 0xFFFD
-#define SURROGATE(c_) (((c_) & ~0x7FF) == 0xD800)
-#define HIGH_SURROGATE(c_) (((c_) & ~0x3FF) == 0xD800)
-#define LOW_SURROGATE(c_) (((c_) & ~0x3FF) == 0xDC00)
+#define SURROGATE(c_) (((c_) & ~0x7FF) == 0xD800)
+#define HIGH_SURROGATE(c_) (((c_) & ~0x3FF) == 0xD800)
+#define LOW_SURROGATE(c_) (((c_) & ~0x3FF) == 0xDC00)
/*
* The following variable is used in the sparse matrix code for a
@@ -259,9 +260,9 @@ static Tcl_EncodingConvertProc Iso88591FromUtfProc;
static Tcl_EncodingConvertProc Iso88591ToUtfProc;
/*
- * A Tcl_ObjType for holding a cached Tcl_Encoding in the twoPtrValue.ptr1 field
- * of the internalrep. This should help the lifetime of encodings be more useful.
- * See concerns raised in [Bug 1077262].
+ * A Tcl_ObjType for holding a cached Tcl_Encoding in the twoPtrValue.ptr1
+ * field of the internalrep. This should help the lifetime of encodings be more
+ * useful. See concerns raised in [Bug 1077262].
*/
static const Tcl_ObjType encodingType = {
@@ -510,9 +511,13 @@ FillEncodingFileMap(void)
*
* To prevent conflicting bits, only define bits within 0xff00 mask here.
*/
-#define TCL_ENCODING_LE 0x100 /* Used to distinguish LE/BE variants */
-#define ENCODING_UTF 0x200 /* For UTF-8 encoding, allow 4-byte output sequences */
-#define ENCODING_INPUT 0x400 /* For UTF-8/CESU-8 encoding, means external -> internal */
+enum InternalEncodingFlags {
+ TCL_ENCODING_LE = 0x100, /* Used to distinguish LE/BE variants */
+ ENCODING_UTF = 0x200, /* For UTF-8 encoding, allow 4-byte output
+ * sequences */
+ ENCODING_INPUT = 0x400 /* For UTF-8/CESU-8 encoding, means
+ * external -> internal */
+};
void
TclInitEncodingSubsystem(void)
@@ -565,30 +570,30 @@ TclInitEncodingSubsystem(void)
Tcl_CreateEncoding(&type);
type.toUtfProc = Utf16ToUtfProc;
- type.fromUtfProc = UtfToUcs2Proc;
+ type.fromUtfProc = UtfToUcs2Proc;
type.freeProc = NULL;
type.nullSize = 2;
- type.encodingName = "ucs-2le";
+ type.encodingName = "ucs-2le";
type.clientData = INT2PTR(TCL_ENCODING_LE);
Tcl_CreateEncoding(&type);
- type.encodingName = "ucs-2be";
+ type.encodingName = "ucs-2be";
type.clientData = NULL;
Tcl_CreateEncoding(&type);
- type.encodingName = "ucs-2";
+ type.encodingName = "ucs-2";
type.clientData = INT2PTR(leFlags);
Tcl_CreateEncoding(&type);
type.toUtfProc = Utf32ToUtfProc;
- type.fromUtfProc = UtfToUtf32Proc;
+ type.fromUtfProc = UtfToUtf32Proc;
type.freeProc = NULL;
type.nullSize = 4;
- type.encodingName = "utf-32le";
+ type.encodingName = "utf-32le";
type.clientData = INT2PTR(TCL_ENCODING_LE);
Tcl_CreateEncoding(&type);
- type.encodingName = "utf-32be";
+ type.encodingName = "utf-32be";
type.clientData = NULL;
Tcl_CreateEncoding(&type);
- type.encodingName = "utf-32";
+ type.encodingName = "utf-32";
type.clientData = INT2PTR(leFlags);
Tcl_CreateEncoding(&type);
@@ -596,18 +601,18 @@ TclInitEncodingSubsystem(void)
type.fromUtfProc = UtfToUtf16Proc;
type.freeProc = NULL;
type.nullSize = 2;
- type.encodingName = "utf-16le";
+ type.encodingName = "utf-16le";
type.clientData = INT2PTR(TCL_ENCODING_LE);
Tcl_CreateEncoding(&type);
- type.encodingName = "utf-16be";
+ type.encodingName = "utf-16be";
type.clientData = NULL;
Tcl_CreateEncoding(&type);
- type.encodingName = "utf-16";
+ type.encodingName = "utf-16";
type.clientData = INT2PTR(leFlags);
Tcl_CreateEncoding(&type);
#ifndef TCL_NO_DEPRECATED
- type.encodingName = "unicode";
+ type.encodingName = "unicode";
Tcl_CreateEncoding(&type);
#endif
@@ -924,7 +929,7 @@ Tcl_GetEncodingNames(
* Tcl_GetEncodingNulLength --
*
* Given an encoding, return the number of nul bytes used for the
- * string termination.
+ * string termination.
*
* Results:
* The number of nul bytes used for the string termination.
@@ -1124,34 +1129,33 @@ Tcl_ExternalToUtfDString(
* - *At most one* of TCL_ENCODING_PROFILE{DEFAULT,TCL8,STRICT}
*
* Results:
- * The return value is one of
- * TCL_OK: success. Converted string in *dstPtr
- * TCL_ERROR: error in passed parameters. Error message in interp
- * TCL_CONVERT_MULTIBYTE: source ends in truncated multibyte sequence
- * TCL_CONVERT_SYNTAX: source is not conformant to encoding definition
- * TCL_CONVERT_UNKNOWN: source contained a character that could not
- * be represented in target encoding.
+ * The return value is one of
+ * TCL_OK: success. Converted string in *dstPtr
+ * TCL_ERROR: error in passed parameters. Error message in interp
+ * TCL_CONVERT_MULTIBYTE: source ends in truncated multibyte sequence
+ * TCL_CONVERT_SYNTAX: source is not conformant to encoding definition
+ * TCL_CONVERT_UNKNOWN: source contained a character that could not
+ * be represented in target encoding.
*
* Side effects:
- *
- * TCL_OK: The converted bytes are stored in the DString and NUL
- * terminated in an encoding-specific manner.
- * TCL_ERROR: an error, message is stored in the interp if not NULL.
- * TCL_CONVERT_*: if errorLocPtr is NULL, an error message is stored
- * in the interpreter (if not NULL). If errorLocPtr is not NULL,
- * no error message is stored as it is expected the caller is
- * interested in whatever is decoded so far and not treating this
- * as an error condition.
- *
- * In addition, *dstPtr is always initialized and must be cleared
- * by the caller irrespective of the return code.
+ * TCL_OK: The converted bytes are stored in the DString and NUL
+ * terminated in an encoding-specific manner.
+ * TCL_ERROR: an error, message is stored in the interp if not NULL.
+ * TCL_CONVERT_*: if errorLocPtr is NULL, an error message is stored
+ * in the interpreter (if not NULL). If errorLocPtr is not NULL,
+ * no error message is stored as it is expected the caller is
+ * interested in whatever is decoded so far and not treating this
+ * as an error condition.
+ *
+ * In addition, *dstPtr is always initialized and must be cleared
+ * by the caller irrespective of the return code.
*
*-------------------------------------------------------------------------
*/
int
Tcl_ExternalToUtfDStringEx(
- Tcl_Interp *interp, /* For error messages. May be NULL. */
+ Tcl_Interp *interp, /* For error messages. May be NULL. */
Tcl_Encoding encoding, /* The encoding for the source string, or NULL
* for the default system encoding. */
const char *src, /* Source string in specified encoding. */
@@ -1160,8 +1164,8 @@ Tcl_ExternalToUtfDStringEx(
int flags, /* Conversion control flags. */
Tcl_DString *dstPtr, /* Uninitialized or free DString in which the
* converted string is stored. */
- Tcl_Size *errorLocPtr) /* Where to store the error location
- * (or TCL_INDEX_NONE if no error). May
+ Tcl_Size *errorLocPtr) /* Where to store the error location
+ * (or TCL_INDEX_NONE if no error). May
* be NULL. */
{
char *dst;
@@ -1231,18 +1235,21 @@ Tcl_ExternalToUtfDStringEx(
* Do not write error message into interpreter if caller
* wants to know error location.
*/
- *errorLocPtr = result == TCL_OK ? TCL_INDEX_NONE : nBytesProcessed;
+ *errorLocPtr = result == TCL_OK
+ ? TCL_INDEX_NONE : nBytesProcessed;
} else {
/* Caller wants error message on failure */
if (result != TCL_OK && interp != NULL) {
char buf[TCL_INTEGER_SPACE];
- snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "d", nBytesProcessed);
+ snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "d",
+ nBytesProcessed);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unexpected byte sequence starting at index %"
TCL_SIZE_MODIFIER "d: '\\x%02X'",
nBytesProcessed, UCHAR(srcStart[nBytesProcessed])));
Tcl_SetErrorCode(
- interp, "TCL", "ENCODING", "ILLEGALSEQUENCE", buf, (void *)NULL);
+ interp, "TCL", "ENCODING", "ILLEGALSEQUENCE", buf,
+ (void *)NULL);
}
}
if (result != TCL_OK) {
@@ -1287,8 +1294,9 @@ Tcl_ExternalToUtf(
Tcl_Encoding encoding, /* The encoding for the source string, or NULL
* for the default system encoding. */
const char *src, /* Source string in specified encoding. */
- Tcl_Size srcLen, /* Source string length in bytes, or TCL_INDEX_NONE for
- * encoding-specific string length. */
+ Tcl_Size srcLen, /* Source string length in bytes, or
+ * TCL_INDEX_NONE for encoding-specific string
+ * length. */
int flags, /* Conversion control flags. */
Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
* information used during a piecewise
@@ -1440,34 +1448,33 @@ Tcl_UtfToExternalDString(
* - *At most one* of TCL_ENCODING_PROFILE_*
*
* Results:
- * The return value is one of
- * TCL_OK: success. Converted string in *dstPtr
- * TCL_ERROR: error in passed parameters. Error message in interp
- * TCL_CONVERT_MULTIBYTE: source ends in truncated multibyte sequence
- * TCL_CONVERT_SYNTAX: source is not conformant to encoding definition
- * TCL_CONVERT_UNKNOWN: source contained a character that could not
- * be represented in target encoding.
+ * The return value is one of
+ * TCL_OK: success. Converted string in *dstPtr
+ * TCL_ERROR: error in passed parameters. Error message in interp
+ * TCL_CONVERT_MULTIBYTE: source ends in truncated multibyte sequence
+ * TCL_CONVERT_SYNTAX: source is not conformant to encoding definition
+ * TCL_CONVERT_UNKNOWN: source contained a character that could not
+ * be represented in target encoding.
*
* Side effects:
- *
- * TCL_OK: The converted bytes are stored in the DString and NUL
- * terminated in an encoding-specific manner
- * TCL_ERROR: an error, message is stored in the interp if not NULL.
- * TCL_CONVERT_*: if errorLocPtr is NULL, an error message is stored
- * in the interpreter (if not NULL). If errorLocPtr is not NULL,
- * no error message is stored as it is expected the caller is
- * interested in whatever is decoded so far and not treating this
- * as an error condition.
- *
- * In addition, *dstPtr is always initialized and must be cleared
- * by the caller irrespective of the return code.
+ * TCL_OK: The converted bytes are stored in the DString and NUL
+ * terminated in an encoding-specific manner
+ * TCL_ERROR: an error, message is stored in the interp if not NULL.
+ * TCL_CONVERT_*: if errorLocPtr is NULL, an error message is stored
+ * in the interpreter (if not NULL). If errorLocPtr is not NULL,
+ * no error message is stored as it is expected the caller is
+ * interested in whatever is decoded so far and not treating this
+ * as an error condition.
+ *
+ * In addition, *dstPtr is always initialized and must be cleared
+ * by the caller irrespective of the return code.
*
*-------------------------------------------------------------------------
*/
int
Tcl_UtfToExternalDStringEx(
- Tcl_Interp *interp, /* For error messages. May be NULL. */
+ Tcl_Interp *interp, /* For error messages. May be NULL. */
Tcl_Encoding encoding, /* The encoding for the converted string, or
* NULL for the default system encoding. */
const char *src, /* Source string in UTF-8. */
@@ -1476,8 +1483,8 @@ Tcl_UtfToExternalDStringEx(
int flags, /* Conversion control flags. */
Tcl_DString *dstPtr, /* Uninitialized or free DString in which the
* converted string is stored. */
- Tcl_Size *errorLocPtr) /* Where to store the error location
- * (or TCL_INDEX_NONE if no error). May
+ Tcl_Size *errorLocPtr) /* Where to store the error location
+ * (or TCL_INDEX_NONE if no error). May
* be NULL. */
{
char *dst;
@@ -1547,7 +1554,8 @@ Tcl_UtfToExternalDStringEx(
* Do not write error message into interpreter if caller
* wants to know error location.
*/
- *errorLocPtr = result == TCL_OK ? TCL_INDEX_NONE : nBytesProcessed;
+ *errorLocPtr = result == TCL_OK
+ ? TCL_INDEX_NONE : nBytesProcessed;
} else {
/* Caller wants error message on failure */
if (result != TCL_OK && interp != NULL) {
@@ -1556,7 +1564,8 @@ Tcl_UtfToExternalDStringEx(
char buf[TCL_INTEGER_SPACE];
TclUtfToUniChar(&srcStart[nBytesProcessed], &ucs4);
- snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "d", nBytesProcessed);
+ snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "d",
+ nBytesProcessed);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unexpected character at index %" TCL_SIZE_MODIFIER
"u: 'U+%06X'",
@@ -1607,8 +1616,8 @@ Tcl_UtfToExternal(
Tcl_Encoding encoding, /* The encoding for the converted string, or
* NULL for the default system encoding. */
const char *src, /* Source string in UTF-8. */
- Tcl_Size srcLen, /* Source string length in bytes, or TCL_INDEX_NONE for
- * strlen(). */
+ Tcl_Size srcLen, /* Source string length in bytes, or
+ * TCL_INDEX_NONE for strlen(). */
int flags, /* Conversion control flags. */
Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
* information used during a piecewise
@@ -1816,7 +1825,8 @@ OpenEncodingFileChannel(
if ((NULL == chan) && (interp != NULL)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unknown encoding \"%s\"", name));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ENCODING", name, (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ENCODING", name,
+ (void *)NULL);
}
Tcl_DecrRefCount(fileNameObj);
Tcl_DecrRefCount(searchPath);
@@ -1890,7 +1900,8 @@ LoadEncodingFile(
if ((encoding == NULL) && (interp != NULL)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"invalid encoding file \"%s\"", name));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ENCODING", name, (void *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ENCODING", name,
+ (void *)NULL);
}
Tcl_CloseEx(NULL, chan, 0);
@@ -2280,8 +2291,8 @@ LoadEscapeEncoding(
e = (Encoding *) Tcl_GetEncoding(NULL, est.name);
if ((e != NULL) && (e->toUtfProc != TableToUtfProc)
&& (e->toUtfProc != Iso88591ToUtfProc)) {
- Tcl_FreeEncoding((Tcl_Encoding) e);
- e = NULL;
+ Tcl_FreeEncoding((Tcl_Encoding) e);
+ e = NULL;
}
est.encodingPtr = e;
Tcl_DStringAppend(&escapeData, (char *) &est, sizeof(est));
@@ -2468,7 +2479,8 @@ UtfToUtfProc(
result = TCL_CONVERT_NOSPACE;
break;
}
- if (UCHAR(*src) < 0x80 && !((UCHAR(*src) == 0) && (flags & ENCODING_INPUT))) {
+ if (UCHAR(*src) < 0x80
+ && !((UCHAR(*src) == 0) && (flags & ENCODING_INPUT))) {
/*
* Copy 7bit characters, but skip null-bytes when we are in input
* mode, so that they get converted to \xC0\x80.
@@ -2480,12 +2492,12 @@ UtfToUtfProc(
/* Special sequence \xC0\x80 */
if (!PROFILE_TCL8(profile) && (flags & ENCODING_INPUT)) {
if (PROFILE_REPLACE(profile)) {
- dst += Tcl_UniCharToUtf(UNICODE_REPLACE_CHAR, dst);
- src += 2;
+ dst += Tcl_UniCharToUtf(UNICODE_REPLACE_CHAR, dst);
+ src += 2;
} else {
- /* PROFILE_STRICT */
- result = TCL_CONVERT_SYNTAX;
- break;
+ /* PROFILE_STRICT */
+ result = TCL_CONVERT_SYNTAX;
+ break;
}
} else {
/*
@@ -2509,8 +2521,8 @@ UtfToUtfProc(
/* Incomplete bytes for modified UTF-8 target */
if (PROFILE_STRICT(profile)) {
result = (flags & TCL_ENCODING_CHAR_LIMIT)
- ? TCL_CONVERT_MULTIBYTE
- : TCL_CONVERT_SYNTAX;
+ ? TCL_CONVERT_MULTIBYTE
+ : TCL_CONVERT_SYNTAX;
break;
}
}
@@ -2527,7 +2539,8 @@ UtfToUtfProc(
} else {
size_t len = TclUtfToUniChar(src, &ch);
if (flags & ENCODING_INPUT) {
- if (((len < 2) && (ch != 0)) || ((ch > 0xFFFF) && !(flags & ENCODING_UTF))) {
+ if (((len < 2) && (ch != 0))
+ || ((ch > 0xFFFF) && !(flags & ENCODING_UTF))) {
if (PROFILE_STRICT(profile)) {
result = TCL_CONVERT_SYNTAX;
break;
@@ -2539,7 +2552,8 @@ UtfToUtfProc(
const char *saveSrc = src;
src += len;
- if (!(flags & ENCODING_UTF) && !(flags & ENCODING_INPUT) && (ch > 0x3FF)) {
+ if (!(flags & ENCODING_UTF) && !(flags & ENCODING_INPUT)
+ && (ch > 0x3FF)) {
if (ch > 0xFFFF) {
/* CESU-8 6-byte sequence for chars > U+FFFF */
ch -= 0x10000;
@@ -2554,7 +2568,8 @@ UtfToUtfProc(
continue;
} else if (SURROGATE(ch)) {
if (PROFILE_STRICT(profile)) {
- result = (flags & ENCODING_INPUT) ? TCL_CONVERT_SYNTAX : TCL_CONVERT_UNKNOWN;
+ result = (flags & ENCODING_INPUT)
+ ? TCL_CONVERT_SYNTAX : TCL_CONVERT_UNKNOWN;
src = saveSrc;
break;
} else if (PROFILE_REPLACE(profile)) {
@@ -2589,7 +2604,7 @@ UtfToUtfProc(
static int
Utf32ToUtfProc(
- void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */
+ void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */
const char *src, /* Source string in Unicode. */
int srcLen, /* Source string length in bytes. */
int flags, /* Conversion control flags. */
@@ -2643,9 +2658,11 @@ Utf32ToUtfProc(
}
if (flags & TCL_ENCODING_LE) {
- ch = (unsigned int)(src[3] & 0xFF) << 24 | (src[2] & 0xFF) << 16 | (src[1] & 0xFF) << 8 | (src[0] & 0xFF);
+ ch = (unsigned int)(src[3] & 0xFF) << 24 | (src[2] & 0xFF) << 16
+ | (src[1] & 0xFF) << 8 | (src[0] & 0xFF);
} else {
- ch = (unsigned int)(src[0] & 0xFF) << 24 | (src[1] & 0xFF) << 16 | (src[2] & 0xFF) << 8 | (src[3] & 0xFF);
+ ch = (unsigned int)(src[0] & 0xFF) << 24 | (src[1] & 0xFF) << 16
+ | (src[2] & 0xFF) << 8 | (src[3] & 0xFF);
}
if ((unsigned)ch > 0x10FFFF) {
if (PROFILE_STRICT(flags)) {
@@ -2718,7 +2735,7 @@ Utf32ToUtfProc(
static int
UtfToUtf32Proc(
- void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */
+ void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */
const char *src, /* Source string in UTF-8. */
int srcLen, /* Source string length in bytes. */
int flags, /* Conversion control flags. */
@@ -2817,7 +2834,7 @@ UtfToUtf32Proc(
static int
Utf16ToUtfProc(
- void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */
+ void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */
const char *src, /* Source string in Unicode. */
int srcLen, /* Source string length in bytes. */
int flags, /* Conversion control flags. */
@@ -2875,7 +2892,8 @@ Utf16ToUtfProc(
dstStart = dst;
dstEnd = dst + dstLen - TCL_UTF_MAX;
- for (numChars = 0; src < srcEnd && numChars <= charLimit; src += 2, numChars++) {
+ for (numChars = 0; src < srcEnd && numChars <= charLimit;
+ src += 2, numChars++) {
if (dst > dstEnd) {
result = TCL_CONVERT_NOSPACE;
break;
@@ -2890,16 +2908,16 @@ Utf16ToUtfProc(
if (HIGH_SURROGATE(prev) && !LOW_SURROGATE(ch)) {
if (PROFILE_STRICT(flags)) {
result = TCL_CONVERT_SYNTAX;
- src -= 2; /* Go back to beginning of high surrogate */
- dst--; /* Also undo writing a single byte too much */
+ src -= 2; /* Go back to beginning of high surrogate */
+ dst--; /* Also undo writing a single byte too much */
numChars--;
break;
} else if (PROFILE_REPLACE(flags)) {
/*
* Previous loop wrote a single byte to mark the high surrogate.
* Replace it with the replacement character. Further, restart
- * current loop iteration since need to recheck destination space
- * and reset processing of current character.
+ * current loop iteration since need to recheck destination
+ * space and reset processing of current character.
*/
ch = UNICODE_REPLACE_CHAR;
dst--;
@@ -2908,7 +2926,10 @@ Utf16ToUtfProc(
numChars--;
continue;
} else {
- /* Bug [10c2c17c32]. If Hi surrogate not followed by Lo surrogate, finish 3-byte UTF-8 */
+ /*
+ * Bug [10c2c17c32]. If Hi surrogate not followed by Lo
+ * surrogate, finish 3-byte UTF-8
+ */
dst += Tcl_UniCharToUtf(-1, dst);
}
}
@@ -2995,7 +3016,7 @@ Utf16ToUtfProc(
static int
UtfToUtf16Proc(
- void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */
+ void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */
const char *src, /* Source string in UTF-8. */
int srcLen, /* Source string length in bytes. */
int flags, /* Conversion control flags. */
@@ -3103,7 +3124,7 @@ UtfToUtf16Proc(
static int
UtfToUcs2Proc(
- void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */
+ void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */
const char *src, /* Source string in UTF-8. */
int srcLen, /* Source string length in bytes. */
int flags, /* Conversion control flags. */
@@ -3207,7 +3228,7 @@ UtfToUcs2Proc(
static int
TableToUtfProc(
- void *clientData, /* TableEncodingData that specifies
+ void *clientData, /* TableEncodingData that specifies
* encoding. */
const char *src, /* Source string in specified encoding. */
int srcLen, /* Source string length in bytes. */
@@ -3270,7 +3291,8 @@ TableToUtfProc(
} else if (PROFILE_REPLACE(flags)) {
ch = UNICODE_REPLACE_CHAR;
} else {
- /* For prefix bytes, we don't fallback to cp1252, see [1355b9a874] */
+ /* For prefix bytes, we don't fallback to cp1252, see
+ * [1355b9a874] */
ch = byte;
}
} else {
@@ -3335,7 +3357,7 @@ TableToUtfProc(
static int
TableFromUtfProc(
- void *clientData, /* TableEncodingData that specifies
+ void *clientData, /* TableEncodingData that specifies
* encoding. */
const char *src, /* Source string in UTF-8. */
int srcLen, /* Source string length in bytes. */
@@ -3627,7 +3649,7 @@ Iso88591FromUtfProc(
static void
TableFreeProc(
- void *clientData) /* TableEncodingData that specifies
+ void *clientData) /* TableEncodingData that specifies
* encoding. */
{
TableEncodingData *dataPtr = (TableEncodingData *)clientData;
@@ -3662,7 +3684,7 @@ TableFreeProc(
static int
EscapeToUtfProc(
- void *clientData, /* EscapeEncodingData that specifies
+ void *clientData, /* EscapeEncodingData that specifies
* encoding. */
const char *src, /* Source string in specified encoding. */
int srcLen, /* Source string length in bytes. */
@@ -3875,7 +3897,7 @@ EscapeToUtfProc(
static int
EscapeFromUtfProc(
- void *clientData, /* EscapeEncodingData that specifies
+ void *clientData, /* EscapeEncodingData that specifies
* encoding. */
const char *src, /* Source string in UTF-8. */
int srcLen, /* Source string length in bytes. */
@@ -3942,7 +3964,7 @@ EscapeFromUtfProc(
}
encodingPtr = GetTableEncoding(dataPtr, state);
- tableDataPtr = (const TableEncodingData *)encodingPtr->clientData;
+ tableDataPtr = (TableEncodingData *) encodingPtr->clientData;
tablePrefixBytes = tableDataPtr->prefixBytes;
tableFromUnicode = (const unsigned short *const *)
tableDataPtr->fromUnicode;
@@ -3970,7 +3992,7 @@ EscapeFromUtfProc(
oldState = state;
for (state = 0; state < dataPtr->numSubTables; state++) {
encodingPtr = GetTableEncoding(dataPtr, state);
- tableDataPtr = (const TableEncodingData *)encodingPtr->clientData;
+ tableDataPtr = (TableEncodingData *) encodingPtr->clientData;
word = tableDataPtr->fromUnicode[(ch >> 8)][ch & 0xFF];
if (word != 0) {
break;
@@ -3984,7 +4006,7 @@ EscapeFromUtfProc(
break;
}
encodingPtr = GetTableEncoding(dataPtr, state);
- tableDataPtr = (const TableEncodingData *)encodingPtr->clientData;
+ tableDataPtr = (TableEncodingData *) encodingPtr->clientData;
word = tableDataPtr->fallback;
}
@@ -4086,7 +4108,7 @@ EscapeFromUtfProc(
static void
EscapeFreeProc(
- void *clientData) /* EscapeEncodingData that specifies
+ void *clientData) /* EscapeEncodingData that specifies
* encoding. */
{
EscapeEncodingData *dataPtr = (EscapeEncodingData *)clientData;
@@ -4308,14 +4330,17 @@ TclEncodingProfileNameToId(
profileName);
for (i = 0; i < (numProfiles - 1); ++i) {
Tcl_AppendStringsToObj(
- errorObj, " ", encodingProfiles[i].name, ",", (void *)NULL);
+ errorObj, " ", encodingProfiles[i].name, ",",
+ (void *)NULL);
}
Tcl_AppendStringsToObj(
- errorObj, " or ", encodingProfiles[numProfiles-1].name, (void *)NULL);
+ errorObj, " or ", encodingProfiles[numProfiles-1].name,
+ (void *)NULL);
Tcl_SetObjResult(interp, errorObj);
Tcl_SetErrorCode(
- interp, "TCL", "ENCODING", "PROFILE", profileName, (void *)NULL);
+ interp, "TCL", "ENCODING", "PROFILE", profileName,
+ (void *)NULL);
}
return TCL_ERROR;
}
@@ -4342,7 +4367,8 @@ TclEncodingProfileIdToName(
{
size_t i;
- for (i = 0; i < sizeof(encodingProfiles) / sizeof(encodingProfiles[0]); ++i) {
+ for (i = 0; i < sizeof(encodingProfiles) / sizeof(encodingProfiles[0]);
+ ++i) {
if (profileValue == encodingProfiles[i].value) {
return encodingProfiles[i].name;
}
@@ -4352,7 +4378,7 @@ TclEncodingProfileIdToName(
"Internal error. Bad profile id \"%d\".",
profileValue));
Tcl_SetErrorCode(
- interp, "TCL", "ENCODING", "PROFILEID", (void *)NULL);
+ interp, "TCL", "ENCODING", "PROFILEID", (void *)NULL);
}
return NULL;
}
@@ -4381,12 +4407,12 @@ TclGetEncodingProfiles(
n = sizeof(encodingProfiles) / sizeof(encodingProfiles[0]);
objPtr = Tcl_NewListObj(n, NULL);
for (i = 0; i < n; ++i) {
- Tcl_ListObjAppendElement(
- interp, objPtr, Tcl_NewStringObj(encodingProfiles[i].name, TCL_INDEX_NONE));
+ Tcl_ListObjAppendElement(interp, objPtr,
+ Tcl_NewStringObj(encodingProfiles[i].name, TCL_INDEX_NONE));
}
Tcl_SetObjResult(interp, objPtr);
}
-
+
/*
* Local Variables:
* mode: c