Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | merge updates from HEAD |
|---|---|
| Timelines: | family | ancestors | descendants | both | dgp-refactor |
| Files: | files | file ages | folders |
| SHA1: |
9f9a3d1982a1a0834443da096c209811 |
| User & Date: | dgp 2006-09-05 16:14:36.000 |
Context
|
2006-10-23
| ||
| 21:01 | merge updates from HEAD check-in: 1f911d4cbb user: dgp tags: dgp-refactor | |
|
2006-09-05
| ||
| 16:14 | merge updates from HEAD check-in: 9f9a3d1982 user: dgp tags: dgp-refactor | |
|
2006-08-29
| ||
| 16:19 | merge updates from HEAD check-in: e1feeec3e7 user: dgp tags: dgp-refactor | |
Changes
Changes to ChangeLog.
1 2 3 4 5 6 7 8 | 2006-08-29 Joe Mistachkin <joe@mistachkin.com> * unix/tclUnixInit.c: Fixed the issue (typo) that was causing * unix/tclUnixThrd.c (TclpThreadGetStackSize): stack.test to fail on FreeBSD (and possibly other Unix platforms). 2006-08-29 Colin McCormack <coldstore@users.sourceforge.net> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | 2006-09-04 Don Porter <dgp@users.sourceforge.net> * generic/tclCompExpr.c: Removed much complexity that is no longer needed. * tests/main.text (Tcl_Main-4.4): Test corrected to not be timing sensitive to the Bug 1481986 fix. [Bug 1550858] 2006-09-04 Jeff Hobbs <jeffh@ActiveState.com> * doc/package.n: correct package example 2006-08-31 Don Porter <dgp@users.sourceforge.net> * generic/tclCompExpr.c: Corrected flawed logic for disabling the INST_TRY_CVT_TO_NUMERIC instruction at the end of an expression when function arguments contain operators. [Bug 1541274] * tests/expr-old.test: The remaining failing tests reported in * tests/expr.test: [Bug 1381715] are all new in Tcl 8.5, so there's really no issue of compatibility with Tcl 8.4 result to deal with. Fixed by updating tests to expect 8.5 results. 2006-08-29 Don Porter <dgp@users.sourceforge.net> * generic/tclParseExpr.c: Dropped the old expr parser. 2006-08-30 Jeff Hobbs <jeffh@ActiveState.com> * generic/tclBasic.c (Tcl_CreateInterp): init iPtr->threadId * win/tclWinChan.c [Bug 819667] Improve logic for identifying COM ports. * generic/tclIOGT.c (ExecuteCallback): * generic/tclPkg.c (Tcl_PkgRequireEx): replace Tcl_GlobalEval(Obj) with more efficient Tcl_Eval(Obj)Ex * unix/Makefile.in (valgrindshell): add valgrindshell target and update default VALGRINDARGS. User can override, or add to it with VALGRIND_OPTS env var. * generic/tclFileName.c (DoGlob): match incrs with decrs. 2006-08-29 Don Porter <dgp@users.sourceforge.net> * generic/tclParseExpr.c: Use the "parent" field of orphan ExprNodes to store the closure of left pointers. This lets us avoid repeated re-scanning leftward for the left boundary of subexpressions, which in worst case led to near O(N^2) runtime. 2006-08-29 Joe Mistachkin <joe@mistachkin.com> * unix/tclUnixInit.c: Fixed the issue (typo) that was causing * unix/tclUnixThrd.c (TclpThreadGetStackSize): stack.test to fail on FreeBSD (and possibly other Unix platforms). 2006-08-29 Colin McCormack <coldstore@users.sourceforge.net> * generic/tclIOUtil.c: Added test for NULL return * generic/tclPathObj.c: from Tcl_FSGetNormalizedPath * unix/tclUnixFile.c: which was causing segv's per * win/tclWinFCmd.c: Bug 1548263 * win/tclWinFile.c: 2006-08-28 Kevin Kenny <kennykb@acm.org> * library/tzdata/America/Havana: Regenerated from Olson's * library/tzdata/America/Tegucigalpa: tzdata2006k. * library/tzdata/Asia/Gaza: |
| ︙ | ︙ |
Changes to doc/package.n.
1 2 3 4 5 6 | '\" '\" Copyright (c) 1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | '\" '\" Copyright (c) 1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: package.n,v 1.6.4.4 2006/09/05 16:14:36 dgp Exp $ '\" .so man.macros .TH package n 7.5 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME package \- Facilities for package loading and version control |
| ︙ | ︙ | |||
197 198 199 200 201 202 203 |
.CE
.PP
To test to see if the Snack package is available and load if it is
(often useful for optional enhancements to programs where the loss of
the functionality is not critical) do this:
.CS
if {[catch {\fBpackage require\fR Snack}]} {
| | > | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
.CE
.PP
To test to see if the Snack package is available and load if it is
(often useful for optional enhancements to programs where the loss of
the functionality is not critical) do this:
.CS
if {[catch {\fBpackage require\fR Snack}]} {
# Error thrown - package not found.
# Set up a dummy interface to work around the absence
} else {
# We have the package, configure the app to use it
}
.CE
.SH "SEE ALSO"
msgcat(n), packagens(n), pkgMkIndex(n)
.SH KEYWORDS
package, version
|
Changes to generic/tclBasic.c.
| ︙ | ︙ | |||
9 10 11 12 13 14 15 | * Copyright (c) 1994-1997 Sun Microsystems, Inc. * Copyright (c) 1998-1999 by Scriptics Corporation. * Copyright (c) 2001, 2002 by Kevin B. Kenny. All rights reserved. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | * Copyright (c) 1994-1997 Sun Microsystems, Inc. * Copyright (c) 1998-1999 by Scriptics Corporation. * Copyright (c) 2001, 2002 by Kevin B. Kenny. All rights reserved. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclBasic.c,v 1.82.2.45 2006/09/05 16:14:36 dgp Exp $ */ #include "tclInt.h" #include "tclCompile.h" #include <float.h> #include <math.h> #include "tommath.h" |
| ︙ | ︙ | |||
339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
iPtr->activeCmdTracePtr = NULL;
iPtr->activeInterpTracePtr = NULL;
iPtr->assocData = NULL;
iPtr->execEnvPtr = NULL; /* set after namespaces initialized */
iPtr->emptyObjPtr = Tcl_NewObj(); /* another empty object */
Tcl_IncrRefCount(iPtr->emptyObjPtr);
iPtr->resultSpace[0] = 0;
iPtr->globalNsPtr = NULL; /* force creation of global ns below */
iPtr->globalNsPtr = (Namespace *) Tcl_CreateNamespace(interp, "",
(ClientData) NULL, NULL);
if (iPtr->globalNsPtr == NULL) {
Tcl_Panic("Tcl_CreateInterp: can't create global namespace");
}
| > | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
iPtr->activeCmdTracePtr = NULL;
iPtr->activeInterpTracePtr = NULL;
iPtr->assocData = NULL;
iPtr->execEnvPtr = NULL; /* set after namespaces initialized */
iPtr->emptyObjPtr = Tcl_NewObj(); /* another empty object */
Tcl_IncrRefCount(iPtr->emptyObjPtr);
iPtr->resultSpace[0] = 0;
iPtr->threadId = Tcl_GetCurrentThread();
iPtr->globalNsPtr = NULL; /* force creation of global ns below */
iPtr->globalNsPtr = (Namespace *) Tcl_CreateNamespace(interp, "",
(ClientData) NULL, NULL);
if (iPtr->globalNsPtr == NULL) {
Tcl_Panic("Tcl_CreateInterp: can't create global namespace");
}
|
| ︙ | ︙ |
Changes to generic/tclCompExpr.c.
1 2 3 4 5 6 7 8 9 10 11 | /* * tclCompExpr.c -- * * This file contains the code to compile Tcl expressions. * * Copyright (c) 1997 Sun Microsystems, Inc. * Copyright (c) 1998-2000 by Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * tclCompExpr.c -- * * This file contains the code to compile Tcl expressions. * * Copyright (c) 1997 Sun Microsystems, Inc. * Copyright (c) 1998-2000 by Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclCompExpr.c,v 1.14.2.14 2006/09/05 16:14:37 dgp Exp $ */ #include "tclInt.h" #include "tclCompile.h" /* * Boolean variable that controls whether expression compilation tracing is * enabled. */ #ifdef TCL_COMPILE_DEBUG static int traceExprComp = 0; #endif /* TCL_COMPILE_DEBUG */ /* * Definitions of numeric codes representing each expression operator. The * order of these must match the entries in the operatorTable below. Also the * codes for the relational operators (OP_LESS, OP_GREATER, OP_LE, OP_GE, * OP_EQ, and OP_NE) must be consecutive and in that order. Note that OP_PLUS * and OP_MINUS represent both unary and binary operators. */ |
| ︙ | ︙ | |||
132 133 134 135 136 137 138 | static Tcl_HashTable opHashTable; /* * Declarations for local procedures to this file: */ | | | | | | < | | | > | | < | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | static Tcl_HashTable opHashTable; /* * Declarations for local procedures to this file: */ static void CompileCondExpr(Tcl_Interp *interp, Tcl_Token *exprTokenPtr, int *convertPtr, CompileEnv *envPtr); static void CompileLandOrLorExpr(Tcl_Interp *interp, Tcl_Token *exprTokenPtr, int opIndex, CompileEnv *envPtr); static void CompileMathFuncCall(Tcl_Interp *interp, Tcl_Token *exprTokenPtr, CONST char *funcName, CompileEnv *envPtr); static void CompileSubExpr(Tcl_Interp *interp, Tcl_Token *exprTokenPtr, int *convertPtr, CompileEnv *envPtr); /* * Macro used to debug the execution of the expression compiler. */ #ifdef TCL_COMPILE_DEBUG #define TRACE(exprBytes, exprLength, tokenBytes, tokenLength) \ |
| ︙ | ︙ | |||
191 192 193 194 195 196 197 |
Tcl_Interp *interp, /* Used for error reporting. */
CONST char *script, /* The source script to compile. */
int numBytes, /* Number of bytes in script. If < 0, the
* string consists of all bytes up to the
* first null character. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
| < < | > > | < < < < < < < < < < < | | | < | < < < | | < < < > | | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
Tcl_Interp *interp, /* Used for error reporting. */
CONST char *script, /* The source script to compile. */
int numBytes, /* Number of bytes in script. If < 0, the
* string consists of all bytes up to the
* first null character. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
Tcl_Parse parse;
int needsNumConversion = 1;
/*
* If this is the first time we've been called, initialize the table of
* expression operators.
*/
if (numBytes < 0) {
numBytes = (script? strlen(script) : 0);
}
if (!opTableInitialized) {
Tcl_MutexLock(&opMutex);
if (!opTableInitialized) {
int i;
Tcl_InitHashTable(&opHashTable, TCL_STRING_KEYS);
for (i = 0; operatorTable[i].name != NULL; i++) {
int new;
Tcl_HashEntry *hPtr = Tcl_CreateHashEntry(&opHashTable,
operatorTable[i].name, &new);
if (new) {
Tcl_SetHashValue(hPtr, (ClientData) i);
}
}
opTableInitialized = 1;
}
Tcl_MutexUnlock(&opMutex);
}
/*
* Parse the expression then compile it.
*/
if (TCL_OK != TclParseExpr(interp, script, numBytes,
/* useInternalTokens */ 1, &parse)) {
return TCL_ERROR;
}
CompileSubExpr(interp, parse.tokenPtr, &needsNumConversion, envPtr);
if (needsNumConversion) {
/*
* Attempt to convert the primary's object to an int or double. This
* is done in order to support Tcl's policy of interpreting operands
* if at all possible as first integers, else floating-point numbers.
*/
TclEmitOpcode(INST_TRY_CVT_TO_NUMERIC, envPtr);
}
Tcl_FreeParse(&parse);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* TclFinalizeCompilation --
*
|
| ︙ | ︙ | |||
300 301 302 303 304 305 306 | * CompileSubExpr -- * * Given a pointer to a TCL_TOKEN_SUB_EXPR token describing a * subexpression, this procedure emits instructions to evaluate the * subexpression at runtime. * * Results: | < < | | > | < > > < < < < < < < < < < < < < < < < < | < < < < | < < | | < < < < < | | > | < | | < | < < < < < | < < < < | > > > > > > | < < < < < | < < < | < < | < < | | | > > | < < < < | < < < < > | > | | | < < < < | | | < < < < | | < < < < < < < < < < | < < < > < < < < < < < | | > < < | < < < < | > < | < < < | < < < < | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 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 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 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 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 477 478 479 480 481 482 483 484 485 486 487 488 |
* CompileSubExpr --
*
* Given a pointer to a TCL_TOKEN_SUB_EXPR token describing a
* subexpression, this procedure emits instructions to evaluate the
* subexpression at runtime.
*
* Results:
* None.
*
* Side effects:
* Adds instructions to envPtr to evaluate the subexpression.
*
*----------------------------------------------------------------------
*/
static void
CompileSubExpr(
Tcl_Interp *interp, /* Interp in which to compile expression */
Tcl_Token *exprTokenPtr, /* Points to TCL_TOKEN_SUB_EXPR token to
* compile. */
int *convertPtr, /* Writes 0 here if it is determined the
* final INST_TRY_CVT_TO_NUMERIC is
* not needed */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
/* Switch on the type of the first token after the subexpression token. */
Tcl_Token *tokenPtr = exprTokenPtr+1;
TRACE(exprTokenPtr->start, exprTokenPtr->size,
tokenPtr->start, tokenPtr->size);
switch (tokenPtr->type) {
case TCL_TOKEN_WORD:
TclCompileTokens(interp, tokenPtr+1, tokenPtr->numComponents, envPtr);
break;
case TCL_TOKEN_TEXT:
TclEmitPush(TclRegisterNewLiteral(envPtr,
tokenPtr->start, tokenPtr->size), envPtr);
break;
case TCL_TOKEN_BS: {
char buffer[TCL_UTF_MAX];
int length = Tcl_UtfBackslash(tokenPtr->start, NULL, buffer);
TclEmitPush(TclRegisterNewLiteral(envPtr, buffer, length), envPtr);
break;
}
case TCL_TOKEN_COMMAND:
TclCompileScript(interp, tokenPtr->start+1, tokenPtr->size-2, envPtr);
break;
case TCL_TOKEN_SCRIPT_SUBST: {
Tcl_Token *lastTokenPtr = tokenPtr + (tokenPtr->numComponents);
TclCompileScriptTokens(interp, tokenPtr+1, lastTokenPtr, envPtr);
tokenPtr += (tokenPtr->numComponents + 1);
break;
}
case TCL_TOKEN_VARIABLE:
TclCompileTokens(interp, tokenPtr, 1, envPtr);
break;
case TCL_TOKEN_SUB_EXPR:
CompileSubExpr(interp, tokenPtr, convertPtr, envPtr);
break;
case TCL_TOKEN_OPERATOR: {
/*
* Look up the operator. If the operator isn't found, treat it as a
* math function.
*/
OperatorDesc *opDescPtr;
Tcl_HashEntry *hPtr;
CONST char *operator;
Tcl_DString opBuf;
int opIndex;
Tcl_DStringInit(&opBuf);
operator = Tcl_DStringAppend(&opBuf, tokenPtr->start, tokenPtr->size);
hPtr = Tcl_FindHashEntry(&opHashTable, operator);
if (hPtr == NULL) {
CompileMathFuncCall(interp, exprTokenPtr, operator, envPtr);
Tcl_DStringFree(&opBuf);
break;
}
Tcl_DStringFree(&opBuf);
opIndex = (int) Tcl_GetHashValue(hPtr);
opDescPtr = &(operatorTable[opIndex]);
/*
* If the operator is "normal", compile it using information from the
* operator table.
*/
if (opDescPtr->numOperands > 0) {
tokenPtr++;
CompileSubExpr(interp, tokenPtr, convertPtr, envPtr);
tokenPtr += (tokenPtr->numComponents + 1);
if (opDescPtr->numOperands == 2) {
CompileSubExpr(interp, tokenPtr, convertPtr, envPtr);
}
TclEmitOpcode(opDescPtr->instruction, envPtr);
*convertPtr = 0;
break;
}
/*
* The operator requires special treatment, and is either * "+" or "-",
* or one of "&&", "||" or "?".
*/
switch (opIndex) {
case OP_PLUS:
case OP_MINUS: {
Tcl_Token *afterSubexprPtr = exprTokenPtr
+ exprTokenPtr->numComponents+1;
tokenPtr++;
CompileSubExpr(interp, tokenPtr, convertPtr, envPtr);
tokenPtr += (tokenPtr->numComponents + 1);
/*
* Check whether the "+" or "-" is unary.
*/
if (tokenPtr == afterSubexprPtr) {
TclEmitOpcode(((opIndex==OP_PLUS)? INST_UPLUS : INST_UMINUS),
envPtr);
break;
}
/*
* The "+" or "-" is binary.
*/
CompileSubExpr(interp, tokenPtr, convertPtr, envPtr);
TclEmitOpcode(((opIndex==OP_PLUS)? INST_ADD : INST_SUB), envPtr);
*convertPtr = 0;
break;
}
case OP_LAND:
case OP_LOR:
CompileLandOrLorExpr(interp, exprTokenPtr, opIndex, envPtr);
*convertPtr = 0;
break;
case OP_QUESTY:
CompileCondExpr(interp, exprTokenPtr, convertPtr, envPtr);
break;
default:
Tcl_Panic("CompileSubExpr: unexpected operator %d "
"requiring special treatment", opIndex);
} /* end switch on operator requiring special treatment */
break;
}
default:
Tcl_Panic("CompileSubExpr: unexpected token type %d", tokenPtr->type);
}
}
/*
*----------------------------------------------------------------------
*
* CompileLandOrLorExpr --
*
* This procedure compiles a Tcl logical and ("&&") or logical or ("||")
* subexpression.
*
* Results:
* None.
*
* Side effects:
* Adds instructions to envPtr to evaluate the expression at runtime.
*
*----------------------------------------------------------------------
*/
static void
CompileLandOrLorExpr(
Tcl_Interp *interp, /* Interp in which compile takes place */
Tcl_Token *exprTokenPtr, /* Points to TCL_TOKEN_SUB_EXPR token
* containing the "&&" or "||" operator. */
int opIndex, /* A code describing the expression operator:
* either OP_LAND or OP_LOR. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
JumpFixup shortCircuitFixup;/* Used to fix up the short circuit jump after
* the first subexpression. */
JumpFixup shortCircuitFixup2;
/* Used to fix up the second jump to the
* short-circuit target. */
JumpFixup endFixup; /* Used to fix up jump to the end. */
int convert = 0;
int savedStackDepth = envPtr->currStackDepth;
Tcl_Token *tokenPtr = exprTokenPtr+2;
/*
* Emit code for the first operand.
*/
CompileSubExpr(interp, tokenPtr, &convert, envPtr);
tokenPtr += (tokenPtr->numComponents + 1);
/*
* Emit the short-circuit jump.
*/
TclEmitForwardJump(envPtr,
((opIndex==OP_LAND)? TCL_FALSE_JUMP : TCL_TRUE_JUMP),
&shortCircuitFixup);
/*
* Emit code for the second operand.
*/
CompileSubExpr(interp, tokenPtr, &convert, envPtr);
/*
* The result is the boolean value of the second operand. We code this in
* a somewhat contorted manner to be able to reuse the shortCircuit value
* and save one INST_JUMP.
*/
|
| ︙ | ︙ | |||
638 639 640 641 642 643 644 |
if (opIndex == OP_LAND) {
TclEmitPush(TclRegisterNewLiteral(envPtr, "0", 1), envPtr);
} else {
TclEmitPush(TclRegisterNewLiteral(envPtr, "1", 1), envPtr);
}
TclFixupForwardJumpToHere(envPtr, &endFixup, 127);
| < < < < < < < < | | > | | < < < | | > < | < < < < | < < < < < < < | < < < < < < < | 514 515 516 517 518 519 520 521 522 523 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 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
if (opIndex == OP_LAND) {
TclEmitPush(TclRegisterNewLiteral(envPtr, "0", 1), envPtr);
} else {
TclEmitPush(TclRegisterNewLiteral(envPtr, "1", 1), envPtr);
}
TclFixupForwardJumpToHere(envPtr, &endFixup, 127);
envPtr->currStackDepth = savedStackDepth + 1;
}
/*
*----------------------------------------------------------------------
*
* CompileCondExpr --
*
* This procedure compiles a Tcl conditional expression:
* condExpr ::= lorExpr ['?' condExpr ':' condExpr]
*
* Results:
* None.
*
* Side effects:
* Adds instructions to envPtr to evaluate the expression at runtime.
*
*----------------------------------------------------------------------
*/
static void
CompileCondExpr(
Tcl_Interp *interp, /* Interp in which compile takes place */
Tcl_Token *exprTokenPtr, /* Points to TCL_TOKEN_SUB_EXPR token
* containing the "?" operator. */
int *convertPtr, /* Describes the compilation state for the
* expression being compiled. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
JumpFixup jumpAroundThenFixup, jumpAroundElseFixup;
/* Used to update or replace one-byte jumps
* around the then and else expressions when
* their target PCs are determined. */
Tcl_Token *tokenPtr = exprTokenPtr+2;
int elseCodeOffset, dist, convert = 0;
int convertThen = 1, convertElse = 1;
int savedStackDepth = envPtr->currStackDepth;
/*
* Emit code for the test.
*/
CompileSubExpr(interp, tokenPtr, &convert, envPtr);
tokenPtr += (tokenPtr->numComponents + 1);
/*
* Emit the jump to the "else" expression if the test was false.
*/
TclEmitForwardJump(envPtr, TCL_FALSE_JUMP, &jumpAroundThenFixup);
/*
* Compile the "then" expression. Note that if a subexpression is only a
* primary, we need to try to convert it to numeric. We do this to support
* Tcl's policy of interpreting operands if at all possible as first
* integers, else floating-point numbers.
*/
CompileSubExpr(interp, tokenPtr, &convertThen, envPtr);
tokenPtr += (tokenPtr->numComponents + 1);
/*
* Emit an unconditional jump around the "else" condExpr.
*/
TclEmitForwardJump(envPtr, TCL_UNCONDITIONAL_JUMP, &jumpAroundElseFixup);
/*
* Compile the "else" expression.
*/
envPtr->currStackDepth = savedStackDepth;
elseCodeOffset = (envPtr->codeNext - envPtr->codeStart);
CompileSubExpr(interp, tokenPtr, &convertElse, envPtr);
/*
* Fix up the second jump around the "else" expression.
*/
dist = (envPtr->codeNext - envPtr->codeStart)
- jumpAroundElseFixup.codeOffset;
|
| ︙ | ︙ | |||
762 763 764 765 766 767 768 |
/*
* Fix up the first jump to the "else" expression if the test was false.
*/
dist = (elseCodeOffset - jumpAroundThenFixup.codeOffset);
TclFixupForwardJump(envPtr, &jumpAroundThenFixup, dist, 127);
| | < < < < < < | | > < < | < < < < | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
/*
* Fix up the first jump to the "else" expression if the test was false.
*/
dist = (elseCodeOffset - jumpAroundThenFixup.codeOffset);
TclFixupForwardJump(envPtr, &jumpAroundThenFixup, dist, 127);
*convertPtr = convertThen || convertElse;
envPtr->currStackDepth = savedStackDepth + 1;
}
/*
*----------------------------------------------------------------------
*
* CompileMathFuncCall --
*
* This procedure compiles a call on a math function in an expression:
* mathFuncCall ::= funcName '(' [condExpr {',' condExpr}] ')'
*
* Results:
* None.
*
* Side effects:
* Adds instructions to envPtr to evaluate the math function at
* runtime.
*
*----------------------------------------------------------------------
*/
static void
CompileMathFuncCall(
Tcl_Interp *interp, /* Interp in which compile takes place */
Tcl_Token *exprTokenPtr, /* Points to TCL_TOKEN_SUB_EXPR token
* containing the math function call. */
CONST char *funcName, /* Name of the math function. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
Tcl_DString cmdName;
int objIndex;
Tcl_Token *tokenPtr, *afterSubexprPtr;
int argCount;
/*
* Prepend "tcl::mathfunc::" to the function name, to produce the name of
* a command that evaluates the function. Push that command name on the
* stack, in a literal registered to the namespace so that resolution can
* be cached.
*/
|
| ︙ | ︙ | |||
832 833 834 835 836 837 838 839 |
* Compile any arguments for the function.
*/
argCount = 1;
tokenPtr = exprTokenPtr+2;
afterSubexprPtr = exprTokenPtr + (exprTokenPtr->numComponents + 1);
while (tokenPtr != afterSubexprPtr) {
++argCount;
| > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 |
* Compile any arguments for the function.
*/
argCount = 1;
tokenPtr = exprTokenPtr+2;
afterSubexprPtr = exprTokenPtr + (exprTokenPtr->numComponents + 1);
while (tokenPtr != afterSubexprPtr) {
int convert = 0;
++argCount;
CompileSubExpr(interp, tokenPtr, &convert, envPtr);
tokenPtr += (tokenPtr->numComponents + 1);
}
/* Invoke the function */
if (argCount < 255) {
TclEmitInstInt1(INST_INVOKE_STK1, argCount, envPtr);
} else {
TclEmitInstInt4(INST_INVOKE_STK4, argCount, envPtr);
}
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
|
Changes to generic/tclFileName.c.
1 2 3 4 5 6 7 8 9 10 11 12 | /* * tclFileName.c -- * * This file contains routines for converting file names betwen native * and network form. * * Copyright (c) 1995-1998 Sun Microsystems, Inc. * Copyright (c) 1998-1999 by Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * tclFileName.c -- * * This file contains routines for converting file names betwen native * and network form. * * Copyright (c) 1995-1998 Sun Microsystems, Inc. * Copyright (c) 1998-1999 by Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclFileName.c,v 1.41.2.19 2006/09/05 16:14:37 dgp Exp $ */ #include "tclInt.h" #include "tclRegexp.h" #include "tclFileSystem.h" /* For TclGetPathType() */ /* |
| ︙ | ︙ | |||
1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 |
* error messsages.
*/
savedResultObj = Tcl_GetObjResult(interp);
Tcl_IncrRefCount(savedResultObj);
Tcl_ResetResult(interp);
TclNewObj(filenamesObj);
/*
* Now we do the actual globbing, adding filenames as we go to buffer in
* filenamesObj
*/
if (*tail == '\0' && pathPrefix != NULL) {
| > | 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 |
* error messsages.
*/
savedResultObj = Tcl_GetObjResult(interp);
Tcl_IncrRefCount(savedResultObj);
Tcl_ResetResult(interp);
TclNewObj(filenamesObj);
Tcl_IncrRefCount(filenamesObj);
/*
* Now we do the actual globbing, adding filenames as we go to buffer in
* filenamesObj
*/
if (*tail == '\0' && pathPrefix != NULL) {
|
| ︙ | ︙ | |||
2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 |
/*
* We do the recursion ourselves. This makes implementing
* Tcl_FSMatchInDirectory for each filesystem much easier.
*/
*p = '\0';
TclNewObj(subdirsPtr);
result = Tcl_FSMatchInDirectory(interp, subdirsPtr, pathPtr,
pattern, &dirOnly);
*p = save;
if (result == TCL_OK) {
int subdirc, i;
Tcl_Obj **subdirv;
| > | 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 |
/*
* We do the recursion ourselves. This makes implementing
* Tcl_FSMatchInDirectory for each filesystem much easier.
*/
*p = '\0';
TclNewObj(subdirsPtr);
Tcl_IncrRefCount(subdirsPtr);
result = Tcl_FSMatchInDirectory(interp, subdirsPtr, pathPtr,
pattern, &dirOnly);
*p = save;
if (result == TCL_OK) {
int subdirc, i;
Tcl_Obj **subdirv;
|
| ︙ | ︙ |
Changes to generic/tclIOGT.c.
1 2 3 4 5 6 7 8 9 10 11 12 | /* * tclIOGT.c -- * * Implements a generic transformation exposing the underlying API at the * script level. Contributed by Andreas Kupries. * * Copyright (c) 2000 Ajuba Solutions * Copyright (c) 1999-2000 Andreas Kupries (a.kupries@westend.com) * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * tclIOGT.c -- * * Implements a generic transformation exposing the underlying API at the * script level. Contributed by Andreas Kupries. * * Copyright (c) 2000 Ajuba Solutions * Copyright (c) 1999-2000 Andreas Kupries (a.kupries@westend.com) * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * CVS: $Id: tclIOGT.c,v 1.7.4.8 2006/09/05 16:14:37 dgp Exp $ */ #include "tclInt.h" #include "tclIO.h" /* * Forward declarations of internal procedures. First the driver procedures of |
| ︙ | ︙ | |||
402 403 404 405 406 407 408 |
* Step 2, execute the command at the global level of the interpreter used
* to create the transformation. Destroy the command afterward. If an
* error occured and the current interpreter is defined and not equal to
* the interpreter for the callback, then copy the error message into
* current interpreter. Don't copy if in preservation mode.
*/
| | | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
* Step 2, execute the command at the global level of the interpreter used
* to create the transformation. Destroy the command afterward. If an
* error occured and the current interpreter is defined and not equal to
* the interpreter for the callback, then copy the error message into
* current interpreter. Don't copy if in preservation mode.
*/
res = Tcl_EvalObjEx(dataPtr->interp, command, TCL_EVAL_GLOBAL);
Tcl_DecrRefCount(command);
command = NULL;
if ((res != TCL_OK) && (interp != NULL) &&
(dataPtr->interp != interp) && !preserve) {
Tcl_SetObjResult(interp, Tcl_GetObjResult(dataPtr->interp));
return res;
|
| ︙ | ︙ |
Changes to generic/tclParseExpr.c.
1 2 3 4 5 6 7 8 9 | /* * tclParseExpr.c -- * * This file contains functions that parse Tcl expressions. They do so in * a general-purpose fashion that can be used for many different * purposes, including compilation, direct execution, code analysis, etc. * * Copyright (c) 1997 Sun Microsystems, Inc. * Copyright (c) 1998-2000 by Scriptics Corporation. | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /* * tclParseExpr.c -- * * This file contains functions that parse Tcl expressions. They do so in * a general-purpose fashion that can be used for many different * purposes, including compilation, direct execution, code analysis, etc. * * Copyright (c) 1997 Sun Microsystems, Inc. * Copyright (c) 1998-2000 by Scriptics Corporation. * Contributions from Don Porter, NIST, 2006. (not subject to US copyright) * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclParseExpr.c,v 1.17.4.18 2006/09/05 16:14:37 dgp Exp $ */ #include "tclInt.h" /* * The ExprNode structure represents one node of the parse tree produced * as an interim structure by the expression parser. */ |
| ︙ | ︙ | |||
2164 2165 2166 2167 2168 2169 2170 |
#define NUM_STATIC_NODES 64
ExprNode staticNodes[NUM_STATIC_NODES];
ExprNode *lastOrphanPtr, *nodes = staticNodes;
int nodesAvailable = NUM_STATIC_NODES;
int nodesUsed = 0;
Tcl_Parse scratch; /* Parsing scratch space */
Tcl_Obj *msg = NULL, *post = NULL;
| < < > | | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
#define NUM_STATIC_NODES 64
ExprNode staticNodes[NUM_STATIC_NODES];
ExprNode *lastOrphanPtr, *nodes = staticNodes;
int nodesAvailable = NUM_STATIC_NODES;
int nodesUsed = 0;
Tcl_Parse scratch; /* Parsing scratch space */
Tcl_Obj *msg = NULL, *post = NULL;
int scanned = 0, code = TCL_OK, insertMark = 0;
CONST char *mark = "_@_";
CONST int limit = 25;
static CONST unsigned char prec[80] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 15, 15, 5, 16, 16, 16, 13, 13, 11, 10, 9, 6, 6, 14, 14,
13, 13, 12, 12, 8, 7, 12, 12, 17, 12, 12, 3, 1, 0, 0, 0,
0, 18, 18, 18, 2, 4, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0,
};
|
| ︙ | ︙ | |||
2298 2299 2300 2301 2302 2303 2304 |
}
}
}
/* Add node to parse tree based on category */
switch (NODE_TYPE & nodePtr->lexeme) {
| | > | 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
}
}
}
/* Add node to parse tree based on category */
switch (NODE_TYPE & nodePtr->lexeme) {
case LEAF: {
CONST char *end;
if ((NODE_TYPE & lastNodePtr->lexeme) == LEAF) {
CONST char *operand =
scratch.tokenPtr[lastNodePtr->token].start;
msg = Tcl_NewObj();
TclObjPrintf(NULL, msg, "missing operator at %s", mark);
|
| ︙ | ︙ | |||
2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 |
nodePtr->left = -1;
nodePtr->right = -1;
nodePtr->parent = -1;
lastOrphanPtr = nodePtr;
nodesUsed++;
break;
case UNARY:
if ((NODE_TYPE & lastNodePtr->lexeme) == LEAF) {
msg = Tcl_NewObj();
TclObjPrintf(NULL, msg, "missing operator at %s", mark);
scanned = 0;
insertMark = 1;
| > | 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
nodePtr->left = -1;
nodePtr->right = -1;
nodePtr->parent = -1;
lastOrphanPtr = nodePtr;
nodesUsed++;
break;
}
case UNARY:
if ((NODE_TYPE & lastNodePtr->lexeme) == LEAF) {
msg = Tcl_NewObj();
TclObjPrintf(NULL, msg, "missing operator at %s", mark);
scanned = 0;
insertMark = 1;
|
| ︙ | ︙ | |||
2497 2498 2499 2500 2501 2502 2503 |
scratch.numTokens++;
lastOrphanPtr = nodePtr;
nodesUsed++;
break;
case BINARY: {
| | > | 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
scratch.numTokens++;
lastOrphanPtr = nodePtr;
nodesUsed++;
break;
case BINARY: {
ExprNode *otherPtr = NULL;
unsigned char precedence = prec[nodePtr->lexeme];
if ((nodePtr->lexeme == CLOSE_PAREN)
&& (lastNodePtr->lexeme == OPEN_PAREN)) {
if (lastNodePtr[-1].lexeme == FUNCTION) {
/* Normally, "()" is a syntax error, but as a special
* case accept it as an argument list for a function */
scanned = 0;
|
| ︙ | ︙ | |||
2524 2525 2526 2527 2528 2529 2530 | TclObjPrintf(NULL, msg, "empty subexpression at %s", mark); scanned = 0; insertMark = 1; code = TCL_ERROR; continue; } | < | 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
TclObjPrintf(NULL, msg, "empty subexpression at %s", mark);
scanned = 0;
insertMark = 1;
code = TCL_ERROR;
continue;
}
if ((NODE_TYPE & lastNodePtr->lexeme) != LEAF) {
if (prec[lastNodePtr->lexeme] > precedence) {
if (lastNodePtr->lexeme == OPEN_PAREN) {
msg = Tcl_NewStringObj("unbalanced open paren", -1);
} else if (lastNodePtr->lexeme == COMMA) {
msg = Tcl_NewObj();
|
| ︙ | ︙ | |||
2563 2564 2565 2566 2567 2568 2569 |
insertMark = 1;
}
code = TCL_ERROR;
continue;
}
while (1) {
| > | > | > > > | | 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
insertMark = 1;
}
code = TCL_ERROR;
continue;
}
while (1) {
if (lastOrphanPtr->parent >= 0) {
otherPtr = nodes + lastOrphanPtr->parent;
} else if (lastOrphanPtr->left >= 0) {
Tcl_Panic("Tcl_ParseExpr: left closure programming error");
} else {
lastOrphanPtr->parent = lastOrphanPtr - nodes;
otherPtr = lastOrphanPtr;
}
otherPtr--;
if (prec[otherPtr->lexeme] < precedence) {
break;
}
|
| ︙ | ︙ | |||
2660 2661 2662 2663 2664 2665 2666 | -1); code = TCL_ERROR; continue; } /* Link orphan as left operand of new node */ nodePtr->right = -1; | < > | 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 | -1); code = TCL_ERROR; continue; } /* Link orphan as left operand of new node */ nodePtr->right = -1; TclGrowParseTokenArray(&scratch,1); nodePtr->token = scratch.numTokens; tokenPtr = scratch.tokenPtr + nodePtr->token; tokenPtr->type = TCL_TOKEN_OPERATOR; tokenPtr->start = start; tokenPtr->size = scanned; tokenPtr->numComponents = 0; scratch.numTokens++; nodePtr->left = lastOrphanPtr - nodes; nodePtr->parent = lastOrphanPtr->parent; lastOrphanPtr->parent = nodePtr - nodes; lastOrphanPtr = nodePtr; nodesUsed++; break; } } |
| ︙ | ︙ | |||
3102 3103 3104 3105 3106 3107 3108 |
utfBytes[numBytes] = '\0';
scanned = Tcl_UtfToUniChar(utfBytes, &ch);
}
}
*lexemePtr = BAREWORD;
return (end-start);
}
| < | 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 |
utfBytes[numBytes] = '\0';
scanned = Tcl_UtfToUniChar(utfBytes, &ch);
}
}
*lexemePtr = BAREWORD;
return (end-start);
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
|
Changes to generic/tclPkg.c.
1 2 3 4 5 6 7 8 9 10 11 | /* * tclPkg.c -- * * This file implements package and version control for Tcl via the * "package" command and a few C APIs. * * Copyright (c) 1996 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* * tclPkg.c -- * * This file implements package and version control for Tcl via the * "package" command and a few C APIs. * * Copyright (c) 1996 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclPkg.c,v 1.9.4.6 2006/09/05 16:14:37 dgp Exp $ */ #include "tclInt.h" /* * Each invocation of the "package ifneeded" command creates a structure of * the following type, which is used to load the package into the interpreter |
| ︙ | ︙ | |||
309 310 311 312 313 314 315 | */ CONST char *versionToProvide = bestPtr->version; script = bestPtr->script; pkgPtr->clientData = (ClientData) versionToProvide; Tcl_Preserve((ClientData) script); Tcl_Preserve((ClientData) versionToProvide); | | | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
*/
CONST char *versionToProvide = bestPtr->version;
script = bestPtr->script;
pkgPtr->clientData = (ClientData) versionToProvide;
Tcl_Preserve((ClientData) script);
Tcl_Preserve((ClientData) versionToProvide);
code = Tcl_EvalEx(interp, script, -1, TCL_EVAL_GLOBAL);
Tcl_Release((ClientData) script);
pkgPtr = FindPackage(interp, name);
if (code == TCL_OK) {
Tcl_ResetResult(interp);
if (pkgPtr->version == NULL) {
code = TCL_ERROR;
|
| ︙ | ︙ | |||
388 389 390 391 392 393 394 |
Tcl_DStringAppendElement(&command, name);
Tcl_DStringAppend(&command, " ", 1);
Tcl_DStringAppend(&command, (version != NULL) ? version : "{}",
-1);
if (exact) {
Tcl_DStringAppend(&command, " -exact", 7);
}
| | > | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
Tcl_DStringAppendElement(&command, name);
Tcl_DStringAppend(&command, " ", 1);
Tcl_DStringAppend(&command, (version != NULL) ? version : "{}",
-1);
if (exact) {
Tcl_DStringAppend(&command, " -exact", 7);
}
code = Tcl_EvalEx(interp, Tcl_DStringValue(&command),
Tcl_DStringLength(&command), TCL_EVAL_GLOBAL);
Tcl_DStringFree(&command);
if ((code != TCL_OK) && (code != TCL_ERROR)) {
Tcl_Obj *codePtr = Tcl_NewIntObj(code);
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "bad return code: ",
Tcl_GetString(codePtr), NULL);
|
| ︙ | ︙ |
Changes to tests/expr-old.test.
| ︙ | ︙ | |||
9 10 11 12 13 14 15 | # Copyright (c) 1991-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. # Copyright (c) 1998-2000 by Scriptics Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# Copyright (c) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: expr-old.test,v 1.17.2.14 2006/09/05 16:14:38 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
namespace import -force ::tcltest::*
}
testConstraint testexprlong [llength [info commands testexprlong]]
|
| ︙ | ︙ | |||
1116 1117 1118 1119 1120 1121 1122 |
test expr-old-37.24 {Tcl_ExprDouble handles overflows that look like int} \
ieeeFloatingPoint&&testexprdouble {
testexprdouble 17976931348623165[string repeat 0 292]
} {This is a result: Inf}
test expr-old-37.25 {Tcl_ExprDouble and NaN} \
{ieeeFloatingPoint testexprdouble} {
list [catch {testexprdouble 0.0/0.0} result] $result
| | | 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 |
test expr-old-37.24 {Tcl_ExprDouble handles overflows that look like int} \
ieeeFloatingPoint&&testexprdouble {
testexprdouble 17976931348623165[string repeat 0 292]
} {This is a result: Inf}
test expr-old-37.25 {Tcl_ExprDouble and NaN} \
{ieeeFloatingPoint testexprdouble} {
list [catch {testexprdouble 0.0/0.0} result] $result
} {1 {domain error: argument not in valid range}}
test expr-old-38.1 {Verify Tcl_ExprString's basic operation} -constraints {testexprstring} -body {
list [testexprstring "1+4"] [testexprstring "2*3+4.2"] \
[catch {testexprstring "1+"} msg] $msg
} -match glob -result {5 10.2 1 *}
test expr-old-38.2 {Tcl_ExprString} testexprstring {
# This one is "magical"
|
| ︙ | ︙ |
Changes to tests/expr.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # Commands covered: expr # # This file contains a collection of tests for one or more of the Tcl # built-in commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # Copyright (c) 1996-1997 Sun Microsystems, Inc. # Copyright (c) 1998-2000 by Scriptics Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# Commands covered: expr
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1996-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: expr.test,v 1.18.2.22 2006/09/05 16:14:38 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
namespace import -force ::tcltest::*
}
testConstraint testmathfunctions [expr {
|
| ︙ | ︙ | |||
6300 6301 6302 6303 6304 6305 6306 |
test expr-39.24 {Tcl_ExprDoubleObj handles overflows that look like int} \
testexprdoubleobj&&ieeeFloatingPoint {
testexprdoubleobj 17976931348623165[string repeat 0 292]
} {This is a result: Inf}
test expr-39.25 {Tcl_ExprDoubleObj and NaN} \
{testexprdoubleobj ieeeFloatingPoint} {
list [catch {testexprdoubleobj 0.0/0.0} result] $result
| | | 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 |
test expr-39.24 {Tcl_ExprDoubleObj handles overflows that look like int} \
testexprdoubleobj&&ieeeFloatingPoint {
testexprdoubleobj 17976931348623165[string repeat 0 292]
} {This is a result: Inf}
test expr-39.25 {Tcl_ExprDoubleObj and NaN} \
{testexprdoubleobj ieeeFloatingPoint} {
list [catch {testexprdoubleobj 0.0/0.0} result] $result
} {1 {domain error: argument not in valid range}}
test expr-40.1 {large octal shift} {
expr 0100000000000000000000000000000000
} [expr 0x1000000000000000000000000]
test expr-40.2 {large octal shift} {
expr 0100000000000000000000000000000001
} [expr 0x1000000000000000000000001]
|
| ︙ | ︙ |
Changes to tests/main.test.
1 2 | # This file contains a collection of tests for generic/tclMain.c. # | | | 1 2 3 4 5 6 7 8 9 10 |
# This file contains a collection of tests for generic/tclMain.c.
#
# RCS: @(#) $Id: main.test,v 1.13.4.7 2006/09/05 16:14:38 dgp Exp $
if {[catch {package require tcltest 2.0.2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2.0.2 required."
return
}
namespace eval ::tcl::test::main {
|
| ︙ | ︙ | |||
542 543 544 545 546 547 548 |
rename exit _exit
proc exit code {
puts "In exit"
_exit $code
}
} rc]
} -body {
| | | | 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
rename exit _exit
proc exit code {
puts "In exit"
_exit $code
}
} rc]
} -body {
exec [interpreter] << {} \
-appinitprocsetrcfile $rc >& result
set f [open result]
read $f
} -cleanup {
close $f
file delete result
removeFile rc
} -result "application-specific initialization failed:\
\nExit MainLoop\nIn exit\neven 0\n"
test Tcl_Main-4.5 {
Tcl_Main: Bug 1481986
} -constraints {
exec Tcltest
} -setup {
set rc [makeFile {
|
| ︙ | ︙ |
Changes to unix/Makefile.in.
1 2 3 4 5 6 7 | # # This file is a Makefile for Tcl. If it has the name "Makefile.in" # then it is a template for a Makefile; to generate the actual Makefile, # run "./configure", which is a configuration script generated by the # "autoconf" program (constructs like "@foo@" will get replaced in the # actual Makefile. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # # This file is a Makefile for Tcl. If it has the name "Makefile.in" # then it is a template for a Makefile; to generate the actual Makefile, # run "./configure", which is a configuration script generated by the # "autoconf" program (constructs like "@foo@" will get replaced in the # actual Makefile. # # RCS: @(#) $Id: Makefile.in,v 1.127.2.26 2006/09/05 16:14:38 dgp Exp $ VERSION = @TCL_VERSION@ MAJOR_VERSION = @TCL_MAJOR_VERSION@ MINOR_VERSION = @TCL_MINOR_VERSION@ PATCH_LEVEL = @TCL_PATCH_LEVEL@ #---------------------------------------------------------------- |
| ︙ | ︙ | |||
637 638 639 640 641 642 643 644 645 646 |
# This target can be used to run tclsh inside ddd
ddd: tclsh
@echo "set env @LD_LIBRARY_PATH_VAR@=`pwd`:$${@LD_LIBRARY_PATH_VAR@}" > gdb.run
@echo "set env TCL_LIBRARY=${TCL_BUILDTIME_LIBRARY}" >> gdb.run
$(DDD) -command=gdb.run ./tclsh
rm gdb.run
valgrind: tclsh tcltest
@LD_LIBRARY_PATH_VAR@=`pwd`:$${@LD_LIBRARY_PATH_VAR@}; export @LD_LIBRARY_PATH_VAR@; \
TCL_LIBRARY="${TCL_BUILDTIME_LIBRARY}"; export TCL_LIBRARY; \
| > > | > > > > > | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
# This target can be used to run tclsh inside ddd
ddd: tclsh
@echo "set env @LD_LIBRARY_PATH_VAR@=`pwd`:$${@LD_LIBRARY_PATH_VAR@}" > gdb.run
@echo "set env TCL_LIBRARY=${TCL_BUILDTIME_LIBRARY}" >> gdb.run
$(DDD) -command=gdb.run ./tclsh
rm gdb.run
VALGRINDARGS=--tool=memcheck --num-callers=8 --leak-resolution=high --leak-check=yes --show-reachable=yes -v
valgrind: tclsh tcltest
@LD_LIBRARY_PATH_VAR@=`pwd`:$${@LD_LIBRARY_PATH_VAR@}; export @LD_LIBRARY_PATH_VAR@; \
TCL_LIBRARY="${TCL_BUILDTIME_LIBRARY}"; export TCL_LIBRARY; \
valgrind $(VALGRINDARGS) ./tcltest $(TOP_DIR)/tests/all.tcl -singleproc 1 $(TESTFLAGS)
valgrindshell: tclsh
@LD_LIBRARY_PATH_VAR@=`pwd`:$${@LD_LIBRARY_PATH_VAR@}; export @LD_LIBRARY_PATH_VAR@; \
TCL_LIBRARY="${TCL_BUILDTIME_LIBRARY}"; export TCL_LIBRARY; \
valgrind $(VALGRINDARGS) ./tclsh $(SCRIPT)
# The following target outputs the name of the top-level source directory
# for Tcl (it is used by Tk's configure script, for example). The
# .NO_PARALLEL line is needed to avoid problems under Sun's "pmake".
# Note: this target is now obsolete (use the autoconf variable
# TCL_SRC_DIR from tclConfig.sh instead).
|
| ︙ | ︙ |
Changes to win/tclWinChan.c.
1 2 3 4 5 6 7 8 9 10 11 | /* * tclWinChan.c * * Channel drivers for Windows channels based on files, command pipes and * TCP sockets. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* * tclWinChan.c * * Channel drivers for Windows channels based on files, command pipes and * TCP sockets. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclWinChan.c,v 1.30.4.13 2006/09/05 16:14:38 dgp Exp $ */ #include "tclWinInt.h" #include "tclIO.h" /* * State flags used in the info structures below. |
| ︙ | ︙ | |||
92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
Tcl_WideInt offset, int mode, int *errorCode);
static void FileSetupProc(ClientData clientData, int flags);
static void FileWatchProc(ClientData instanceData, int mask);
static void FileThreadActionProc(ClientData instanceData,
int action);
static int FileTruncateProc(ClientData instanceData,
Tcl_WideInt length);
/*
* This structure describes the channel type structure for file based IO.
*/
static Tcl_ChannelType fileChannelType = {
"file", /* Type name. */
| > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
Tcl_WideInt offset, int mode, int *errorCode);
static void FileSetupProc(ClientData clientData, int flags);
static void FileWatchProc(ClientData instanceData, int mask);
static void FileThreadActionProc(ClientData instanceData,
int action);
static int FileTruncateProc(ClientData instanceData,
Tcl_WideInt length);
static DWORD FileGetType(HANDLE handle);
/*
* This structure describes the channel type structure for file based IO.
*/
static Tcl_ChannelType fileChannelType = {
"file", /* Type name. */
|
| ︙ | ︙ | |||
846 847 848 849 850 851 852 |
Tcl_Obj *pathPtr, /* Name of file to open. */
int mode, /* POSIX mode. */
int permissions) /* If the open involves creating a file, with
* what modes to create it? */
{
Tcl_Channel channel = 0;
int channelPermissions = 0;
| | | 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
Tcl_Obj *pathPtr, /* Name of file to open. */
int mode, /* POSIX mode. */
int permissions) /* If the open involves creating a file, with
* what modes to create it? */
{
Tcl_Channel channel = 0;
int channelPermissions = 0;
DWORD accessMode = 0, createMode, shareMode, flags;
CONST TCHAR *nativeName;
HANDLE handle;
char channelName[16 + TCL_INTEGER_SPACE];
TclFile readFile = NULL, writeFile = NULL;
nativeName = (TCHAR*) Tcl_FSGetNativePath(pathPtr);
if (nativeName == NULL) {
|
| ︙ | ︙ | |||
944 945 946 947 948 949 950 |
if (interp != (Tcl_Interp *) NULL) {
Tcl_AppendResult(interp, "couldn't open \"", TclGetString(pathPtr),
"\": ", Tcl_PosixError(interp), NULL);
}
return NULL;
}
| < < < < < < < < < < < < < < < < < < < < < | | 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 |
if (interp != (Tcl_Interp *) NULL) {
Tcl_AppendResult(interp, "couldn't open \"", TclGetString(pathPtr),
"\": ", Tcl_PosixError(interp), NULL);
}
return NULL;
}
channel = NULL;
switch (FileGetType(handle)) {
case FILE_TYPE_SERIAL:
/*
* Reopen channel for OVERLAPPED operation. Normally this shouldn't
* fail, because the channel exists.
*/
handle = TclWinSerialReopen(handle, nativeName, accessMode);
|
| ︙ | ︙ | |||
1051 1052 1053 1054 1055 1056 1057 |
#ifdef HAVE_NO_SEH
EXCEPTION_REGISTRATION registration;
#endif
char channelName[16 + TCL_INTEGER_SPACE];
Tcl_Channel channel = NULL;
HANDLE handle = (HANDLE) rawHandle;
HANDLE dupedHandle;
| < < < < < < < < < < < < < < < < < < < < < < < < < < | | 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 |
#ifdef HAVE_NO_SEH
EXCEPTION_REGISTRATION registration;
#endif
char channelName[16 + TCL_INTEGER_SPACE];
Tcl_Channel channel = NULL;
HANDLE handle = (HANDLE) rawHandle;
HANDLE dupedHandle;
TclFile readFile = NULL, writeFile = NULL;
BOOL result;
if (mode == 0) {
return NULL;
}
switch (FileGetType(handle)) {
case FILE_TYPE_SERIAL:
channel = TclWinOpenSerialChannel(handle, channelName, mode);
break;
case FILE_TYPE_CONSOLE:
channel = TclWinOpenConsoleChannel(handle, channelName, mode);
break;
case FILE_TYPE_PIPE:
|
| ︙ | ︙ | |||
1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 |
*/
if (!removed) {
Tcl_Panic("file info ptr not on thread channel list");
}
}
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 |
*/
if (!removed) {
Tcl_Panic("file info ptr not on thread channel list");
}
}
}
/*
*----------------------------------------------------------------------
*
* FileGetType --
*
* Given a file handle, return its type
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
DWORD
FileGetType(handle)
HANDLE handle; /* Opened file handle */
{
DWORD type;
type = GetFileType(handle);
/*
* If the file is a character device, we need to try to figure out
* whether it is a serial port, a console, or something else. We
* test for the console case first because this is more common.
*/
if ((type == FILE_TYPE_CHAR)
|| ((type == FILE_TYPE_UNKNOWN) && !GetLastError())) {
DWORD consoleParams;
if (GetConsoleMode(handle, &consoleParams)) {
type = FILE_TYPE_CONSOLE;
} else {
DCB dcb;
dcb.DCBlength = sizeof(DCB);
if (GetCommState(handle, &dcb)) {
type = FILE_TYPE_SERIAL;
}
}
}
return type;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
|