Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Tranche 3 of adoption of TclPrintfResult |
|---|---|
| Timelines: | family | ancestors | descendants | both | c11-printf-result |
| Files: | files | file ages | folders |
| SHA3-256: |
3aa1ace500b221c1ac121e41c4254924 |
| User & Date: | dkf 2025-10-05 19:26:15.517 |
Context
|
2025-10-06
| ||
| 08:31 | Adoption of TclAppendPrintfToErrorInfo check-in: e3a772f56c user: dkf tags: c11-printf-result | |
|
2025-10-05
| ||
| 19:26 | Tranche 3 of adoption of TclPrintfResult check-in: 3aa1ace500 user: dkf tags: c11-printf-result | |
| 10:38 | Tranche 2 of adoption of TclPrintfResult check-in: 9a6fb43196 user: dkf tags: c11-printf-result | |
Changes
Changes to generic/tclArithSeries.c.
| ︙ | ︙ | |||
774 775 776 777 778 779 780 |
if (objPtr == NULL && interp) {
description = "invalid arithmetic series parameter values";
goto domain;
}
return objPtr;
exceeded:
| < | | | 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 |
if (objPtr == NULL && interp) {
description = "invalid arithmetic series parameter values";
goto domain;
}
return objPtr;
exceeded:
TclPrintfResult(interp, "max length of a Tcl list exceeded");
Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL);
return NULL;
domain:
TclPrintfResult(interp, "%s", description);
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", description, (char *)NULL);
return NULL;
notANumber:
description = "non-numeric floating-point value";
Tcl_PrintDouble(NULL, isnan(dstart) ? dstart : dend, tmp);
TclPrintfResult(interp,
|
| ︙ | ︙ | |||
1018 1019 1020 1021 1022 1023 1024 |
/* If this exists, it has already been populated */
objv = arithSeriesRepPtr->elements;
} else {
/* Construct the elements array */
objv = (Tcl_Obj **) Tcl_Alloc(sizeof(Tcl_Obj*) * objc);
if (objv == NULL) {
if (interp) {
| | | < | 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 |
/* If this exists, it has already been populated */
objv = arithSeriesRepPtr->elements;
} else {
/* Construct the elements array */
objv = (Tcl_Obj **) Tcl_Alloc(sizeof(Tcl_Obj*) * objc);
if (objv == NULL) {
if (interp) {
TclPrintfResult(interp,
"max length of a Tcl list exceeded");
Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL);
}
return TCL_ERROR;
}
arithSeriesRepPtr->elements = objv;
Tcl_Size i;
|
| ︙ | ︙ | |||
1044 1045 1046 1047 1048 1049 1050 |
} else {
objv = NULL;
}
*objvPtr = objv;
*objcPtr = objc;
} else {
if (interp != NULL) {
| < | | 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 |
} else {
objv = NULL;
}
*objvPtr = objv;
*objcPtr = objc;
} else {
if (interp != NULL) {
TclPrintfResult(interp, "value is not an arithseries");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "UNKNOWN", (char *)NULL);
}
return TCL_ERROR;
}
return TCL_OK;
}
|
| ︙ | ︙ |
Changes to generic/tclAssembly.c.
| ︙ | ︙ | |||
1348 1349 1350 1351 1352 1353 1354 |
Tcl_WrongNumArgs(interp, 1, &instNameObj, "imm8");
goto cleanup;
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
if (opnd < 0 || opnd > 3) {
| < | | 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 |
Tcl_WrongNumArgs(interp, 1, &instNameObj, "imm8");
goto cleanup;
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
if (opnd < 0 || opnd > 3) {
TclPrintfResult(interp, "operand must be [0..3]");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "OPERAND<0,>3", (char *)NULL);
goto cleanup;
}
BBEmitInstInt1(assemEnvPtr, tblIdx, opnd, opnd);
break;
case ASSEM_CONCAT1:
|
| ︙ | ︙ | |||
1507 1508 1509 1510 1511 1512 1513 |
if (GetNextOperand(assemEnvPtr, &tokenPtr, &operand1Obj) != TCL_OK) {
goto cleanup;
}
if (TclListObjGetElements(interp, operand1Obj, &jtObjc, &jtObjv) != TCL_OK) {
goto cleanup;
}
if (jtObjc % 2 != 0) {
| | | < | 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 |
if (GetNextOperand(assemEnvPtr, &tokenPtr, &operand1Obj) != TCL_OK) {
goto cleanup;
}
if (TclListObjGetElements(interp, operand1Obj, &jtObjc, &jtObjv) != TCL_OK) {
goto cleanup;
}
if (jtObjc % 2 != 0) {
TclPrintfResult(interp,
"jump table must have an even number of list elements");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADJUMPTABLE", (char *)NULL);
goto cleanup;
}
if (TalInstructionTable[tblIdx].tclInstCode == INST_JUMP_TABLE) {
JumptableInfo* jtPtr = AllocJumptable();
|
| ︙ | ︙ | |||
1615 1616 1617 1618 1619 1620 1621 |
goto cleanup;
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
if (opnd < 2) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
| < | | 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 |
goto cleanup;
}
if (GetIntegerOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
goto cleanup;
}
if (opnd < 2) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
TclPrintfResult(interp, "operand must be >=2");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "OPERAND>=2", (char *)NULL);
}
goto cleanup;
}
BBEmitInstInt4(assemEnvPtr, tblIdx, opnd, opnd);
break;
|
| ︙ | ︙ | |||
2044 2045 2046 2047 2048 2049 2050 |
DEBUG_PRINT("jump table {\n");
for (i = 0; i < objc; i+=2) {
DEBUG_PRINT(" %s -> %s\n", TclGetString(objv[i]),
TclGetString(objv[i+1]));
if (Tcl_GetWideIntFromObj(NULL, objv[i], &key) != TCL_OK) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
| | | < | 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 |
DEBUG_PRINT("jump table {\n");
for (i = 0; i < objc; i+=2) {
DEBUG_PRINT(" %s -> %s\n", TclGetString(objv[i]),
TclGetString(objv[i+1]));
if (Tcl_GetWideIntFromObj(NULL, objv[i], &key) != TCL_OK) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
TclPrintfResult(interp,
"jump table must have 64-bit integer keys");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADJUMPTABLEENTRY", (char *)NULL);
}
goto error;
}
hPtr = Tcl_CreateHashEntry(&jtnPtr->hashTable, INT2PTR(key), &isNew);
if (!isNew) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
|
| ︙ | ︙ | |||
2158 2159 2160 2161 2162 2163 2164 |
Tcl_Interp* interp = (Tcl_Interp*) assemEnvPtr->envPtr->iPtr;
Tcl_Obj* operandObj;
TclNewObj(operandObj);
if (!TclWordKnownAtCompileTime(*tokenPtrPtr, operandObj)) {
Tcl_DecrRefCount(operandObj);
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
| | | < | 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 |
Tcl_Interp* interp = (Tcl_Interp*) assemEnvPtr->envPtr->iPtr;
Tcl_Obj* operandObj;
TclNewObj(operandObj);
if (!TclWordKnownAtCompileTime(*tokenPtrPtr, operandObj)) {
Tcl_DecrRefCount(operandObj);
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
TclPrintfResult(interp,
"assembly code may not contain substitutions");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NOSUBST", (char *)NULL);
}
return TCL_ERROR;
}
*tokenPtrPtr = TokenAfter(*tokenPtrPtr);
Tcl_IncrRefCount(operandObj);
*operandObjPtr = operandObj;
|
| ︙ | ︙ | |||
2381 2382 2383 2384 2385 2386 2387 |
Tcl_DecrRefCount(varNameObj);
return TCL_INDEX_NONE;
}
localVar = TclFindCompiledLocal(varNameStr, varNameLen, 1, envPtr);
Tcl_DecrRefCount(varNameObj);
if (localVar < 0) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
| | | | 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 |
Tcl_DecrRefCount(varNameObj);
return TCL_INDEX_NONE;
}
localVar = TclFindCompiledLocal(varNameStr, varNameLen, 1, envPtr);
Tcl_DecrRefCount(varNameObj);
if (localVar < 0) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
TclPrintfResult(interp,
"cannot use this instruction to create a variable"
" in a non-proc context");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "LVT", (char *)NULL);
}
return TCL_INDEX_NONE;
}
*tokenPtrPtr = TokenAfter(tokenPtr);
return localVar;
}
|
| ︙ | ︙ | |||
2446 2447 2448 2449 2450 2451 2452 |
static int
CheckOneByte(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
Tcl_Size value) /* Value to check */
{
if (value < 0 || value > 0xFF) {
| < | | 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 |
static int
CheckOneByte(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
Tcl_Size value) /* Value to check */
{
if (value < 0 || value > 0xFF) {
TclPrintfResult(interp, "operand does not fit in one byte");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "1BYTE", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
2478 2479 2480 2481 2482 2483 2484 |
static int
CheckSignedOneByte(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
Tcl_Size value) /* Value to check */
{
if (value > 0x7F || value < -0x80) {
| < | | 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 |
static int
CheckSignedOneByte(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
Tcl_Size value) /* Value to check */
{
if (value > 0x7F || value < -0x80) {
TclPrintfResult(interp, "operand does not fit in one byte");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "1BYTE", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
2509 2510 2511 2512 2513 2514 2515 |
static int
CheckNonNegative(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
Tcl_Size value) /* Value to check */
{
if (value < 0 || value > INT_MAX) {
| < | | 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 |
static int
CheckNonNegative(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
Tcl_Size value) /* Value to check */
{
if (value < 0 || value > INT_MAX) {
TclPrintfResult(interp, "operand must be nonnegative");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NONNEGATIVE", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
2540 2541 2542 2543 2544 2545 2546 |
static int
CheckStrictlyPositive(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
Tcl_Size value) /* Value to check */
{
if (value <= 0 || value > INT_MAX) {
| < | | 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 |
static int
CheckStrictlyPositive(
Tcl_Interp* interp, /* Tcl interpreter for error reporting */
Tcl_Size value) /* Value to check */
{
if (value <= 0 || value > INT_MAX) {
TclPrintfResult(interp, "operand must be positive");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "POSITIVE", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
3399 3400 3401 3402 3403 3404 3405 |
* among the paths that reach it.
*/
if (blockPtr->initialStackDepth == initialStackDepth) {
return TCL_OK;
}
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
| | | < | 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 |
* among the paths that reach it.
*/
if (blockPtr->initialStackDepth == initialStackDepth) {
return TCL_OK;
}
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
TclPrintfResult(interp,
"inconsistent stack depths on two execution paths");
/*
* TODO - add execution trace of both paths
*/
Tcl_SetErrorLine(interp, blockPtr->startLine);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACK", (char *)NULL);
|
| ︙ | ︙ | |||
3430 3431 3432 3433 3434 3435 3436 |
/*
* Calculate minimum stack depth, and flag an error if the block
* underflows the stack.
*/
if (initialStackDepth + blockPtr->minStackDepth < 0) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
| < | | | < | 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 |
/*
* Calculate minimum stack depth, and flag an error if the block
* underflows the stack.
*/
if (initialStackDepth + blockPtr->minStackDepth < 0) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
TclPrintfResult(interp, "stack underflow");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACK", (char *)NULL);
AddBasicBlockRangeToErrorInfo(assemEnvPtr, blockPtr);
Tcl_SetErrorLine(interp, blockPtr->startLine);
}
return TCL_ERROR;
}
/*
* Make sure that the block doesn't try to pop below the stack level of an
* enclosing catch.
*/
if (blockPtr->enclosingCatch != 0 &&
initialStackDepth + blockPtr->minStackDepth
< (blockPtr->enclosingCatch->initialStackDepth
+ blockPtr->enclosingCatch->finalStackDepth)) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
TclPrintfResult(interp,
"code pops stack below level of enclosing catch");
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADSTACKINCATCH", (char *)NULL);
AddBasicBlockRangeToErrorInfo(assemEnvPtr, blockPtr);
Tcl_SetErrorLine(interp, blockPtr->startLine);
}
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
3722 3723 3724 3725 3726 3727 3728 |
* rechecked.
*/
if (bbPtr->catchState == BBCS_UNKNOWN) {
bbPtr->enclosingCatch = enclosing;
} else if (bbPtr->enclosingCatch != enclosing) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
| | | | 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 |
* rechecked.
*/
if (bbPtr->catchState == BBCS_UNKNOWN) {
bbPtr->enclosingCatch = enclosing;
} else if (bbPtr->enclosingCatch != enclosing) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
TclPrintfResult(interp,
"execution reaches an instruction in inconsistent "
"exception contexts");
Tcl_SetErrorLine(interp, bbPtr->startLine);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADCATCH", (char *)NULL);
}
return TCL_ERROR;
}
if (state > bbPtr->catchState) {
bbPtr->catchState = state;
|
| ︙ | ︙ | |||
3782 3783 3784 3785 3786 3787 3788 |
/*
* If the block ends a catch, the state for the successor is whatever
* the state was on entry to the catch.
*/
if (enclosing == NULL) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
| | | < | 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 |
/*
* If the block ends a catch, the state for the successor is whatever
* the state was on entry to the catch.
*/
if (enclosing == NULL) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
TclPrintfResult(interp,
"endCatch without a corresponding beginCatch");
Tcl_SetErrorLine(interp, bbPtr->startLine);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "BADENDCATCH", (char *)NULL);
}
return TCL_ERROR;
}
fallThruEnclosing = enclosing->enclosingCatch;
fallThruState = enclosing->catchState;
|
| ︙ | ︙ | |||
3860 3861 3862 3863 3864 3865 3866 |
CompileEnv* envPtr = assemEnvPtr->envPtr;
/* Compilation environment */
Tcl_Interp* interp = (Tcl_Interp*) envPtr->iPtr;
/* Tcl interpreter */
if (assemEnvPtr->curr_bb->catchState >= BBCS_INCATCH) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
| | | < | 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 |
CompileEnv* envPtr = assemEnvPtr->envPtr;
/* Compilation environment */
Tcl_Interp* interp = (Tcl_Interp*) envPtr->iPtr;
/* Tcl interpreter */
if (assemEnvPtr->curr_bb->catchState >= BBCS_INCATCH) {
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
TclPrintfResult(interp,
"catch still active on exit from assembly code");
Tcl_SetErrorLine(interp,
assemEnvPtr->curr_bb->enclosingCatch->startLine);
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "UNCLOSEDCATCH", (char *)NULL);
}
return TCL_ERROR;
}
return TCL_OK;
|
| ︙ | ︙ |
Changes to generic/tclBasic.c.
| ︙ | ︙ | |||
1521 1522 1523 1524 1525 1526 1527 |
void *clientData,
Tcl_Interp *interp,
TCL_UNUSED(int) /*objc*/,
TCL_UNUSED(Tcl_Obj *const *) /* objv */)
{
const UnsafeEnsembleInfo *infoPtr = (const UnsafeEnsembleInfo *)clientData;
| < | | 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 |
void *clientData,
Tcl_Interp *interp,
TCL_UNUSED(int) /*objc*/,
TCL_UNUSED(Tcl_Obj *const *) /* objv */)
{
const UnsafeEnsembleInfo *infoPtr = (const UnsafeEnsembleInfo *)clientData;
TclPrintfResult(interp, "not allowed to invoke subcommand %s of %s",
infoPtr->commandName, infoPtr->ensembleNsName);
Tcl_SetErrorCode(interp, "TCL", "SAFE", "SUBCOMMAND", (char *)NULL);
return TCL_ERROR;
}
/*
*--------------------------------------------------------------
|
| ︙ | ︙ | |||
2216 2217 2218 2219 2220 2221 2222 |
*
* But as we currently limit ourselves to the global namespace only for
* the source, in order to avoid potential confusion, lets prevent "::" in
* the token too. - dl
*/
if (strstr(hiddenCmdToken, "::") != NULL) {
| | | | 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 |
*
* But as we currently limit ourselves to the global namespace only for
* the source, in order to avoid potential confusion, lets prevent "::" in
* the token too. - dl
*/
if (strstr(hiddenCmdToken, "::") != NULL) {
TclPrintfResult(interp,
"cannot use namespace qualifiers in hidden command"
" token (rename)");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "HIDDENTOKEN", (char *)NULL);
return TCL_ERROR;
}
/*
* Find the command to hide. An error is returned if cmdName can't be
* found. Look up the command only from the global namespace. Full path of
|
| ︙ | ︙ | |||
2241 2242 2243 2244 2245 2246 2247 |
cmdPtr = (Command *) cmd;
/*
* Check that the command is really in global namespace
*/
if (cmdPtr->nsPtr != iPtr->globalNsPtr) {
| | | < | 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 |
cmdPtr = (Command *) cmd;
/*
* Check that the command is really in global namespace
*/
if (cmdPtr->nsPtr != iPtr->globalNsPtr) {
TclPrintfResult(interp,
"can only hide global namespace commands (use rename then hide)");
Tcl_SetErrorCode(interp, "TCL", "HIDE", "NON_GLOBAL", (char *)NULL);
return TCL_ERROR;
}
/*
* Initialize the hidden command table if necessary.
*/
|
| ︙ | ︙ | |||
2267 2268 2269 2270 2271 2272 2273 |
* It is an error to move an exposed command to a hidden command with
* hiddenCmdToken if a hidden command with the name hiddenCmdToken already
* exists.
*/
hPtr = Tcl_CreateHashEntry(hiddenCmdTablePtr, hiddenCmdToken, &isNew);
if (!isNew) {
| | | | 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 |
* It is an error to move an exposed command to a hidden command with
* hiddenCmdToken if a hidden command with the name hiddenCmdToken already
* exists.
*/
hPtr = Tcl_CreateHashEntry(hiddenCmdTablePtr, hiddenCmdToken, &isNew);
if (!isNew) {
TclPrintfResult(interp, "hidden command named \"%s\" already exists",
hiddenCmdToken);
Tcl_SetErrorCode(interp, "TCL", "HIDE", "ALREADY_HIDDEN", (char *)NULL);
return TCL_ERROR;
}
/*
* NB: This code is currently 'like' a rename to a special separate name
* table. Changes here and in TclRenameCommand must be kept in synch until
|
| ︙ | ︙ | |||
2370 2371 2372 2373 2374 2375 2376 |
/*
* Check that we have a regular name for the command (that the user is not
* trying to do an expose and a rename (to another namespace) at the same
* time).
*/
if (strstr(cmdName, "::") != NULL) {
| | | < | | | | < | | | 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 |
/*
* Check that we have a regular name for the command (that the user is not
* trying to do an expose and a rename (to another namespace) at the same
* time).
*/
if (strstr(cmdName, "::") != NULL) {
TclPrintfResult(interp,
"cannot expose to a namespace (use expose to toplevel, then rename)");
Tcl_SetErrorCode(interp, "TCL", "EXPOSE", "NON_GLOBAL", (char *)NULL);
return TCL_ERROR;
}
/*
* Get the command from the hidden command table:
*/
hPtr = NULL;
hiddenCmdTablePtr = iPtr->hiddenCmdTablePtr;
if (hiddenCmdTablePtr != NULL) {
hPtr = Tcl_FindHashEntry(hiddenCmdTablePtr, hiddenCmdToken);
}
if (hPtr == NULL) {
TclPrintfResult(interp, "unknown hidden command \"%s\"",
hiddenCmdToken);
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "HIDDENTOKEN",
hiddenCmdToken, (char *)NULL);
return TCL_ERROR;
}
cmdPtr = (Command *)Tcl_GetHashValue(hPtr);
/*
* Check that we have a true global namespace command (enforced by
* Tcl_HideCommand but let's double check. (If it was not, we would not
* really know how to handle it).
*/
if (cmdPtr->nsPtr != iPtr->globalNsPtr) {
/*
* This case is theoretically impossible, we might rather Tcl_Panic
* than 'nicely' erroring out ?
*/
TclPrintfResult(interp,
"trying to expose a non-global command namespace command");
return TCL_ERROR;
}
/*
* This is the global table.
*/
nsPtr = cmdPtr->nsPtr;
/*
* It is an error to overwrite an existing exposed command as a result of
* exposing a previously hidden command.
*/
hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, cmdName, &isNew);
if (!isNew) {
TclPrintfResult(interp, "exposed command \"%s\" already exists",
cmdName);
Tcl_SetErrorCode(interp, "TCL", "EXPOSE", "COMMAND_EXISTS", (char *)NULL);
return TCL_ERROR;
}
/*
* Command resolvers (per-interp, per-namespace) might have resolved to a
* command for the given namespace scope with this command not being
|
| ︙ | ︙ | |||
3076 3077 3078 3079 3080 3081 3082 |
* Find the existing command. An error is returned if cmdName can't be
* found.
*/
cmd = Tcl_FindCommand(interp, oldName, NULL, /*flags*/ 0);
cmdPtr = (Command *) cmd;
if (cmdPtr == NULL) {
| < | | 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 |
* Find the existing command. An error is returned if cmdName can't be
* found.
*/
cmd = Tcl_FindCommand(interp, oldName, NULL, /*flags*/ 0);
cmdPtr = (Command *) cmd;
if (cmdPtr == NULL) {
TclPrintfResult(interp, "can't %s \"%s\": command doesn't exist",
((newName == NULL) || (*newName == '\0')) ? "delete" : "rename",
oldName);
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COMMAND", oldName, (char *)NULL);
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
3109 3110 3111 3112 3113 3114 3115 |
* create the containing namespaces just like Tcl_CreateObjCommand would.
*/
TclGetNamespaceForQualName(interp, newName, NULL,
TCL_CREATE_NS_IF_UNKNOWN, &newNsPtr, &dummy1, &dummy2, &newTail);
if ((newNsPtr == NULL) || (newTail == NULL)) {
| | | < | > | 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 |
* create the containing namespaces just like Tcl_CreateObjCommand would.
*/
TclGetNamespaceForQualName(interp, newName, NULL,
TCL_CREATE_NS_IF_UNKNOWN, &newNsPtr, &dummy1, &dummy2, &newTail);
if ((newNsPtr == NULL) || (newTail == NULL)) {
TclPrintfResult(interp, "can't rename to \"%s\": bad command name",
newName);
Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMMAND", (char *)NULL);
result = TCL_ERROR;
goto done;
}
if (Tcl_FindHashEntry(&newNsPtr->cmdTable, newTail) != NULL) {
TclPrintfResult(interp, "can't rename to \"%s\": command already exists",
newName);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "RENAME",
"TARGET_EXISTS", (char *)NULL);
result = TCL_ERROR;
goto done;
}
/*
|
| ︙ | ︙ | |||
4066 4067 4068 4069 4070 4071 4072 |
Tcl_ResetResult(interp);
/*
* If the interpreter has been deleted, return an error.
*/
if (iPtr->flags & DELETED) {
| | | | 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 |
Tcl_ResetResult(interp);
/*
* If the interpreter has been deleted, return an error.
*/
if (iPtr->flags & DELETED) {
TclPrintfResult(interp,
"attempt to call eval in deleted interpreter");
Tcl_SetErrorCode(interp, "TCL", "IDELETE",
"attempt to call eval in deleted interpreter", (char *)NULL);
return TCL_ERROR;
}
if (iPtr->execEnvPtr->rewind) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
4095 4096 4097 4098 4099 4100 4101 |
* probably because of an infinite loop somewhere.
*/
if ((iPtr->numLevels <= iPtr->maxNestingDepth)) {
return TCL_OK;
}
| | | | 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 |
* probably because of an infinite loop somewhere.
*/
if ((iPtr->numLevels <= iPtr->maxNestingDepth)) {
return TCL_OK;
}
TclPrintfResult(interp,
"too many nested evaluations (infinite loop?)");
Tcl_SetErrorCode(interp, "TCL", "LIMIT", "STACK", (char *)NULL);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
4523 4524 4525 4526 4527 4528 4529 |
cmdPtr = preCmdPtr;
} else if (flags & TCL_EVAL_NORESOLVE) {
/*
* When it's been deleted, and we're told not to attempt resolving
* it ourselves, all we can do is raise an error.
*/
| | | 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 |
cmdPtr = preCmdPtr;
} else if (flags & TCL_EVAL_NORESOLVE) {
/*
* When it's been deleted, and we're told not to attempt resolving
* it ourselves, all we can do is raise an error.
*/
TclPrintfResult(interp, "attempt to invoke a deleted command");
Tcl_SetErrorCode(interp, "TCL", "EVAL", "DELETEDCOMMAND", (char *)NULL);
return TCL_ERROR;
}
}
if (cmdPtr == NULL) {
cmdPtr = TEOV_LookupCmdFromObj(interp, objv[0], lookupNsPtr);
if (!cmdPtr) {
|
| ︙ | ︙ | |||
4897 4898 4899 4900 4901 4902 4903 |
*
* In this case we worry a bit less about recursion for now, and call the
* "blocking" interface.
*/
cmdPtr = TEOV_LookupCmdFromObj(interp, newObjv[0], lookupNsPtr);
if (cmdPtr == NULL) {
| | | | 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 |
*
* In this case we worry a bit less about recursion for now, and call the
* "blocking" interface.
*/
cmdPtr = TEOV_LookupCmdFromObj(interp, newObjv[0], lookupNsPtr);
if (cmdPtr == NULL) {
TclPrintfResult(interp, "invalid command name \"%s\"",
TclGetString(objv[0]));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COMMAND",
TclGetString(objv[0]), (char *)NULL);
/*
* Release any resources we locked and allocated during the handler
* call.
*/
|
| ︙ | ︙ | |||
6382 6383 6384 6385 6386 6387 6388 |
* result code was returned. */
int returnCode) /* The unexpected result code. */
{
char buf[TCL_INTEGER_SPACE];
Tcl_ResetResult(interp);
if (returnCode == TCL_BREAK) {
| < | < | < | | 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 |
* result code was returned. */
int returnCode) /* The unexpected result code. */
{
char buf[TCL_INTEGER_SPACE];
Tcl_ResetResult(interp);
if (returnCode == TCL_BREAK) {
TclPrintfResult(interp, "invoked \"break\" outside of a loop");
} else if (returnCode == TCL_CONTINUE) {
TclPrintfResult(interp, "invoked \"continue\" outside of a loop");
} else {
TclPrintfResult(interp, "command returned bad code: %d", returnCode);
}
snprintf(buf, sizeof(buf), "%d", returnCode);
Tcl_SetErrorCode(interp, "TCL", "UNEXPECTED_RESULT_CODE", buf, (char *)NULL);
}
/*
*---------------------------------------------------------------------------
|
| ︙ | ︙ | |||
6694 6695 6696 6697 6698 6699 6700 |
* TCL_INVOKE_HIDDEN, TCL_INVOKE_NO_UNKNOWN,
* or TCL_INVOKE_NO_TRACEBACK. */
{
if (interp == NULL) {
return TCL_ERROR;
}
if ((objc < 1) || (objv == NULL)) {
| < | | 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 |
* TCL_INVOKE_HIDDEN, TCL_INVOKE_NO_UNKNOWN,
* or TCL_INVOKE_NO_TRACEBACK. */
{
if (interp == NULL) {
return TCL_ERROR;
}
if ((objc < 1) || (objv == NULL)) {
TclPrintfResult(interp, "illegal argument vector");
return TCL_ERROR;
}
if ((flags & TCL_INVOKE_HIDDEN) == 0) {
Tcl_Panic("TclObjInvoke: called without TCL_INVOKE_HIDDEN");
}
return Tcl_NRCallObjProc(interp, TclNRInvoke, NULL, objc, objv);
}
|
| ︙ | ︙ | |||
6723 6724 6725 6726 6727 6728 6729 |
cmdName = TclGetString(objv[0]);
hTblPtr = iPtr->hiddenCmdTablePtr;
if (hTblPtr != NULL) {
hPtr = Tcl_FindHashEntry(hTblPtr, cmdName);
}
if (hPtr == NULL) {
| < | | 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 |
cmdName = TclGetString(objv[0]);
hTblPtr = iPtr->hiddenCmdTablePtr;
if (hTblPtr != NULL) {
hPtr = Tcl_FindHashEntry(hTblPtr, cmdName);
}
if (hPtr == NULL) {
TclPrintfResult(interp, "invalid hidden command name \"%s\"", cmdName);
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "HIDDENTOKEN", cmdName,
(char *)NULL);
return TCL_ERROR;
}
cmdPtr = (Command *)Tcl_GetHashValue(hPtr);
/*
|
| ︙ | ︙ | |||
7213 7214 7215 7216 7217 7218 7219 |
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewBignumObj(&root));
}
return TCL_OK;
negarg:
| < | | 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 |
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewBignumObj(&root));
}
return TCL_OK;
negarg:
TclPrintfResult(interp, "square root of negative argument");
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"domain error: argument not in valid range", (char *)NULL);
return TCL_ERROR;
}
static int
ExprSqrtFunc(
|
| ︙ | ︙ | |||
8229 8230 8231 8232 8233 8234 8235 |
case FP_SUBNORMAL:
TclNewLiteralStringObj(objPtr, "subnormal");
break;
case FP_ZERO:
TclNewLiteralStringObj(objPtr, "zero");
break;
default:
| | | 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 |
case FP_SUBNORMAL:
TclNewLiteralStringObj(objPtr, "subnormal");
break;
case FP_ZERO:
TclNewLiteralStringObj(objPtr, "zero");
break;
default:
TclPrintfResult(interp, "unable to classify number: %f", d);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, objPtr);
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
8270 8271 8272 8273 8274 8275 8276 |
while (tail > name + 1) {
tail--;
if (*tail == ':' && tail[-1] == ':') {
name = tail + 1;
break;
}
}
| < | | 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 |
while (tail > name + 1) {
tail--;
if (*tail == ':' && tail[-1] == ':') {
name = tail + 1;
break;
}
}
TclPrintfResult(interp, "%s arguments for math function \"%s\"",
(found < expected ? "not enough" : "too many"), name);
Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
}
#ifdef USE_DTRACE
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
8779 8780 8781 8782 8783 8784 8785 |
if (objc < 1) {
Tcl_WrongNumArgs(interp, 1, objv, "?command? ?arg ...?");
return TCL_ERROR;
}
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
| | | | 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 |
if (objc < 1) {
Tcl_WrongNumArgs(interp, 1, objv, "?command? ?arg ...?");
return TCL_ERROR;
}
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
TclPrintfResult(interp,
"tailcall can only be called from a proc, lambda or method");
Tcl_SetErrorCode(interp, "TCL", "TAILCALL", "ILLEGAL", (char *)NULL);
return TCL_ERROR;
}
/*
* Invocation without args just clears a scheduled tailcall; invocation
* with an argument replaces any previously scheduled tailcall.
|
| ︙ | ︙ | |||
8941 8942 8943 8944 8945 8946 8947 |
if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?returnValue?");
return TCL_ERROR;
}
if (!corPtr) {
| < | | 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 |
if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?returnValue?");
return TCL_ERROR;
}
if (!corPtr) {
TclPrintfResult(interp, "yield can only be called in a coroutine");
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD", (char *)NULL);
return TCL_ERROR;
}
if (objc == 2) {
Tcl_SetObjResult(interp, objv[1]);
}
|
| ︙ | ︙ | |||
8974 8975 8976 8977 8978 8979 8980 |
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "command ?arg ...?");
return TCL_ERROR;
}
if (!corPtr) {
| < | < | | 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 |
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "command ?arg ...?");
return TCL_ERROR;
}
if (!corPtr) {
TclPrintfResult(interp, "yieldto can only be called in a coroutine");
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD", (char *)NULL);
return TCL_ERROR;
}
if (((Namespace *) nsPtr)->flags & NS_DYING) {
TclPrintfResult(interp, "yieldto called in deleted namespace");
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "YIELDTO_IN_DELETED",
(char *)NULL);
return TCL_ERROR;
}
/*
* Add the tailcall in the caller env, then just yield.
|
| ︙ | ︙ | |||
9215 9216 9217 9218 9219 9220 9221 | corPtr->yieldPtr = NULL; break; } } } iPtr->execEnvPtr = corPtr->eePtr; | < | | 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 |
corPtr->yieldPtr = NULL;
break;
}
}
}
iPtr->execEnvPtr = corPtr->eePtr;
TclPrintfResult(interp, "cannot yield: C stack busy");
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "CANT_YIELD",
(char *)NULL);
return TCL_ERROR;
}
void *type = data[1];
if (type == CORO_ACTIVATE_YIELD) {
|
| ︙ | ︙ | |||
9275 9276 9277 9278 9279 9280 9281 |
/*
* Look up the coroutine.
*/
cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, objv[1]);
if ((!cmdPtr) || (cmdPtr->nreProc != TclNRInterpCoroutine)) {
| < | | 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 |
/*
* Look up the coroutine.
*/
cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, objv[1]);
if ((!cmdPtr) || (cmdPtr->nreProc != TclNRInterpCoroutine)) {
TclPrintfResult(interp, "can only get coroutine type of a coroutine");
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COROUTINE",
TclGetString(objv[1]), (char *)NULL);
return TCL_ERROR;
}
/*
* An active coroutine is "active". Can't tell what it might do in the
|
| ︙ | ︙ | |||
9306 9307 9308 9309 9310 9311 9312 |
case COROUTINE_ARGUMENTS_SINGLE_OPTIONAL:
Tcl_SetObjResult(interp, Tcl_NewStringObj("yield", TCL_INDEX_NONE));
return TCL_OK;
case COROUTINE_ARGUMENTS_ARBITRARY:
Tcl_SetObjResult(interp, Tcl_NewStringObj("yieldto", TCL_INDEX_NONE));
return TCL_OK;
default:
| < | | 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 |
case COROUTINE_ARGUMENTS_SINGLE_OPTIONAL:
Tcl_SetObjResult(interp, Tcl_NewStringObj("yield", TCL_INDEX_NONE));
return TCL_OK;
case COROUTINE_ARGUMENTS_ARBITRARY:
Tcl_SetObjResult(interp, Tcl_NewStringObj("yieldto", TCL_INDEX_NONE));
return TCL_OK;
default:
TclPrintfResult(interp, "unknown coroutine type");
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "BAD_TYPE", (char *)NULL);
return TCL_ERROR;
}
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
9369 9370 9371 9372 9373 9374 9375 |
corPtr = GetCoroutineFromObj(interp, objv[1],
"can only inject a command into a coroutine");
if (!corPtr) {
return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
| | | | 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 |
corPtr = GetCoroutineFromObj(interp, objv[1],
"can only inject a command into a coroutine");
if (!corPtr) {
return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
TclPrintfResult(interp,
"can only inject a command into a suspended coroutine");
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", (char *)NULL);
return TCL_ERROR;
}
/*
* Add the callback to the coro's execEnv, so that it is the first thing
* to happen when the coro is resumed.
|
| ︙ | ︙ | |||
9414 9415 9416 9417 9418 9419 9420 |
corPtr = GetCoroutineFromObj(interp, objv[1],
"can only inject a probe command into a coroutine");
if (!corPtr) {
return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
| | | < | 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 |
corPtr = GetCoroutineFromObj(interp, objv[1],
"can only inject a probe command into a coroutine");
if (!corPtr) {
return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
TclPrintfResult(interp,
"can only inject a probe command into a suspended coroutine");
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", (char *)NULL);
return TCL_ERROR;
}
/*
* Add the callback to the coro's execEnv, so that it is the first thing
* to happen when the coro is resumed.
|
| ︙ | ︙ | |||
9580 9581 9582 9583 9584 9585 9586 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
CoroutineData *corPtr = (CoroutineData *)clientData;
if (!COR_IS_SUSPENDED(corPtr)) {
| | | 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
CoroutineData *corPtr = (CoroutineData *)clientData;
if (!COR_IS_SUSPENDED(corPtr)) {
TclPrintfResult(interp, "coroutine \"%s\" is already running",
TclGetString(objv[0]));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "BUSY", (char *)NULL);
return TCL_ERROR;
}
/*
* Parse all the arguments to work out what to feed as the result of the
|
| ︙ | ︙ | |||
9603 9604 9605 9606 9607 9608 9609 |
} else if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?arg?");
return TCL_ERROR;
}
break;
default:
if (corPtr->nargs + 1 != objc) {
| | | | 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 |
} else if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "?arg?");
return TCL_ERROR;
}
break;
default:
if (corPtr->nargs + 1 != objc) {
TclPrintfResult(interp,
"wrong coro nargs; how did we get here? "
"not implemented!");
Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
return TCL_ERROR;
}
TCL_FALLTHROUGH();
case COROUTINE_ARGUMENTS_ARBITRARY:
if (objc > 1) {
Tcl_SetObjResult(interp, Tcl_NewListObj(objc - 1, objv + 1));
|
| ︙ | ︙ | |||
9657 9658 9659 9660 9661 9662 9663 |
}
procName = TclGetString(objv[1]);
TclGetNamespaceForQualName(interp, procName, inNsPtr, 0,
&nsPtr, &altNsPtr, &cxtNsPtr, &simpleName);
if (nsPtr == NULL) {
| < | < | | 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 |
}
procName = TclGetString(objv[1]);
TclGetNamespaceForQualName(interp, procName, inNsPtr, 0,
&nsPtr, &altNsPtr, &cxtNsPtr, &simpleName);
if (nsPtr == NULL) {
TclPrintfResult(interp, "can't create procedure \"%s\": unknown namespace",
procName);
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "NAMESPACE", (char *)NULL);
return TCL_ERROR;
}
if (simpleName == NULL) {
TclPrintfResult(interp, "can't create procedure \"%s\": bad procedure name",
procName);
Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMMAND", procName, (char *)NULL);
return TCL_ERROR;
}
/*
* We ARE creating the coroutine command: allocate the corresponding
|
| ︙ | ︙ |
Changes to generic/tclBinary.c.
| ︙ | ︙ | |||
399 400 401 402 403 404 405 |
if (bytes && numBytesPtr) {
if (numBytes > INT_MAX) {
/* Caller asked for numBytes to be written to an int, but the
* value is outside the int range. */
if (interp) {
| < | | 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
if (bytes && numBytesPtr) {
if (numBytes > INT_MAX) {
/* Caller asked for numBytes to be written to an int, but the
* value is outside the int range. */
if (interp) {
TclPrintfResult(interp, "byte sequence length exceeds INT_MAX");
Tcl_SetErrorCode(interp, "TCL", "API", "OUTDATED", (char *)NULL);
}
return NULL;
} else {
*(int *)numBytesPtr = (int) numBytes;
}
}
|
| ︙ | ︙ | |||
516 517 518 519 520 521 522 |
int ch;
Tcl_Size count = TclUtfToUniChar(src, &ch);
if (ch > 255) {
proper = 0;
if (demandProper) {
if (interp) {
| | | 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
int ch;
Tcl_Size count = TclUtfToUniChar(src, &ch);
if (ch > 255) {
proper = 0;
if (demandProper) {
if (interp) {
TclPrintfResult(interp,
"expected byte sequence but character %"
TCL_Z_MODIFIER "u was '%1s' (U+%06X)",
dst - byteArrayPtr->bytes, src, ch);
Tcl_SetErrorCode(interp, "TCL", "VALUE", "BYTES", (char *)NULL);
}
Tcl_Free(byteArrayPtr);
*byteArrayPtrPtr = NULL;
|
| ︙ | ︙ | |||
962 963 964 965 966 967 968 |
if (TclListObjLength(interp, objv[arg], &listc) != TCL_OK) {
return TCL_ERROR;
}
if (count == BINARY_ALL) {
count = listc;
} else if (count > listc) {
| | | < | | | 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 |
if (TclListObjLength(interp, objv[arg], &listc) != TCL_OK) {
return TCL_ERROR;
}
if (count == BINARY_ALL) {
count = listc;
} else if (count > listc) {
TclPrintfResult(interp,
"number of elements in list does not match count");
return TCL_ERROR;
}
if (TclListObjGetElements(interp, objv[arg], &listc,
&listv) != TCL_OK) {
return TCL_ERROR;
}
arg++;
}
offset += count*size;
break;
case 'x':
if (count == BINARY_ALL) {
TclPrintfResult(interp,
"cannot use \"*\" in format string with \"x\"");
return TCL_ERROR;
} else if (count == BINARY_NOCOUNT) {
count = 1;
}
offset += count;
break;
case 'X':
|
| ︙ | ︙ | |||
1293 1294 1295 1296 1297 1298 1299 |
}
}
Tcl_SetObjResult(interp, resultPtr);
return TCL_OK;
badValue:
Tcl_ResetResult(interp);
| < | | | 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 |
}
}
Tcl_SetObjResult(interp, resultPtr);
return TCL_OK;
badValue:
Tcl_ResetResult(interp);
TclPrintfResult(interp, "expected %s string but got \"%s\" instead",
errorString, errorValue);
return TCL_ERROR;
badCount:
errorString = "missing count for \"@\" field specifier";
goto error;
badIndex:
errorString = "not enough arguments for all format specifiers";
goto error;
badField:
{
Tcl_UniChar ch = 0;
char buf[5] = "";
TclUtfToUniChar(errorString, &ch);
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
TclPrintfResult(interp, "bad field specifier \"%s\"", buf);
return TCL_ERROR;
}
error:
Tcl_SetObjResult(interp, Tcl_NewStringObj(errorString, -1));
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1693 1694 1695 1696 1697 1698 1699 |
badField:
{
Tcl_UniChar ch = 0;
char buf[5] = "";
TclUtfToUniChar(errorString, &ch);
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
| < | | 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 |
badField:
{
Tcl_UniChar ch = 0;
char buf[5] = "";
TclUtfToUniChar(errorString, &ch);
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
TclPrintfResult(interp, "bad field specifier \"%s\"", buf);
return TCL_ERROR;
}
error:
Tcl_SetObjResult(interp, Tcl_NewStringObj(errorString, -1));
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2561 2562 2563 2564 2565 2566 2567 |
badChar:
if (pure) {
ucs4 = c;
} else {
TclUtfToUniChar((const char *)(data - 1), &ucs4);
}
TclDecrRefCount(resultObj);
| | | 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 |
badChar:
if (pure) {
ucs4 = c;
} else {
TclUtfToUniChar((const char *)(data - 1), &ucs4);
}
TclDecrRefCount(resultObj);
TclPrintfResult(interp,
"invalid hexadecimal digit \"%c\" (U+%06X) at position %"
TCL_Z_MODIFIER "u", ucs4, ucs4, data - datastart - 1);
Tcl_SetErrorCode(interp, "TCL", "BINARY", "DECODE", "INVALID", (char *)NULL);
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
2630 2631 2632 2633 2634 2635 2636 |
}
switch (index) {
case OPT_MAXLEN:
if (TclGetWideIntFromObj(interp, objv[i + 1], &maxlen) != TCL_OK) {
return TCL_ERROR;
}
if (maxlen < 0) {
| < | | 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 |
}
switch (index) {
case OPT_MAXLEN:
if (TclGetWideIntFromObj(interp, objv[i + 1], &maxlen) != TCL_OK) {
return TCL_ERROR;
}
if (maxlen < 0) {
TclPrintfResult(interp, "line length out of range");
Tcl_SetErrorCode(interp, "TCL", "BINARY", "ENCODE",
"LINE_LENGTH", (char *)NULL);
return TCL_ERROR;
}
break;
case OPT_WRAPCHAR:
wrapchar = (const char *)Tcl_GetBytesFromObj(NULL,
|
| ︙ | ︙ | |||
2760 2761 2762 2763 2764 2765 2766 |
switch (index) {
case OPT_MAXLEN:
if (Tcl_GetIntFromObj(interp, objv[i + 1],
&lineLength) != TCL_OK) {
return TCL_ERROR;
}
if (lineLength < 5 || lineLength > 85) {
| < | | 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 |
switch (index) {
case OPT_MAXLEN:
if (Tcl_GetIntFromObj(interp, objv[i + 1],
&lineLength) != TCL_OK) {
return TCL_ERROR;
}
if (lineLength < 5 || lineLength > 85) {
TclPrintfResult(interp, "line length out of range");
Tcl_SetErrorCode(interp, "TCL", "BINARY", "ENCODE",
"LINE_LENGTH", (char *)NULL);
return TCL_ERROR;
}
lineLength = ((lineLength - 1) & -4) + 1; /* 5, 9, 13 ... */
break;
case OPT_WRAPCHAR:
|
| ︙ | ︙ | |||
2792 2793 2794 2795 2796 2797 2798 |
break;
default:
goto badwrap;
}
}
if (numBytes) {
badwrap:
| < | | 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 |
break;
default:
goto badwrap;
}
}
if (numBytes) {
badwrap:
TclPrintfResult(interp, "invalid wrapchar; will defeat decoding");
Tcl_SetErrorCode(interp, "TCL", "BINARY",
"ENCODE", "WRAPCHAR", (char *)NULL);
return TCL_ERROR;
}
break;
}
}
|
| ︙ | ︙ | |||
3016 3017 3018 3019 3020 3021 3022 |
goto shortUu;
}
Tcl_SetByteArrayLength(resultObj, cursor - begin);
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
shortUu:
| | | | 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 |
goto shortUu;
}
Tcl_SetByteArrayLength(resultObj, cursor - begin);
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
shortUu:
TclPrintfResult(interp, "short uuencode data");
Tcl_SetErrorCode(interp, "TCL", "BINARY", "DECODE", "SHORT", (char *)NULL);
TclDecrRefCount(resultObj);
return TCL_ERROR;
badUu:
if (pure) {
ucs4 = c;
} else {
TclUtfToUniChar((const char *)(data - 1), &ucs4);
}
TclPrintfResult(interp,
"invalid uuencode character \"%c\" (U+%06X) at position %"
TCL_Z_MODIFIER "u", ucs4, ucs4, data - datastart - 1);
Tcl_SetErrorCode(interp, "TCL", "BINARY", "DECODE", "INVALID", (char *)NULL);
TclDecrRefCount(resultObj);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
3205 3206 3207 3208 3209 3210 3211 |
* valid member of the base64 alphabet, it could be the lead byte
* of a multi-byte character. */
/* Safe because we know data is NUL-terminated */
TclUtfToUniChar((const char *)(data - 1), &ucs4);
}
| | | 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 |
* valid member of the base64 alphabet, it could be the lead byte
* of a multi-byte character. */
/* Safe because we know data is NUL-terminated */
TclUtfToUniChar((const char *)(data - 1), &ucs4);
}
TclPrintfResult(interp,
"invalid base64 character \"%c\" (U+%06X) at position %"
TCL_Z_MODIFIER "u", ucs4, ucs4, data - datastart - 1);
Tcl_SetErrorCode(interp, "TCL", "BINARY", "DECODE", "INVALID", (char *)NULL);
TclDecrRefCount(resultObj);
return TCL_ERROR;
}
|
| ︙ | ︙ |
Changes to generic/tclCkalloc.c.
| ︙ | ︙ | |||
821 822 823 824 825 826 827 |
fileName = Tcl_TranslateFileName(interp, TclGetString(objv[2]), &buffer);
if (fileName == NULL) {
return TCL_ERROR;
}
result = Tcl_DumpActiveMemory(fileName);
Tcl_DStringFree(&buffer);
if (result != TCL_OK) {
| | | | 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 |
fileName = Tcl_TranslateFileName(interp, TclGetString(objv[2]), &buffer);
if (fileName == NULL) {
return TCL_ERROR;
}
result = Tcl_DumpActiveMemory(fileName);
Tcl_DStringFree(&buffer);
if (result != TCL_OK) {
TclPrintfResult(interp, "error accessing %s: %s",
TclGetString(objv[2]), Tcl_PosixError(interp));
return TCL_ERROR;
}
return TCL_OK;
}
if (strcmp(TclGetString(objv[1]),"break_on_malloc") == 0) {
Tcl_WideInt value;
if (objc != 3) {
goto argError;
}
if (TclGetWideIntFromObj(interp, objv[2], &value) != TCL_OK) {
return TCL_ERROR;
}
break_on_malloc = value;
return TCL_OK;
}
if (strcmp(TclGetString(objv[1]),"info") == 0) {
TclPrintfResult(interp,
"%-25s %10" TCL_Z_MODIFIER "u\n%-25s %10" TCL_Z_MODIFIER "u\n%-25s %10" TCL_Z_MODIFIER "u\n%-25s %10" TCL_Z_MODIFIER "u\n%-25s %10" TCL_Z_MODIFIER "u\n%-25s %10" TCL_Z_MODIFIER "u\n",
"total mallocs", total_mallocs, "total frees", total_frees,
"current packets allocated", current_malloc_packets,
"current bytes allocated", current_bytes_malloced,
"maximum packets allocated", maximum_malloc_packets,
"maximum bytes allocated", maximum_bytes_malloced);
return TCL_OK;
|
| ︙ | ︙ | |||
866 867 868 869 870 871 872 |
}
fileName = Tcl_TranslateFileName(interp, TclGetString(objv[2]), &buffer);
if (fileName == NULL) {
return TCL_ERROR;
}
fileP = fopen(fileName, "w");
if (fileP == NULL) {
| < | | 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
}
fileName = Tcl_TranslateFileName(interp, TclGetString(objv[2]), &buffer);
if (fileName == NULL) {
return TCL_ERROR;
}
fileP = fopen(fileName, "w");
if (fileP == NULL) {
TclPrintfResult(interp, "cannot open output file: %s",
Tcl_PosixError(interp));
return TCL_ERROR;
}
TclDbDumpActiveObjects(fileP);
fclose(fileP);
Tcl_DStringFree(&buffer);
return TCL_OK;
|
| ︙ | ︙ | |||
931 932 933 934 935 936 937 |
if (objc != 3) {
goto bad_suboption;
}
validate_memory = (strcmp(TclGetString(objv[2]),"on") == 0);
return TCL_OK;
}
| | | 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 |
if (objc != 3) {
goto bad_suboption;
}
validate_memory = (strcmp(TclGetString(objv[2]),"on") == 0);
return TCL_OK;
}
TclPrintfResult(interp,
"bad option \"%s\": should be active, break_on_malloc, info, "
"init, objs, onexit, tag, trace, trace_on_at_malloc, or validate",
TclGetString(objv[1]));
return TCL_ERROR;
argError:
Tcl_WrongNumArgs(interp, 2, objv, "count");
|
| ︙ | ︙ |
Changes to generic/tclClock.c.
| ︙ | ︙ | |||
705 706 707 708 709 710 711 |
/* if locale was not yet used */
if (!(opts->flags & CLF_LOCALE_USED)) {
opts->localeObj = NormLocaleObj(dataPtr, opts->interp,
opts->localeObj, &opts->mcDictObj);
if (opts->localeObj == NULL) {
| | | < | 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
/* if locale was not yet used */
if (!(opts->flags & CLF_LOCALE_USED)) {
opts->localeObj = NormLocaleObj(dataPtr, opts->interp,
opts->localeObj, &opts->mcDictObj);
if (opts->localeObj == NULL) {
TclPrintfResult(opts->interp,
"locale not specified and no default locale set");
Tcl_SetErrorCode(opts->interp, "CLOCK", "badOption", (char *)NULL);
return NULL;
}
opts->flags |= CLF_LOCALE_USED;
/* check locale literals already available (on demand creation) */
if (dataPtr->mcLiterals == NULL) {
|
| ︙ | ︙ | |||
1432 1433 1434 1435 1436 1437 1438 |
}
dict = objv[1];
if (Tcl_DictObjGet(interp, dict, dataPtr->literals[LIT_LOCALSECONDS],
&secondsObj)!= TCL_OK) {
return TCL_ERROR;
}
if (secondsObj == NULL) {
| | < | 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 |
}
dict = objv[1];
if (Tcl_DictObjGet(interp, dict, dataPtr->literals[LIT_LOCALSECONDS],
&secondsObj)!= TCL_OK) {
return TCL_ERROR;
}
if (secondsObj == NULL) {
TclPrintfResult(interp, "key \"localseconds\" not found in dictionary");
return TCL_ERROR;
}
if ((TclGetWideIntFromObj(interp, secondsObj, &fields.localSeconds) != TCL_OK)
|| (TclGetIntFromObj(interp, objv[3], &changeover) != TCL_OK)
|| ConvertLocalToUTC(dataPtr, interp, &fields, objv[2], changeover)) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1659 1660 1661 1662 1663 1664 1665 |
{
Tcl_Obj *value = NULL;
if (Tcl_DictObjGet(interp, dict, key, &value) != TCL_OK) {
return TCL_ERROR;
}
if (value == NULL) {
| < | < | | 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 |
{
Tcl_Obj *value = NULL;
if (Tcl_DictObjGet(interp, dict, key, &value) != TCL_OK) {
return TCL_ERROR;
}
if (value == NULL) {
TclPrintfResult(interp, "expected key(s) not found in dictionary");
return TCL_ERROR;
}
return Tcl_GetIndexFromObj(interp, value, eras, "era", TCL_EXACT, storePtr);
}
static int
FetchIntField(
Tcl_Interp *interp,
Tcl_Obj *dict,
Tcl_Obj *key,
int *storePtr)
{
Tcl_Obj *value = NULL;
if (Tcl_DictObjGet(interp, dict, key, &value) != TCL_OK) {
return TCL_ERROR;
}
if (value == NULL) {
TclPrintfResult(interp, "expected key(s) not found in dictionary");
return TCL_ERROR;
}
return TclGetIntFromObj(interp, value, storePtr);
}
static int
ClockGetjuliandayfromerayearmonthdayObjCmd(
|
| ︙ | ︙ | |||
2123 2124 2125 2126 2127 2128 2129 |
/*
* If conversion fails, report an error.
*/
if (localErrno != 0
|| (fields->seconds == -1 && timeVal.tm_yday == -1)) {
| | | | 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 |
/*
* If conversion fails, report an error.
*/
if (localErrno != 0
|| (fields->seconds == -1 && timeVal.tm_yday == -1)) {
TclPrintfResult(interp,
"time value too large/small to represent");
return TCL_ERROR;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
2345 2346 2347 2348 2349 2350 2351 |
/*
* Use 'localtime' to determine local year, month, day, time of day.
*/
tock = (time_t) fields->seconds;
if ((Tcl_WideInt) tock != fields->seconds) {
| < | | | | 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 |
/*
* Use 'localtime' to determine local year, month, day, time of day.
*/
tock = (time_t) fields->seconds;
if ((Tcl_WideInt) tock != fields->seconds) {
TclPrintfResult(interp, "number too large to represent as a Posix time");
Tcl_SetErrorCode(interp, "CLOCK", "argTooLarge", (char *)NULL);
return TCL_ERROR;
}
TzsetIfNecessary();
timeVal = ThreadSafeLocalTime(&tock);
if (timeVal == NULL) {
TclPrintfResult(interp,
"localtime failed (clock value may be too "
"large/small to represent)");
Tcl_SetErrorCode(interp, "CLOCK", "localtimeFailed", (char *)NULL);
return TCL_ERROR;
}
/*
* Fill in the date in 'fields' and use it to derive Julian Day.
*/
|
| ︙ | ︙ | |||
3335 3336 3337 3338 3339 3340 3341 |
goto badOptionMsg;
}
/* if already specified */
if (saw & (1 << optionIndex)) {
if (operation != CLC_OP_SCN && optionIndex == CLC_ARGS_BASE) {
goto badOptionMsg;
}
| | | 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 |
goto badOptionMsg;
}
/* if already specified */
if (saw & (1 << optionIndex)) {
if (operation != CLC_OP_SCN && optionIndex == CLC_ARGS_BASE) {
goto badOptionMsg;
}
TclPrintfResult(interp, "bad option \"%s\": doubly present",
TclGetString(objv[i]));
goto badOption;
}
switch (optionIndex) {
case CLC_ARGS_FORMAT:
if (operation == CLC_OP_ADD) {
goto badOptionMsg;
|
| ︙ | ︙ | |||
3388 3389 3390 3391 3392 3393 3394 |
/*
* Check options.
*/
if ((saw & (1 << CLC_ARGS_GMT))
&& (saw & (1 << CLC_ARGS_TIMEZONE))) {
| < | | 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 |
/*
* Check options.
*/
if ((saw & (1 << CLC_ARGS_GMT))
&& (saw & (1 << CLC_ARGS_TIMEZONE))) {
TclPrintfResult(interp, "cannot use -gmt and -timezone in same call");
Tcl_SetErrorCode(interp, "CLOCK", "gmtWithTimezone", (char *)NULL);
return TCL_ERROR;
}
if (gmtFlag) {
opts->timezoneObj = dataPtr->literals[LIT_GMT];
} else if (opts->timezoneObj == NULL
|| TclGetString(opts->timezoneObj) == NULL
|
| ︙ | ︙ | |||
3437 3438 3439 3440 3441 3442 3443 |
goto baseNow;
}
if (TclHasInternalRep(baseObj, &tclBignumType)) {
goto baseOverflow;
}
| < | | 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 |
goto baseNow;
}
if (TclHasInternalRep(baseObj, &tclBignumType)) {
goto baseOverflow;
}
TclPrintfResult(interp, "bad seconds \"%s\": must be now or integer",
TclGetString(baseObj));
i = baseIdx;
goto badOption;
}
/*
* Seconds could be an unsigned number that overflowed. Make sure
* that it isn't. Additionally it may be too complex to calculate
|
| ︙ | ︙ | |||
3493 3494 3495 3496 3497 3498 3499 |
memcpy(&dataPtr->lastBase.date, date, ClockCacheableDateFieldsSize);
TclSetObjRef(dataPtr->lastBase.timezoneObj, opts->timezoneObj);
}
return TCL_OK;
badOptionMsg:
| | | 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 |
memcpy(&dataPtr->lastBase.date, date, ClockCacheableDateFieldsSize);
TclSetObjRef(dataPtr->lastBase.timezoneObj, opts->timezoneObj);
}
return TCL_OK;
badOptionMsg:
TclPrintfResult(interp, "bad option \"%s\": must be %s",
TclGetString(objv[i]), syntax);
badOption:
Tcl_SetErrorCode(interp, "CLOCK", "badOption",
(i < objc) ? TclGetString(objv[i]) : (char *)NULL, (char *)NULL);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
3640 3641 3642 3643 3644 3645 3646 |
/* If free scan */
if (opts.formatObj == NULL) {
/* Use compiled version of FreeScan - */
/* [SB] TODO: Perhaps someday we'll localize the legacy code. Right now,
* it's not localized. */
if (opts.localeObj != NULL) {
| < | | 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 |
/* If free scan */
if (opts.formatObj == NULL) {
/* Use compiled version of FreeScan - */
/* [SB] TODO: Perhaps someday we'll localize the legacy code. Right now,
* it's not localized. */
if (opts.localeObj != NULL) {
TclPrintfResult(interp, "legacy [clock scan] does not support -locale");
Tcl_SetErrorCode(interp, "CLOCK", "flagWithLegacyFormat", (char *)NULL);
ret = TCL_ERROR;
goto done;
}
ret = ClockFreeScan(&yy, objv[1], &opts);
} else {
/* Use compiled version of Scan - */
|
| ︙ | ︙ | |||
3733 3734 3735 3736 3737 3738 3739 |
}
/* some overflow checks */
if (info->flags & CLF_JULIANDAY) {
double curJDN = (double)yydate.julianDay
+ ((double)yySecondOfDay - SECONDS_PER_DAY/2) / SECONDS_PER_DAY;
if (curJDN > opts->dataPtr->maxJDN) {
| < | | 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 |
}
/* some overflow checks */
if (info->flags & CLF_JULIANDAY) {
double curJDN = (double)yydate.julianDay
+ ((double)yySecondOfDay - SECONDS_PER_DAY/2) / SECONDS_PER_DAY;
if (curJDN > opts->dataPtr->maxJDN) {
TclPrintfResult(opts->interp, "requested date too large to represent");
Tcl_SetErrorCode(opts->interp, "CLOCK", "dateTooLarge", (char *)NULL);
return TCL_ERROR;
}
}
/* If seconds overflows the day (not valide case, or 24:00), increase days */
if (yySecondOfDay >= SECONDS_PER_DAY) {
|
| ︙ | ︙ | |||
4008 4009 4010 4011 4012 4013 4014 |
* Notice that many yy-defines point to values in the "info" or "date"
* structure, e. g. yySecondOfDay -> info->date.secondOfDay or
* yyMonth -> info->date.month (same as yydate.month)
*/
yyInput = TclGetString(strObj);
if (TclClockFreeScan(interp, info) != TCL_OK) {
| < | | 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 |
* Notice that many yy-defines point to values in the "info" or "date"
* structure, e. g. yySecondOfDay -> info->date.secondOfDay or
* yyMonth -> info->date.month (same as yydate.month)
*/
yyInput = TclGetString(strObj);
if (TclClockFreeScan(interp, info) != TCL_OK) {
TclPrintfResult(interp, "unable to convert date-time string \"%s\": %s",
TclGetString(strObj), Tcl_GetString(Tcl_GetObjResult(interp)));
return TCL_ERROR;
}
/*
* If the caller supplied a date in the string, update the date with
* the value. If the caller didn't specify a time with the date, default to
|
| ︙ | ︙ |
Changes to generic/tclClockFmt.c.
| ︙ | ︙ | |||
1618 1619 1620 1621 1622 1623 1624 |
return TCL_RETURN;
}
if (val == 0) {
val = 7;
}
if (val > 7) {
| < | | 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 |
return TCL_RETURN;
}
if (val == 0) {
val = 7;
}
if (val > 7) {
TclPrintfResult(opts->interp, "day of week is greater than 7");
Tcl_SetErrorCode(opts->interp, "CLOCK", "badDayOfWeek", (char *)NULL);
return TCL_ERROR;
}
info->date.dayOfWeek = val;
yyInput++;
return TCL_OK;
}
|
| ︙ | ︙ |
Changes to generic/tclCmdAH.c.
| ︙ | ︙ | |||
287 288 289 290 291 292 293 |
Tcl_DString ds;
result = Tcl_UtfToExternalDStringEx(NULL, TCLFSENCODING, TclGetString(dir), -1, 0, &ds, NULL);
Tcl_DStringFree(&ds);
if (result == TCL_OK) {
result = Tcl_FSChdir(dir);
}
if (result != TCL_OK) {
| < | | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
Tcl_DString ds;
result = Tcl_UtfToExternalDStringEx(NULL, TCLFSENCODING, TclGetString(dir), -1, 0, &ds, NULL);
Tcl_DStringFree(&ds);
if (result == TCL_OK) {
result = Tcl_FSChdir(dir);
}
if (result != TCL_OK) {
TclPrintfResult(interp, "couldn't change working directory to \"%s\": %s",
TclGetString(dir), Tcl_PosixError(interp));
result = TCL_ERROR;
}
}
if (objc != 2) {
Tcl_DecrRefCount(dir);
}
|
| ︙ | ︙ | |||
728 729 730 731 732 733 734 |
if (objc == 1) {
Tcl_SetObjResult(interp, Tcl_GetEncodingSearchPath());
return TCL_OK;
}
dirListObj = objv[1];
if (Tcl_SetEncodingSearchPath(dirListObj) == TCL_ERROR) {
| | | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
if (objc == 1) {
Tcl_SetObjResult(interp, Tcl_GetEncodingSearchPath());
return TCL_OK;
}
dirListObj = objv[1];
if (Tcl_SetEncodingSearchPath(dirListObj) == TCL_ERROR) {
TclPrintfResult(interp, "expected directory list but got \"%s\"",
TclGetString(dirListObj));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "ENCODING", "BADPATH",
(char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, dirListObj);
return TCL_OK;
|
| ︙ | ︙ | |||
1223 1224 1225 1226 1227 1228 1229 |
}
if (GetStatBuf(interp, objv[1], Tcl_FSStat, &buf) != TCL_OK) {
return TCL_ERROR;
}
#if defined(_WIN32)
/* We use a value of 0 to indicate the access time not available */
if (Tcl_GetAccessTimeFromStat(&buf) == 0) {
| | | 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 |
}
if (GetStatBuf(interp, objv[1], Tcl_FSStat, &buf) != TCL_OK) {
return TCL_ERROR;
}
#if defined(_WIN32)
/* We use a value of 0 to indicate the access time not available */
if (Tcl_GetAccessTimeFromStat(&buf) == 0) {
TclPrintfResult(interp, "could not get access time for file \"%s\"",
TclGetString(objv[1]));
return TCL_ERROR;
}
#endif
if (objc == 3) {
/*
|
| ︙ | ︙ | |||
1245 1246 1247 1248 1249 1250 1251 |
return TCL_ERROR;
}
tval.actime = newTime;
tval.modtime = Tcl_GetModificationTimeFromStat(&buf);
if (Tcl_FSUtime(objv[1], &tval) != 0) {
| < | | 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
return TCL_ERROR;
}
tval.actime = newTime;
tval.modtime = Tcl_GetModificationTimeFromStat(&buf);
if (Tcl_FSUtime(objv[1], &tval) != 0) {
TclPrintfResult(interp, "could not set access time for file \"%s\": %s",
TclGetString(objv[1]), Tcl_PosixError(interp));
return TCL_ERROR;
}
/*
* Do another stat to ensure that the we return the new recognized
* atime - hopefully the same as the one we sent in. However, fs's
|
| ︙ | ︙ | |||
1304 1305 1306 1307 1308 1309 1310 |
}
if (GetStatBuf(interp, objv[1], Tcl_FSStat, &buf) != TCL_OK) {
return TCL_ERROR;
}
#if defined(_WIN32)
/* We use a value of 0 to indicate the modification time not available */
if (Tcl_GetModificationTimeFromStat(&buf) == 0) {
| | | 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 |
}
if (GetStatBuf(interp, objv[1], Tcl_FSStat, &buf) != TCL_OK) {
return TCL_ERROR;
}
#if defined(_WIN32)
/* We use a value of 0 to indicate the modification time not available */
if (Tcl_GetModificationTimeFromStat(&buf) == 0) {
TclPrintfResult(interp,
"could not get modification time for file \"%s\"",
TclGetString(objv[1]));
return TCL_ERROR;
}
#endif
if (objc == 3) {
/*
|
| ︙ | ︙ | |||
1326 1327 1328 1329 1330 1331 1332 |
return TCL_ERROR;
}
tval.actime = Tcl_GetAccessTimeFromStat(&buf);
tval.modtime = newTime;
if (Tcl_FSUtime(objv[1], &tval) != 0) {
| | | 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 |
return TCL_ERROR;
}
tval.actime = Tcl_GetAccessTimeFromStat(&buf);
tval.modtime = newTime;
if (Tcl_FSUtime(objv[1], &tval) != 0) {
TclPrintfResult(interp,
"could not set modification time for file \"%s\": %s",
TclGetString(objv[1]), Tcl_PosixError(interp));
return TCL_ERROR;
}
/*
* Do another stat to ensure that the we return the new recognized
|
| ︙ | ︙ | |||
1951 1952 1953 1954 1955 1956 1957 |
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "name");
return TCL_ERROR;
}
fsInfo = Tcl_FSFileSystemInfo(objv[1]);
if (fsInfo == NULL) {
| | | 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 |
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "name");
return TCL_ERROR;
}
fsInfo = Tcl_FSFileSystemInfo(objv[1]);
if (fsInfo == NULL) {
TclPrintfResult(interp, "unrecognised path");
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "FILESYSTEM",
TclGetString(objv[1]), (char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, fsInfo);
return TCL_OK;
}
|
| ︙ | ︙ | |||
2099 2100 2101 2102 2103 2104 2105 |
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "name");
return TCL_ERROR;
}
res = Tcl_FSSplitPath(objv[1], (Tcl_Size *)NULL);
if (res == NULL) {
| < | | 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 |
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "name");
return TCL_ERROR;
}
res = Tcl_FSSplitPath(objv[1], (Tcl_Size *)NULL);
if (res == NULL) {
TclPrintfResult(interp, "could not read \"%s\": no such file or directory",
TclGetString(objv[1]));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PATHSPLIT", "NONESUCH",
(char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, res);
return TCL_OK;
|
| ︙ | ︙ | |||
2201 2202 2203 2204 2205 2206 2207 |
break;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(separator, 1));
} else {
Tcl_Obj *separatorObj = Tcl_FSPathSeparator(objv[1]);
if (separatorObj == NULL) {
| < | | 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 |
break;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(separator, 1));
} else {
Tcl_Obj *separatorObj = Tcl_FSPathSeparator(objv[1]);
if (separatorObj == NULL) {
TclPrintfResult(interp, "unrecognised path");
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "FILESYSTEM",
TclGetString(objv[1]), (char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, separatorObj);
}
return TCL_OK;
|
| ︙ | ︙ | |||
2334 2335 2336 2337 2338 2339 2340 |
} else {
status = statProc(pathPtr, statPtr);
}
Tcl_DStringFree(&ds);
if (status < 0) {
if (interp != NULL) {
| < | | 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 |
} else {
status = statProc(pathPtr, statPtr);
}
Tcl_DStringFree(&ds);
if (status < 0) {
if (interp != NULL) {
TclPrintfResult(interp, "could not read \"%s\": %s",
TclGetString(pathPtr), Tcl_PosixError(interp));
}
return TCL_ERROR;
}
return TCL_OK;
}
|
| ︙ | ︙ | |||
2846 2847 2848 2849 2850 2851 2852 |
result = TclListObjLength(interp, statePtr->vCopyList[i],
&statePtr->varcList[i]);
if (result != TCL_OK) {
result = TCL_ERROR;
goto done;
}
if (statePtr->varcList[i] < 1) {
| < | | 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 |
result = TclListObjLength(interp, statePtr->vCopyList[i],
&statePtr->varcList[i]);
if (result != TCL_OK) {
result = TCL_ERROR;
goto done;
}
if (statePtr->varcList[i] < 1) {
TclPrintfResult(interp, "%s varlist is empty",
(statePtr->resultList != NULL ? "lmap" : "foreach"));
Tcl_SetErrorCode(interp, "TCL", "OPERATION",
(statePtr->resultList != NULL ? "LMAP" : "FOREACH"),
"NEEDVARS", (char *)NULL);
result = TCL_ERROR;
goto done;
}
|
| ︙ | ︙ |
Changes to generic/tclCmdIL.c.
| ︙ | ︙ | |||
218 219 220 221 222 223 224 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *boolObj;
if (objc <= 1) {
| < | | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Obj *boolObj;
if (objc <= 1) {
TclPrintfResult(interp, "wrong # args: no expression after \"%s\" argument",
TclGetString(objv[0]));
Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
return TCL_ERROR;
}
/*
* At this point, objv[1] refers to the main expression to test. The
|
| ︙ | ︙ | |||
309 310 311 312 313 314 315 |
* At this point in the loop, objv and objc refer to an expression to
* test, either for the main expression or an expression following an
* "elseif". The arguments after the expression must be "then"
* (optional) and a script to execute if the expression is true.
*/
if (i >= objc) {
| < | | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
* At this point in the loop, objv and objc refer to an expression to
* test, either for the main expression or an expression following an
* "elseif". The arguments after the expression must be "then"
* (optional) and a script to execute if the expression is true.
*/
if (i >= objc) {
TclPrintfResult(interp, "wrong # args: no expression after \"%s\" argument",
clause);
Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
return TCL_ERROR;
}
if (!thenScriptIndex) {
TclNewObj(boolObj);
Tcl_NRAddCallback(interp, IfConditionCallback, data[0], data[1],
|
| ︙ | ︙ | |||
336 337 338 339 340 341 342 |
if (strcmp(clause, "else") == 0) {
i++;
if (i >= objc) {
goto missingScript;
}
}
if (i < objc - 1) {
| | | < < | | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
if (strcmp(clause, "else") == 0) {
i++;
if (i >= objc) {
goto missingScript;
}
}
if (i < objc - 1) {
TclPrintfResult(interp,
"wrong # args: extra words after \"else\" clause in \"if\" command");
Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
return TCL_ERROR;
}
if (thenScriptIndex) {
/*
* TIP #280. Make invoking context available to branch/else.
*/
return TclNREvalObjEx(interp, objv[thenScriptIndex], 0,
iPtr->cmdFramePtr, thenScriptIndex);
}
return TclNREvalObjEx(interp, objv[i], 0, iPtr->cmdFramePtr, i);
missingScript:
TclPrintfResult(interp, "wrong # args: no script following \"%s\" argument",
TclGetString(objv[i-1]));
Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
1544 1545 1546 1547 1548 1549 1550 |
name = Tcl_GetHostName();
if (name) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1));
return TCL_OK;
}
| < | | 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 |
name = Tcl_GetHostName();
if (name) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1));
return TCL_OK;
}
TclPrintfResult(interp, "unable to determine name of host");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "HOSTNAME", "UNKNOWN", (char *)NULL);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
1663 1664 1665 1666 1667 1668 1669 |
libDirName = Tcl_GetVar2(interp, "tcl_library", NULL, TCL_GLOBAL_ONLY);
if (libDirName != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(libDirName, -1));
return TCL_OK;
}
| < | | 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 |
libDirName = Tcl_GetVar2(interp, "tcl_library", NULL, TCL_GLOBAL_ONLY);
if (libDirName != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(libDirName, -1));
return TCL_OK;
}
TclPrintfResult(interp, "no library has been specified for Tcl");
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARIABLE", "tcl_library", (char *)NULL);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
2617 2618 2619 2620 2621 2622 2623 |
* First, extract the element to be returned.
* TclLindexFlat adds a ref count which is handled.
*/
if (objc == 2) {
if (!listLen) {
/* empty list, throw the same error as with index "end" */
| < | | 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 |
* First, extract the element to be returned.
* TclLindexFlat adds a ref count which is handled.
*/
if (objc == 2) {
if (!listLen) {
/* empty list, throw the same error as with index "end" */
TclPrintfResult(interp, "index \"end\" out of range");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", "OUTOFRANGE", (char *)NULL);
return TCL_ERROR;
}
result = Tcl_ListObjIndex(interp, listPtr, (listLen-1), &elemPtr);
if (result != TCL_OK) {
return result;
|
| ︙ | ︙ | |||
3227 3228 3229 3230 3231 3232 3233 |
*/
if (startPtr != NULL) {
Tcl_DecrRefCount(startPtr);
startPtr = NULL;
}
if (i > objc-4) {
| < | | 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 |
*/
if (startPtr != NULL) {
Tcl_DecrRefCount(startPtr);
startPtr = NULL;
}
if (i > objc-4) {
TclPrintfResult(interp, "missing starting index");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
result = TCL_ERROR;
goto done;
}
i++;
if (objv[i] == objv[objc - 2]) {
/*
|
| ︙ | ︙ | |||
3250 3251 3252 3253 3254 3255 3256 |
} else {
startPtr = objv[i];
}
Tcl_IncrRefCount(startPtr);
break;
case LSEARCH_STRIDE: /* -stride */
if (i > objc-4) {
| | | < | | | < | 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 |
} else {
startPtr = objv[i];
}
Tcl_IncrRefCount(startPtr);
break;
case LSEARCH_STRIDE: /* -stride */
if (i > objc-4) {
TclPrintfResult(interp,
"\"-stride\" option must be "
"followed by stride length");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
result = TCL_ERROR;
goto done;
}
if (TclGetWideIntFromObj(interp, objv[i+1], &wide) != TCL_OK) {
result = TCL_ERROR;
goto done;
}
if (wide < 1) {
TclPrintfResult(interp, "stride length must be at least 1");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSEARCH",
"BADSTRIDE", (char *)NULL);
result = TCL_ERROR;
goto done;
}
groupSize = wide;
i++;
break;
case LSEARCH_INDEX: { /* -index */
Tcl_Obj **indices;
Tcl_Size j;
if (allocatedIndexVector) {
TclStackFree(interp, sortInfo.indexv);
allocatedIndexVector = 0;
}
if (i > objc-4) {
TclPrintfResult(interp,
"\"-index\" option must be followed by list index");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
result = TCL_ERROR;
goto done;
}
/*
* Store the extracted indices for processing by sublist
|
| ︙ | ︙ | |||
3352 3353 3354 3355 3356 3357 3358 |
}
/*
* Subindices only make sense if asked for with -index option set.
*/
if (returnSubindices && sortInfo.indexc==0) {
| | | | | | 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 |
}
/*
* Subindices only make sense if asked for with -index option set.
*/
if (returnSubindices && sortInfo.indexc==0) {
TclPrintfResult(interp,
"-subindices cannot be used without -index option");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSEARCH",
"BAD_OPTION_MIX", (char *)NULL);
result = TCL_ERROR;
goto done;
}
if (bisect && (allMatches || negatedMatch)) {
TclPrintfResult(interp,
"-bisect is not compatible with -all or -not");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSEARCH",
"BAD_OPTION_MIX", (char *)NULL);
result = TCL_ERROR;
goto done;
}
if (mode == REGEXP) {
|
| ︙ | ︙ | |||
3414 3415 3416 3417 3418 3419 3420 |
/*
* Check for sanity when grouping elements of the overall list together
* because of the -stride option. [TIP #351]
*/
if (groupSize > 1) {
if (listc % groupSize) {
| | | < | | | 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 |
/*
* Check for sanity when grouping elements of the overall list together
* because of the -stride option. [TIP #351]
*/
if (groupSize > 1) {
if (listc % groupSize) {
TclPrintfResult(interp,
"list size must be a multiple of the stride length");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSEARCH", "BADSTRIDE",
(char *)NULL);
result = TCL_ERROR;
goto done;
}
if (sortInfo.indexc > 0) {
/*
* Use the first value in the list supplied to -index as the
* offset of the element within each group by which to sort.
*/
groupOffset = TclIndexDecode(sortInfo.indexv[0], groupSize - 1);
if (groupOffset < 0 || groupOffset >= groupSize) {
TclPrintfResult(interp,
"when used with \"-stride\", the leading \"-index\""
" value must be within the group");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSEARCH",
"BADINDEX", (char *)NULL);
result = TCL_ERROR;
goto done;
}
if (sortInfo.indexc == 1) {
sortInfo.indexc = 0;
|
| ︙ | ︙ | |||
4409 4410 4411 4412 4413 4414 4415 |
}
switch (index) {
case LSORT_ASCII:
sortInfo.sortMode = SORTMODE_ASCII;
break;
case LSORT_COMMAND:
if (i == objc-2) {
| | | | 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 |
}
switch (index) {
case LSORT_ASCII:
sortInfo.sortMode = SORTMODE_ASCII;
break;
case LSORT_COMMAND:
if (i == objc-2) {
TclPrintfResult(interp,
"\"-command\" option must be followed "
"by comparison command");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
sortInfo.sortMode = SORTMODE_COMMAND;
cmdPtr = objv[i+1];
i++;
|
| ︙ | ︙ | |||
4434 4435 4436 4437 4438 4439 4440 |
sortInfo.isIncreasing = 1;
break;
case LSORT_INDEX: {
Tcl_Size sortindex;
Tcl_Obj **indexv;
if (i == objc-2) {
| | | < | 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 |
sortInfo.isIncreasing = 1;
break;
case LSORT_INDEX: {
Tcl_Size sortindex;
Tcl_Obj **indexv;
if (i == objc-2) {
TclPrintfResult(interp,
"\"-index\" option must be followed by list index");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
if (TclListObjGetElements(interp, objv[i+1], &sortindex,
&indexv) != TCL_OK) {
sortInfo.resultCode = TCL_ERROR;
|
| ︙ | ︙ | |||
4494 4495 4496 4497 4498 4499 4500 |
sortInfo.unique = 1;
break;
case LSORT_INDICES:
indices = 1;
break;
case LSORT_STRIDE:
if (i == objc-2) {
| | | < < | | 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 |
sortInfo.unique = 1;
break;
case LSORT_INDICES:
indices = 1;
break;
case LSORT_STRIDE:
if (i == objc-2) {
TclPrintfResult(interp,
"\"-stride\" option must be followed by stride length");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
if (TclGetWideIntFromObj(interp, objv[i+1], &wide) != TCL_OK) {
sortInfo.resultCode = TCL_ERROR;
goto done;
}
if (wide < 2) {
TclPrintfResult(interp, "stride length must be at least 2");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSORT",
"BADSTRIDE", (char *)NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
groupSize = wide;
group = 1;
|
| ︙ | ︙ | |||
4610 4611 4612 4613 4614 4615 4616 |
/*
* Check for sanity when grouping elements of the overall list together
* because of the -stride option. [TIP #326]
*/
if (group) {
if (length % groupSize) {
| | | < | | | 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 |
/*
* Check for sanity when grouping elements of the overall list together
* because of the -stride option. [TIP #326]
*/
if (group) {
if (length % groupSize) {
TclPrintfResult(interp,
"list size must be a multiple of the stride length");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSORT", "BADSTRIDE",
(char *)NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
length = length / groupSize;
if (sortInfo.indexc > 0) {
/*
* Use the first value in the list supplied to -index as the
* offset of the element within each group by which to sort.
*/
groupOffset = TclIndexDecode(sortInfo.indexv[0], groupSize - 1);
if (groupOffset < 0 || groupOffset >= groupSize) {
TclPrintfResult(interp,
"when used with \"-stride\", the leading \"-index\""
" value must be within the group");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSORT",
"BADINDEX", (char *)NULL);
sortInfo.resultCode = TCL_ERROR;
goto done;
}
if (sortInfo.indexc == 1) {
sortInfo.indexc = 0;
|
| ︙ | ︙ | |||
5144 5145 5146 5147 5148 5149 5150 |
/*
* Parse the result of the command.
*/
if (TclGetIntFromObj(infoPtr->interp,
Tcl_GetObjResult(infoPtr->interp), &order) != TCL_OK) {
| | | | 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 |
/*
* Parse the result of the command.
*/
if (TclGetIntFromObj(infoPtr->interp,
Tcl_GetObjResult(infoPtr->interp), &order) != TCL_OK) {
TclPrintfResult(infoPtr->interp,
"-compare command returned non-integer result");
Tcl_SetErrorCode(infoPtr->interp, "TCL", "OPERATION", "LSORT",
"COMPARISONFAILED", (char *)NULL);
infoPtr->resultCode = TCL_ERROR;
return 0;
}
}
if (!infoPtr->isIncreasing) {
|
| ︙ | ︙ |
Changes to generic/tclCmdMZ.c.
| ︙ | ︙ | |||
228 229 230 231 232 233 234 |
/*
* Check if the user requested -inline, but specified match variables; a
* no-no.
*/
if (doinline && ((objc - 2) != 0)) {
| | | | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
/*
* Check if the user requested -inline, but specified match variables; a
* no-no.
*/
if (doinline && ((objc - 2) != 0)) {
TclPrintfResult(interp,
"regexp match variables not allowed when using -inline");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "REGEXP",
"MIX_VAR_INLINE", (char *)NULL);
goto optionError;
}
/*
* Handle the odd about case separately.
|
| ︙ | ︙ | |||
682 683 684 685 686 687 688 |
* object. (If they aren't, that's cheap to do.)
*/
if (TclListObjLength(interp, objv[2], &numParts) != TCL_OK) {
return TCL_ERROR;
}
if (numParts < 1) {
| | | < | 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 |
* object. (If they aren't, that's cheap to do.)
*/
if (TclListObjLength(interp, objv[2], &numParts) != TCL_OK) {
return TCL_ERROR;
}
if (numParts < 1) {
TclPrintfResult(interp,
"command prefix must be a list of at least one element");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "REGSUB",
"CMDEMPTY", (char *)NULL);
return TCL_ERROR;
}
regExpr = Tcl_GetRegExpFromObj(interp, objv[0], cflags);
}
|
| ︙ | ︙ | |||
2045 2046 2047 2048 2049 2050 2051 |
Tcl_SetObjResult(interp, objv[objc-1]);
return TCL_OK;
} else if (mapElemc & 1) {
/*
* The charMap must be an even number of key/value items.
*/
| < | | 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 |
Tcl_SetObjResult(interp, objv[objc-1]);
return TCL_OK;
} else if (mapElemc & 1) {
/*
* The charMap must be an even number of key/value items.
*/
TclPrintfResult(interp, "char map list unbalanced");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "MAP",
"UNBALANCED", (char *)NULL);
return TCL_ERROR;
}
}
/*
|
| ︙ | ︙ | |||
3367 3368 3369 3370 3371 3372 3373 |
return TCL_ERROR;
}
flags |= optionFlags[optionIndex];
}
if (flags >> 16) { /* negative options specified */
if (flags & 0xFFFF) { /* positive options specified too */
if (interp) {
| | | | 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 |
return TCL_ERROR;
}
flags |= optionFlags[optionIndex];
}
if (flags >> 16) { /* negative options specified */
if (flags & 0xFFFF) { /* positive options specified too */
if (interp) {
TclPrintfResult(interp,
"cannot combine positive and negative options");
}
return TCL_ERROR;
}
/* mask default flags using negative options */
flags = TCL_SUBST_ALL & ~(flags >> 16);
}
*flagPtr = flags;
|
| ︙ | ︙ | |||
3633 3634 3635 3636 3637 3638 3639 |
/*
* Complain if there is an odd number of words in the list of patterns and
* bodies.
*/
if (objc % 2) {
Tcl_ResetResult(interp);
| < | | 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 |
/*
* Complain if there is an odd number of words in the list of patterns and
* bodies.
*/
if (objc % 2) {
Tcl_ResetResult(interp);
TclPrintfResult(interp, "extra switch pattern with no body");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "SWITCH", "BADARM",
(char *)NULL);
/*
* Check if this can be due to a badly placed comment in the switch
* block.
*
|
| ︙ | ︙ | |||
4013 4014 4015 4016 4017 4018 4019 |
/*
* The type must be a list of at least length 1.
*/
if (TclListObjLength(interp, objv[1], &len) != TCL_OK) {
return TCL_ERROR;
} else if (len < 1) {
| < | | 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 |
/*
* The type must be a list of at least length 1.
*/
if (TclListObjLength(interp, objv[1], &len) != TCL_OK) {
return TCL_ERROR;
} else if (len < 1) {
TclPrintfResult(interp, "type must be non-empty list");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "THROW", "BADEXCEPTION",
(char *)NULL);
return TCL_ERROR;
}
/*
* Now prepare the result options dictionary. We use the list API as it is
|
| ︙ | ︙ | |||
4803 4804 4805 4806 4807 4808 4809 |
0, &type) != TCL_OK) {
Tcl_DecrRefCount(handlersObj);
return TCL_ERROR;
}
switch (type) {
case TryFinally: /* finally script */
if (i < objc-2) {
| < | | | | | | | < | 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 |
0, &type) != TCL_OK) {
Tcl_DecrRefCount(handlersObj);
return TCL_ERROR;
}
switch (type) {
case TryFinally: /* finally script */
if (i < objc-2) {
TclPrintfResult(interp, "finally clause must be last");
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "FINALLY",
"NONTERMINAL", (char *)NULL);
return TCL_ERROR;
} else if (i == objc-1) {
TclPrintfResult(interp,
"wrong # args to finally clause: must be"
" \"... finally script\"");
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "FINALLY",
"ARGUMENT", (char *)NULL);
return TCL_ERROR;
}
finallyObj = objv[++i];
break;
case TryOn: /* on code variableList script */
if (i > objc-4) {
TclPrintfResult(interp,
"wrong # args to on clause: must be \"... on code"
" variableList script\"");
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "ON",
"ARGUMENT", (char *)NULL);
return TCL_ERROR;
}
if (TclGetCompletionCodeFromObj(interp, objv[i+1],
&code) != TCL_OK) {
Tcl_DecrRefCount(handlersObj);
return TCL_ERROR;
}
info[2] = NULL;
goto commonHandler;
case TryTrap: /* trap pattern variableList script */
if (i > objc-4) {
TclPrintfResult(interp,
"wrong # args to trap clause: "
"must be \"... trap pattern variableList script\"");
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "TRAP",
"ARGUMENT", (char *)NULL);
return TCL_ERROR;
}
code = 1;
if (TclListObjLength(NULL, objv[i+1], &dummy) != TCL_OK) {
|
| ︙ | ︙ | |||
4886 4887 4888 4889 4890 4891 4892 |
i += 3;
break;
default:
TCL_UNREACHABLE();
}
}
if (bodyShared) {
| | | | 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 |
i += 3;
break;
default:
TCL_UNREACHABLE();
}
}
if (bodyShared) {
TclPrintfResult(interp,
"last non-finally clause must not have a body of \"-\"");
Tcl_DecrRefCount(handlersObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRY", "BADFALLTHROUGH",
(char *)NULL);
return TCL_ERROR;
}
if (!haveHandlers) {
Tcl_DecrRefCount(handlersObj);
|
| ︙ | ︙ |
Changes to generic/tclCompile.c.
| ︙ | ︙ | |||
2489 2490 2491 2492 2493 2494 2495 |
* Check depth to avoid overflow of the C execution stack by too many
* nested calls of TclCompileScript, considering interp recursionlimit.
* Use factor 5/4 (1.25) to avoid being too mistaken when recognizing the
* limit during "mixed" evaluation and compilation process (nested
* eval+compile) and is good enough for default recursionlimit (1000).
*/
if (iPtr->numLevels / 5 > iPtr->maxNestingDepth / 4) {
| | | < | 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 |
* Check depth to avoid overflow of the C execution stack by too many
* nested calls of TclCompileScript, considering interp recursionlimit.
* Use factor 5/4 (1.25) to avoid being too mistaken when recognizing the
* limit during "mixed" evaluation and compilation process (nested
* eval+compile) and is good enough for default recursionlimit (1000).
*/
if (iPtr->numLevels / 5 > iPtr->maxNestingDepth / 4) {
TclPrintfResult(interp,
"too many nested compilations (infinite loop?)");
Tcl_SetErrorCode(interp, "TCL", "LIMIT", "STACK", (char *)NULL);
TclCompileSyntaxError(interp, envPtr);
return;
}
if (numBytes < 0) {
numBytes = strlen(script);
|
| ︙ | ︙ |
Changes to generic/tclConfig.c.
| ︙ | ︙ | |||
223 224 225 226 227 228 229 |
if (Tcl_DictObjGet(interp, pDB, pkgName, &pkgDict) != TCL_OK
|| pkgDict == NULL) {
/*
* Maybe a Tcl_Panic is better, because the package data has to be
* present.
*/
| | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
if (Tcl_DictObjGet(interp, pDB, pkgName, &pkgDict) != TCL_OK
|| pkgDict == NULL) {
/*
* Maybe a Tcl_Panic is better, because the package data has to be
* present.
*/
TclPrintfResult(interp, "package not known");
Tcl_SetErrorCode(interp, "TCL", "FATAL", "PKGCFG_BASE",
TclGetString(pkgName), (char *)NULL);
return TCL_ERROR;
}
switch (index) {
case CFG_GET:
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "key");
return TCL_ERROR;
}
if (Tcl_DictObjGet(interp, pkgDict, objv[2], &val) != TCL_OK
|| val == NULL) {
TclPrintfResult(interp, "key not known");
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CONFIG",
TclGetString(objv[2]), (char *)NULL);
return TCL_ERROR;
}
if (cdPtr->encoding) {
venc = Tcl_GetEncoding(interp, cdPtr->encoding);
|
| ︙ | ︙ | |||
274 275 276 277 278 279 280 |
return TCL_ERROR;
}
Tcl_DictObjSize(interp, pkgDict, &m);
listPtr = Tcl_NewListObj(m, NULL);
if (!listPtr) {
| < | | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
return TCL_ERROR;
}
Tcl_DictObjSize(interp, pkgDict, &m);
listPtr = Tcl_NewListObj(m, NULL);
if (!listPtr) {
TclPrintfResult(interp, "insufficient memory to create list");
Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL);
return TCL_ERROR;
}
if (m) {
Tcl_DictSearch s;
Tcl_Obj *key;
|
| ︙ | ︙ |
Changes to generic/tclDictObj.c.
| ︙ | ︙ | |||
714 715 716 717 718 719 720 |
dict->chain = NULL;
dict->refCount = 1;
DictSetInternalRep(objPtr, dict);
return TCL_OK;
missingValue:
if (interp != NULL) {
| < | | 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
dict->chain = NULL;
dict->refCount = 1;
DictSetInternalRep(objPtr, dict);
return TCL_OK;
missingValue:
if (interp != NULL) {
TclPrintfResult(interp, "missing value to go with key");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DICTIONARY", (char *)NULL);
}
errorInFindDictElement:
DeleteChainTable(dict);
Tcl_Free(dict);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2700 2701 2702 2703 2704 2705 2706 |
* Parse arguments.
*/
if (TclListObjGetElements(interp, objv[1], &varc, &varv) != TCL_OK) {
return TCL_ERROR;
}
if (varc != 2) {
| < | | 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 |
* Parse arguments.
*/
if (TclListObjGetElements(interp, objv[1], &varc, &varv) != TCL_OK) {
return TCL_ERROR;
}
if (varc != 2) {
TclPrintfResult(interp, "must have exactly two variable names");
Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "for", (char *)NULL);
return TCL_ERROR;
}
searchPtr = (Tcl_DictSearch *)TclStackAlloc(interp, sizeof(Tcl_DictSearch));
if (Tcl_DictObjFirst(interp, objv[2], searchPtr, &keyObj, &valueObj,
&done) != TCL_OK) {
TclStackFree(interp, searchPtr);
|
| ︙ | ︙ | |||
2895 2896 2897 2898 2899 2900 2901 |
* Parse arguments.
*/
if (TclListObjGetElements(interp, objv[1], &varc, &varv) != TCL_OK) {
return TCL_ERROR;
}
if (varc != 2) {
| < | | 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 |
* Parse arguments.
*/
if (TclListObjGetElements(interp, objv[1], &varc, &varv) != TCL_OK) {
return TCL_ERROR;
}
if (varc != 2) {
TclPrintfResult(interp, "must have exactly two variable names");
Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "map", (char *)NULL);
return TCL_ERROR;
}
storagePtr = (DictMapStorage *)TclStackAlloc(interp, sizeof(DictMapStorage));
if (Tcl_DictObjFirst(interp, objv[2], &storagePtr->search, &keyObj,
&valueObj, &done) != TCL_OK) {
TclStackFree(interp, storagePtr);
|
| ︙ | ︙ | |||
3335 3336 3337 3338 3339 3340 3341 |
* copying from the "dict for" implementation has occurred!
*/
if (TclListObjGetElements(interp, objv[3], &varc, &varv) != TCL_OK) {
return TCL_ERROR;
}
if (varc != 2) {
| < | | 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 |
* copying from the "dict for" implementation has occurred!
*/
if (TclListObjGetElements(interp, objv[3], &varc, &varv) != TCL_OK) {
return TCL_ERROR;
}
if (varc != 2) {
TclPrintfResult(interp, "must have exactly two variable names");
Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "dict", "filter", (char *)NULL);
return TCL_ERROR;
}
keyVarObj = varv[0];
valueVarObj = varv[1];
scriptObj = objv[4];
|
| ︙ | ︙ |
Changes to generic/tclDisassemble.c.
| ︙ | ︙ | |||
1485 1486 1487 1488 1489 1490 1491 |
TclGetString(ooWhat));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"CONSRUCTOR", (char *)NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod(methodPtr);
if (procPtr == NULL) {
| | | | 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 |
TclGetString(ooWhat));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"CONSRUCTOR", (char *)NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod(methodPtr);
if (procPtr == NULL) {
TclPrintfResult(interp,
"body not available for this kind of constructor");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"METHODTYPE", (char *)NULL);
return TCL_ERROR;
}
oPtr = classPtr->thisPtr;
bodyType = "body of constructor";
|
| ︙ | ︙ | |||
1522 1523 1524 1525 1526 1527 1528 |
TclGetString(ooWhat));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"DESRUCTOR", (char *)NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod(methodPtr);
if (procPtr == NULL) {
| | | | 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 |
TclGetString(ooWhat));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"DESRUCTOR", (char *)NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod(methodPtr);
if (procPtr == NULL) {
TclPrintfResult(interp,
"body not available for this kind of destructor");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"METHODTYPE", (char *)NULL);
return TCL_ERROR;
}
oPtr = classPtr->thisPtr;
bodyType = "body of destructor";
|
| ︙ | ︙ | |||
1587 1588 1589 1590 1591 1592 1593 |
TclGetString(ooWhat));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(ooWhat), (char *)NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod((Method *)Tcl_GetHashValue(hPtr));
if (procPtr == NULL) {
| | | | 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 |
TclGetString(ooWhat));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(ooWhat), (char *)NULL);
return TCL_ERROR;
}
procPtr = TclOOGetProcFromMethod((Method *)Tcl_GetHashValue(hPtr));
if (procPtr == NULL) {
TclPrintfResult(interp,
"body not available for this kind of method");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"METHODTYPE", (char *)NULL);
return TCL_ERROR;
}
bodyType = "body of method";
compileMethodIfNeeded:
|
| ︙ | ︙ | |||
1627 1628 1629 1630 1631 1632 1633 |
/*
* Do the actual disassembly.
*/
ByteCodeGetInternalRep(codeObjPtr, &tclByteCodeType, codePtr);
if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
| < | | 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 |
/*
* Do the actual disassembly.
*/
ByteCodeGetInternalRep(codeObjPtr, &tclByteCodeType, codePtr);
if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
TclPrintfResult(interp, "may not disassemble prebuilt bytecode");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
"BYTECODE", (char *)NULL);
return TCL_ERROR;
}
if (clientData) {
Tcl_SetObjResult(interp,
DisassembleByteCodeAsDicts(codeObjPtr));
|
| ︙ | ︙ |
Changes to generic/tclEncoding.c.
| ︙ | ︙ | |||
4670 4671 4672 4673 4674 4675 4676 |
*/
static inline void
Utf8procErrorToTclError(
Tcl_Interp *interp, // Interpreter to put error description into.
utf8proc_ssize_t errcode) // Error code to convert.
{
const char *errorMsg = utf8proc_errmsg(errcode);
| | | < | 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 |
*/
static inline void
Utf8procErrorToTclError(
Tcl_Interp *interp, // Interpreter to put error description into.
utf8proc_ssize_t errcode) // Error code to convert.
{
const char *errorMsg = utf8proc_errmsg(errcode);
TclPrintfResult(interp, "%s",
errorMsg ? errorMsg : "Unicode normalization failed.");
switch (errcode) {
case UTF8PROC_ERROR_NOMEM:
// Memory allocation failure can use the standard Tcl code.
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
break;
case UTF8PROC_ERROR_OVERFLOW:
Tcl_SetErrorCode(interp, "TCL", "UNICODE", "OVERFLOW", NULL);
|
| ︙ | ︙ | |||
4901 4902 4903 4904 4905 4906 4907 |
break;
}
*to++ = 0x80;
from++;
}
}
if (from < fromEnd) {
| < | | 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 |
break;
}
*to++ = 0x80;
from++;
}
}
if (from < fromEnd) {
TclPrintfResult(interp, "Output buffer too small.");
result = TCL_CONVERT_NOSPACE;
} else {
assert(to <= toEnd);
*to = '\0'; /* NUL terminate the output */
if (lengthPtr) {
*lengthPtr = to-bufPtr;
}
|
| ︙ | ︙ |
Changes to generic/tclEnsemble.c.
| ︙ | ︙ | |||
156 157 158 159 160 161 162 |
{
Namespace *nsPtr = (Namespace *) TclGetCurrentNamespace(interp);
Tcl_Command token; /* The ensemble command. */
enum EnsSubcmds index;
if (nsPtr == NULL || nsPtr->flags & NS_DEAD) {
if (!Tcl_InterpDeleted(interp)) {
| | | < | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
{
Namespace *nsPtr = (Namespace *) TclGetCurrentNamespace(interp);
Tcl_Command token; /* The ensemble command. */
enum EnsSubcmds index;
if (nsPtr == NULL || nsPtr->flags & NS_DEAD) {
if (!Tcl_InterpDeleted(interp)) {
TclPrintfResult(interp,
"tried to manipulate ensemble of deleted namespace");
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "DEAD", (char *)NULL);
}
return TCL_ERROR;
}
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?arg ...?");
|
| ︙ | ︙ | |||
329 330 331 332 333 334 335 |
const char *cmd;
if (TclListObjGetElements(interp, listObj, &len,
&listv) != TCL_OK) {
goto mapError;
}
if (len < 1) {
| | | | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
const char *cmd;
if (TclListObjGetElements(interp, listObj, &len,
&listv) != TCL_OK) {
goto mapError;
}
if (len < 1) {
TclPrintfResult(interp,
"ensemble subcommand implementations "
"must be non-empty lists");
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE",
"EMPTY_TARGET", (char *)NULL);
goto mapError;
}
cmd = TclGetString(listv[0]);
if (!(cmd[0] == ':' && cmd[1] == ':')) {
Tcl_Obj *newList = Tcl_NewListObj(len, listv);
|
| ︙ | ︙ | |||
651 652 653 654 655 656 657 |
}
do {
if (TclListObjLength(interp, listObj, &len) != TCL_OK) {
goto finishSearchAndError;
}
if (len < 1) {
| | | | 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
}
do {
if (TclListObjLength(interp, listObj, &len) != TCL_OK) {
goto finishSearchAndError;
}
if (len < 1) {
TclPrintfResult(interp,
"ensemble subcommand implementations "
"must be non-empty lists");
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE",
"EMPTY_TARGET", (char *)NULL);
goto finishSearchAndError;
}
if (TclListObjGetElements(interp, listObj, &len,
&listv) != TCL_OK) {
goto finishSearchAndError;
|
| ︙ | ︙ | |||
697 698 699 700 701 702 703 |
Tcl_DictObjDone(&search);
if (patchedDict) {
Tcl_DecrRefCount(patchedDict);
}
goto freeMapAndError;
}
case CONF_NAMESPACE:
| < | | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
Tcl_DictObjDone(&search);
if (patchedDict) {
Tcl_DecrRefCount(patchedDict);
}
goto freeMapAndError;
}
case CONF_NAMESPACE:
TclPrintfResult(interp, "option -namespace is read-only");
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "READ_ONLY",
(char *)NULL);
goto freeMapAndError;
case CONF_PREFIX:
if (Tcl_GetBooleanFromObj(interp, objv[1],
&permitPrefix) != TCL_OK) {
goto freeMapAndError;
|
| ︙ | ︙ | |||
871 872 873 874 875 876 877 |
Tcl_Interp *interp, /* Where to report an error. May be NULL. */
Tcl_Command token) /* What to check for ensemble-ness. */
{
Command *cmdPtr = (Command *) token;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
| < | | 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 |
Tcl_Interp *interp, /* Where to report an error. May be NULL. */
Tcl_Command token) /* What to check for ensemble-ness. */
{
Command *cmdPtr = (Command *) token;
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
if (interp != NULL) {
TclPrintfResult(interp, "command is not an ensemble");
Tcl_SetErrorCode(interp,
"TCL", "ENSEMBLE", "NOT_ENSEMBLE", (char *)NULL);
}
return NULL;
}
return (EnsembleConfig *) cmdPtr->objClientData;
}
|
| ︙ | ︙ | |||
1086 1087 1088 1089 1090 1091 1092 |
if (Tcl_ListObjIndex(interp, valuePtr, 0, &cmdObjPtr) != TCL_OK) {
Tcl_DictObjDone(&search);
return TCL_ERROR;
}
bytes = TclGetString(cmdObjPtr);
if (bytes[0] != ':' || bytes[1] != ':') {
| | | < | 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
if (Tcl_ListObjIndex(interp, valuePtr, 0, &cmdObjPtr) != TCL_OK) {
Tcl_DictObjDone(&search);
return TCL_ERROR;
}
bytes = TclGetString(cmdObjPtr);
if (bytes[0] != ':' || bytes[1] != ':') {
TclPrintfResult(interp,
"ensemble target is not a fully-qualified command");
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE",
"UNQUALIFIED_TARGET", (char *)NULL);
Tcl_DictObjDone(&search);
return TCL_ERROR;
}
}
|
| ︙ | ︙ | |||
1793 1794 1795 1796 1797 1798 1799 |
if (ensemblePtr->nsPtr->flags & NS_DEAD) {
/*
* Don't know how we got here, but make things give up quickly.
*/
if (!Tcl_InterpDeleted(interp)) {
| | | < | 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 |
if (ensemblePtr->nsPtr->flags & NS_DEAD) {
/*
* Don't know how we got here, but make things give up quickly.
*/
if (!Tcl_InterpDeleted(interp)) {
TclPrintfResult(interp,
"ensemble activated for deleted namespace");
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "DEAD", (char *)NULL);
}
return TCL_ERROR;
}
/*
* If the table of subcommands is valid just lookup up the command there
|
| ︙ | ︙ | |||
2378 2379 2380 2381 2382 2383 2384 |
*/
Tcl_Preserve(ensemblePtr);
TclSkipTailcall(interp);
result = Tcl_EvalObjv(interp, paramc, paramv, 0);
if ((result == TCL_OK) && (ensemblePtr->flags & ENSEMBLE_DEAD)) {
if (!Tcl_InterpDeleted(interp)) {
| | | < | 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 |
*/
Tcl_Preserve(ensemblePtr);
TclSkipTailcall(interp);
result = Tcl_EvalObjv(interp, paramc, paramv, 0);
if ((result == TCL_OK) && (ensemblePtr->flags & ENSEMBLE_DEAD)) {
if (!Tcl_InterpDeleted(interp)) {
TclPrintfResult(interp,
"unknown subcommand handler deleted its ensemble");
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "UNKNOWN_DELETED",
(char *)NULL);
}
result = TCL_ERROR;
}
Tcl_Release(ensemblePtr);
|
| ︙ | ︙ | |||
2427 2428 2429 2430 2431 2432 2433 |
/*
* Convert exceptional result to an error.
*/
if (!Tcl_InterpDeleted(interp)) {
if (result != TCL_ERROR) {
Tcl_ResetResult(interp);
| | | < | 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 |
/*
* Convert exceptional result to an error.
*/
if (!Tcl_InterpDeleted(interp)) {
if (result != TCL_ERROR) {
Tcl_ResetResult(interp);
TclPrintfResult(interp,
"unknown subcommand handler returned bad code: ");
switch (result) {
case TCL_RETURN:
Tcl_AppendToObj(Tcl_GetObjResult(interp), "return",
TCL_AUTO_LENGTH);
break;
case TCL_BREAK:
Tcl_AppendToObj(Tcl_GetObjResult(interp), "break",
|
| ︙ | ︙ |
Changes to generic/tclEvent.c.
| ︙ | ︙ | |||
347 348 349 350 351 352 353 |
/*
* Check for a valid return options dictionary.
*/
result = TclDictGet(NULL, objv[2], "-level", &valuePtr);
if (result != TCL_OK || valuePtr == NULL) {
| < | < | | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
/*
* Check for a valid return options dictionary.
*/
result = TclDictGet(NULL, objv[2], "-level", &valuePtr);
if (result != TCL_OK || valuePtr == NULL) {
TclPrintfResult(interp, "missing return option \"-level\"");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, valuePtr, &level) == TCL_ERROR) {
return TCL_ERROR;
}
result = TclDictGet(NULL, objv[2], "-code", &valuePtr);
if (result != TCL_OK || valuePtr == NULL) {
TclPrintfResult(interp, "missing return option \"-code\"");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, valuePtr, &code) == TCL_ERROR) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1579 1580 1581 1582 1583 1584 1585 |
}
if (Tcl_GetIntFromObj(interp, objv[i], &timeout) != TCL_OK) {
result = TCL_ERROR;
goto done;
}
if (timeout < 0) {
Tcl_ResetResult(interp);
| < | | 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 |
}
if (Tcl_GetIntFromObj(interp, objv[i], &timeout) != TCL_OK) {
result = TCL_ERROR;
goto done;
}
if (timeout < 0) {
Tcl_ResetResult(interp);
TclPrintfResult(interp, "timeout must be positive");
Tcl_SetErrorCode(interp, "TCL", "EVENT", "NEGTIME", (char *)NULL);
result = TCL_ERROR;
goto done;
}
break;
case OPT_LAST:
i++;
|
| ︙ | ︙ | |||
1661 1662 1663 1664 1665 1666 1667 |
TCL_UNREACHABLE();
}
}
endOfOptionLoop:
if ((mask & (TCL_FILE_EVENTS | TCL_IDLE_EVENTS |
TCL_TIMER_EVENTS | TCL_WINDOW_EVENTS)) == 0) {
| < | < | | 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 |
TCL_UNREACHABLE();
}
}
endOfOptionLoop:
if ((mask & (TCL_FILE_EVENTS | TCL_IDLE_EVENTS |
TCL_TIMER_EVENTS | TCL_WINDOW_EVENTS)) == 0) {
TclPrintfResult(interp, "can't wait: would block forever");
Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_SOURCES", (char *)NULL);
result = TCL_ERROR;
goto done;
}
if ((timeout > 0) && ((mask & TCL_TIMER_EVENTS) == 0)) {
TclPrintfResult(interp, "timer events disabled with timeout specified");
Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_TIME", (char *)NULL);
result = TCL_ERROR;
goto done;
}
for (result = TCL_OK; i < objc; i++) {
result = Tcl_TraceVar2(interp, TclGetString(objv[i]), NULL,
|
| ︙ | ︙ | |||
1697 1698 1699 1700 1701 1702 1703 |
result = TCL_ERROR;
goto done;
}
if (!(mask & TCL_FILE_EVENTS)) {
for (i = 0; i < numItems; i++) {
if (vwaitItems[i].mask) {
| | | | 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 |
result = TCL_ERROR;
goto done;
}
if (!(mask & TCL_FILE_EVENTS)) {
for (i = 0; i < numItems; i++) {
if (vwaitItems[i].mask) {
TclPrintfResult(interp,
"file events disabled with channel(s) specified");
Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_FILE_EVENT", (char *)NULL);
result = TCL_ERROR;
goto done;
}
}
}
|
| ︙ | ︙ | |||
1737 1738 1739 1740 1741 1742 1743 |
((!any && (done < numItems)) || (any && !done))) {
foundEvent = Tcl_DoOneEvent(mask);
if (Tcl_Canceled(interp, TCL_LEAVE_ERR_MSG) == TCL_ERROR) {
break;
}
if (Tcl_LimitExceeded(interp)) {
Tcl_ResetResult(interp);
| | < | | < | 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 |
((!any && (done < numItems)) || (any && !done))) {
foundEvent = Tcl_DoOneEvent(mask);
if (Tcl_Canceled(interp, TCL_LEAVE_ERR_MSG) == TCL_ERROR) {
break;
}
if (Tcl_LimitExceeded(interp)) {
Tcl_ResetResult(interp);
TclPrintfResult(interp, "limit exceeded");
Tcl_SetErrorCode(interp, "TCL", "EVENT", "LIMIT", (char *)NULL);
break;
}
if ((numItems == 0) && (timeout == 0)) {
/*
* Behavior like "update": clear interpreter's result because
* event handlers could have executed commands.
*/
Tcl_ResetResult(interp);
result = TCL_OK;
goto done;
}
}
if (!foundEvent) {
Tcl_ResetResult(interp);
TclPrintfResult(interp, "can't wait%s: would wait forever",
numItems ? " for variable(s)/channel(s)" : "");
Tcl_SetErrorCode(interp, "TCL", "EVENT", "NO_SOURCES", (char *)NULL);
result = TCL_ERROR;
goto done;
}
if (!done && !timedOut) {
/*
|
| ︙ | ︙ | |||
1985 1986 1987 1988 1989 1990 1991 |
while (Tcl_DoOneEvent(flags) != 0) {
if (Tcl_Canceled(interp, TCL_LEAVE_ERR_MSG) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tcl_LimitExceeded(interp)) {
Tcl_ResetResult(interp);
| | | 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 |
while (Tcl_DoOneEvent(flags) != 0) {
if (Tcl_Canceled(interp, TCL_LEAVE_ERR_MSG) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tcl_LimitExceeded(interp)) {
Tcl_ResetResult(interp);
TclPrintfResult(interp, "limit exceeded");
return TCL_ERROR;
}
}
/*
* Must clear the interpreter's result because event handlers could have
* executed commands.
|
| ︙ | ︙ |
Changes to generic/tclExecute.c.
| ︙ | ︙ | |||
2512 2513 2514 2515 2516 2517 2518 |
void *yieldParameter;
case INST_YIELD:
corPtr = iPtr->execEnvPtr->corPtr;
TRACE(("%.30s => ", O2S(OBJ_AT_TOS)));
if (!corPtr) {
TRACE_APPEND(("ERROR: yield outside coroutine\n"));
| < | | 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 |
void *yieldParameter;
case INST_YIELD:
corPtr = iPtr->execEnvPtr->corPtr;
TRACE(("%.30s => ", O2S(OBJ_AT_TOS)));
if (!corPtr) {
TRACE_APPEND(("ERROR: yield outside coroutine\n"));
TclPrintfResult(interp, "yield can only be called in a coroutine");
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD",
(char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
|
| ︙ | ︙ | |||
2542 2543 2544 2545 2546 2547 2548 |
case INST_YIELD_TO_INVOKE:
corPtr = iPtr->execEnvPtr->corPtr;
valuePtr = OBJ_AT_TOS;
TRACE(("[%.30s] => ", O2S(valuePtr)));
if (!corPtr) {
TRACE_APPEND(("ERROR: yield outside coroutine\n"));
| < | < | | 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 |
case INST_YIELD_TO_INVOKE:
corPtr = iPtr->execEnvPtr->corPtr;
valuePtr = OBJ_AT_TOS;
TRACE(("[%.30s] => ", O2S(valuePtr)));
if (!corPtr) {
TRACE_APPEND(("ERROR: yield outside coroutine\n"));
TclPrintfResult(interp, "yieldto can only be called in a coroutine");
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD",
(char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
if (((Namespace *)TclGetCurrentNamespace(interp))->flags & NS_DYING) {
TRACE_APPEND(("ERROR: yield in deleted\n"));
TclPrintfResult(interp, "yieldto called in deleted namespace");
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "YIELDTO_IN_DELETED",
(char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
Tcl_Size yieldTargetLength;
|
| ︙ | ︙ | |||
2639 2640 2641 2642 2643 2644 2645 |
#ifndef REMOVE_DEPRECATED_OPCODES
doTailcall:
#endif // REMOVE_DEPRECATED_OPCODES
TRACE(("%u ", (unsigned) numArgs));
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
TRACE_APPEND(("=> ERROR: tailcall in non-proc context\n"));
| | | | 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 |
#ifndef REMOVE_DEPRECATED_OPCODES
doTailcall:
#endif // REMOVE_DEPRECATED_OPCODES
TRACE(("%u ", (unsigned) numArgs));
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
TRACE_APPEND(("=> ERROR: tailcall in non-proc context\n"));
TclPrintfResult(interp,
"tailcall can only be called from a proc or lambda");
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "TAILCALL", "ILLEGAL", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
if (numArgs < 2) {
Tcl_Panic("must be at least one command word argument to INST_TAILCALL");
|
| ︙ | ︙ | |||
2688 2689 2690 2691 2692 2693 2694 |
}
#endif // REMOVE_DEPRECATED_OPCODES
goto setTailcall;
case INST_TAILCALL_LIST:
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
TRACE((" => ERROR: tailcall in non-proc context\n"));
| | | | 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 |
}
#endif // REMOVE_DEPRECATED_OPCODES
goto setTailcall;
case INST_TAILCALL_LIST:
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
TRACE((" => ERROR: tailcall in non-proc context\n"));
TclPrintfResult(interp,
"tailcall can only be called from a proc or lambda");
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "TAILCALL", "ILLEGAL", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
}
listPtr = OBJ_AT_TOS;
|
| ︙ | ︙ | |||
4791 4792 4793 4794 4795 4796 4797 |
CallContext *contextPtr;
Tcl_Size skip, newDepth;
case INST_TCLOO_SELF:
contextPtr = GetTclOOCallContext(iPtr);
if (!contextPtr) {
TRACE(("=> ERROR: no TclOO call context\n"));
| | | < | 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 |
CallContext *contextPtr;
Tcl_Size skip, newDepth;
case INST_TCLOO_SELF:
contextPtr = GetTclOOCallContext(iPtr);
if (!contextPtr) {
TRACE(("=> ERROR: no TclOO call context\n"));
TclPrintfResult(interp,
"self may only be called from inside a method");
DECACHE_STACK_INFO();
OO_ERROR(interp, CONTEXT_REQUIRED);
CACHE_STACK_INFO();
goto gotError;
}
/*
|
| ︙ | ︙ | |||
6283 6284 6285 6286 6287 6288 6289 |
wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 -
(Tcl_WideUInt)w2*(Tcl_WideUInt)wResult);
goto wideResultOfArithmetic;
}
case INST_RSHIFT:
if (w2 < 0) {
| < | | 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 |
wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 -
(Tcl_WideUInt)w2*(Tcl_WideUInt)wResult);
goto wideResultOfArithmetic;
}
case INST_RSHIFT:
if (w2 < 0) {
TclPrintfResult(interp, "negative shift argument");
#ifdef ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"domain error: argument not in valid range",
(char *)NULL);
CACHE_STACK_INFO();
#endif /* ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR */
|
| ︙ | ︙ | |||
6331 6332 6333 6334 6335 6336 6337 |
wResult = w1 >> ((int) w2);
goto wideResultOfArithmetic;
}
case INST_LSHIFT:
if (w2 < 0) {
| < | | 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 |
wResult = w1 >> ((int) w2);
goto wideResultOfArithmetic;
}
case INST_LSHIFT:
if (w2 < 0) {
TclPrintfResult(interp, "negative shift argument");
#ifdef ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"domain error: argument not in valid range",
(char *)NULL);
CACHE_STACK_INFO();
#endif /* ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR */
|
| ︙ | ︙ | |||
6354 6355 6356 6357 6358 6359 6360 | /* * Technically, we could hold the value (1 << (INT_MAX+1)) * in an mp_int, but since we're using mp_mul_2d() to do * the work, and it takes only an int argument, that's a * good place to draw the line. */ | | | | 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 | /* * Technically, we could hold the value (1 << (INT_MAX+1)) * in an mp_int, but since we're using mp_mul_2d() to do * the work, and it takes only an int argument, that's a * good place to draw the line. */ TclPrintfResult(interp, "integer value too large to represent"); #ifdef ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR DECACHE_STACK_INFO(); Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", "integer value too large to represent", (char *)NULL); CACHE_STACK_INFO(); #endif /* ERROR_CODE_FOR_EARLY_DETECTED_ARITH_ERROR */ goto gotError; |
| ︙ | ︙ | |||
7964 7965 7966 7967 7968 7969 7970 |
/*
* Division by zero in an expression. Control only reaches this point
* by "goto divideByZero".
*/
divideByZero:
| | | < | | 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 |
/*
* Division by zero in an expression. Control only reaches this point
* by "goto divideByZero".
*/
divideByZero:
TclPrintfResult(interp, "divide by zero");
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DIVZERO", "divide by zero", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
outOfMemory:
TclPrintfResult(interp, "cannot allocate");
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL);
CACHE_STACK_INFO();
goto gotError;
/*
* Exponentiation of zero by negative number in an expression. Control
* only reaches this point by "goto exponOfZero".
*/
exponOfZero:
TclPrintfResult(interp, "exponentiation of zero by negative power");
DECACHE_STACK_INFO();
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"exponentiation of zero by negative power", (char *)NULL);
CACHE_STACK_INFO();
/*
* Almost all error paths feed through here rather than assigning to
|
| ︙ | ︙ | |||
8540 8541 8542 8543 8544 8545 8546 |
invalid = mp_isneg(&big2);
mp_clear(&big2);
break;
default:
TCL_UNREACHABLE();
}
if (invalid) {
| < | | 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 |
invalid = mp_isneg(&big2);
mp_clear(&big2);
break;
default:
TCL_UNREACHABLE();
}
if (invalid) {
TclPrintfResult(interp, "negative shift argument");
return GENERAL_ARITHMETIC_ERROR;
}
/*
* Zero shifted any number of bits is still zero.
*/
|
| ︙ | ︙ | |||
8571 8572 8573 8574 8575 8576 8577 | /* * Technically, we could hold the value (1 << (INT_MAX+1)) in * an mp_int, but since we're using mp_mul_2d() to do the * work, and it takes only an int argument, that's a good * place to draw the line. */ | < | | 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 | /* * Technically, we could hold the value (1 << (INT_MAX+1)) in * an mp_int, but since we're using mp_mul_2d() to do the * work, and it takes only an int argument, that's a good * place to draw the line. */ TclPrintfResult(interp, "integer value too large to represent"); return GENERAL_ARITHMETIC_ERROR; } shift = (int)(*((const Tcl_WideInt *)ptr2)); /* * Handle shifts within the native wide range. */ |
| ︙ | ︙ | |||
8815 8816 8817 8818 8819 8820 8821 |
* 268435455, which fits into a signed 32 bit int which is within the
* range of the Tcl_WideInt type. This means any numeric Tcl_Obj value
* not using TCL_NUMBER_INT type must hold a value larger than we
* accept.
*/
if (type2 != TCL_NUMBER_INT) {
| < | | 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 |
* 268435455, which fits into a signed 32 bit int which is within the
* range of the Tcl_WideInt type. This means any numeric Tcl_Obj value
* not using TCL_NUMBER_INT type must hold a value larger than we
* accept.
*/
if (type2 != TCL_NUMBER_INT) {
TclPrintfResult(interp, "exponent too large");
return GENERAL_ARITHMETIC_ERROR;
}
/* From here (up to overflowExpon) w1 and exponent w2 are wide-int's. */
assert(type1 == TCL_NUMBER_INT && type2 == TCL_NUMBER_INT);
if (w1 == 2) {
|
| ︙ | ︙ | |||
8895 8896 8897 8898 8899 8900 8901 |
}
overflowExpon:
if ((TclGetWideIntFromObj(NULL, value2Ptr, &w2) != TCL_OK)
|| !TclHasInternalRep(value2Ptr, &tclIntType)
|| (Tcl_WideUInt)w2 >= (1<<28)) {
| < | | 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 |
}
overflowExpon:
if ((TclGetWideIntFromObj(NULL, value2Ptr, &w2) != TCL_OK)
|| !TclHasInternalRep(value2Ptr, &tclIntType)
|| (Tcl_WideUInt)w2 >= (1<<28)) {
TclPrintfResult(interp, "exponent too large");
return GENERAL_ARITHMETIC_ERROR;
}
Tcl_TakeBignumFromObj(NULL, valuePtr, &big1);
err = mp_init(&bigResult);
if (err == MP_OKAY) {
/* Don't use "mp_expt_n" directly here, it doesn't exist in libtommath 1.2 */
err = TclBN_mp_expt_n(&big1, (int)w2, &bigResult);
|
| ︙ | ︙ |
Changes to generic/tclFileName.c.
| ︙ | ︙ | |||
1166 1167 1168 1169 1170 1171 1172 |
/*
* Do nothing; This is normal operations in Tcl 9.
* Keep accepting as a no-op option to accommodate old scripts.
*/
break;
case GLOB_DIR: /* -dir */
if (i == (objc-1)) {
| < | | 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 |
/*
* Do nothing; This is normal operations in Tcl 9.
* Keep accepting as a no-op option to accommodate old scripts.
*/
break;
case GLOB_DIR: /* -dir */
if (i == (objc-1)) {
TclPrintfResult(interp, "missing argument to \"-directory\"");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
return TCL_ERROR;
}
if (dir != PATH_NONE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
dir == PATH_DIR
? "\"-directory\" may only be used once"
|
| ︙ | ︙ | |||
1194 1195 1196 1197 1198 1199 1200 |
join = 1;
break;
case GLOB_TAILS: /* -tails */
globFlags |= TCL_GLOBMODE_TAILS;
break;
case GLOB_PATH: /* -path */
if (i == (objc-1)) {
| < | < | | | | 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 |
join = 1;
break;
case GLOB_TAILS: /* -tails */
globFlags |= TCL_GLOBMODE_TAILS;
break;
case GLOB_PATH: /* -path */
if (i == (objc-1)) {
TclPrintfResult(interp, "missing argument to \"-path\"");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
return TCL_ERROR;
}
if (dir != PATH_NONE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
dir == PATH_GENERAL
? "\"-path\" may only be used once"
: "\"-path\" cannot be used with \"-dictionary\"",
-1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB",
"BADOPTIONCOMBINATION", (char *)NULL);
return TCL_ERROR;
}
dir = PATH_GENERAL;
pathOrDir = objv[i+1];
i++;
break;
case GLOB_TYPE: /* -types */
if (i == (objc-1)) {
TclPrintfResult(interp, "missing argument to \"-types\"");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", (char *)NULL);
return TCL_ERROR;
}
typePtr = objv[i+1];
if (TclListObjLength(interp, typePtr, &length) != TCL_OK) {
return TCL_ERROR;
}
i++;
break;
case GLOB_LAST: /* -- */
i++;
goto endOfForLoop;
default:
TCL_UNREACHABLE();
}
}
endOfForLoop:
if ((globFlags & TCL_GLOBMODE_TAILS) && (pathOrDir == NULL)) {
TclPrintfResult(interp,
"\"-tails\" must be used with either "
"\"-directory\" or \"-path\"");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB",
"BADOPTIONCOMBINATION", (char *)NULL);
return TCL_ERROR;
}
separators = NULL;
switch (tclPlatform) {
|
| ︙ | ︙ | |||
2031 2032 2033 2034 2035 2036 2037 | /* * Balanced braces. */ closeBrace = p; break; } | < | < | | 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 |
/*
* Balanced braces.
*/
closeBrace = p;
break;
}
TclPrintfResult(interp, "unmatched open-brace in file name");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB", "BALANCE",
(char *)NULL);
return TCL_ERROR;
} else if (*p == '}') {
TclPrintfResult(interp, "unmatched close-brace in file name");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB", "BALANCE",
(char *)NULL);
return TCL_ERROR;
}
}
/*
|
| ︙ | ︙ |
Changes to generic/tclIO.c.
| ︙ | ︙ | |||
1241 1242 1243 1244 1245 1246 1247 |
{
ChannelState *statePtr; /* State of the real channel. */
statePtr = ((Channel *) chan)->state->bottomChanPtr->state;
if (GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (interp != NULL) {
| | | | 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 |
{
ChannelState *statePtr; /* State of the real channel. */
statePtr = ((Channel *) chan)->state->bottomChanPtr->state;
if (GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (interp != NULL) {
TclPrintfResult(interp,
"illegal recursive call to close through close-handler"
" of channel");
}
return TCL_ERROR;
}
if (DetachChannel(interp, chan) != TCL_OK) {
return TCL_OK;
}
|
| ︙ | ︙ | |||
2693 2694 2695 2696 2697 2698 2699 |
{
if (!GotFlag(statePtr, CHANNEL_DEAD)) {
return 0;
}
Tcl_SetErrno(EINVAL);
if (interp) {
| < | | 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 |
{
if (!GotFlag(statePtr, CHANNEL_DEAD)) {
return 0;
}
Tcl_SetErrno(EINVAL);
if (interp) {
TclPrintfResult(interp, "unable to access channel: invalid channel");
}
return 1;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
3481 3482 3483 3484 3485 3486 3487 |
if (statePtr->refCount > 0) {
Tcl_Panic("called Tcl_Close on channel with refCount > 0");
}
if (GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (interp) {
| | | | 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 |
if (statePtr->refCount > 0) {
Tcl_Panic("called Tcl_Close on channel with refCount > 0");
}
if (GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (interp) {
TclPrintfResult(interp,
"illegal recursive call to close through close-handler"
" of channel");
}
return TCL_ERROR;
}
SetFlag(statePtr, CHANNEL_INCLOSE);
/*
* When the channel has an escape sequence driven encoding such as
|
| ︙ | ︙ | |||
8201 8202 8203 8204 8205 8206 8207 |
/*
* If the channel is in the middle of a background copy, fail.
*/
if (statePtr->csPtrR || statePtr->csPtrW) {
if (interp) {
| | | | 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 |
/*
* If the channel is in the middle of a background copy, fail.
*/
if (statePtr->csPtrR || statePtr->csPtrW) {
if (interp) {
TclPrintfResult(interp,
"unable to set channel options: background copy in"
" progress");
}
return TCL_ERROR;
}
/*
* Disallow options on dead channels -- channels that have been closed but
* not yet been deallocated. Such channels can be found if the exit
|
| ︙ | ︙ | |||
8252 8253 8254 8255 8256 8257 8258 |
ResetFlag(statePtr, CHANNEL_UNBUFFERED);
SetFlag(statePtr, CHANNEL_LINEBUFFERED);
} else if ((newValue[0] == 'n') &&
(strncmp(newValue, "none", len) == 0)) {
ResetFlag(statePtr, CHANNEL_LINEBUFFERED);
SetFlag(statePtr, CHANNEL_UNBUFFERED);
} else if (interp) {
| | | | 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 |
ResetFlag(statePtr, CHANNEL_UNBUFFERED);
SetFlag(statePtr, CHANNEL_LINEBUFFERED);
} else if ((newValue[0] == 'n') &&
(strncmp(newValue, "none", len) == 0)) {
ResetFlag(statePtr, CHANNEL_LINEBUFFERED);
SetFlag(statePtr, CHANNEL_UNBUFFERED);
} else if (interp) {
TclPrintfResult(interp,
"bad value for -buffering: must be one of"
" full, line, or none");
return TCL_ERROR;
}
return TCL_OK;
} else if (HaveOpt(7, "-buffersize")) {
Tcl_WideInt newBufferSize;
Tcl_Obj obj;
int code;
|
| ︙ | ︙ | |||
8329 8330 8331 8332 8333 8334 8335 |
#endif
))) {
if (GotFlag(statePtr, TCL_READABLE)) {
statePtr->inEofChar = newValue[0];
}
} else {
if (interp) {
| | | | 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 |
#endif
))) {
if (GotFlag(statePtr, TCL_READABLE)) {
statePtr->inEofChar = newValue[0];
}
} else {
if (interp) {
TclPrintfResult(interp,
"bad value for -eofchar: must be non-NUL ASCII"
" character");
}
Tcl_Free((void *)argv);
return TCL_ERROR;
}
if (argv != NULL) {
Tcl_Free((void *)argv);
}
|
| ︙ | ︙ | |||
8376 8377 8378 8379 8380 8381 8382 |
readMode = GotFlag(statePtr, TCL_READABLE) ? argv[0] : NULL;
writeMode = GotFlag(statePtr, TCL_WRITABLE) ? argv[0] : NULL;
} else if (argc == 2) {
readMode = GotFlag(statePtr, TCL_READABLE) ? argv[0] : NULL;
writeMode = GotFlag(statePtr, TCL_WRITABLE) ? argv[1] : NULL;
} else {
if (interp) {
| | | | 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 |
readMode = GotFlag(statePtr, TCL_READABLE) ? argv[0] : NULL;
writeMode = GotFlag(statePtr, TCL_WRITABLE) ? argv[0] : NULL;
} else if (argc == 2) {
readMode = GotFlag(statePtr, TCL_READABLE) ? argv[0] : NULL;
writeMode = GotFlag(statePtr, TCL_WRITABLE) ? argv[1] : NULL;
} else {
if (interp) {
TclPrintfResult(interp,
"bad value for -translation: must be a one or two"
" element list");
}
Tcl_Free((void *)argv);
return TCL_ERROR;
}
if (readMode) {
TclEolTranslation translation;
|
| ︙ | ︙ | |||
8406 8407 8408 8409 8410 8411 8412 |
translation = TCL_TRANSLATE_CR;
} else if (strcmp(readMode, "crlf") == 0) {
translation = TCL_TRANSLATE_CRLF;
} else if (strcmp(readMode, "platform") == 0) {
translation = TCL_PLATFORM_TRANSLATION;
} else {
if (interp) {
| | | | 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 |
translation = TCL_TRANSLATE_CR;
} else if (strcmp(readMode, "crlf") == 0) {
translation = TCL_TRANSLATE_CRLF;
} else if (strcmp(readMode, "platform") == 0) {
translation = TCL_PLATFORM_TRANSLATION;
} else {
if (interp) {
TclPrintfResult(interp,
"bad value for -translation: must be one of "
"auto, binary, cr, lf, crlf, or platform");
}
Tcl_Free((void *)argv);
return TCL_ERROR;
}
/*
* Reset the EOL flags since we need to look at any buffered data
|
| ︙ | ︙ | |||
8455 8456 8457 8458 8459 8460 8461 |
statePtr->outputTranslation = TCL_TRANSLATE_CR;
} else if (strcmp(writeMode, "crlf") == 0) {
statePtr->outputTranslation = TCL_TRANSLATE_CRLF;
} else if (strcmp(writeMode, "platform") == 0) {
statePtr->outputTranslation = TCL_PLATFORM_TRANSLATION;
} else {
if (interp) {
| | | | 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 |
statePtr->outputTranslation = TCL_TRANSLATE_CR;
} else if (strcmp(writeMode, "crlf") == 0) {
statePtr->outputTranslation = TCL_TRANSLATE_CRLF;
} else if (strcmp(writeMode, "platform") == 0) {
statePtr->outputTranslation = TCL_PLATFORM_TRANSLATION;
} else {
if (interp) {
TclPrintfResult(interp,
"bad value for -translation: must be one of "
"auto, binary, cr, lf, crlf, or platform");
}
Tcl_Free((void *)argv);
return TCL_ERROR;
}
}
Tcl_Free((void *)argv);
return TCL_OK;
|
| ︙ | ︙ |
Changes to generic/tclIOCmd.c.
| ︙ | ︙ | |||
940 941 942 943 944 945 946 |
keepNewline = 1;
break;
case EXEC_IGNORESTDERR:
ignoreStderr = 1;
break;
case EXEC_ENCODING:
if (++skip >= objc) {
| | | 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 |
keepNewline = 1;
break;
case EXEC_IGNORESTDERR:
ignoreStderr = 1;
break;
case EXEC_ENCODING:
if (++skip >= objc) {
TclPrintfResult(interp, "No value given for option -encoding");
return TCL_ERROR;
} else {
Tcl_Encoding encoding;
encodingObj = objv[skip];
/* Verify validity - bug [da5e1bc7bc] */
if (Tcl_GetEncodingFromObj(interp, encodingObj, &encoding)
!= TCL_OK) {
|
| ︙ | ︙ | |||
1552 1553 1554 1555 1556 1557 1558 |
if (Tcl_GetIndexFromObj(interp, objv[a], socketOptions, "option",
TCL_EXACT, &optionIndex) != TCL_OK) {
return TCL_ERROR;
}
switch (optionIndex) {
case SKT_ASYNC:
if (server == 1) {
| | | < | < | | | < | | | | | | | < | | | | 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 |
if (Tcl_GetIndexFromObj(interp, objv[a], socketOptions, "option",
TCL_EXACT, &optionIndex) != TCL_OK) {
return TCL_ERROR;
}
switch (optionIndex) {
case SKT_ASYNC:
if (server == 1) {
TclPrintfResult(interp,
"cannot set -async option for server sockets");
return TCL_ERROR;
}
async = 1;
break;
case SKT_MYADDR:
a++;
if (a >= objc) {
TclPrintfResult(interp, "no argument given for -myaddr option");
return TCL_ERROR;
}
myaddr = TclGetString(objv[a]);
break;
case SKT_MYPORT: {
const char *myPortName;
a++;
if (a >= objc) {
TclPrintfResult(interp, "no argument given for -myport option");
return TCL_ERROR;
}
myPortName = TclGetString(objv[a]);
if (TclSockGetPort(interp, myPortName, "tcp", &myport) != TCL_OK) {
return TCL_ERROR;
}
break;
}
case SKT_SERVER:
if (async == 1) {
TclPrintfResult(interp,
"cannot set -async option for server sockets");
return TCL_ERROR;
}
server = 1;
a++;
if (a >= objc) {
TclPrintfResult(interp, "no argument given for -server option");
return TCL_ERROR;
}
script = objv[a];
break;
case SKT_REUSEADDR:
a++;
if (a >= objc) {
TclPrintfResult(interp,
"no argument given for -reuseaddr option");
return TCL_ERROR;
}
if (Tcl_GetBooleanFromObj(interp, objv[a], &reusea) != TCL_OK) {
return TCL_ERROR;
}
break;
case SKT_REUSEPORT:
a++;
if (a >= objc) {
TclPrintfResult(interp,
"no argument given for -reuseport option");
return TCL_ERROR;
}
if (Tcl_GetBooleanFromObj(interp, objv[a], &reusep) != TCL_OK) {
return TCL_ERROR;
}
break;
case SKT_BACKLOG:
a++;
if (a >= objc) {
TclPrintfResult(interp,
"no argument given for -backlog option");
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[a], &backlog) != TCL_OK) {
return TCL_ERROR;
}
break;
default:
TCL_UNREACHABLE();
}
}
if (server) {
host = myaddr; /* NULL implies INADDR_ANY */
if (myport != 0) {
TclPrintfResult(interp, "option -myport is not valid for servers");
return TCL_ERROR;
}
} else if (a < objc) {
host = TclGetString(objv[a]);
a++;
} else {
Interp *iPtr;
wrongNumArgs:
iPtr = (Interp *) interp;
Tcl_WrongNumArgs(interp, 1, objv,
"?-async? ?-myaddr addr? ?-myport myport? host port");
iPtr->flags |= INTERP_ALTERNATE_WRONG_ARGS;
Tcl_WrongNumArgs(interp, 1, objv,
"-server command ?-backlog count? ?-myaddr addr? "
"?-reuseaddr boolean? ?-reuseport boolean? port");
return TCL_ERROR;
}
if (!server && (reusea != -1 || reusep != -1 || backlog != -1)) {
TclPrintfResult(interp,
"options -backlog, -reuseaddr, and -reuseport are only valid "
"for servers");
return TCL_ERROR;
}
/*
* Set the options to their default value if the user didn't override
* their value.
*/
|
| ︙ | ︙ | |||
1952 1953 1954 1955 1956 1957 1958 |
* User is supplying an explicit length.
*/
if (TclGetWideIntFromObj(interp, objv[2], &length) != TCL_OK) {
return TCL_ERROR;
}
if (length < 0) {
| | | | 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 |
* User is supplying an explicit length.
*/
if (TclGetWideIntFromObj(interp, objv[2], &length) != TCL_OK) {
return TCL_ERROR;
}
if (length < 0) {
TclPrintfResult(interp,
"cannot truncate to negative length of file");
return TCL_ERROR;
}
} else {
/*
* User wants to truncate to the current file position.
*/
|
| ︙ | ︙ |
Changes to generic/tclIOGT.c.
| ︙ | ︙ | |||
266 267 268 269 270 271 272 |
Tcl_DString ds;
if (chan == NULL) {
return TCL_ERROR;
}
if (TCL_OK != TclListObjLength(interp, cmdObjPtr, &objc)) {
| < | | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
Tcl_DString ds;
if (chan == NULL) {
return TCL_ERROR;
}
if (TCL_OK != TclListObjLength(interp, cmdObjPtr, &objc)) {
TclPrintfResult(interp, "-command value is not a list");
return TCL_ERROR;
}
chanPtr = (Channel *) chan;
statePtr = chanPtr->state;
chanPtr = statePtr->topChanPtr;
chan = (Tcl_Channel) chanPtr;
|
| ︙ | ︙ |
Changes to generic/tclIORChan.c.
| ︙ | ︙ | |||
919 920 921 922 923 924 925 |
* "write". Expect at least one list element. Abbreviations are ok.
*/
if (EncodeEventMask(interp, "event", objv[EVENT], &events) != TCL_OK) {
return TCL_ERROR;
}
if (events == 0) {
| < | | 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 |
* "write". Expect at least one list element. Abbreviations are ok.
*/
if (EncodeEventMask(interp, "event", objv[EVENT], &events) != TCL_OK) {
return TCL_ERROR;
}
if (events == 0) {
TclPrintfResult(interp, "bad event list: is empty");
return TCL_ERROR;
}
/*
* Check that the channel is actually interested in the provided events.
*/
|
| ︙ | ︙ |
Changes to generic/tclIOSock.c.
| ︙ | ︙ | |||
91 92 93 94 95 96 97 |
return TCL_OK;
}
}
if (Tcl_GetInt(interp, string, portPtr) != TCL_OK) {
return TCL_ERROR;
}
if (*portPtr > 0xFFFF) {
| < | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
return TCL_OK;
}
}
if (Tcl_GetInt(interp, string, portPtr) != TCL_OK) {
return TCL_ERROR;
}
if (*portPtr > 0xFFFF) {
TclPrintfResult(interp, "couldn't open socket: port number too high");
return TCL_ERROR;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ |
Changes to generic/tclIOUtil.c.
| ︙ | ︙ | |||
1047 1048 1049 1050 1051 1052 1053 |
* generic code because otherwise every filesystem implementation of
* Tcl_FSMatchInDirectory has to do it.
*/
cwd = Tcl_FSGetCwd(NULL);
if (cwd == NULL) {
if (interp != NULL) {
| | | < | 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 |
* generic code because otherwise every filesystem implementation of
* Tcl_FSMatchInDirectory has to do it.
*/
cwd = Tcl_FSGetCwd(NULL);
if (cwd == NULL) {
if (interp != NULL) {
TclPrintfResult(interp,
"glob couldn't determine the current working directory");
}
return TCL_ERROR;
}
fsPtr = Tcl_FSGetFileSystemForPath(cwd);
if (fsPtr != NULL && fsPtr->matchInDirectoryProc != NULL) {
TclNewObj(tmpResultPtr);
|
| ︙ | ︙ | |||
1639 1640 1641 1642 1643 1644 1645 |
}
}
Tcl_Free((void *)modeArgv);
if (!gotRW) {
if (interp != NULL) {
| | | < | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 |
}
}
Tcl_Free((void *)modeArgv);
if (!gotRW) {
if (interp != NULL) {
TclPrintfResult(interp,
"access mode must include either RDONLY, RDWR, or WRONLY");
}
return -1;
}
return mode;
}
/*
|
| ︙ | ︙ | |||
3276 3277 3278 3279 3280 3281 3282 |
/*
* Try to delete the file we probably created and then exit.
*/
Tcl_FSDeleteFile(copyToPtr);
Tcl_DecrRefCount(copyToPtr);
if (interp) {
| < | | 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 |
/*
* Try to delete the file we probably created and then exit.
*/
Tcl_FSDeleteFile(copyToPtr);
Tcl_DecrRefCount(copyToPtr);
if (interp) {
TclPrintfResult(interp, "couldn't load from current filesystem");
}
return TCL_ERROR;
}
if (TclCrossFilesystemCopy(interp, pathPtr, copyToPtr) != TCL_OK) {
Tcl_FSDeleteFile(copyToPtr);
Tcl_DecrRefCount(copyToPtr);
|
| ︙ | ︙ | |||
3577 3578 3579 3580 3581 3582 3583 |
int
Tcl_FSUnloadFile(
Tcl_Interp *interp, /* The relevant interpreter. */
Tcl_LoadHandle handle) /* A handle for the object to unload. */
{
if (handle->unloadFileProcPtr == NULL) {
if (interp != NULL) {
| | | < | 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 |
int
Tcl_FSUnloadFile(
Tcl_Interp *interp, /* The relevant interpreter. */
Tcl_LoadHandle handle) /* A handle for the object to unload. */
{
if (handle->unloadFileProcPtr == NULL) {
if (interp != NULL) {
TclPrintfResult(interp,
"cannot unload: filesystem does not support unloading");
}
return TCL_ERROR;
}
if (handle->unloadFileProcPtr != NULL) {
handle->unloadFileProcPtr(handle);
}
return TCL_OK;
|
| ︙ | ︙ |
Changes to generic/tclIcu.c.
| ︙ | ︙ | |||
263 264 265 266 267 268 269 |
/* Error handlers. */
static int
FunctionNotAvailableError(
Tcl_Interp *interp)
{
if (interp) {
| < | | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
/* Error handlers. */
static int
FunctionNotAvailableError(
Tcl_Interp *interp)
{
if (interp) {
TclPrintfResult(interp, "ICU function not available");
Tcl_SetErrorCode(interp, "TCL", "ICU", "UNSUPPORTED_OP", NULL);
}
return TCL_ERROR;
}
static int
IcuError(
|
| ︙ | ︙ | |||
322 323 324 325 326 327 328 |
}
bytes = (char *)Tcl_GetBytesFromObj(interp, objPtr, &len);
if (bytes == NULL) {
return TCL_ERROR;
}
if (len > INT_MAX) {
| < | | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
}
bytes = (char *)Tcl_GetBytesFromObj(interp, objPtr, &len);
if (bytes == NULL) {
return TCL_ERROR;
}
if (len > INT_MAX) {
TclPrintfResult(interp, "Max length supported by ICU exceeded.");
return TCL_ERROR;
}
UErrorCodex status = U_ZERO_ERRORZ;
UCharsetDetector* csd = ucsdet_open(&status);
if (U_FAILURE(status)) {
return IcuError(interp, "Could not open charset detector", status);
|
| ︙ | ︙ | |||
733 734 735 736 737 738 739 |
}
}
UCharx *utf16 = (UCharx *) Tcl_DStringValue(dsInPtr);
Tcl_Size utf16len = Tcl_DStringLength(dsInPtr) / sizeof(UCharx);
Tcl_Size dstLen, dstCapacity;
if (utf16len > INT_MAX) {
| < | | 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
}
}
UCharx *utf16 = (UCharx *) Tcl_DStringValue(dsInPtr);
Tcl_Size utf16len = Tcl_DStringLength(dsInPtr) / sizeof(UCharx);
Tcl_Size dstLen, dstCapacity;
if (utf16len > INT_MAX) {
TclPrintfResult(interp, "Max length supported by ICU exceeded.");
return TCL_ERROR;
}
dstCapacity = utf16len;
Tcl_DStringInit(dsOutPtr);
Tcl_DStringSetLength(dsOutPtr, dstCapacity);
dstLen = ucnv_fromUChars(ucnvPtr, Tcl_DStringValue(dsOutPtr), (int)dstCapacity,
|
| ︙ | ︙ | |||
797 798 799 800 801 802 803 |
{
if (ucnv_open == NULL || ucnv_close == NULL ||
ucnv_toUChars == NULL || UCNV_TO_U_CALLBACK_STOP == NULL) {
return FunctionNotAvailableError(interp);
}
if (nbytes > INT_MAX) {
| < | | 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
{
if (ucnv_open == NULL || ucnv_close == NULL ||
ucnv_toUChars == NULL || UCNV_TO_U_CALLBACK_STOP == NULL) {
return FunctionNotAvailableError(interp);
}
if (nbytes > INT_MAX) {
TclPrintfResult(interp, "Max length supported by ICU exceeded.");
return TCL_ERROR;
}
UErrorCodex status = U_ZERO_ERRORZ;
UConverter *ucnvPtr = ucnv_open(icuEncName, &status);
if (ucnvPtr == NULL) {
return IcuError(interp, "Could not get encoding converter", status);
|
| ︙ | ︙ | |||
906 907 908 909 910 911 912 |
Tcl_Size utf16len;
UCharx *normPtr;
int32_t normLen;
utf16 = (UCharx *) Tcl_DStringValue(dsInPtr);
utf16len = Tcl_DStringLength(dsInPtr) / sizeof(UCharx);
if (utf16len > INT_MAX) {
| < | | 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 |
Tcl_Size utf16len;
UCharx *normPtr;
int32_t normLen;
utf16 = (UCharx *) Tcl_DStringValue(dsInPtr);
utf16len = Tcl_DStringLength(dsInPtr) / sizeof(UCharx);
if (utf16len > INT_MAX) {
TclPrintfResult(interp, "Max length supported by ICU exceeded.");
return TCL_ERROR;
}
Tcl_DStringInit(dsOutPtr);
Tcl_DStringSetLength(dsOutPtr, utf16len * sizeof(UCharx));
normPtr = (UCharx *) Tcl_DStringValue(dsOutPtr);
normLen = unorm2_normalize(
|
| ︙ | ︙ | |||
990 991 992 993 994 995 996 | " \"-profile\". Must be \"strict\" or \"replace\".", s); return TCL_ERROR; } break; case OPT_FAILINDEX: /* TBD */ | < | | 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
" \"-profile\". Must be \"strict\" or \"replace\".",
s);
return TCL_ERROR;
}
break;
case OPT_FAILINDEX:
/* TBD */
TclPrintfResult(interp, "Option -failindex not implemented.");
return TCL_ERROR;
default:
TCL_UNREACHABLE();
}
}
*strictPtr = strict;
*failindexVarPtr = NULL;
|
| ︙ | ︙ |
Changes to generic/tclIndexObj.c.
| ︙ | ︙ | |||
537 538 539 540 541 542 543 |
}
switch (index) {
case PRFMATCH_EXACT:
flags |= TCL_EXACT;
break;
case PRFMATCH_MESSAGE:
if (i > objc-4) {
| < | < | | | < | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
}
switch (index) {
case PRFMATCH_EXACT:
flags |= TCL_EXACT;
break;
case PRFMATCH_MESSAGE:
if (i > objc-4) {
TclPrintfResult(interp, "missing value for -message");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "NOARG", (char *)NULL);
return TCL_ERROR;
}
i++;
message = TclGetString(objv[i]);
break;
case PRFMATCH_ERROR:
if (i > objc-4) {
TclPrintfResult(interp, "missing value for -error");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "NOARG", (char *)NULL);
return TCL_ERROR;
}
i++;
result = TclListObjLength(interp, objv[i], &errorLength);
if (result != TCL_OK) {
return TCL_ERROR;
}
if ((errorLength % 2) != 0) {
TclPrintfResult(interp,
"error options must have an even number of elements");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DICTIONARY", (char *)NULL);
return TCL_ERROR;
}
errorPtr = objv[i];
break;
}
}
|
| ︙ | ︙ |
Changes to generic/tclInterp.c.
| ︙ | ︙ | |||
881 882 883 884 885 886 887 |
InterpInfo *iiPtr;
for (i = 2; i < objc; i++) {
childInterp = GetInterp(interp, objv[i]);
if (childInterp == NULL) {
return TCL_ERROR;
} else if (childInterp == interp) {
| | | | 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 |
InterpInfo *iiPtr;
for (i = 2; i < objc; i++) {
childInterp = GetInterp(interp, objv[i]);
if (childInterp == NULL) {
return TCL_ERROR;
} else if (childInterp == interp) {
TclPrintfResult(interp,
"cannot delete the current interpreter");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"DELETESELF", (char *)NULL);
return TCL_ERROR;
}
iiPtr = INTERP_INFO(childInterp);
Tcl_DeleteCommandFromToken(iiPtr->child.parentInterp,
iiPtr->child.interpCmd);
|
| ︙ | ︙ | |||
2345 2346 2347 2348 2349 2350 2351 |
Tcl_Obj *const objv[]) /* Argument strings. */
{
if (objc) {
Tcl_Size length;
if (TCL_ERROR == TclListObjLength(NULL, objv[0], &length)
|| (length < 1)) {
| | | | 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 |
Tcl_Obj *const objv[]) /* Argument strings. */
{
if (objc) {
Tcl_Size length;
if (TCL_ERROR == TclListObjLength(NULL, objv[0], &length)
|| (length < 1)) {
TclPrintfResult(interp,
"cmdPrefix must be list of length >= 1");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BGERRORFORMAT", (char *)NULL);
return TCL_ERROR;
}
TclSetBgErrorHandler(childInterp, objv[0]);
}
Tcl_SetObjResult(interp, TclGetBgErrorHandler(childInterp));
|
| ︙ | ︙ | |||
2965 2966 2967 2968 2969 2970 2971 |
Tcl_Interp *childInterp, /* Interp in which command will be exposed. */
Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
const char *name;
if (Tcl_IsSafe(interp)) {
| | | < | 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 |
Tcl_Interp *childInterp, /* Interp in which command will be exposed. */
Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
const char *name;
if (Tcl_IsSafe(interp)) {
TclPrintfResult(interp,
"permission denied: safe interpreter cannot expose commands");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "UNSAFE",
(char *)NULL);
return TCL_ERROR;
}
name = TclGetString(objv[(objc == 1) ? 0 : 1]);
if (Tcl_ExposeCommand(childInterp, TclGetString(objv[0]),
|
| ︙ | ︙ | |||
3011 3012 3013 3014 3015 3016 3017 |
Tcl_Obj *const objv[]) /* Argument strings. */
{
Interp *iPtr;
Tcl_WideInt limit;
if (objc) {
if (Tcl_IsSafe(interp)) {
| | | < | < | | 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 |
Tcl_Obj *const objv[]) /* Argument strings. */
{
Interp *iPtr;
Tcl_WideInt limit;
if (objc) {
if (Tcl_IsSafe(interp)) {
TclPrintfResult(interp, "permission denied: "
"safe interpreters cannot change recursion limit");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "UNSAFE",
(char *)NULL);
return TCL_ERROR;
}
if (TclGetWideIntFromObj(interp, objv[0], &limit) == TCL_ERROR) {
return TCL_ERROR;
}
if (limit <= 0) {
TclPrintfResult(interp, "recursion limit must be > 0");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "BADLIMIT",
(char *)NULL);
return TCL_ERROR;
}
Tcl_SetRecursionLimit(childInterp, limit);
iPtr = (Interp *) childInterp;
if (interp == childInterp && iPtr->numLevels > limit) {
TclPrintfResult(interp, "falling back due to new recursion limit");
Tcl_SetErrorCode(interp, "TCL", "RECURSION", (char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, objv[0]);
return TCL_OK;
} else {
limit = Tcl_SetRecursionLimit(childInterp, 0);
|
| ︙ | ︙ | |||
3071 3072 3073 3074 3075 3076 3077 |
Tcl_Interp *childInterp, /* Interp in which command will be exposed. */
Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
const char *name;
if (Tcl_IsSafe(interp)) {
| | | < | 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 |
Tcl_Interp *childInterp, /* Interp in which command will be exposed. */
Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
const char *name;
if (Tcl_IsSafe(interp)) {
TclPrintfResult(interp,
"permission denied: safe interpreter cannot hide commands");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "UNSAFE",
(char *)NULL);
return TCL_ERROR;
}
name = TclGetString(objv[(objc == 1) ? 0 : 1]);
if (Tcl_HideCommand(childInterp, TclGetString(objv[0]), name) != TCL_OK) {
|
| ︙ | ︙ | |||
3157 3158 3159 3160 3161 3162 3163 |
const char *namespaceName, /* The namespace to use, if any. */
Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int result;
if (Tcl_IsSafe(interp)) {
| | | < | 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 |
const char *namespaceName, /* The namespace to use, if any. */
Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int result;
if (Tcl_IsSafe(interp)) {
TclPrintfResult(interp,
"not allowed to invoke hidden commands from safe interpreter");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "UNSAFE",
(char *)NULL);
return TCL_ERROR;
}
Tcl_Preserve(childInterp);
Tcl_AllowExceptions(childInterp);
|
| ︙ | ︙ | |||
3234 3235 3236 3237 3238 3239 3240 |
static int
ChildMarkTrusted(
Tcl_Interp *interp, /* Interp for error return. */
Tcl_Interp *childInterp) /* The child interpreter which will be marked
* trusted. */
{
if (Tcl_IsSafe(interp)) {
| | | < | 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 |
static int
ChildMarkTrusted(
Tcl_Interp *interp, /* Interp for error return. */
Tcl_Interp *childInterp) /* The child interpreter which will be marked
* trusted. */
{
if (Tcl_IsSafe(interp)) {
TclPrintfResult(interp,
"permission denied: safe interpreter cannot mark trusted");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "UNSAFE",
(char *)NULL);
return TCL_ERROR;
}
((Interp *) childInterp)->flags &= ~SAFE_INTERP;
return TCL_OK;
}
|
| ︙ | ︙ | |||
3489 3490 3491 3492 3493 3494 3495 |
(iPtr->limit.cmdCount < iPtr->cmdCount)) {
iPtr->limit.exceeded |= TCL_LIMIT_COMMANDS;
Tcl_Preserve(interp);
RunLimitHandlers(iPtr->limit.cmdHandlers, interp);
if (iPtr->limit.cmdCount >= iPtr->cmdCount) {
iPtr->limit.exceeded &= ~TCL_LIMIT_COMMANDS;
} else if (iPtr->limit.exceeded & TCL_LIMIT_COMMANDS) {
| < | | 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 |
(iPtr->limit.cmdCount < iPtr->cmdCount)) {
iPtr->limit.exceeded |= TCL_LIMIT_COMMANDS;
Tcl_Preserve(interp);
RunLimitHandlers(iPtr->limit.cmdHandlers, interp);
if (iPtr->limit.cmdCount >= iPtr->cmdCount) {
iPtr->limit.exceeded &= ~TCL_LIMIT_COMMANDS;
} else if (iPtr->limit.exceeded & TCL_LIMIT_COMMANDS) {
TclPrintfResult(interp, "command count limit exceeded");
Tcl_SetErrorCode(interp, "TCL", "LIMIT", "COMMANDS", (char *)NULL);
Tcl_Release(interp);
return TCL_ERROR;
}
Tcl_Release(interp);
}
|
| ︙ | ︙ | |||
3515 3516 3517 3518 3519 3520 3521 |
Tcl_Preserve(interp);
RunLimitHandlers(iPtr->limit.timeHandlers, interp);
if (iPtr->limit.time.sec > now.sec ||
(iPtr->limit.time.sec == now.sec &&
iPtr->limit.time.usec >= now.usec)) {
iPtr->limit.exceeded &= ~TCL_LIMIT_TIME;
} else if (iPtr->limit.exceeded & TCL_LIMIT_TIME) {
| < | | 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 |
Tcl_Preserve(interp);
RunLimitHandlers(iPtr->limit.timeHandlers, interp);
if (iPtr->limit.time.sec > now.sec ||
(iPtr->limit.time.sec == now.sec &&
iPtr->limit.time.usec >= now.usec)) {
iPtr->limit.exceeded &= ~TCL_LIMIT_TIME;
} else if (iPtr->limit.exceeded & TCL_LIMIT_TIME) {
TclPrintfResult(interp, "time limit exceeded");
Tcl_SetErrorCode(interp, "TCL", "LIMIT", "TIME", (char *)NULL);
Tcl_Release(interp);
return TCL_ERROR;
}
Tcl_Release(interp);
}
}
|
| ︙ | ︙ | |||
4519 4520 4521 4522 4523 4524 4525 |
* First, ensure that we are not reading or writing the calling
* interpreter's limits; it may only manipulate its children. Note that
* the low level API enforces this with Tcl_Panic, which we want to
* avoid. [Bug 3398794]
*/
if (interp == childInterp) {
| < | | 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 |
* First, ensure that we are not reading or writing the calling
* interpreter's limits; it may only manipulate its children. Note that
* the low level API enforces this with Tcl_Panic, which we want to
* avoid. [Bug 3398794]
*/
if (interp == childInterp) {
TclPrintfResult(interp, "limits on current interpreter inaccessible");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "SELF",
(char *)NULL);
return TCL_ERROR;
}
if (objc == consumedObjc) {
Tcl_Obj *dictPtr;
|
| ︙ | ︙ | |||
4617 4618 4619 4620 4621 4622 4623 |
break;
case OPT_GRAN:
granObj = objv[i+1];
if (TclGetIntFromObj(interp, objv[i+1], &gran) != TCL_OK) {
return TCL_ERROR;
}
if (gran < 1) {
| < | | | | 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 |
break;
case OPT_GRAN:
granObj = objv[i+1];
if (TclGetIntFromObj(interp, objv[i+1], &gran) != TCL_OK) {
return TCL_ERROR;
}
if (gran < 1) {
TclPrintfResult(interp, "granularity must be at least 1");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADVALUE", (char *)NULL);
return TCL_ERROR;
}
break;
case OPT_VAL:
limitObj = objv[i+1];
(void) TclGetStringFromObj(objv[i+1], &limitLen);
if (limitLen == 0) {
break;
}
if (Tcl_GetSizeIntFromObj(interp, objv[i+1], &limit) != TCL_OK) {
return TCL_ERROR;
}
if (limit < 0) {
TclPrintfResult(interp,
"command limit value must be at least 0");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADVALUE", (char *)NULL);
return TCL_ERROR;
}
break;
default:
TCL_UNREACHABLE();
|
| ︙ | ︙ | |||
4708 4709 4710 4711 4712 4713 4714 |
* First, ensure that we are not reading or writing the calling
* interpreter's limits; it may only manipulate its children. Note that
* the low level API enforces this with Tcl_Panic, which we want to
* avoid. [Bug 3398794]
*/
if (interp == childInterp) {
| | | | 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 |
* First, ensure that we are not reading or writing the calling
* interpreter's limits; it may only manipulate its children. Note that
* the low level API enforces this with Tcl_Panic, which we want to
* avoid. [Bug 3398794]
*/
if (interp == childInterp) {
TclPrintfResult(interp,
"limits on current interpreter inaccessible");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP", "SELF",
(char *)NULL);
return TCL_ERROR;
}
if (objc == consumedObjc) {
Tcl_Obj *dictPtr;
|
| ︙ | ︙ | |||
4825 4826 4827 4828 4829 4830 4831 |
break;
case OPT_GRAN:
granObj = objv[i+1];
if (TclGetIntFromObj(interp, objv[i+1], &gran) != TCL_OK) {
return TCL_ERROR;
}
if (gran < 1) {
| < | < | < | | | | | | 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 |
break;
case OPT_GRAN:
granObj = objv[i+1];
if (TclGetIntFromObj(interp, objv[i+1], &gran) != TCL_OK) {
return TCL_ERROR;
}
if (gran < 1) {
TclPrintfResult(interp, "granularity must be at least 1");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADVALUE", (char *)NULL);
return TCL_ERROR;
}
break;
case OPT_MILLI:
milliObj = objv[i+1];
(void) TclGetStringFromObj(objv[i+1], &milliLen);
if (milliLen == 0) {
break;
}
if (TclGetWideIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
return TCL_ERROR;
}
if (tmp < 0) {
TclPrintfResult(interp, "milliseconds must be non-negative");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADVALUE", (char *)NULL);
return TCL_ERROR;
}
limitMoment.usec = tmp*1000;
break;
case OPT_SEC:
secObj = objv[i+1];
(void) TclGetStringFromObj(objv[i+1], &secLen);
if (secLen == 0) {
break;
}
if (TclGetWideIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
return TCL_ERROR;
}
if (tmp < 0) {
TclPrintfResult(interp, "seconds must be non-negative");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADVALUE", (char *)NULL);
return TCL_ERROR;
}
limitMoment.sec = (long long) tmp;
break;
default:
TCL_UNREACHABLE();
}
}
if (milliObj != NULL || secObj != NULL) {
if (milliObj != NULL) {
/*
* Setting -milliseconds but clearing -seconds, or resetting
* -milliseconds but not resetting -seconds? Bad voodoo!
*/
if (secObj != NULL && secLen == 0 && milliLen > 0) {
TclPrintfResult(interp,
"may only set -milliseconds if -seconds is not "
"also being reset");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADUSAGE", (char *)NULL);
return TCL_ERROR;
}
if (milliLen == 0 && (secObj == NULL || secLen > 0)) {
TclPrintfResult(interp,
"may only reset -milliseconds if -seconds is "
"also being reset");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADUSAGE", (char *)NULL);
return TCL_ERROR;
}
}
if (milliLen > 0 || secLen > 0) {
|
| ︙ | ︙ |
Changes to generic/tclLink.c.
| ︙ | ︙ | |||
239 240 241 242 243 244 245 |
Tcl_Obj *objPtr;
Link *linkPtr;
Namespace *dummy;
const char *name;
int code;
if (size < 1) {
| < | | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
Tcl_Obj *objPtr;
Link *linkPtr;
Namespace *dummy;
const char *name;
int code;
if (size < 1) {
TclPrintfResult(interp, "wrong array size given");
return TCL_ERROR;
}
linkPtr = (Link *)Tcl_Alloc(sizeof(Link));
linkPtr->type = type & ~TCL_LINK_READ_ONLY;
linkPtr->numElems = size;
if (type & TCL_LINK_READ_ONLY) {
|
| ︙ | ︙ | |||
307 308 309 310 311 312 313 |
break;
case TCL_LINK_CHARS:
case TCL_LINK_BINARY:
linkPtr->bytes = size * sizeof(char);
break;
default:
LinkFree(linkPtr);
| < | | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
break;
case TCL_LINK_CHARS:
case TCL_LINK_BINARY:
linkPtr->bytes = size * sizeof(char);
break;
default:
LinkFree(linkPtr);
TclPrintfResult(interp, "bad linked array variable type");
return TCL_ERROR;
}
/*
* Allocate C variable space in case no address is given
*/
|
| ︙ | ︙ |
Changes to generic/tclLoad.c.
| ︙ | ︙ | |||
194 195 196 197 198 199 200 |
if (objc >= 3) {
prefix = TclGetString(objv[2]);
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
| < | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
if (objc >= 3) {
prefix = TclGetString(objv[2]);
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
TclPrintfResult(interp, "must specify either file name or prefix");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD", "NOLIBRARY",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
|
| ︙ | ︙ | |||
488 489 490 491 492 493 494 |
if (code != TCL_OK) {
Interp *iPtr = (Interp *) target;
if (iPtr->legacyResult && *(iPtr->legacyResult) && !iPtr->legacyFreeProc) {
/*
* A call to Tcl_InitStubs() determined the caller extension
* Stubs were introduced in Tcl 8.1, so there's only one possible reason.
*/
| | | 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
if (code != TCL_OK) {
Interp *iPtr = (Interp *) target;
if (iPtr->legacyResult && *(iPtr->legacyResult) && !iPtr->legacyFreeProc) {
/*
* A call to Tcl_InitStubs() determined the caller extension
* Stubs were introduced in Tcl 8.1, so there's only one possible reason.
*/
TclPrintfResult(interp, "this extension is compiled for Tcl 8.x");
iPtr->legacyResult = NULL;
iPtr->legacyFreeProc = (void (*) (void))-1;
}
Tcl_TransferResult(target, code, interp);
goto done;
}
|
| ︙ | ︙ | |||
627 628 629 630 631 632 633 |
if (objc - i >= 2) {
prefix = TclGetString(objv[i+1]);
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
| < | | 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 |
if (objc - i >= 2) {
prefix = TclGetString(objv[i+1]);
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
TclPrintfResult(interp, "must specify either file name or prefix");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NOLIBRARY",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
|
| ︙ | ︙ |
Changes to generic/tclLoadNone.c.
| ︙ | ︙ | |||
42 43 44 45 46 47 48 |
Tcl_FSUnloadFileProc **unloadProcPtr,
/* Filled with address of Tcl_FSUnloadFileProc
* function which should be used for this
* file. */
int flags)
{
if (interp) {
| | | < | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
Tcl_FSUnloadFileProc **unloadProcPtr,
/* Filled with address of Tcl_FSUnloadFileProc
* function which should be used for this
* file. */
int flags)
{
if (interp) {
TclPrintfResult(interp,
"dynamic loading is not currently available on this system");
}
return TCL_ERROR;
}
/*
* These functions are fallbacks if we somehow determine that the platform can
* do loading from memory but the user wishes to disable it. They just report
|
| ︙ | ︙ |
Changes to generic/tclNamesp.c.
| ︙ | ︙ | |||
827 828 829 830 831 832 833 |
/*
* If we've ended up with an empty string now, we're attempting to create
* the global namespace despite the global namespace existing. That's
* naughty!
*/
if (*name == '\0') {
| | | | 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 |
/*
* If we've ended up with an empty string now, we're attempting to create
* the global namespace despite the global namespace existing. That's
* naughty!
*/
if (*name == '\0') {
TclPrintfResult(interp,"can't create namespace \"\": "
"only global namespace can have empty name");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "NAMESPACE",
"CREATEGLOBAL", (char *)NULL);
Tcl_DStringFree(&tmpBuffer);
return NULL;
}
/*
|
| ︙ | ︙ | |||
1710 1711 1712 1713 1714 1715 1716 |
/*
* From the pattern, find the namespace from which we are importing and
* get the simple pattern (no namespace qualifiers or ::'s) at the end.
*/
if (strlen(pattern) == 0) {
| | | 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 |
/*
* From the pattern, find the namespace from which we are importing and
* get the simple pattern (no namespace qualifiers or ::'s) at the end.
*/
if (strlen(pattern) == 0) {
TclPrintfResult(interp, "empty import pattern");
Tcl_SetErrorCode(interp, "TCL", "IMPORT", "EMPTY", (char *)NULL);
return TCL_ERROR;
}
TclGetNamespaceForQualName(interp, pattern, nsPtr, TCL_NAMESPACE_ONLY,
&importNsPtr, &dummyPtr, &dummyPtr, &simplePattern);
if (importNsPtr == NULL) {
|
| ︙ | ︙ |
Changes to generic/tclOO.c.
| ︙ | ︙ | |||
2177 2178 2179 2180 2181 2182 2183 |
/*
* Ensure an error if the object was deleted in the constructor. Don't
* want to lose errors by accident. [Bug 2903011]
*/
if (result != TCL_ERROR && Destructing(oPtr)) {
| < | | 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 |
/*
* Ensure an error if the object was deleted in the constructor. Don't
* want to lose errors by accident. [Bug 2903011]
*/
if (result != TCL_ERROR && Destructing(oPtr)) {
TclPrintfResult(interp, "object deleted in constructor");
OO_ERROR(interp, STILLBORN);
result = TCL_ERROR;
}
if (result != TCL_OK) {
Tcl_DiscardInterpState(state);
/*
|
| ︙ | ︙ | |||
2248 2249 2250 2251 2252 2253 2254 |
int result;
/*
* Sanity check.
*/
if (IsRootClass(oPtr)) {
| < | | 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 |
int result;
/*
* Sanity check.
*/
if (IsRootClass(oPtr)) {
TclPrintfResult(interp, "may not clone the class of classes");
OO_ERROR(interp, CLONING_CLASS);
return NULL;
}
/*
* Build the instance. Note that this does not run any constructors.
*/
|
| ︙ | ︙ | |||
3057 3058 3059 3060 3061 3062 3063 |
continue;
}
if (miPtr->mPtr->declaringClassPtr == startCls) {
break;
}
}
if (contextPtr->index >= contextPtr->callPtr->numChain) {
| < | | 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 |
continue;
}
if (miPtr->mPtr->declaringClassPtr == startCls) {
break;
}
}
if (contextPtr->index >= contextPtr->callPtr->numChain) {
TclPrintfResult(interp, "no valid method implementation");
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD",
TclGetString(methodNamePtr), (char *)NULL);
TclOODeleteContext(contextPtr);
return TCL_ERROR;
}
}
|
| ︙ | ︙ |
Changes to generic/tclOOBasic.c.
| ︙ | ︙ | |||
330 331 332 333 334 335 336 |
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"objectName ?arg ...?");
return TCL_ERROR;
}
objName = Tcl_GetStringFromObj(
objv[Tcl_ObjectContextSkippedArgs(context)], &len);
if (len == 0) {
| < | | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"objectName ?arg ...?");
return TCL_ERROR;
}
objName = Tcl_GetStringFromObj(
objv[Tcl_ObjectContextSkippedArgs(context)], &len);
if (len == 0) {
TclPrintfResult(interp, "object name must not be empty");
OO_ERROR(interp, EMPTY_NAME);
return TCL_ERROR;
}
/*
* Make the object and return its name.
*/
|
| ︙ | ︙ | |||
395 396 397 398 399 400 401 |
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"objectName namespaceName ?arg ...?");
return TCL_ERROR;
}
objName = Tcl_GetStringFromObj(
objv[Tcl_ObjectContextSkippedArgs(context)], &len);
if (len == 0) {
| < | < | | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
"objectName namespaceName ?arg ...?");
return TCL_ERROR;
}
objName = Tcl_GetStringFromObj(
objv[Tcl_ObjectContextSkippedArgs(context)], &len);
if (len == 0) {
TclPrintfResult(interp, "object name must not be empty");
OO_ERROR(interp, EMPTY_NAME);
return TCL_ERROR;
}
nsName = Tcl_GetStringFromObj(
objv[Tcl_ObjectContextSkippedArgs(context) + 1], &len);
if (len == 0) {
TclPrintfResult(interp, "namespace name must not be empty");
OO_ERROR(interp, EMPTY_NAME);
return TCL_ERROR;
}
/*
* Make the object and return its name.
*/
|
| ︙ | ︙ | |||
1496 1497 1498 1499 1500 1501 1502 |
Tcl_SetObjResult(interp,
TclNewNamespaceObj(contextPtr->oPtr->namespacePtr));
return TCL_OK;
case SELF_CLASS: {
Class *clsPtr = CurrentlyInvoked(contextPtr).mPtr->declaringClassPtr;
if (clsPtr == NULL) {
| < | < | | 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 |
Tcl_SetObjResult(interp,
TclNewNamespaceObj(contextPtr->oPtr->namespacePtr));
return TCL_OK;
case SELF_CLASS: {
Class *clsPtr = CurrentlyInvoked(contextPtr).mPtr->declaringClassPtr;
if (clsPtr == NULL) {
TclPrintfResult(interp, "method not defined by a class");
OO_ERROR(interp, UNMATCHED_CONTEXT);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, TclOOObjectName(interp, clsPtr->thisPtr));
return TCL_OK;
}
case SELF_METHOD:
if (contextPtr->callPtr->flags & CONSTRUCTOR) {
Tcl_SetObjResult(interp, contextPtr->oPtr->fPtr->constructorName);
} else if (contextPtr->callPtr->flags & DESTRUCTOR) {
Tcl_SetObjResult(interp, contextPtr->oPtr->fPtr->destructorName);
} else {
Tcl_SetObjResult(interp,
CurrentlyInvoked(contextPtr).mPtr->namePtr);
}
return TCL_OK;
case SELF_FILTER:
if (!CurrentlyInvoked(contextPtr).isFilter) {
TclPrintfResult(interp, "not inside a filtering context");
OO_ERROR(interp, UNMATCHED_CONTEXT);
return TCL_ERROR;
} else {
MInvoke *miPtr = &CurrentlyInvoked(contextPtr);
Object *oPtr;
const char *type;
|
| ︙ | ︙ | |||
1543 1544 1545 1546 1547 1548 1549 |
result[2] = miPtr->mPtr->namePtr;
Tcl_SetObjResult(interp, Tcl_NewListObj(3, result));
return TCL_OK;
}
case SELF_CALLER:
if ((framePtr->callerVarPtr == NULL) ||
!(framePtr->callerVarPtr->isProcCallFrame & FRAME_IS_METHOD)){
| < | | 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 |
result[2] = miPtr->mPtr->namePtr;
Tcl_SetObjResult(interp, Tcl_NewListObj(3, result));
return TCL_OK;
}
case SELF_CALLER:
if ((framePtr->callerVarPtr == NULL) ||
!(framePtr->callerVarPtr->isProcCallFrame & FRAME_IS_METHOD)){
TclPrintfResult(interp, "caller is not an object");
OO_ERROR(interp, CONTEXT_REQUIRED);
return TCL_ERROR;
} else {
CallContext *callerPtr = (CallContext *)
framePtr->callerVarPtr->clientData;
Method *mPtr = callerPtr->callPtr->chain[callerPtr->index].mPtr;
Object *declarerPtr;
|
| ︙ | ︙ | |||
1600 1601 1602 1603 1604 1605 1606 |
result[1] = mPtr->namePtr;
}
Tcl_SetObjResult(interp, Tcl_NewListObj(2, result));
}
return TCL_OK;
case SELF_TARGET:
if (!CurrentlyInvoked(contextPtr).isFilter) {
| < | | 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 |
result[1] = mPtr->namePtr;
}
Tcl_SetObjResult(interp, Tcl_NewListObj(2, result));
}
return TCL_OK;
case SELF_TARGET:
if (!CurrentlyInvoked(contextPtr).isFilter) {
TclPrintfResult(interp, "not inside a filtering context");
OO_ERROR(interp, UNMATCHED_CONTEXT);
return TCL_ERROR;
} else {
Method *mPtr;
Object *declarerPtr;
Tcl_Size i;
|
| ︙ | ︙ |
Changes to generic/tclOODefineCmds.c.
| ︙ | ︙ | |||
765 766 767 768 769 770 771 |
goto noSuchMethod;
}
if (toPtr) {
newHPtr = Tcl_CreateHashEntry(oPtr->methodsPtr, toPtr,
&isNew);
if (hPtr == newHPtr) {
renameToSelf:
| < | | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 |
goto noSuchMethod;
}
if (toPtr) {
newHPtr = Tcl_CreateHashEntry(oPtr->methodsPtr, toPtr,
&isNew);
if (hPtr == newHPtr) {
renameToSelf:
TclPrintfResult(interp, "cannot rename method to itself");
OO_ERROR(interp, RENAME_TO_SELF);
return TCL_ERROR;
} else if (!isNew) {
renameToExisting:
TclPrintfResult(interp, "method called %s already exists",
TclGetString(toPtr));
OO_ERROR(interp, RENAME_OVER);
|
| ︙ | ︙ | |||
839 840 841 842 843 844 845 |
{
Namespace *nsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
FOREACH_HASH_DECLS;
Tcl_Size soughtLen;
const char *soughtStr, *nameStr, *matchedStr = NULL;
if (objc < 2) {
| < | | 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 |
{
Namespace *nsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
FOREACH_HASH_DECLS;
Tcl_Size soughtLen;
const char *soughtStr, *nameStr, *matchedStr = NULL;
if (objc < 2) {
TclPrintfResult(interp, "bad call of unknown handler");
OO_ERROR(interp, BAD_UNKNOWN);
return TCL_ERROR;
}
if (TclOOGetDefineCmdContext(interp) == NULL) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
971 972 973 974 975 976 977 |
Object *oPtr,
int objc,
Tcl_Obj *const objv[])
{
CallFrame *framePtr, **framePtrPtr = &framePtr;
if (namespacePtr == NULL) {
| < | | 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 |
Object *oPtr,
int objc,
Tcl_Obj *const objv[])
{
CallFrame *framePtr, **framePtrPtr = &framePtr;
if (namespacePtr == NULL) {
TclPrintfResult(interp, "no definition namespace available");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
/*
* framePtrPtr is needed to satisfy GCC 3.3's strict aliasing rules.
*/
|
| ︙ | ︙ | |||
1011 1012 1013 1014 1015 1016 1017 |
{
Interp *iPtr = (Interp *) interp;
Tcl_Object object;
if ((iPtr->varFramePtr == NULL)
|| (iPtr->varFramePtr->isProcCallFrame != FRAME_IS_OO_DEFINE
&& iPtr->varFramePtr->isProcCallFrame != PRIVATE_FRAME)) {
| | | < | | < | | 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 |
{
Interp *iPtr = (Interp *) interp;
Tcl_Object object;
if ((iPtr->varFramePtr == NULL)
|| (iPtr->varFramePtr->isProcCallFrame != FRAME_IS_OO_DEFINE
&& iPtr->varFramePtr->isProcCallFrame != PRIVATE_FRAME)) {
TclPrintfResult(interp,
"this command may only be called from within the context of"
" an ::oo::define or ::oo::objdefine command");
OO_ERROR(interp, MONKEY_BUSINESS);
return NULL;
}
object = (Tcl_Object) iPtr->varFramePtr->clientData;
if (Tcl_ObjectDeleted(object)) {
TclPrintfResult(interp,
"this command cannot be called when the object has been"
" deleted");
OO_ERROR(interp, MONKEY_BUSINESS);
return NULL;
}
return object;
}
Class *
TclOOGetClassDefineCmdContext(
Tcl_Interp *interp)
{
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return NULL;
}
if (!oPtr->classPtr) {
TclPrintfResult(interp, "attempt to misuse API");
OO_ERROR(interp, MONKEY_BUSINESS);
return NULL;
}
return oPtr->classPtr;
}
/*
|
| ︙ | ︙ | |||
1082 1083 1084 1085 1086 1087 1088 |
}
oPtr = (Object *) Tcl_GetObjectFromObj(interp, className);
iPtr->varFramePtr = savedFramePtr;
if (oPtr == NULL) {
return NULL;
}
if (oPtr->classPtr == NULL) {
| | | 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
}
oPtr = (Object *) Tcl_GetObjectFromObj(interp, className);
iPtr->varFramePtr = savedFramePtr;
if (oPtr == NULL) {
return NULL;
}
if (oPtr->classPtr == NULL) {
TclPrintfResult(interp, "%s", errMsg);
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CLASS",
TclGetString(className), (char *)NULL);
return NULL;
}
return oPtr->classPtr;
}
|
| ︙ | ︙ | |||
1735 1736 1737 1738 1739 1740 1741 |
*/
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (oPtr->flags & ROOT_OBJECT) {
| | | < | | < | | < | 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 |
*/
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (oPtr->flags & ROOT_OBJECT) {
TclPrintfResult(interp,
"may not modify the class of the root object class");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
if (oPtr->flags & ROOT_CLASS) {
TclPrintfResult(interp,
"may not modify the class of the class of classes");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
/*
* Parse the argument to get the class to set the object's class to.
*/
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "className");
return TCL_ERROR;
}
clsPtr = GetClassInOuterContext(interp, objv[1],
"the class of an object must be a class");
if (clsPtr == NULL) {
return TCL_ERROR;
}
if (oPtr == clsPtr->thisPtr) {
TclPrintfResult(interp,
"may not change classes into an instance of themselves");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
/*
* Set the object's class.
*/
|
| ︙ | ︙ | |||
1905 1906 1907 1908 1909 1910 1911 |
Class *clsPtr = TclOOGetClassDefineCmdContext(interp);
Tcl_Namespace *nsPtr;
Tcl_Obj *nsNamePtr, **storagePtr;
if (clsPtr == NULL) {
return TCL_ERROR;
} else if (clsPtr->thisPtr->flags & (ROOT_OBJECT | ROOT_CLASS)) {
| | | < | 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 |
Class *clsPtr = TclOOGetClassDefineCmdContext(interp);
Tcl_Namespace *nsPtr;
Tcl_Obj *nsNamePtr, **storagePtr;
if (clsPtr == NULL) {
return TCL_ERROR;
} else if (clsPtr->thisPtr->flags & (ROOT_OBJECT | ROOT_CLASS)) {
TclPrintfResult(interp,
"may not modify the definition namespace of the root classes");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
/*
* Parse the arguments and work out what the user wants to do.
*/
|
| ︙ | ︙ | |||
1983 1984 1985 1986 1987 1988 1989 |
}
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceDeleteMethod && !oPtr->classPtr) {
| < | | 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 |
}
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceDeleteMethod && !oPtr->classPtr) {
TclPrintfResult(interp, "attempt to misuse API");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
for (i = 1; i < objc; i++) {
/*
* Delete the method structure from the appropriate hash table.
|
| ︙ | ︙ | |||
2101 2102 2103 2104 2105 2106 2107 |
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
Class *clsPtr = oPtr->classPtr;
if (!isInstanceExport && !clsPtr) {
| < | | 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 |
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
Class *clsPtr = oPtr->classPtr;
if (!isInstanceExport && !clsPtr) {
TclPrintfResult(interp, "attempt to misuse API");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
for (i = 1; i < objc; i++) {
/*
* Exporting is done by adding the PUBLIC_METHOD flag to the method
|
| ︙ | ︙ | |||
2172 2173 2174 2175 2176 2177 2178 |
}
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceForward && !oPtr->classPtr) {
| < | | 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 |
}
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceForward && !oPtr->classPtr) {
TclPrintfResult(interp, "attempt to misuse API");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
isPublic = Tcl_StringMatch(TclGetString(objv[1]), PUBLIC_PATTERN)
? PUBLIC_METHOD : 0;
if (IsPrivateDefine(interp)) {
isPublic = TRUE_PRIVATE_METHOD;
|
| ︙ | ︙ | |||
2297 2298 2299 2300 2301 2302 2303 |
}
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceMethod && !oPtr->classPtr) {
| < | | 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 |
}
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceMethod && !oPtr->classPtr) {
TclPrintfResult(interp, "attempt to misuse API");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
if (objc == 5) {
if (Tcl_GetIndexFromObj(interp, objv[2], exportModes, "export flag",
0, &exportMode) != TCL_OK) {
return TCL_ERROR;
|
| ︙ | ︙ | |||
2444 2445 2446 2447 2448 2449 2450 |
}
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceRenameMethod && !oPtr->classPtr) {
| < | | 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 |
}
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!isInstanceRenameMethod && !oPtr->classPtr) {
TclPrintfResult(interp, "attempt to misuse API");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
/*
* Delete the method entry from the appropriate hash table, and transfer
* the thing it points to to its new entry. To do this, we first need to
|
| ︙ | ︙ | |||
2504 2505 2506 2507 2508 2509 2510 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
clsPtr = oPtr->classPtr;
if (!isInstanceUnexport && !clsPtr) {
| < | | 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 |
oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
clsPtr = oPtr->classPtr;
if (!isInstanceUnexport && !clsPtr) {
TclPrintfResult(interp, "attempt to misuse API");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
for (i = 1; i < objc; i++) {
if (isInstanceUnexport) {
changed |= UnexportInstanceMethod(oPtr, objv[i]);
|
| ︙ | ︙ | |||
3118 3119 3120 3121 3122 3123 3124 |
Slot_Unimplemented(
TCL_UNUSED(void *),
Tcl_Interp *interp,
TCL_UNUSED(Tcl_ObjectContext),
TCL_UNUSED(int),
TCL_UNUSED(Tcl_Obj *const *))
{
| | | 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 |
Slot_Unimplemented(
TCL_UNUSED(void *),
Tcl_Interp *interp,
TCL_UNUSED(Tcl_ObjectContext),
TCL_UNUSED(int),
TCL_UNUSED(Tcl_Obj *const *))
{
TclPrintfResult(interp, "unimplemented");
OO_ERROR(interp, ABSTRACT_SLOT);
return TCL_ERROR;
}
/*
* ----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
3351 3352 3353 3354 3355 3356 3357 |
"may only mix in classes");
if (mixins[i] == NULL) {
i--;
goto freeAndError;
}
(void) Tcl_CreateHashEntry(&uniqueCheck, (void *) mixins[i], &isNew);
if (!isNew) {
| < | < < | | 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 |
"may only mix in classes");
if (mixins[i] == NULL) {
i--;
goto freeAndError;
}
(void) Tcl_CreateHashEntry(&uniqueCheck, (void *) mixins[i], &isNew);
if (!isNew) {
TclPrintfResult(interp, "class should only be a direct mixin once");
OO_ERROR(interp, REPETITIOUS);
goto freeAndError;
}
if (TclOOIsReachable(clsPtr, mixins[i])) {
TclPrintfResult(interp, "may not mix a class into itself");
OO_ERROR(interp, SELF_MIXIN);
goto freeAndError;
}
}
TclOOClassSetMixins(interp, clsPtr, mixinc, mixins);
Tcl_DeleteHashTable(&uniqueCheck);
|
| ︙ | ︙ | |||
3441 3442 3443 3444 3445 3446 3447 |
"superclassList");
return TCL_ERROR;
}
objv += Tcl_ObjectContextSkippedArgs(context);
Foundation *fPtr = clsPtr->thisPtr->fPtr;
if (clsPtr == fPtr->objectCls) {
| | | < | 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 |
"superclassList");
return TCL_ERROR;
}
objv += Tcl_ObjectContextSkippedArgs(context);
Foundation *fPtr = clsPtr->thisPtr->fPtr;
if (clsPtr == fPtr->objectCls) {
TclPrintfResult(interp,
"may not modify the superclass of the root object");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
} else if (TclListObjGetElements(interp, objv[0], &superc,
&superv) != TCL_OK) {
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
3482 3483 3484 3485 3486 3487 3488 |
superclasses[i] = GetClassInOuterContext(interp, superv[i],
"only a class can be a superclass");
if (superclasses[i] == NULL) {
goto failedAfterAlloc;
}
for (j = 0; j < i; j++) {
if (superclasses[j] == superclasses[i]) {
| | | < | | < | 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 |
superclasses[i] = GetClassInOuterContext(interp, superv[i],
"only a class can be a superclass");
if (superclasses[i] == NULL) {
goto failedAfterAlloc;
}
for (j = 0; j < i; j++) {
if (superclasses[j] == superclasses[i]) {
TclPrintfResult(interp,
"class should only be a direct superclass once");
OO_ERROR(interp, REPETITIOUS);
goto failedAfterAlloc;
}
}
if (TclOOIsReachable(clsPtr, superclasses[i])) {
TclPrintfResult(interp,
"attempt to form circular dependency graph");
OO_ERROR(interp, CIRCULARITY);
failedAfterAlloc:
for (; i-- > 0 ;) {
TclOODecrRefCount(superclasses[i]->thisPtr);
}
Tcl_Free(superclasses);
return TCL_ERROR;
|
| ︙ | ︙ | |||
3778 3779 3780 3781 3782 3783 3784 |
mixins[i] = GetClassInOuterContext(interp, mixinv[i],
"may only mix in classes");
if (mixins[i] == NULL) {
goto freeAndError;
}
(void) Tcl_CreateHashEntry(&uniqueCheck, (void *) mixins[i], &isNew);
if (!isNew) {
| | | < | 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 |
mixins[i] = GetClassInOuterContext(interp, mixinv[i],
"may only mix in classes");
if (mixins[i] == NULL) {
goto freeAndError;
}
(void) Tcl_CreateHashEntry(&uniqueCheck, (void *) mixins[i], &isNew);
if (!isNew) {
TclPrintfResult(interp,
"class should only be a direct mixin once");
OO_ERROR(interp, REPETITIOUS);
goto freeAndError;
}
}
TclOOObjectSetMixins(oPtr, mixinc, mixins);
TclStackFree(interp, mixins);
|
| ︙ | ︙ |
Changes to generic/tclOOInfo.c.
| ︙ | ︙ | |||
1008 1009 1010 1011 1012 1013 1014 |
return TCL_ERROR;
}
if (clsPtr->constructorPtr == NULL) {
return TCL_OK;
}
procPtr = TclOOGetProcFromMethod(clsPtr->constructorPtr);
if (procPtr == NULL) {
| | | < | 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 |
return TCL_ERROR;
}
if (clsPtr->constructorPtr == NULL) {
return TCL_OK;
}
procPtr = TclOOGetProcFromMethod(clsPtr->constructorPtr);
if (procPtr == NULL) {
TclPrintfResult(interp,
"definition not available for this kind of method");
OO_ERROR(interp, METHOD_TYPE);
return TCL_ERROR;
}
resultObjs[0] = DescribeMethodArgs(procPtr);
resultObjs[1] = TclOOGetMethodBody(clsPtr->constructorPtr);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, resultObjs));
|
| ︙ | ︙ | |||
1158 1159 1160 1161 1162 1163 1164 |
}
if (clsPtr->destructorPtr == NULL) {
return TCL_OK;
}
procPtr = TclOOGetProcFromMethod(clsPtr->destructorPtr);
if (procPtr == NULL) {
| | | < | 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 |
}
if (clsPtr->destructorPtr == NULL) {
return TCL_OK;
}
procPtr = TclOOGetProcFromMethod(clsPtr->destructorPtr);
if (procPtr == NULL) {
TclPrintfResult(interp,
"definition not available for this kind of method");
OO_ERROR(interp, METHOD_TYPE);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, TclOOGetMethodBody(clsPtr->destructorPtr));
return TCL_OK;
}
|
| ︙ | ︙ | |||
1721 1722 1723 1724 1725 1726 1727 |
/*
* Get the call context and render its call chain.
*/
contextPtr = TclOOGetCallContext(oPtr, objv[2], PUBLIC_METHOD, NULL, NULL,
NULL);
if (contextPtr == NULL) {
| < | | 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 |
/*
* Get the call context and render its call chain.
*/
contextPtr = TclOOGetCallContext(oPtr, objv[2], PUBLIC_METHOD, NULL, NULL,
NULL);
if (contextPtr == NULL) {
TclPrintfResult(interp, "cannot construct any call chain");
OO_ERROR(interp, BAD_CALL_CHAIN);
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
TclOORenderCallChain(interp, contextPtr->callPtr));
TclOODeleteContext(contextPtr);
return TCL_OK;
|
| ︙ | ︙ | |||
1767 1768 1769 1770 1771 1772 1773 |
/*
* Get an render the stereotypical call chain.
*/
callPtr = TclOOGetStereotypeCallChain(clsPtr, objv[2], PUBLIC_METHOD);
if (callPtr == NULL) {
| < | | 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 |
/*
* Get an render the stereotypical call chain.
*/
callPtr = TclOOGetStereotypeCallChain(clsPtr, objv[2], PUBLIC_METHOD);
if (callPtr == NULL) {
TclPrintfResult(interp, "cannot construct any call chain");
OO_ERROR(interp, BAD_CALL_CHAIN);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, TclOORenderCallChain(interp, callPtr));
TclOODeleteChain(callPtr);
return TCL_OK;
}
|
| ︙ | ︙ |
Changes to generic/tclOOMethod.c.
| ︙ | ︙ | |||
1498 1499 1500 1501 1502 1503 1504 |
Tcl_Size prefixLen;
ForwardMethod *fmPtr;
if (TclListObjLength(interp, prefixObj, &prefixLen) != TCL_OK) {
return NULL;
}
if (prefixLen < 1) {
| < | | 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 |
Tcl_Size prefixLen;
ForwardMethod *fmPtr;
if (TclListObjLength(interp, prefixObj, &prefixLen) != TCL_OK) {
return NULL;
}
if (prefixLen < 1) {
TclPrintfResult(interp, "method forward prefix must be non-empty");
OO_ERROR(interp, BAD_FORWARD);
return NULL;
}
fmPtr = (ForwardMethod *) Tcl_Alloc(sizeof(ForwardMethod));
fmPtr->prefixObj = prefixObj;
Tcl_IncrRefCount(prefixObj);
|
| ︙ | ︙ | |||
1537 1538 1539 1540 1541 1542 1543 |
Tcl_Size prefixLen;
ForwardMethod *fmPtr;
if (TclListObjLength(interp, prefixObj, &prefixLen) != TCL_OK) {
return NULL;
}
if (prefixLen < 1) {
| < | | 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 |
Tcl_Size prefixLen;
ForwardMethod *fmPtr;
if (TclListObjLength(interp, prefixObj, &prefixLen) != TCL_OK) {
return NULL;
}
if (prefixLen < 1) {
TclPrintfResult(interp, "method forward prefix must be non-empty");
OO_ERROR(interp, BAD_FORWARD);
return NULL;
}
fmPtr = (ForwardMethod *) Tcl_Alloc(sizeof(ForwardMethod));
fmPtr->prefixObj = prefixObj;
Tcl_IncrRefCount(prefixObj);
|
| ︙ | ︙ |
Changes to generic/tclOOProp.c.
| ︙ | ︙ | |||
1045 1046 1047 1048 1049 1050 1051 |
};
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!useInstance && !oPtr->classPtr) {
| < | | 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 |
};
Object *oPtr = (Object *) TclOOGetDefineCmdContext(interp);
if (oPtr == NULL) {
return TCL_ERROR;
}
if (!useInstance && !oPtr->classPtr) {
TclPrintfResult(interp, "attempt to misuse API");
OO_ERROR(interp, MONKEY_BUSINESS);
return TCL_ERROR;
}
for (i = 1; i < objc; i++) {
Tcl_Obj *propObj = objv[i], *nextObj, *argObj, *hyphenated;
Tcl_Obj *getterScript = NULL, *setterScript = NULL;
|
| ︙ | ︙ |
Changes to generic/tclObj.c.
| ︙ | ︙ | |||
2389 2390 2391 2392 2393 2394 2395 |
Tcl_Obj *objPtr, /* The object from which to get a double. */
double *dblPtr) /* Place to store resulting double. */
{
do {
if (TclHasInternalRep(objPtr, &tclDoubleType)) {
if (isnan(objPtr->internalRep.doubleValue)) {
if (interp != NULL) {
| | | | 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 |
Tcl_Obj *objPtr, /* The object from which to get a double. */
double *dblPtr) /* Place to store resulting double. */
{
do {
if (TclHasInternalRep(objPtr, &tclDoubleType)) {
if (isnan(objPtr->internalRep.doubleValue)) {
if (interp != NULL) {
TclPrintfResult(interp,
"floating point value is Not a Number");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DOUBLE", "NAN",
(char *)NULL);
}
return TCL_ERROR;
}
*dblPtr = (double) objPtr->internalRep.doubleValue;
return TCL_OK;
|
| ︙ | ︙ | |||
2520 2521 2522 2523 2524 2525 2526 |
long l;
if (TclGetLongFromObj(interp, objPtr, &l) != TCL_OK) {
return TCL_ERROR;
}
if ((ULONG_MAX > UINT_MAX) && ((l > UINT_MAX) || (l < INT_MIN))) {
if (interp != NULL) {
| < | | | 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 |
long l;
if (TclGetLongFromObj(interp, objPtr, &l) != TCL_OK) {
return TCL_ERROR;
}
if ((ULONG_MAX > UINT_MAX) && ((l > UINT_MAX) || (l < INT_MIN))) {
if (interp != NULL) {
static const char *s = "integer value too large to represent";
TclPrintfResult(interp, "%s", s);
Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, (char *)NULL);
}
return TCL_ERROR;
}
*intPtr = (int) l;
return TCL_OK;
#endif
|
| ︙ | ︙ |
Changes to generic/tclParse.c.
| ︙ | ︙ | |||
222 223 224 225 226 227 228 |
if (numBytes < 0 && start) {
numBytes = strlen(start);
}
TclParseInit(interp, start, numBytes, parsePtr);
if ((start == NULL) && (numBytes != 0)) {
if (interp != NULL) {
| < | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
if (numBytes < 0 && start) {
numBytes = strlen(start);
}
TclParseInit(interp, start, numBytes, parsePtr);
if ((start == NULL) && (numBytes != 0)) {
if (interp != NULL) {
TclPrintfResult(interp, "can't parse a NULL pointer");
}
return TCL_ERROR;
}
parsePtr->commentStart = NULL;
parsePtr->commentSize = 0;
parsePtr->commandStart = NULL;
parsePtr->commandSize = 0;
|
| ︙ | ︙ | |||
276 277 278 279 280 281 282 |
}
/* Are we missing white space after previous word? */
if (scanned == 0) {
if (src[-1] == '"') {
if (interp != NULL) {
| | | | | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
}
/* Are we missing white space after previous word? */
if (scanned == 0) {
if (src[-1] == '"') {
if (interp != NULL) {
TclPrintfResult(interp,
"extra characters after close-quote");
}
parsePtr->errorType = TCL_PARSE_QUOTE_EXTRA;
} else {
if (interp != NULL) {
TclPrintfResult(interp,
"extra characters after close-brace");
}
parsePtr->errorType = TCL_PARSE_BRACE_EXTRA;
}
parsePtr->term = src;
error:
Tcl_FreeParse(parsePtr);
parsePtr->commandSize = parsePtr->end - parsePtr->commandStart;
|
| ︙ | ︙ | |||
1156 1157 1158 1159 1160 1161 1162 |
if ((nestedPtr->term < parsePtr->end)
&& (*(nestedPtr->term) == ']')
&& !(nestedPtr->incomplete)) {
break;
}
if (numBytes == 0) {
if (parsePtr->interp != NULL) {
| | | | 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 |
if ((nestedPtr->term < parsePtr->end)
&& (*(nestedPtr->term) == ']')
&& !(nestedPtr->incomplete)) {
break;
}
if (numBytes == 0) {
if (parsePtr->interp != NULL) {
TclPrintfResult(parsePtr->interp,
"missing close-bracket");
}
parsePtr->errorType = TCL_PARSE_MISSING_BRACKET;
parsePtr->term = tokenPtr->start;
parsePtr->incomplete = 1;
TclStackFree(parsePtr->interp, nestedPtr);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1408 1409 1410 1411 1412 1413 1414 |
}
numBytes--;
src++;
ch= *src;
}
if (numBytes == 0) {
if (parsePtr->interp != NULL) {
| | | | 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 |
}
numBytes--;
src++;
ch= *src;
}
if (numBytes == 0) {
if (parsePtr->interp != NULL) {
TclPrintfResult(parsePtr->interp,
"missing close-brace for variable name");
}
parsePtr->errorType = TCL_PARSE_MISSING_VAR_BRACE;
parsePtr->term = tokenPtr->start-1;
parsePtr->incomplete = 1;
goto error;
}
tokenPtr->size = src - tokenPtr->start;
|
| ︙ | ︙ | |||
1466 1467 1468 1469 1470 1471 1472 |
if (TCL_OK != ParseTokens(src+1, numBytes-1, TYPE_BAD_ARRAY_INDEX,
TCL_SUBST_ALL, parsePtr)) {
goto error;
}
if (parsePtr->term == src+numBytes){
if (parsePtr->interp != NULL) {
| | < | | | 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 |
if (TCL_OK != ParseTokens(src+1, numBytes-1, TYPE_BAD_ARRAY_INDEX,
TCL_SUBST_ALL, parsePtr)) {
goto error;
}
if (parsePtr->term == src+numBytes){
if (parsePtr->interp != NULL) {
TclPrintfResult(parsePtr->interp, "missing )");
}
parsePtr->errorType = TCL_PARSE_MISSING_PAREN;
parsePtr->term = src;
parsePtr->incomplete = 1;
goto error;
} else if ((*parsePtr->term != ')')){
if (parsePtr->interp != NULL) {
TclPrintfResult(parsePtr->interp,
"invalid character in array index");
}
parsePtr->errorType = TCL_PARSE_SYNTAX;
parsePtr->term = src;
goto error;
}
src = parsePtr->term + 1;
}
|
| ︙ | ︙ | |||
1746 1747 1748 1749 1750 1751 1752 |
* Skip straight to the exit code since we have no interpreter to put
* error message in.
*/
goto error;
}
| < | | 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 |
* Skip straight to the exit code since we have no interpreter to put
* error message in.
*/
goto error;
}
TclPrintfResult(parsePtr->interp, "missing close-brace");
/*
* Guess if the problem is due to comments by searching the source string
* for a possible open brace within the context of a comment. Since we
* aren't performing a full Tcl parse, just look for an open brace
* preceded by a '<whitespace>#' on the same line.
*/
|
| ︙ | ︙ | |||
1847 1848 1849 1850 1851 1852 1853 |
if (TCL_OK != ParseTokens(start+1, numBytes-1, TYPE_QUOTE, TCL_SUBST_ALL,
parsePtr)) {
goto error;
}
if (*parsePtr->term != '"') {
if (parsePtr->interp != NULL) {
| | < | 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 |
if (TCL_OK != ParseTokens(start+1, numBytes-1, TYPE_QUOTE, TCL_SUBST_ALL,
parsePtr)) {
goto error;
}
if (*parsePtr->term != '"') {
if (parsePtr->interp != NULL) {
TclPrintfResult(parsePtr->interp, "missing \"");
}
parsePtr->errorType = TCL_PARSE_MISSING_QUOTE;
parsePtr->term = start;
parsePtr->incomplete = 1;
goto error;
}
if (termPtr != NULL) {
|
| ︙ | ︙ |
Changes to generic/tclPathObj.c.
| ︙ | ︙ | |||
2482 2483 2484 2485 2486 2487 2488 |
if (user == NULL || user[0] == 0) {
/* No user name specified -> current user */
dir = TclGetEnv("HOME", &dirString);
if (dir == NULL) {
if (interp) {
| | | < | 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 |
if (user == NULL || user[0] == 0) {
/* No user name specified -> current user */
dir = TclGetEnv("HOME", &dirString);
if (dir == NULL) {
if (interp) {
TclPrintfResult(interp,
"couldn't find HOME environment variable to expand path");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "PATH",
"HOMELESS", (char *)NULL);
}
return TCL_ERROR;
}
} else {
/* User name specified - ~user */
|
| ︙ | ︙ |
Changes to generic/tclPipe.c.
| ︙ | ︙ | |||
352 353 354 355 356 357 358 |
/*
* If a child exited abnormally but didn't output any error information at
* all, generate an error message here.
*/
if ((abnormalExit != 0) && (anyErrorInfo == 0) && (interp != NULL)) {
| < | | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
/*
* If a child exited abnormally but didn't output any error information at
* all, generate an error message here.
*/
if ((abnormalExit != 0) && (anyErrorInfo == 0) && (interp != NULL)) {
TclPrintfResult(interp, "child process exited abnormally");
}
return result;
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
503 504 505 506 507 508 509 |
switch (*p++) {
case '|':
if (*p == '&') {
p++;
}
if (*p == '\0') {
if ((i == (lastBar + 1)) || (i == (argc - 1))) {
| | | | 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
switch (*p++) {
case '|':
if (*p == '&') {
p++;
}
if (*p == '\0') {
if ((i == (lastBar + 1)) || (i == (argc - 1))) {
TclPrintfResult(interp,
"illegal use of | or |& in command");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
"PIPESYNTAX", (char *)NULL);
goto error;
}
}
lastBar = i;
cmdCount++;
|
| ︙ | ︙ | |||
691 692 693 694 695 696 697 |
}
if (needCmd) {
/*
* We had a bar followed only by redirections.
*/
| < | | 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
}
if (needCmd) {
/*
* We had a bar followed only by redirections.
*/
TclPrintfResult(interp, "illegal use of | or |& in command");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC", "PIPESYNTAX",
(char *)NULL);
goto error;
}
if (inputFile == NULL) {
if (inputLiteral != NULL) {
|
| ︙ | ︙ | |||
1044 1045 1046 1047 1048 1049 1050 |
/*
* Verify that the pipes that were created satisfy the readable/writable
* constraints.
*/
if (flags & TCL_ENFORCE_MODE) {
if ((flags & TCL_STDOUT) && (outPipe == NULL)) {
| | | | | < | | 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 |
/*
* Verify that the pipes that were created satisfy the readable/writable
* constraints.
*/
if (flags & TCL_ENFORCE_MODE) {
if ((flags & TCL_STDOUT) && (outPipe == NULL)) {
TclPrintfResult(interp,
"can't read output from command:"
" standard output was redirected");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
"BADREDIRECT", (char *)NULL);
goto error;
}
if ((flags & TCL_STDIN) && (inPipe == NULL)) {
TclPrintfResult(interp,
"can't write input to command:"
" standard input was redirected");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC",
"BADREDIRECT", (char *)NULL);
goto error;
}
}
channel = TclpCreateCommandChannel(outPipe, inPipe, errFile,
numPids, pidPtr);
if (channel == NULL) {
TclPrintfResult(interp, "pipe for command could not be created");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC", "NOPIPE", (char *)NULL);
goto error;
}
return channel;
error:
if (pidPtr) {
|
| ︙ | ︙ |
Changes to generic/tclProc.c.
| ︙ | ︙ | |||
524 525 526 527 528 529 530 |
result = TclListObjGetElements(interp, argArray[i], &fieldCount,
&fieldValues);
if (result != TCL_OK) {
goto procError;
}
if (fieldCount > 2) {
| | | | < < < | | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
result = TclListObjGetElements(interp, argArray[i], &fieldCount,
&fieldValues);
if (result != TCL_OK) {
goto procError;
}
if (fieldCount > 2) {
TclPrintfResult(interp,
"too many fields in argument specifier \"%s\"",
Tcl_GetString(argArray[i]));
errorCode = "FORMALARGUMENTFORMAT";
goto procError;
}
if ((fieldCount == 0) || (Tcl_GetCharLength(fieldValues[0]) == 0)) {
TclPrintfResult(interp, "argument with no name");
errorCode = "FORMALARGUMENTFORMAT";
goto procError;
}
argname = TclGetStringFromObj(fieldValues[0], &nameLength);
/*
|
| ︙ | ︙ | |||
557 558 559 560 561 562 563 |
TclPrintfResult(interp,
"formal parameter \"%s\" is an array element",
TclGetString(fieldValues[0]));
errorCode = "FORMALARGUMENTFORMAT";
goto procError;
}
} else if (argnamei[0] == ':' && argnamei[1] == ':') {
| | | | < < | 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
TclPrintfResult(interp,
"formal parameter \"%s\" is an array element",
TclGetString(fieldValues[0]));
errorCode = "FORMALARGUMENTFORMAT";
goto procError;
}
} else if (argnamei[0] == ':' && argnamei[1] == ':') {
TclPrintfResult(interp,
"formal parameter \"%s\" is not a simple name",
Tcl_GetString(fieldValues[0]));
errorCode = "FORMALARGUMENTFORMAT";
goto procError;
}
argnamei++;
}
if (precompiled) {
|
| ︙ | ︙ | |||
604 605 606 607 608 609 610 |
if (localPtr->defValuePtr != NULL) {
Tcl_Size tmpLength, valueLength;
const char *tmpPtr = TclGetStringFromObj(localPtr->defValuePtr, &tmpLength);
const char *value = TclGetStringFromObj(fieldValues[1], &valueLength);
if ((valueLength != tmpLength)
|| memcmp(value, tmpPtr, tmpLength) != 0) {
| | | < < | | | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
if (localPtr->defValuePtr != NULL) {
Tcl_Size tmpLength, valueLength;
const char *tmpPtr = TclGetStringFromObj(localPtr->defValuePtr, &tmpLength);
const char *value = TclGetStringFromObj(fieldValues[1], &valueLength);
if ((valueLength != tmpLength)
|| memcmp(value, tmpPtr, tmpLength) != 0) {
TclPrintfResult(interp,
"procedure \"%s\": formal parameter \"%s\" has "
"default value inconsistent with precompiled body",
procName, Tcl_GetString(fieldValues[0]));
errorCode = "BYTECODELIES";
goto procError;
}
}
if ((i == numArgs - 1)
&& (localPtr->nameLength == 4)
&& (localPtr->name[0] == 'a')
|
| ︙ | ︙ | |||
1957 1958 1959 1960 1961 1962 1963 |
&& (codePtr->nsEpoch == nsPtr->resolverEpoch)
&& ((codePtr->procPtr == procPtr) || !bodyPtr->bytes)) {
return TCL_OK;
}
if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
if ((Interp *) *codePtr->interpHandle != iPtr) {
| < | | 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 |
&& (codePtr->nsEpoch == nsPtr->resolverEpoch)
&& ((codePtr->procPtr == procPtr) || !bodyPtr->bytes)) {
return TCL_OK;
}
if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
if ((Interp *) *codePtr->interpHandle != iPtr) {
TclPrintfResult(interp, "a precompiled script jumped interps");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"CROSSINTERPBYTECODE", (char *)NULL);
return TCL_ERROR;
}
codePtr->compileEpoch = iPtr->compileEpoch;
codePtr->nsPtr = nsPtr;
} else {
|
| ︙ | ︙ |
Changes to generic/tclScan.c.
| ︙ | ︙ | |||
338 339 340 341 342 343 344 |
goto xpgCheckDone;
}
notXpg:
gotSequential = 1;
if (gotXpg) {
mixedXPG:
| | | < | 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
goto xpgCheckDone;
}
notXpg:
gotSequential = 1;
if (gotXpg) {
mixedXPG:
TclPrintfResult(interp,
"cannot mix \"%%\" and \"%%n$\" conversion specifiers");
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "MIXEDSPECTYPES", (char *)NULL);
goto error;
}
xpgCheckDone:
/*
* Parse any width specifier.
|
| ︙ | ︙ | |||
412 413 414 415 416 417 418 |
/*
* Handle the various field types.
*/
switch (ch) {
case 'c':
if (flags & SCAN_WIDTH) {
| | | < | | | < < | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
/*
* Handle the various field types.
*/
switch (ch) {
case 'c':
if (flags & SCAN_WIDTH) {
TclPrintfResult(interp,
"field width may not be specified in %%c conversion");
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BADWIDTH", (char *)NULL);
goto error;
}
TCL_FALLTHROUGH();
case 'n':
case 's':
if (flags & (SCAN_LONGER|SCAN_BIG)) {
invalidFieldSize:
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
TclPrintfResult(interp,
"field size modifier may not be specified in %%%s conversion",
buf);
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BADSIZE", (char *)NULL);
goto error;
}
TCL_FALLTHROUGH();
case 'd':
case 'e':
case 'E':
|
| ︙ | ︙ | |||
477 478 479 480 481 482 483 |
if (*format == '\0') {
goto badSet;
}
format += TclUtfToUniChar(format, &ch);
}
break;
badSet:
| < | | | < < < | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
if (*format == '\0') {
goto badSet;
}
format += TclUtfToUniChar(format, &ch);
}
break;
badSet:
TclPrintfResult(interp, "unmatched [ in format string");
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BRACKET", (char *)NULL);
goto error;
default:
buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
TclPrintfResult(interp,
"bad scan conversion character \"%s\"", buf);
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BADTYPE", (char *)NULL);
goto error;
}
if (!(flags & SCAN_SUPPRESS)) {
if (objIndex >= nspace) {
/*
* Expand the nassign buffer. If we are using XPG specifiers,
|
| ︙ | ︙ | |||
532 533 534 535 536 537 538 |
}
}
if (totalSubs) {
*totalSubs = numVars;
}
for (i = 0; i < numVars; i++) {
if (nassign[i] > 1) {
| | | < | | < < | | | < | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
}
}
if (totalSubs) {
*totalSubs = numVars;
}
for (i = 0; i < numVars; i++) {
if (nassign[i] > 1) {
TclPrintfResult(interp,
"variable is assigned by multiple \"%%n$\" conversion specifiers");
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "POLYASSIGNED", (char *)NULL);
goto error;
} else if (!xpgSize && (nassign[i] == 0)) {
/*
* If the space is empty, and xpgSize is 0 (means XPG wasn't used,
* and/or numVars != 0), then too many vars were given
*/
TclPrintfResult(interp,
"variable is not assigned by any conversion specifiers");
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "UNASSIGNED", (char *)NULL);
goto error;
}
}
TclStackFree(interp, nassign);
return TCL_OK;
badIndex:
if (gotXpg) {
TclPrintfResult(interp, "\"%%n$\" argument index out of range");
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "INDEXRANGE", (char *)NULL);
} else {
TclPrintfResult(interp,
"different numbers of variable names and field specifiers");
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "FIELDVARMISMATCH", (char *)NULL);
}
error:
TclStackFree(interp, nassign);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
968 969 970 971 972 973 974 |
} else {
wideValue = WIDE_MAX;
}
}
if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) {
mp_int big;
if (mp_init_u64(&big, (Tcl_WideUInt)wideValue) != MP_OKAY) {
| | | | 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 |
} else {
wideValue = WIDE_MAX;
}
}
if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) {
mp_int big;
if (mp_init_u64(&big, (Tcl_WideUInt)wideValue) != MP_OKAY) {
TclPrintfResult(interp,
"insufficient memory to create bignum");
Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL);
return TCL_ERROR;
} else {
Tcl_SetBignumObj(objPtr, &big);
}
} else {
TclSetIntObj(objPtr, wideValue);
|
| ︙ | ︙ | |||
995 996 997 998 999 1000 1001 |
}
if (res == TCL_ERROR) {
if (objs != NULL) {
Tcl_Free(objs);
}
Tcl_DecrRefCount(objPtr);
| | | | | | 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 |
}
if (res == TCL_ERROR) {
if (objs != NULL) {
Tcl_Free(objs);
}
Tcl_DecrRefCount(objPtr);
TclPrintfResult(interp,
"unsigned bignum scans are invalid");
Tcl_SetErrorCode(interp, "TCL", "FORMAT",
"BADUNSIGNED", (char *)NULL);
return TCL_ERROR;
}
}
} else {
if (TclGetIntFromObj(NULL, objPtr, &value) != TCL_OK) {
if (TclGetString(objPtr)[0] == '-') {
value = INT_MIN;
} else {
value = INT_MAX;
}
}
if ((flags & SCAN_UNSIGNED) && (value < 0)) {
#ifdef TCL_WIDE_INT_IS_LONG
mp_int big;
if (mp_init_u64(&big, (unsigned long)value) != MP_OKAY) {
TclPrintfResult(interp,
"insufficient memory to create bignum");
Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL);
return TCL_ERROR;
} else {
Tcl_SetBignumObj(objPtr, &big);
}
#else
Tcl_SetWideIntObj(objPtr, (unsigned long)value);
|
| ︙ | ︙ |
Changes to generic/tclTest.c.
| ︙ | ︙ | |||
1926 1927 1928 1929 1930 1931 1932 |
TCL_EXACT, &type) != TCL_OK) {
fprintf(stderr, "bad value? %g\n", d);
return TCL_ERROR;
}
type = types[type];
if (objc > 4) {
if (strcmp(Tcl_GetString(objv[4]), "shorten")) {
| | | 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 |
TCL_EXACT, &type) != TCL_OK) {
fprintf(stderr, "bad value? %g\n", d);
return TCL_ERROR;
}
type = types[type];
if (objc > 4) {
if (strcmp(Tcl_GetString(objv[4]), "shorten")) {
TclPrintfResult(interp, "bad flag");
return TCL_ERROR;
}
type |= TCL_DD_SHORTEST;
}
str = TclDoubleDigits(d, ndigits, type, &decpt, &signum, &endPtr);
strObj = Tcl_NewStringObj(str, endPtr-str);
Tcl_Free(str);
|
| ︙ | ︙ | |||
3784 3785 3786 3787 3788 3789 3790 |
i++;
}
if (Tcl_GetIndexFromObj(interp, objv[i++], LinkType, "type", 0,
&typeIndex) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[i++], &size) == TCL_ERROR) {
| | < | | 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 |
i++;
}
if (Tcl_GetIndexFromObj(interp, objv[i++], LinkType, "type", 0,
&typeIndex) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[i++], &size) == TCL_ERROR) {
TclPrintfResult(interp, "wrong size value");
return TCL_ERROR;
}
name = Tcl_GetString(objv[i++]);
/*
* If no address is given request one in the underlying function
*/
if (i < objc) {
if (Tcl_GetWideIntFromObj(interp, objv[i], &addr) == TCL_ERROR) {
TclPrintfResult(interp, "wrong address value");
return TCL_ERROR;
}
} else {
addr = 0;
}
return Tcl_LinkArray(interp, name, INT2PTR(addr),
LinkTypes[typeIndex] | readonly, size);
|
| ︙ | ︙ | |||
4270 4271 4272 4273 4274 4275 4276 |
Tcl_WrongNumArgs(interp, 1, objv, "integer");
return TCL_ERROR;
}
if (TCL_OK != Tcl_GetWideIntFromObj(interp, objv[1], &w)) {
return TCL_ERROR;
}
if (w <= 0) {
| < | | 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 |
Tcl_WrongNumArgs(interp, 1, objv, "integer");
return TCL_ERROR;
}
if (TCL_OK != Tcl_GetWideIntFromObj(interp, objv[1], &w)) {
return TCL_ERROR;
}
if (w <= 0) {
TclPrintfResult(interp, "argument must be positive");
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewIntObj(TclMSB((unsigned long long)w)));
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
6077 6078 6079 6080 6081 6082 6083 |
if (Tcl_IsShared(obj)) {
obj = Tcl_DuplicateObj(obj);
}
if (Tcl_SetByteArrayLength(obj, n) == NULL) {
if (obj != objv[1]) {
Tcl_DecrRefCount(obj);
}
| | | 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 |
if (Tcl_IsShared(obj)) {
obj = Tcl_DuplicateObj(obj);
}
if (Tcl_SetByteArrayLength(obj, n) == NULL) {
if (obj != objv[1]) {
Tcl_DecrRefCount(obj);
}
TclPrintfResult(interp, "expected bytes");
return TCL_ERROR;
}
Tcl_SetObjResult(interp, obj);
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
8349 8350 8351 8352 8353 8354 8355 |
Tcl_Obj *objv[3];
/*
* Set the start of the error message as obj result; it will be cleared at
* the end if no errors were found.
*/
| < | | 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 |
Tcl_Obj *objv[3];
/*
* Set the start of the error message as obj result; it will be cleared at
* the end if no errors were found.
*/
TclPrintfResult(interp, "Tcl_ConcatObj is unsafe:");
emptyPtr = Tcl_NewObj();
list1Ptr = Tcl_NewStringObj("foo bar sum", -1);
Tcl_ListObjLength(NULL, list1Ptr, &len);
Tcl_InvalidateStringRep(list1Ptr);
|
| ︙ | ︙ | |||
9289 9290 9291 9292 9293 9294 9295 |
Tcl_WrongNumArgs(interp, 1, objv, "");
return TCL_ERROR;
}
if (GetProcessHandleCount(GetCurrentProcess(), &count)) {
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(count));
return TCL_OK;
}
| < | | 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 |
Tcl_WrongNumArgs(interp, 1, objv, "");
return TCL_ERROR;
}
if (GetProcessHandleCount(GetCurrentProcess(), &count)) {
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(count));
return TCL_OK;
}
TclPrintfResult(interp, "GetProcessHandleCount failed");
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* TestAppVerifierPresentCmd --
|
| ︙ | ︙ |
Changes to generic/tclTestObj.c.
| ︙ | ︙ | |||
198 199 200 201 202 203 204 |
case BIGNUM_SET:
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "var value");
return TCL_ERROR;
}
string = Tcl_GetString(objv[3]);
if (mp_init(&bignumValue) != MP_OKAY) {
| < | < | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
case BIGNUM_SET:
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "var value");
return TCL_ERROR;
}
string = Tcl_GetString(objv[3]);
if (mp_init(&bignumValue) != MP_OKAY) {
TclPrintfResult(interp, "error in mp_init");
return TCL_ERROR;
}
if (mp_read_radix(&bignumValue, string, 10) != MP_OKAY) {
mp_clear(&bignumValue);
TclPrintfResult(interp, "error in mp_read_radix");
return TCL_ERROR;
}
/*
* If the object currently bound to the variable with index varIndex
* has ref count 1 (i.e. the object is unshared) we can modify that
* object directly. Otherwise, if RC>1 (i.e. the object is shared),
|
| ︙ | ︙ | |||
248 249 250 251 252 253 254 |
}
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_mul_d(&bignumValue, 10, &bignumValue) != MP_OKAY) {
mp_clear(&bignumValue);
| < | | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
}
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_mul_d(&bignumValue, 10, &bignumValue) != MP_OKAY) {
mp_clear(&bignumValue);
TclPrintfResult(interp, "error in mp_mul_d");
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
Tcl_SetBignumObj(varPtr[varIndex], &bignumValue);
} else {
SetVarToObj(varPtr, varIndex, Tcl_NewBignumObj(&bignumValue));
}
|
| ︙ | ︙ | |||
273 274 275 276 277 278 279 |
}
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_div_d(&bignumValue, 10, &bignumValue, NULL) != MP_OKAY) {
mp_clear(&bignumValue);
| < | | 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
}
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_div_d(&bignumValue, 10, &bignumValue, NULL) != MP_OKAY) {
mp_clear(&bignumValue);
TclPrintfResult(interp, "error in mp_div_d");
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
Tcl_SetBignumObj(varPtr[varIndex], &bignumValue);
} else {
SetVarToObj(varPtr, varIndex, Tcl_NewBignumObj(&bignumValue));
}
|
| ︙ | ︙ | |||
298 299 300 301 302 303 304 |
}
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_mod_2d(&bignumValue, 1, &bignumValue) != MP_OKAY) {
mp_clear(&bignumValue);
| < | | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
}
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
&bignumValue) != TCL_OK) {
return TCL_ERROR;
}
if (mp_mod_2d(&bignumValue, 1, &bignumValue) != MP_OKAY) {
mp_clear(&bignumValue);
TclPrintfResult(interp, "error in mp_mod_2d");
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
Tcl_SetBooleanObj(varPtr[varIndex], mp_iszero(&bignumValue));
} else {
SetVarToObj(varPtr, varIndex, Tcl_NewBooleanObj(mp_iszero(&bignumValue)));
}
|
| ︙ | ︙ | |||
990 991 992 993 994 995 996 |
for (i = 0; i < len; ++i) {
Tcl_Obj *objP;
if (Tcl_ListObjIndex(interp, varPtr[varIndex], i, &objP)
!= TCL_OK) {
return TCL_ERROR;
}
if (objP->refCount < 0) {
| | | < | 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 |
for (i = 0; i < len; ++i) {
Tcl_Obj *objP;
if (Tcl_ListObjIndex(interp, varPtr[varIndex], i, &objP)
!= TCL_OK) {
return TCL_ERROR;
}
if (objP->refCount < 0) {
TclPrintfResult(interp,
"Tcl_ListObjIndex returned object with ref count < 0");
/* Keep looping since we are also looping for leaks */
}
Tcl_BounceRefCount(objP);
}
break;
case LISTOBJ_GETELEMENTSMEMCHECK:
|
| ︙ | ︙ | |||
1014 1015 1016 1017 1018 1019 1020 |
Tcl_Obj **elems;
if (Tcl_ListObjGetElements(interp, varPtr[varIndex], &len, &elems)
!= TCL_OK) {
return TCL_ERROR;
}
for (i = 0; i < len; ++i) {
if (elems[i]->refCount <= 0) {
| | | < | 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 |
Tcl_Obj **elems;
if (Tcl_ListObjGetElements(interp, varPtr[varIndex], &len, &elems)
!= TCL_OK) {
return TCL_ERROR;
}
for (i = 0; i < len; ++i) {
if (elems[i]->refCount <= 0) {
TclPrintfResult(interp,
"Tcl_ListObjGetElements element has ref count <= 0");
break;
}
}
}
break;
case LISTOBJ_INDEX:
/*
|
| ︙ | ︙ | |||
1206 1207 1208 1209 1210 1211 1212 |
} else {
const char *typeName;
if (objv[2]->typePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
} else {
typeName = objv[2]->typePtr->name;
| | | 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 |
} else {
const char *typeName;
if (objv[2]->typePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
} else {
typeName = objv[2]->typePtr->name;
Tcl_SetObjResult(interp, Tcl_NewStringObj(typeName, -1));
}
}
return TCL_OK;
case TESTOBJ_NEWOBJ:
if (objc != 3) {
goto wrongNumArgs;
}
|
| ︙ | ︙ |
Changes to generic/tclTrace.c.
| ︙ | ︙ | |||
312 313 314 315 316 317 318 |
*/
result = TclListObjLength(interp, objv[4], &listLen);
if (result != TCL_OK) {
return result;
}
if (listLen == 0) {
| | | | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
*/
result = TclListObjLength(interp, objv[4], &listLen);
if (result != TCL_OK) {
return result;
}
if (listLen == 0) {
TclPrintfResult(interp,
"bad operation list \"\": must be one or more of"
" enter, leave, enterstep, or leavestep");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRACE", "NOOPS",
(char *)NULL);
return TCL_ERROR;
}
result = TclListObjGetElements(interp, objv[4], &listLen, &elemPtrs);
if (result != TCL_OK) {
return result;
|
| ︙ | ︙ | |||
558 559 560 561 562 563 564 |
*/
result = TclListObjLength(interp, objv[4], &listLen);
if (result != TCL_OK) {
return result;
}
if (listLen == 0) {
| | | | 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
*/
result = TclListObjLength(interp, objv[4], &listLen);
if (result != TCL_OK) {
return result;
}
if (listLen == 0) {
TclPrintfResult(interp,
"bad operation list \"\": must be one or more of"
" delete or rename");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRACE", "NOOPS",
(char *)NULL);
return TCL_ERROR;
}
result = TclListObjGetElements(interp, objv[4], &listLen, &elemPtrs);
if (result != TCL_OK) {
return result;
|
| ︙ | ︙ | |||
761 762 763 764 765 766 767 |
*/
result = TclListObjLength(interp, objv[4], &listLen);
if (result != TCL_OK) {
return result;
}
if (listLen == 0) {
| | | | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
*/
result = TclListObjLength(interp, objv[4], &listLen);
if (result != TCL_OK) {
return result;
}
if (listLen == 0) {
TclPrintfResult(interp,
"bad operation list \"\": must be one or more of"
" array, read, unset, or write");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "TRACE", "NOOPS",
(char *)NULL);
return TCL_ERROR;
}
result = TclListObjGetElements(interp, objv[4], &listLen, &elemPtrs);
if (result != TCL_OK) {
return result;
|
| ︙ | ︙ |
Changes to generic/tclUtil.c.
| ︙ | ︙ | |||
906 907 908 909 910 911 912 |
length > (Tcl_Size) (TCL_SIZE_MAX - 1 - (size * sizeof(char *)))) {
goto memerror;
}
argv = (const char **)Tcl_AttemptAlloc((size * sizeof(char *)) + length + 1);
if (!argv) {
memerror:
if (interp) {
| | | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 |
length > (Tcl_Size) (TCL_SIZE_MAX - 1 - (size * sizeof(char *)))) {
goto memerror;
}
argv = (const char **)Tcl_AttemptAlloc((size * sizeof(char *)) + length + 1);
if (!argv) {
memerror:
if (interp) {
TclPrintfResult(interp, "cannot allocate");
Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL);
}
return TCL_ERROR;
}
for (i = 0, p = ((char *) argv) + size*sizeof(char *);
*list != 0; i++) {
|
| ︙ | ︙ | |||
930 931 932 933 934 935 936 |
}
if (*element == 0) {
break;
}
if (i >= size) {
Tcl_Free((void *)argv);
if (interp != NULL) {
| < | | 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 |
}
if (*element == 0) {
break;
}
if (i >= size) {
Tcl_Free((void *)argv);
if (interp != NULL) {
TclPrintfResult(interp, "internal error in Tcl_SplitList");
Tcl_SetErrorCode(interp, "TCL", "INTERNAL", "Tcl_SplitList",
(char *)NULL);
}
return TCL_ERROR;
}
argv[i] = p;
if (literal) {
|
| ︙ | ︙ |
Changes to generic/tclVar.c.
| ︙ | ︙ | |||
3128 3129 3130 3131 3132 3133 3134 |
*/
if (TclListObjLength(interp, objv[1], &numVars) != TCL_OK) {
return TCL_ERROR;
}
if (numVars != 2) {
| < | | 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 |
*/
if (TclListObjLength(interp, objv[1], &numVars) != TCL_OK) {
return TCL_ERROR;
}
if (numVars != 2) {
TclPrintfResult(interp, "must have two variable names");
Tcl_SetErrorCode(interp, "TCL", "SYNTAX", "array", "for", (char *)NULL);
return TCL_ERROR;
}
arrayNameObj = objv[2];
if (TCL_ERROR == LocateArray(interp, arrayNameObj, &varPtr, &isArray)) {
|
| ︙ | ︙ | |||
3229 3230 3231 3232 3233 3234 3235 |
&valueObj);
}
result = TCL_OK;
if (done != TCL_CONTINUE) {
Tcl_ResetResult(interp);
if (done == TCL_ERROR) {
| < | | 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 |
&valueObj);
}
result = TCL_OK;
if (done != TCL_CONTINUE) {
Tcl_ResetResult(interp);
if (done == TCL_ERROR) {
TclPrintfResult(interp, "array changed during iteration");
Tcl_SetErrorCode(interp, "TCL", "READ", "array", "for", (char *)NULL);
varPtr->flags |= TCL_LEAVE_ERR_MSG;
result = done;
}
goto arrayfordone;
}
|
| ︙ | ︙ | |||
4113 4114 4115 4116 4117 4118 4119 |
Tcl_Size i;
result = TclListObjLength(interp, arrayElemObj, &elemLen);
if (result != TCL_OK) {
return result;
}
if (elemLen & 1) {
| < | | 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 |
Tcl_Size i;
result = TclListObjLength(interp, arrayElemObj, &elemLen);
if (result != TCL_OK) {
return result;
}
if (elemLen & 1) {
TclPrintfResult(interp, "list must have an even number of elements");
Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "FORMAT", (char *)NULL);
return TCL_ERROR;
}
if (elemLen == 0) {
goto ensureArray;
}
result = TclListObjGetElements(interp, arrayElemObj,
|
| ︙ | ︙ | |||
4286 4287 4288 4289 4290 4291 4292 |
if (!isArray) {
return NotArrayError(interp, varNameObj);
}
stats = Tcl_HashStats((Tcl_HashTable *) varPtr->value.tablePtr);
if (stats == NULL) {
| < | | 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 |
if (!isArray) {
return NotArrayError(interp, varNameObj);
}
stats = Tcl_HashStats((Tcl_HashTable *) varPtr->value.tablePtr);
if (stats == NULL) {
TclPrintfResult(interp, "error reading array statistics");
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(stats, -1));
Tcl_Free(stats);
return TCL_OK;
}
|
| ︙ | ︙ | |||
4699 4700 4701 4702 4703 4704 4705 |
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME",
TclGetString(myNamePtr), (char *)NULL);
return TCL_ERROR;
}
}
if (varPtr == otherPtr) {
| | | | 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 |
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME",
TclGetString(myNamePtr), (char *)NULL);
return TCL_ERROR;
}
}
if (varPtr == otherPtr) {
TclPrintfResult((Tcl_Interp *) iPtr,
"can't upvar from variable to itself");
Tcl_SetErrorCode(interp, "TCL", "UPVAR", "SELF", (char *)NULL);
return TCL_ERROR;
}
if (TclIsVarTraced(varPtr)) {
TclPrintfResult((Tcl_Interp *) iPtr,
"variable \"%s\" has traces: can't use for upvar", myName);
|
| ︙ | ︙ | |||
6884 6885 6886 6887 6888 6889 6890 |
if (!varPtr || TclIsVarUndefined(varPtr) || !isArray) {
return NotArrayError(interp, arrayNameObj);
}
defaultValueObj = TclGetArrayDefault(varPtr);
if (!defaultValueObj) {
/* Array default must exist. */
| < | | 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 |
if (!varPtr || TclIsVarUndefined(varPtr) || !isArray) {
return NotArrayError(interp, arrayNameObj);
}
defaultValueObj = TclGetArrayDefault(varPtr);
if (!defaultValueObj) {
/* Array default must exist. */
TclPrintfResult(interp, "array has no default value");
Tcl_SetErrorCode(interp, "TCL", "READ", "ARRAY", "DEFAULT", (char *)NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, defaultValueObj);
return TCL_OK;
case OPT_SET:
|
| ︙ | ︙ |
Changes to generic/tclZlib.c.
| ︙ | ︙ | |||
826 827 828 829 830 831 832 |
goto error;
}
Tcl_DStringInit(&cmdname);
TclDStringAppendLiteral(&cmdname, "::tcl::zlib::streamcmd_");
TclDStringAppendObj(&cmdname, Tcl_GetObjResult(interp));
if (Tcl_FindCommand(interp, Tcl_DStringValue(&cmdname),
NULL, 0) != NULL) {
| < | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 |
goto error;
}
Tcl_DStringInit(&cmdname);
TclDStringAppendLiteral(&cmdname, "::tcl::zlib::streamcmd_");
TclDStringAppendObj(&cmdname, Tcl_GetObjResult(interp));
if (Tcl_FindCommand(interp, Tcl_DStringValue(&cmdname),
NULL, 0) != NULL) {
TclPrintfResult(interp, "BUG: Stream command name already exists");
Tcl_SetErrorCode(interp, "TCL", "BUG", "EXISTING_CMD", (char *)NULL);
Tcl_DStringFree(&cmdname);
goto error;
}
Tcl_ResetResult(interp);
/*
|
| ︙ | ︙ | |||
1218 1219 1220 1221 1222 1223 1224 |
int e;
Tcl_Size size = 0;
size_t outSize, toStore;
unsigned char *bytes;
if (zshPtr->streamEnd) {
if (zshPtr->interp) {
| < | | 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 |
int e;
Tcl_Size size = 0;
size_t outSize, toStore;
unsigned char *bytes;
if (zshPtr->streamEnd) {
if (zshPtr->interp) {
TclPrintfResult(zshPtr->interp, "already past compressed stream end");
Tcl_SetErrorCode(zshPtr->interp, "TCL", "ZIP", "CLOSED", (char *)NULL);
}
return TCL_ERROR;
}
bytes = Tcl_GetBytesFromObj(zshPtr->interp, data, &size);
if (bytes == NULL) {
|
| ︙ | ︙ | |||
1448 1449 1450 1451 1452 1453 1454 |
/*
* State: We have not satisfied the request yet and there may be
* more to inflate.
*/
if (zshPtr->stream.avail_in > 0) {
if (zshPtr->interp) {
| | | | 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 |
/*
* State: We have not satisfied the request yet and there may be
* more to inflate.
*/
if (zshPtr->stream.avail_in > 0) {
if (zshPtr->interp) {
TclPrintfResult(zshPtr->interp,
"unexpected zlib internal state during"
" decompression");
Tcl_SetErrorCode(zshPtr->interp, "TCL", "ZIP", "STATE",
(char *)NULL);
}
Tcl_SetByteArrayLength(data, existing);
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
2365 2366 2367 2368 2369 2370 2371 |
*/
if (levelObj == NULL) {
level = Z_DEFAULT_COMPRESSION;
} else if (Tcl_GetIntFromObj(interp, levelObj, &level) != TCL_OK) {
return TCL_ERROR;
} else if (level < 0 || level > 9) {
| < | | 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 |
*/
if (levelObj == NULL) {
level = Z_DEFAULT_COMPRESSION;
} else if (Tcl_GetIntFromObj(interp, levelObj, &level) != TCL_OK) {
return TCL_ERROR;
} else if (level < 0 || level > 9) {
TclPrintfResult(interp, "level must be 0 to 9");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMPRESSIONLEVEL", (char *)NULL);
Tcl_AddErrorInfo(interp, "\n (in -level option)");
return TCL_ERROR;
}
if (compDictObj) {
if (NULL == Tcl_GetBytesFromObj(interp, compDictObj, (Tcl_Size *)NULL)) {
|
| ︙ | ︙ | |||
2484 2485 2486 2487 2488 2489 2490 |
}
/*
* Sanity checks.
*/
if (mode == TCL_ZLIB_STREAM_DEFLATE && !(chanMode & TCL_WRITABLE)) {
| | | < | | < | 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 |
}
/*
* Sanity checks.
*/
if (mode == TCL_ZLIB_STREAM_DEFLATE && !(chanMode & TCL_WRITABLE)) {
TclPrintfResult(interp,
"compression may only be applied to writable channels");
Tcl_SetErrorCode(interp, "TCL", "ZIP", "UNWRITABLE", (char *)NULL);
return TCL_ERROR;
}
if (mode == TCL_ZLIB_STREAM_INFLATE && !(chanMode & TCL_READABLE)) {
TclPrintfResult(interp,
"decompression may only be applied to readable channels");
Tcl_SetErrorCode(interp, "TCL", "ZIP", "UNREADABLE", (char *)NULL);
return TCL_ERROR;
}
/*
* Parse options.
*/
|
| ︙ | ︙ | |||
2888 2889 2890 2891 2892 2893 2894 |
flush = -2;
} else {
flush = Z_FINISH;
}
break;
case po_dictionary: /* -dictionary compDict */
if (i == objc - 2) {
| | | | | | 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 |
flush = -2;
} else {
flush = Z_FINISH;
}
break;
case po_dictionary: /* -dictionary compDict */
if (i == objc - 2) {
TclPrintfResult(interp,
"\"-dictionary\" option must be followed by"
" compression dictionary bytes");
Tcl_SetErrorCode(interp, "TCL", "ZIP", "NOVAL", (char *)NULL);
return TCL_ERROR;
}
compDictObj = objv[++i];
break;
default:
TCL_UNREACHABLE();
}
if (flush == -2) {
TclPrintfResult(interp,
"\"-flush\", \"-fullflush\" and \"-finalize\" options"
" are mutually exclusive");
Tcl_SetErrorCode(interp, "TCL", "ZIP", "EXCLUSIVE", (char *)NULL);
return TCL_ERROR;
}
}
if (flush == -1) {
flush = 0;
}
|
| ︙ | ︙ | |||
2949 2950 2951 2952 2953 2954 2955 |
Tcl_Obj *resultObj;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return TCL_ERROR;
} else if (zshPtr->mode != TCL_ZLIB_STREAM_INFLATE
|| zshPtr->format != TCL_ZLIB_FORMAT_GZIP) {
| | | < | 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 |
Tcl_Obj *resultObj;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return TCL_ERROR;
} else if (zshPtr->mode != TCL_ZLIB_STREAM_INFLATE
|| zshPtr->format != TCL_ZLIB_FORMAT_GZIP) {
TclPrintfResult(interp,
"only gunzip streams can produce header information");
Tcl_SetErrorCode(interp, "TCL", "ZIP", "BADOP", (char *)NULL);
return TCL_ERROR;
}
TclNewObj(resultObj);
ExtractHeader(&zshPtr->gzHeaderPtr->header, resultObj);
Tcl_SetObjResult(interp, resultObj);
|
| ︙ | ︙ | |||
3430 3431 3432 3433 3434 3435 3436 |
} else {
if (optionName && strcmp(optionName, "-limit") == 0) {
int newLimit;
if (Tcl_GetInt(interp, value, &newLimit) != TCL_OK) {
return TCL_ERROR;
} else if (newLimit < 1 || newLimit > MAX_BUFFER_SIZE) {
| | | | 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 |
} else {
if (optionName && strcmp(optionName, "-limit") == 0) {
int newLimit;
if (Tcl_GetInt(interp, value, &newLimit) != TCL_OK) {
return TCL_ERROR;
} else if (newLimit < 1 || newLimit > MAX_BUFFER_SIZE) {
TclPrintfResult(interp,
"-limit must be between 1 and 65536");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "READLIMIT",
(char *)NULL);
return TCL_ERROR;
}
}
}
|
| ︙ | ︙ |
Changes to macosx/tclMacOSXFCmd.c.
| ︙ | ︙ | |||
186 187 188 189 190 191 192 |
break;
case MACOSX_RSRCLENGTH_ATTRIBUTE:
TclNewIntObj(*attributePtrPtr, *rsrcForkSize);
break;
}
return TCL_OK;
#else
| < | | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
break;
case MACOSX_RSRCLENGTH_ATTRIBUTE:
TclNewIntObj(*attributePtrPtr, *rsrcForkSize);
break;
}
return TCL_OK;
#else
TclPrintfResult(interp, "Mac OS X file attributes not supported");
Tcl_SetErrorCode(interp, "TCL", "UNSUPPORTED", (char *)NULL);
return TCL_ERROR;
#endif /* HAVE_GETATTRLIST */
}
/*
*---------------------------------------------------------------------------
|
| ︙ | ︙ | |||
315 316 317 318 319 320 321 |
/*
* Only setting rsrclength to 0 to strip a file's resource fork is
* supported.
*/
if (newRsrcForkSize != 0) {
| | | | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
/*
* Only setting rsrclength to 0 to strip a file's resource fork is
* supported.
*/
if (newRsrcForkSize != 0) {
TclPrintfResult(interp,
"setting nonzero rsrclength not supported");
Tcl_SetErrorCode(interp, "TCL", "UNSUPPORTED", (char *)NULL);
return TCL_ERROR;
}
/*
* Construct path to resource fork.
*/
|
| ︙ | ︙ |
Changes to unix/tclUnixChan.c.
| ︙ | ︙ | |||
818 819 820 821 822 823 824 |
return TCL_ERROR;
#endif /* CRTSCTS */
} else if (strncasecmp(value, "DTRDSR", vlen) == 0) {
UNSUPPORTED_OPTION("-handshake DTRDSR");
return TCL_ERROR;
} else {
if (interp) {
| | | | | | 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 |
return TCL_ERROR;
#endif /* CRTSCTS */
} else if (strncasecmp(value, "DTRDSR", vlen) == 0) {
UNSUPPORTED_OPTION("-handshake DTRDSR");
return TCL_ERROR;
} else {
if (interp) {
TclPrintfResult(interp,
"bad value for -handshake: must be one of"
" xonxoff, rtscts, dtrdsr or none");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE",
"VALUE", (char *)NULL);
}
return TCL_ERROR;
}
tcsetattr(fsPtr->fileState.fd, TCSADRAIN, &iostate);
return TCL_OK;
}
/*
* Option -xchar {\x11 \x13}
*/
if ((len > 1) && (strncmp(optionName, "-xchar", len) == 0)) {
if (Tcl_SplitList(interp, value, &argc, &argv) == TCL_ERROR) {
return TCL_ERROR;
} else if (argc != 2) {
badXchar:
if (interp) {
TclPrintfResult(interp,
"bad value for -xchar: should be a list of"
" two elements with each a single 8-bit character");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "XCHAR", (char *)NULL);
}
Tcl_Free(argv);
return TCL_ERROR;
}
tcgetattr(fsPtr->fileState.fd, &iostate);
|
| ︙ | ︙ | |||
905 906 907 908 909 910 911 |
Tcl_Size i;
if (Tcl_SplitList(interp, value, &argc, &argv) == TCL_ERROR) {
return TCL_ERROR;
}
if ((argc % 2) == 1) {
if (interp) {
| | | | 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 |
Tcl_Size i;
if (Tcl_SplitList(interp, value, &argc, &argv) == TCL_ERROR) {
return TCL_ERROR;
}
if ((argc % 2) == 1) {
if (interp) {
TclPrintfResult(interp,
"bad value for -ttycontrol: should be a list of"
" signal,value pairs");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE",
"VALUE", (char *)NULL);
}
Tcl_Free(argv);
return TCL_ERROR;
}
|
| ︙ | ︙ |
Changes to win/tclWinDde.c.
| ︙ | ︙ | |||
541 542 543 544 545 546 547 |
RegisteredInterp *riPtr, /* Info about this server. */
Tcl_Obj *ddeObjectPtr) /* The object to execute. */
{
Tcl_Obj *returnPackagePtr;
int result = TCL_OK;
if ((riPtr->handlerPtr == NULL) && Tcl_IsSafe(riPtr->interp)) {
| | | | 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
RegisteredInterp *riPtr, /* Info about this server. */
Tcl_Obj *ddeObjectPtr) /* The object to execute. */
{
Tcl_Obj *returnPackagePtr;
int result = TCL_OK;
if ((riPtr->handlerPtr == NULL) && Tcl_IsSafe(riPtr->interp)) {
TclPrintfResult(riPtr->interp, "permission denied: "
"a handler procedure must be defined for use in a safe "
"interp");
Tcl_SetErrorCode(riPtr->interp, "TCL", "DDE", "SECURITY_CHECK", (char *)NULL);
result = TCL_ERROR;
}
if (riPtr->handlerPtr != NULL) {
/*
* Add the dde request data to the handler proc list.
|
| ︙ | ︙ | |||
1531 1532 1533 1534 1535 1536 1537 |
Tcl_DStringInit(&dsBuf);
dataString =
Tcl_UtfToWCharDString(src, dataLength, &dsBuf);
dataLength = Tcl_DStringLength(&dsBuf) + sizeof(WCHAR);
}
if (dataLength + 1 < 2) {
| < | | 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 |
Tcl_DStringInit(&dsBuf);
dataString =
Tcl_UtfToWCharDString(src, dataLength, &dsBuf);
dataLength = Tcl_DStringLength(&dsBuf) + sizeof(WCHAR);
}
if (dataLength + 1 < 2) {
TclPrintfResult(interp, "cannot execute null data");
Tcl_DStringFree(&dsBuf);
Tcl_SetErrorCode(interp, "TCL", "DDE", "NULL", (char *)NULL);
result = TCL_ERROR;
break;
}
hConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL);
DdeFreeStringHandle(ddeInstance, ddeService);
|
| ︙ | ︙ | |||
1582 1583 1584 1585 1586 1587 1588 |
src = Tcl_GetStringFromObj(objv[firstArg + 2], &length);
Tcl_DStringInit(&itemBuf);
itemString = Tcl_UtfToWCharDString(src, length, &itemBuf);
length = Tcl_DStringLength(&itemBuf) / sizeof(WCHAR);
if (length == 0) {
| < | | 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 |
src = Tcl_GetStringFromObj(objv[firstArg + 2], &length);
Tcl_DStringInit(&itemBuf);
itemString = Tcl_UtfToWCharDString(src, length, &itemBuf);
length = Tcl_DStringLength(&itemBuf) / sizeof(WCHAR);
if (length == 0) {
TclPrintfResult(interp, "cannot request value of null data");
Tcl_SetErrorCode(interp, "TCL", "DDE", "NULL", (char *)NULL);
result = TCL_ERROR;
goto cleanup;
}
hConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL);
DdeFreeStringHandle(ddeInstance, ddeService);
DdeFreeStringHandle(ddeInstance, ddeTopic);
|
| ︙ | ︙ | |||
1648 1649 1650 1651 1652 1653 1654 |
const char *src;
src = Tcl_GetStringFromObj(objv[firstArg + 2], &length);
Tcl_DStringInit(&itemBuf);
itemString = Tcl_UtfToWCharDString(src, length, &itemBuf);
length = Tcl_DStringLength(&itemBuf) / sizeof(WCHAR);
if (length == 0) {
| | | | 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 |
const char *src;
src = Tcl_GetStringFromObj(objv[firstArg + 2], &length);
Tcl_DStringInit(&itemBuf);
itemString = Tcl_UtfToWCharDString(src, length, &itemBuf);
length = Tcl_DStringLength(&itemBuf) / sizeof(WCHAR);
if (length == 0) {
TclPrintfResult(interp,
"cannot have a null item");
Tcl_SetErrorCode(interp, "TCL", "DDE", "NULL", (char *)NULL);
result = TCL_ERROR;
goto cleanup;
}
Tcl_DStringInit(&dsBuf);
if (flags & DDE_FLAG_BINARY) {
dataString = (BYTE *)
|
| ︙ | ︙ | |||
1702 1703 1704 1705 1706 1707 1708 |
break;
case DDE_EVAL: {
RegisteredInterp *riPtr;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
if (serviceName == NULL) {
| < | | 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 |
break;
case DDE_EVAL: {
RegisteredInterp *riPtr;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
if (serviceName == NULL) {
TclPrintfResult(interp, "invalid service name \"\"");
Tcl_SetErrorCode(interp, "TCL", "DDE", "NO_SERVER", (char *)NULL);
result = TCL_ERROR;
goto cleanup;
}
objc -= firstArg + 1;
objv += firstArg + 1;
|
| ︙ | ︙ | |||
1749 1750 1751 1752 1753 1754 1755 |
* compile an object, producing a bytecode structure that refers
* to other objects owned by the target interp. If the target
* interp is then deleted, the bytecode structure would be
* referring to deallocated objects.
*/
if (Tcl_IsSafe(riPtr->interp) && (riPtr->handlerPtr == NULL)) {
| | | | 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 |
* compile an object, producing a bytecode structure that refers
* to other objects owned by the target interp. If the target
* interp is then deleted, the bytecode structure would be
* referring to deallocated objects.
*/
if (Tcl_IsSafe(riPtr->interp) && (riPtr->handlerPtr == NULL)) {
TclPrintfResult(riPtr->interp,
"permission denied: a handler procedure must be"
" defined for use in a safe interp");
Tcl_SetErrorCode(interp, "TCL", "DDE", "SECURITY_CHECK",
(char *)NULL);
result = TCL_ERROR;
}
if (result == TCL_OK) {
if (objc == 1) {
|
| ︙ | ︙ | |||
1816 1817 1818 1819 1820 1821 1822 |
/*
* This is a non-local request. Send the script to the server and
* poll it for a result.
*/
if (MakeDdeConnection(interp, serviceName, &hConv) != TCL_OK) {
invalidServerResponse:
| < | | 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 |
/*
* This is a non-local request. Send the script to the server and
* poll it for a result.
*/
if (MakeDdeConnection(interp, serviceName, &hConv) != TCL_OK) {
invalidServerResponse:
TclPrintfResult(interp, "invalid data returned from server");
Tcl_SetErrorCode(interp, "TCL", "DDE", "BAD_RESPONSE", (char *)NULL);
result = TCL_ERROR;
goto cleanup;
}
objPtr = Tcl_ConcatObj(objc, objv);
string = Tcl_GetStringFromObj(objPtr, &length);
|
| ︙ | ︙ |
Changes to win/tclWinReg.c.
| ︙ | ︙ | |||
426 427 428 429 430 431 432 |
if (ParseKeyName(interp, buffer, &hostName, &rootKey,
&keyName) != TCL_OK) {
Tcl_Free(buffer);
return TCL_ERROR;
}
if (*keyName == '\0') {
| < | < | < | | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
if (ParseKeyName(interp, buffer, &hostName, &rootKey,
&keyName) != TCL_OK) {
Tcl_Free(buffer);
return TCL_ERROR;
}
if (*keyName == '\0') {
TclPrintfResult(interp, "bad key: cannot delete root keys");
Tcl_SetErrorCode(interp, "WIN_REG", "DEL_ROOT_KEY", (char *)NULL);
Tcl_Free(buffer);
return TCL_ERROR;
}
tail = strrchr(keyName, '\\');
if (tail) {
*tail++ = '\0';
} else {
tail = keyName;
keyName = NULL;
}
mode |= KEY_ENUMERATE_SUB_KEYS | DELETE;
result = OpenSubKey(hostName, rootKey, keyName, mode, 0, &subkey);
if (result != ERROR_SUCCESS) {
Tcl_Free(buffer);
if (result == ERROR_FILE_NOT_FOUND) {
return TCL_OK;
}
TclPrintfResult(interp, "unable to delete key: ");
AppendSystemError(interp, result);
return TCL_ERROR;
}
/*
* Now we recursively delete the key and everything below it.
*/
Tcl_DStringInit(&buf);
nativeTail = Tcl_UtfToWCharDString(tail, -1, &buf);
result = RecursiveDeleteKey(subkey, nativeTail, saveMode);
Tcl_DStringFree(&buf);
if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) {
TclPrintfResult(interp, "unable to delete key: ");
AppendSystemError(interp, result);
result = TCL_ERROR;
} else {
result = TCL_OK;
}
RegCloseKey(subkey);
|
| ︙ | ︙ | |||
957 958 959 960 961 962 963 |
buffer = (char *)Tcl_Alloc(len + 1);
strcpy(buffer, keyName);
result = ParseKeyName(interp, buffer, &hostName, &rootKey, &keyName);
if (result == TCL_OK) {
result = OpenSubKey(hostName, rootKey, keyName, mode, flags, keyPtr);
if (result != ERROR_SUCCESS) {
| < | | 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 |
buffer = (char *)Tcl_Alloc(len + 1);
strcpy(buffer, keyName);
result = ParseKeyName(interp, buffer, &hostName, &rootKey, &keyName);
if (result == TCL_OK) {
result = OpenSubKey(hostName, rootKey, keyName, mode, flags, keyPtr);
if (result != ERROR_SUCCESS) {
TclPrintfResult(interp, "unable to open key: ");
AppendSystemError(interp, result);
result = TCL_ERROR;
} else {
result = TCL_OK;
}
}
|
| ︙ | ︙ | |||
1345 1346 1347 1348 1349 1350 1351 |
(DWORD) type, data, (DWORD) bytelength);
}
Tcl_DStringFree(&nameBuf);
RegCloseKey(key);
if (result != ERROR_SUCCESS) {
| < | | 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 |
(DWORD) type, data, (DWORD) bytelength);
}
Tcl_DStringFree(&nameBuf);
RegCloseKey(key);
if (result != ERROR_SUCCESS) {
TclPrintfResult(interp, "unable to set value: ");
AppendSystemError(interp, result);
return TCL_ERROR;
}
return TCL_OK;
}
/*
|
| ︙ | ︙ |
Changes to win/tclWinSerial.c.
| ︙ | ︙ | |||
1770 1771 1772 1773 1774 1775 1776 |
if (Tcl_SplitList(interp, value, &argc, &argv) == TCL_ERROR) {
return TCL_ERROR;
}
if (argc != 2) {
badXchar:
if (interp != NULL) {
| | | < | 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 |
if (Tcl_SplitList(interp, value, &argc, &argv) == TCL_ERROR) {
return TCL_ERROR;
}
if (argc != 2) {
badXchar:
if (interp != NULL) {
TclPrintfResult(interp,
"bad value for -xchar: should be a list of"
" two elements with each a single 8-bit character");
Tcl_SetErrorCode(interp, "TCL", "VALUE", "XCHAR", (char *)NULL);
}
Tcl_Free((void *)argv);
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
1846 1847 1848 1849 1850 1851 1852 |
res = TCL_ERROR;
break;
}
if (strncasecmp(argv[i], "DTR", strlen(argv[i])) == 0) {
if (!EscapeCommFunction(infoPtr->handle,
(DWORD) (flag ? SETDTR : CLRDTR))) {
if (interp != NULL) {
| < | < | < | | 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 |
res = TCL_ERROR;
break;
}
if (strncasecmp(argv[i], "DTR", strlen(argv[i])) == 0) {
if (!EscapeCommFunction(infoPtr->handle,
(DWORD) (flag ? SETDTR : CLRDTR))) {
if (interp != NULL) {
TclPrintfResult(interp, "can't set DTR signal");
Tcl_SetErrorCode(interp, "TCL", "OPERATION",
"FCONFIGURE", "TTY_SIGNAL", (char *)NULL);
}
res = TCL_ERROR;
break;
}
} else if (strncasecmp(argv[i], "RTS", strlen(argv[i])) == 0) {
if (!EscapeCommFunction(infoPtr->handle,
(DWORD) (flag ? SETRTS : CLRRTS))) {
if (interp != NULL) {
TclPrintfResult(interp, "can't set RTS signal");
Tcl_SetErrorCode(interp, "TCL", "OPERATION",
"FCONFIGURE", "TTY_SIGNAL", (char *)NULL);
}
res = TCL_ERROR;
break;
}
} else if (strncasecmp(argv[i], "BREAK", strlen(argv[i])) == 0) {
if (!EscapeCommFunction(infoPtr->handle,
(DWORD) (flag ? SETBREAK : CLRBREAK))) {
if (interp != NULL) {
TclPrintfResult(interp, "can't set BREAK signal");
Tcl_SetErrorCode(interp, "TCL", "OPERATION",
"FCONFIGURE", "TTY_SIGNAL", (char *)NULL);
}
res = TCL_ERROR;
break;
}
} else {
|
| ︙ | ︙ |