summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-06-20 21:47:26 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-06-20 21:47:26 (GMT)
commit26e99bad85be55cb8f27649867fdcebfd92d424b (patch)
tree2622dff5d8005e8fac304fc4fee533d5d1c34a8b /generic
parentc43ea691ad581cf0ce07b45cdbafc84a1fe2a07e (diff)
downloadtcl-26e99bad85be55cb8f27649867fdcebfd92d424b.zip
tcl-26e99bad85be55cb8f27649867fdcebfd92d424b.tar.gz
tcl-26e99bad85be55cb8f27649867fdcebfd92d424b.tar.bz2
Fix (internal) TclFindElement() signature (int -> size_t)
Diffstat (limited to 'generic')
-rw-r--r--generic/tclInt.decls2
-rw-r--r--generic/tclIntDecls.h4
-rw-r--r--generic/tclUtil.c18
3 files changed, 11 insertions, 13 deletions
diff --git a/generic/tclInt.decls b/generic/tclInt.decls
index 9a92888..4c05de8 100644
--- a/generic/tclInt.decls
+++ b/generic/tclInt.decls
@@ -62,7 +62,7 @@ declare 16 {
}
declare 22 {
int TclFindElement(Tcl_Interp *interp, const char *listStr,
- int listLength, const char **elementPtr, const char **nextPtr,
+ size_t listLength, const char **elementPtr, const char **nextPtr,
size_t *sizePtr, int *bracePtr)
}
declare 23 {
diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h
index d3c05d5..9393c96 100644
--- a/generic/tclIntDecls.h
+++ b/generic/tclIntDecls.h
@@ -87,7 +87,7 @@ EXTERN void TclExprFloatError(Tcl_Interp *interp, double value);
/* Slot 21 is reserved */
/* 22 */
EXTERN int TclFindElement(Tcl_Interp *interp,
- const char *listStr, int listLength,
+ const char *listStr, size_t listLength,
const char **elementPtr,
const char **nextPtr, size_t *sizePtr,
int *bracePtr);
@@ -603,7 +603,7 @@ typedef struct TclIntStubs {
void (*reserved19)(void);
void (*reserved20)(void);
void (*reserved21)(void);
- int (*tclFindElement) (Tcl_Interp *interp, const char *listStr, int listLength, const char **elementPtr, const char **nextPtr, size_t *sizePtr, int *bracePtr); /* 22 */
+ int (*tclFindElement) (Tcl_Interp *interp, const char *listStr, size_t listLength, const char **elementPtr, const char **nextPtr, size_t *sizePtr, int *bracePtr); /* 22 */
Proc * (*tclFindProc) (Interp *iPtr, const char *procName); /* 23 */
size_t (*tclFormatInt) (char *buffer, Tcl_WideInt n); /* 24 */
void (*tclFreePackageInfo) (Interp *iPtr); /* 25 */
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 17a9dfe..43a24f7 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -493,7 +493,7 @@ TclFindElement(
const char *list, /* Points to the first byte of a string
* containing a Tcl list with zero or more
* elements (possibly in braces). */
- int listLength, /* Number of bytes in the list's string. */
+ size_t listLength, /* Number of bytes in the list's string. */
const char **elementPtr, /* Where to put address of first significant
* character in first element of list. */
const char **nextPtr, /* Fill in with location of character just
@@ -550,7 +550,7 @@ FindElement(
* containing a Tcl list or dictionary with
* zero or more elements (possibly in
* braces). */
- size_t stringLength1, /* Number of bytes in the string. */
+ size_t stringLength, /* Number of bytes in the string. */
const char *typeStr, /* The name of the type of thing we are
* parsing, for error messages. */
const char *typeCode, /* The type code for thing we are parsing, for
@@ -572,13 +572,12 @@ FindElement(
const char *p = string;
const char *elemStart; /* Points to first byte of first element. */
const char *limit; /* Points just after list/dict's last byte. */
- int openBraces = 0; /* Brace nesting level during parse. */
+ size_t openBraces = 0; /* Brace nesting level during parse. */
int inQuotes = 0;
- int size = 0;
+ size_t size = 0;
size_t numChars;
int literal = 1;
const char *p2;
- int stringLength = stringLength1;
/*
* Skim off leading white space and check for an opening brace or quote.
@@ -976,7 +975,7 @@ Tcl_ScanCountedElement(
* Tcl_ConvertElement. */
{
char flags = CONVERT_ANY;
- int numBytes = TclScanElement(src, length, &flags);
+ size_t numBytes = TclScanElement(src, length, &flags);
*flagPtr = flags;
return numBytes;
@@ -1020,7 +1019,7 @@ TclScanElement(
* Tcl_ConvertElement. */
{
const char *p = src;
- int nestingLevel = 0; /* Brace nesting count */
+ size_t nestingLevel = 0; /* Brace nesting count */
int forbidNone = 0; /* Do not permit CONVERT_NONE mode. Something
* needs protection or escape. */
int requireEscape = 0; /* Force use of CONVERT_ESCAPE mode. For some
@@ -1089,8 +1088,7 @@ TclScanElement(
braceCount++;
#endif /* COMPAT */
extra++; /* Escape '}' => '\}' */
- nestingLevel--;
- if (nestingLevel < 0) {
+ if (nestingLevel-- < 1) {
/*
* Unbalanced braces! Cannot format with brace quoting.
*/
@@ -1171,7 +1169,7 @@ TclScanElement(
}
endOfString:
- if (nestingLevel != 0) {
+ if (nestingLevel > 0) {
/*
* Unbalanced braces! Cannot format with brace quoting.
*/