Tcl Source Code

Check-in [73e7e3f694]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:merge 8.6
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | sebres-8-6-clock-speedup-cr2
Files: files | file ages | folders
SHA3-256:73e7e3f6942255510242d7c9c6200ca891adbe0666150509976ab1f3842ad0c3
User & Date: sebres 2019-03-13 00:44:22
Context
2019-03-13
00:44
merge 8.6 Leaf check-in: 73e7e3f694 user: sebres tags: sebres-8-6-clock-speedup-cr2
00:33
integrate branch clock-astronomical-jdn: merge pull request #16 from sebres/astronomical-jdn (https:... check-in: 39a21f437a user: sebres tags: sebres-8-6-clock-speedup-cr2
2019-03-08
14:46
[39fed4dae5] Make sure return value from Tcl_PkgRequire*() survives long enough for caller to use it... check-in: 6bf2a6d132 user: dgp tags: core-8-6-branch
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to generic/tclCmdMZ.c.

  2388   2388   	 * to be replaced.
  2389   2389   	 */
  2390   2390   	Tcl_SetObjResult(interp, objv[1]);
  2391   2391       } else {
  2392   2392   	Tcl_Obj *resultPtr;
  2393   2393   
  2394   2394   	/*
  2395         -	 * We are re-fetching in case the string argument is same value as 
         2395  +	 * We are re-fetching in case the string argument is same value as
  2396   2396   	 * an index argument, and shimmering cost us our ustring.
  2397   2397   	 */
  2398   2398   
  2399   2399   	ustring = Tcl_GetUnicodeFromObj(objv[1], &length);
  2400   2400   	end = length-1;
  2401   2401   
  2402   2402   	if (first < 0) {
................................................................................
  4270   4270   
  4271   4271   /*
  4272   4272    *----------------------------------------------------------------------
  4273   4273    *
  4274   4274    * Tcl_TimeRateObjCmd --
  4275   4275    *
  4276   4276    *	This object-based procedure is invoked to process the "timerate" Tcl
  4277         - *	command. 
  4278         - *	This is similar to command "time", except the execution limited by 
         4277  + *	command.
         4278  + *	This is similar to command "time", except the execution limited by
  4279   4279    *	given time (in milliseconds) instead of repetition count.
  4280   4280    *
  4281   4281    * Example:
  4282   4282    *	timerate {after 5} 1000 ; # equivalent for `time {after 5} [expr 1000/5]`
  4283   4283    *
  4284   4284    * Results:
  4285   4285    *	A standard Tcl object result.
................................................................................
  4293   4293   int
  4294   4294   Tcl_TimeRateObjCmd(
  4295   4295       ClientData dummy,		/* Not used. */
  4296   4296       Tcl_Interp *interp,		/* Current interpreter. */
  4297   4297       int objc,			/* Number of arguments. */
  4298   4298       Tcl_Obj *const objv[])	/* Argument objects. */
  4299   4299   {
  4300         -    static 
  4301         -    double measureOverhead = 0; /* global measure-overhead */
         4300  +    static double measureOverhead = 0; /* global measure-overhead */
  4302   4301       double overhead = -1;	/* given measure-overhead */
  4303   4302       register Tcl_Obj *objPtr;
  4304   4303       register int result, i;
  4305   4304       Tcl_Obj *calibrate = NULL, *direct = NULL;
  4306   4305       Tcl_WideUInt count = 0;	/* Holds repetition count */
  4307   4306       Tcl_WideInt  maxms  = WIDE_MIN;
  4308   4307   				/* Maximal running time (in milliseconds) */
................................................................................
  4382   4381       if (calibrate) {
  4383   4382   
  4384   4383   	/* if no time specified for the calibration */
  4385   4384   	if (maxms == WIDE_MIN) {
  4386   4385   	    Tcl_Obj *clobjv[6];
  4387   4386   	    Tcl_WideInt maxCalTime = 5000;
  4388   4387   	    double lastMeasureOverhead = measureOverhead;
  4389         -	    
  4390         -	    clobjv[0] = objv[0]; 
         4388  +
         4389  +	    clobjv[0] = objv[0];
  4391   4390   	    i = 1;
  4392   4391   	    if (direct) {
  4393   4392   	    	clobjv[i++] = direct;
  4394   4393   	    }
  4395         -	    clobjv[i++] = objPtr; 
         4394  +	    clobjv[i++] = objPtr;
  4396   4395   
  4397   4396   	    /* reset last measurement overhead */
  4398   4397   	    measureOverhead = (double)0;
  4399   4398   
  4400   4399   	    /* self-call with 100 milliseconds to warm-up,
  4401   4400   	     * before entering the calibration cycle */
  4402   4401   	    TclNewLongObj(clobjv[i], 100);
................................................................................
  4405   4404   	    Tcl_DecrRefCount(clobjv[i]);
  4406   4405   	    if (result != TCL_OK) {
  4407   4406   		return result;
  4408   4407   	    }
  4409   4408   
  4410   4409   	    i--;
  4411   4410   	    clobjv[i++] = calibrate;
  4412         -	    clobjv[i++] = objPtr; 
         4411  +	    clobjv[i++] = objPtr;
  4413   4412   
  4414   4413   	    /* set last measurement overhead to max */
  4415   4414   	    measureOverhead = (double)UWIDE_MAX;
  4416   4415   
  4417   4416   	    /* calibration cycle until it'll be preciser */
  4418   4417   	    maxms = -1000;
  4419   4418   	    do {
................................................................................
  4506   4505   		goto done;
  4507   4506   	    }
  4508   4507   	    /* force stop immediately */
  4509   4508   	    threshold = 1;
  4510   4509   	    maxcnt = 0;
  4511   4510   	    result = TCL_OK;
  4512   4511   	}
  4513         -	
         4512  +
  4514   4513   	/* don't check time up to threshold */
  4515   4514   	if (--threshold > 0) continue;
  4516   4515   
  4517   4516   	/* check stop time reached, estimate new threshold */
  4518   4517       #ifdef TCL_WIDE_CLICKS
  4519   4518   	middle = TclpGetWideClicks();
  4520   4519       #else
................................................................................
  4576   4575   
  4577   4576   	/* if not calibrate */
  4578   4577   	if (!calibrate) {
  4579   4578   	    /* minimize influence of measurement overhead */
  4580   4579   	    if (overhead > 0) {
  4581   4580   		/* estimate the time of overhead (microsecs) */
  4582   4581   		Tcl_WideUInt curOverhead = overhead * count;
  4583         -		if (middle > curOverhead) {
         4582  +		if ((Tcl_WideUInt)middle > curOverhead) {
  4584   4583   		    middle -= curOverhead;
  4585   4584   		} else {
  4586   4585   		    middle = 0;
  4587   4586   		}
  4588   4587   	    }
  4589   4588   	} else {
  4590   4589   	    /* calibration - obtaining new measurement overhead */
................................................................................
  4605   4604   	    if (val < 1000)  { fmt = "%.3f"; } else
  4606   4605   	    if (val < 10000) { fmt = "%.2f"; } else
  4607   4606   			     { fmt = "%.1f"; };
  4608   4607   	    objs[0] = Tcl_ObjPrintf(fmt, ((double)middle)/count);
  4609   4608   	}
  4610   4609   
  4611   4610   	objs[2] = Tcl_NewWideIntObj(count); /* iterations */
  4612         -	
         4611  +
  4613   4612   	/* calculate speed as rate (count) per sec */
  4614   4613   	if (!middle) middle++; /* +1 ms, just to avoid divide by zero */
  4615   4614   	if (count < (WIDE_MAX / 1000000)) {
  4616   4615   	    val = (count * 1000000) / middle;
  4617   4616   	    if (val < 100000) {
  4618   4617   		if (val < 100)	{ fmt = "%.3f"; } else
  4619   4618   		if (val < 1000) { fmt = "%.2f"; } else

Changes to generic/tclEnv.c.

   136    136   		 */
   137    137   
   138    138   		Tcl_DStringFree(&envString);
   139    139   		continue;
   140    140   	    }
   141    141   	    p2++;
   142    142   	    p2[-1] = '\0';
          143  +#if defined(_WIN32)
          144  +	    /*
          145  +	     * Enforce PATH and COMSPEC to be all uppercase. This eliminates
          146  +	     * additional trace logic otherwise required in init.tcl.
          147  +	     */
          148  +
          149  +	    if (strcasecmp(p1, "PATH") == 0) {
          150  +		p1 = "PATH";
          151  +	    } else if (strcasecmp(p1, "COMSPEC") == 0) {
          152  +		p1 = "COMSPEC";
          153  +	    }
          154  +#endif
   143    155   	    obj1 = Tcl_NewStringObj(p1, -1);
   144    156   	    obj2 = Tcl_NewStringObj(p2, -1);
   145    157   	    Tcl_DStringFree(&envString);
   146    158   
   147    159   	    Tcl_IncrRefCount(obj1);
   148    160   	    Tcl_IncrRefCount(obj2);
   149    161   	    Tcl_ObjSetVar2(interp, varNamePtr, obj1, obj2, TCL_GLOBAL_ONLY);

Changes to generic/tclPkg.c.

    36     36    * For each package that is known in any way to an interpreter, there is one
    37     37    * record of the following type. These records are stored in the
    38     38    * "packageTable" hash table in the interpreter, keyed by package name such as
    39     39    * "Tk" (no version number).
    40     40    */
    41     41   
    42     42   typedef struct Package {
    43         -    char *version;		/* Version that has been supplied in this
    44         -				 * interpreter via "package provide"
    45         -				 * (malloc'ed). NULL means the package doesn't
    46         -				 * exist in this interpreter yet. */
           43  +    Tcl_Obj *version;
    47     44       PkgAvail *availPtr;		/* First in list of all available versions of
    48     45   				 * this package. */
    49     46       const void *clientData;	/* Client data. */
    50     47   } Package;
    51     48   
    52     49   typedef struct Require {
    53     50       void * clientDataPtr;
................................................................................
   146    143   {
   147    144       Package *pkgPtr;
   148    145       char *pvi, *vi;
   149    146       int res;
   150    147   
   151    148       pkgPtr = FindPackage(interp, name);
   152    149       if (pkgPtr->version == NULL) {
   153         -	DupString(pkgPtr->version, version);
          150  +	pkgPtr->version = Tcl_NewStringObj(version, -1);
          151  +	Tcl_IncrRefCount(pkgPtr->version);
   154    152   	pkgPtr->clientData = clientData;
   155    153   	return TCL_OK;
   156    154       }
   157    155   
   158         -    if (CheckVersionAndConvert(interp, pkgPtr->version, &pvi,
          156  +    if (CheckVersionAndConvert(interp, Tcl_GetString(pkgPtr->version), &pvi,
   159    157   	    NULL) != TCL_OK) {
   160    158   	return TCL_ERROR;
   161    159       } else if (CheckVersionAndConvert(interp, version, &vi, NULL) != TCL_OK) {
   162    160   	ckfree(pvi);
   163    161   	return TCL_ERROR;
   164    162       }
   165    163   
................................................................................
   171    169   	if (clientData != NULL) {
   172    170   	    pkgPtr->clientData = clientData;
   173    171   	}
   174    172   	return TCL_OK;
   175    173       }
   176    174       Tcl_SetObjResult(interp, Tcl_ObjPrintf(
   177    175   	    "conflicting versions provided for package \"%s\": %s, then %s",
   178         -	    name, pkgPtr->version, version));
          176  +	    name, Tcl_GetString(pkgPtr->version), version));
   179    177       Tcl_SetErrorCode(interp, "TCL", "PACKAGE", "VERSIONCONFLICT", NULL);
   180    178       return TCL_ERROR;
   181    179   }
   182    180   
   183    181   /*
   184    182    *----------------------------------------------------------------------
   185    183    *
................................................................................
   314    312   
   315    313       /*
   316    314        * Translate between old and new API, and defer to the new function.
   317    315        */
   318    316   
   319    317       if (version == NULL) {
   320    318   	if (Tcl_PkgRequireProc(interp, name, 0, NULL, clientDataPtr) == TCL_OK) {
   321         -	    result = Tcl_GetStringResult(interp);
          319  +	    result = Tcl_GetString(Tcl_GetObjResult(interp));
   322    320   	    Tcl_ResetResult(interp);
   323    321   	}
   324    322       } else {
   325    323   	if (exact && TCL_OK
   326    324   		!= CheckVersionAndConvert(interp, version, NULL, NULL)) {
   327    325   	    return NULL;
   328    326   	}
   329    327   	ov = Tcl_NewStringObj(version, -1);
   330    328   	if (exact) {
   331    329   	    Tcl_AppendStringsToObj(ov, "-", version, NULL);
   332    330   	}
   333    331   	Tcl_IncrRefCount(ov);
   334    332   	if (Tcl_PkgRequireProc(interp, name, 1, &ov, clientDataPtr) == TCL_OK) {
   335         -	    result = Tcl_GetStringResult(interp);
          333  +	    result = Tcl_GetString(Tcl_GetObjResult(interp));
   336    334   	    Tcl_ResetResult(interp);
   337    335   	}
   338    336   	TclDecrRefCount(ov);
   339    337       }
   340    338       return result;
   341    339   }
   342    340   
................................................................................
   470    468       }
   471    469   
   472    470       /*
   473    471        * Ensure that the provided version meets the current requirements.
   474    472        */
   475    473   
   476    474       if (reqc != 0) {
   477         -	CheckVersionAndConvert(interp, reqPtr->pkgPtr->version, &pkgVersionI, NULL);
          475  +	CheckVersionAndConvert(interp, Tcl_GetString(reqPtr->pkgPtr->version),
          476  +		&pkgVersionI, NULL);
   478    477   	satisfies = SomeRequirementSatisfied(pkgVersionI, reqc, reqv);
   479    478   
   480    479   	ckfree(pkgVersionI);
   481    480   
   482    481   	if (!satisfies) {
   483    482   	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
   484    483   		    "version conflict for package \"%s\": have %s, need",
   485         -		    name, reqPtr->pkgPtr->version));
          484  +		    name, Tcl_GetString(reqPtr->pkgPtr->version)));
   486    485   	    Tcl_SetErrorCode(interp, "TCL", "PACKAGE", "VERSIONCONFLICT",
   487    486   		    NULL);
   488    487   	    AddRequirementsToResult(interp, reqc, reqv);
   489    488   	    return TCL_ERROR;
   490    489   	}
   491    490       }
   492    491   
   493    492       if (clientDataPtr) {
   494    493   	const void **ptr = (const void **) clientDataPtr;
   495    494   
   496    495   	*ptr = reqPtr->pkgPtr->clientData;
   497    496       }
   498         -    Tcl_SetObjResult(interp, Tcl_NewStringObj(reqPtr->pkgPtr->version, -1));
          497  +    Tcl_SetObjResult(interp, reqPtr->pkgPtr->version);
   499    498       return TCL_OK;
   500    499   }
   501    500   
   502    501   static int
   503    502   PkgRequireCoreCleanup(ClientData data[], Tcl_Interp *interp, int result) {
   504    503       ckfree(data[0]);
   505    504       return result;
................................................................................
   690    689   		    " no version of package %s provided",
   691    690   		    name, versionToProvide, name));
   692    691   	    Tcl_SetErrorCode(interp, "TCL", "PACKAGE", "UNPROVIDED",
   693    692   		    NULL);
   694    693   	} else {
   695    694   	    char *pvi, *vi;
   696    695   
   697         -	    if (CheckVersionAndConvert(interp, reqPtr->pkgPtr->version, &pvi,
   698         -		    NULL) != TCL_OK) {
          696  +	    if (TCL_OK != CheckVersionAndConvert(interp,
          697  +		    Tcl_GetString(reqPtr->pkgPtr->version), &pvi, NULL)) {
   699    698   		result = TCL_ERROR;
   700    699   	    } else if (CheckVersionAndConvert(interp,
   701    700   		    versionToProvide, &vi, NULL) != TCL_OK) {
   702    701   		ckfree(pvi);
   703    702   		result = TCL_ERROR;
   704    703   	    } else {
   705    704   		int res = CompareVersions(pvi, vi, NULL);
................................................................................
   708    707   		ckfree(vi);
   709    708   		if (res != 0) {
   710    709   		    result = TCL_ERROR;
   711    710   		    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
   712    711   			    "attempt to provide package %s %s failed:"
   713    712   			    " package %s %s provided instead",
   714    713   			    name, versionToProvide,
   715         -			    name, reqPtr->pkgPtr->version));
          714  +			    name, Tcl_GetString(reqPtr->pkgPtr->version)));
   716    715   		    Tcl_SetErrorCode(interp, "TCL", "PACKAGE",
   717    716   			    "WRONGPROVIDE", NULL);
   718    717   		}
   719    718   	    }
   720    719   	}
   721    720       } else if (result != TCL_ERROR) {
   722    721   	Tcl_Obj *codePtr = Tcl_NewIntObj(result);
................................................................................
   746    745   	 * This is consistent with our returning NULL. If we're not
   747    746   	 * willing to tell our caller we got a particular version, we
   748    747   	 * shouldn't store that version for telling future callers
   749    748   	 * either.
   750    749   	 */
   751    750   
   752    751   	if (reqPtr->pkgPtr->version != NULL) {
   753         -	    ckfree(reqPtr->pkgPtr->version);
          752  +	    Tcl_DecrRefCount(reqPtr->pkgPtr->version);
   754    753   	    reqPtr->pkgPtr->version = NULL;
   755    754   	}
   756    755   	reqPtr->pkgPtr->clientData = NULL;
   757    756   	return result;
   758    757       }
   759    758   
   760    759       Tcl_NRAddCallback(interp, data[3], reqPtr, INT2PTR(reqc), (void *)reqv, NULL);
................................................................................
   922    921   	    hPtr = Tcl_FindHashEntry(&iPtr->packageTable, keyString);
   923    922   	    if (hPtr == NULL) {
   924    923   		continue;
   925    924   	    }
   926    925   	    pkgPtr = Tcl_GetHashValue(hPtr);
   927    926   	    Tcl_DeleteHashEntry(hPtr);
   928    927   	    if (pkgPtr->version != NULL) {
   929         -		ckfree(pkgPtr->version);
          928  +		Tcl_DecrRefCount(pkgPtr->version);
   930    929   	    }
   931    930   	    while (pkgPtr->availPtr != NULL) {
   932    931   		availPtr = pkgPtr->availPtr;
   933    932   		pkgPtr->availPtr = availPtr->nextPtr;
   934    933   		Tcl_EventuallyFree(availPtr->version, TCL_DYNAMIC);
   935    934   		Tcl_EventuallyFree(availPtr->script, TCL_DYNAMIC);
   936    935   		ckfree(availPtr);
................................................................................
  1080   1079   	}
  1081   1080   	argv2 = TclGetString(objv[2]);
  1082   1081   	if (objc == 3) {
  1083   1082   	    hPtr = Tcl_FindHashEntry(&iPtr->packageTable, argv2);
  1084   1083   	    if (hPtr != NULL) {
  1085   1084   		pkgPtr = Tcl_GetHashValue(hPtr);
  1086   1085   		if (pkgPtr->version != NULL) {
  1087         -		    Tcl_SetObjResult(interp,
  1088         -			    Tcl_NewStringObj(pkgPtr->version, -1));
         1086  +		    Tcl_SetObjResult(interp, pkgPtr->version);
  1089   1087   		}
  1090   1088   	    }
  1091   1089   	    return TCL_OK;
  1092   1090   	}
  1093   1091   	argv3 = TclGetString(objv[3]);
  1094   1092   	if (CheckVersionAndConvert(interp, argv3, NULL, NULL) != TCL_OK) {
  1095   1093   	    return TCL_ERROR;
................................................................................
  1374   1372       Tcl_HashEntry *hPtr;
  1375   1373       PkgAvail *availPtr;
  1376   1374   
  1377   1375       for (hPtr = Tcl_FirstHashEntry(&iPtr->packageTable, &search);
  1378   1376   	    hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
  1379   1377   	pkgPtr = Tcl_GetHashValue(hPtr);
  1380   1378   	if (pkgPtr->version != NULL) {
  1381         -	    ckfree(pkgPtr->version);
         1379  +	    Tcl_DecrRefCount(pkgPtr->version);
  1382   1380   	}
  1383   1381   	while (pkgPtr->availPtr != NULL) {
  1384   1382   	    availPtr = pkgPtr->availPtr;
  1385   1383   	    pkgPtr->availPtr = availPtr->nextPtr;
  1386   1384   	    Tcl_EventuallyFree(availPtr->version, TCL_DYNAMIC);
  1387   1385   	    Tcl_EventuallyFree(availPtr->script, TCL_DYNAMIC);
  1388   1386   	    ckfree(availPtr);

Changes to generic/tclTestProcBodyObj.c.

    17     17   #include "tclInt.h"
    18     18   
    19     19   /*
    20     20    * name and version of this package
    21     21    */
    22     22   
    23     23   static const char packageName[] = "procbodytest";
    24         -static const char packageVersion[] = "1.0";
           24  +static const char packageVersion[] = "1.1";
    25     25   
    26     26   /*
    27     27    * Name of the commands exported by this package
    28     28    */
    29     29   
    30     30   static const char procCommand[] = "proc";
           31  +static const char checkCommand[] = "check";
    31     32   
    32     33   /*
    33     34    * this struct describes an entry in the table of command names and command
    34     35    * procs
    35     36    */
    36     37   
    37     38   typedef struct CmdTable {
................................................................................
    41     42   } CmdTable;
    42     43   
    43     44   /*
    44     45    * Declarations for functions defined in this file.
    45     46    */
    46     47   
    47     48   static int	ProcBodyTestProcObjCmd(ClientData dummy,
           49  +			Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
           50  +static int	ProcBodyTestCheckObjCmd(ClientData dummy,
    48     51   			Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
    49     52   static int	ProcBodyTestInitInternal(Tcl_Interp *interp, int isSafe);
    50     53   static int	RegisterCommand(Tcl_Interp* interp,
    51     54   			const char *namespace, const CmdTable *cmdTablePtr);
    52     55   
    53     56   /*
    54     57    * List of commands to create when the package is loaded; must go after the
    55     58    * declarations of the enable command procedure.
    56     59    */
    57     60   
    58     61   static const CmdTable commands[] = {
    59     62       { procCommand,	ProcBodyTestProcObjCmd,	1 },
           63  +    { checkCommand,	ProcBodyTestCheckObjCmd,	1 },
    60     64       { 0, 0, 0 }
    61     65   };
    62     66   
    63     67   static const CmdTable safeCommands[] = {
    64     68       { procCommand,	ProcBodyTestProcObjCmd,	1 },
           69  +    { checkCommand,	ProcBodyTestCheckObjCmd,	1 },
    65     70       { 0, 0, 0 }
    66     71   };
    67     72   
    68     73   /*
    69     74    *----------------------------------------------------------------------
    70     75    *
    71     76    * Procbodytest_Init --
................................................................................
   295    300       myobjv[4] = NULL;
   296    301   
   297    302       result = Tcl_ProcObjCmd(NULL, interp, objc, myobjv);
   298    303       Tcl_DecrRefCount(bodyObjPtr);
   299    304   
   300    305       return result;
   301    306   }
          307  +
          308  +/*
          309  + *----------------------------------------------------------------------
          310  + *
          311  + * ProcBodyTestCheckObjCmd --
          312  + *
          313  + *  Implements the "procbodytest::check" command. Here is the command
          314  + *  description:
          315  + *	procbodytest::check
          316  + *
          317  + *  Performs an internal check that the Tcl_PkgPresent() command returns
          318  + *  the same version number as was registered when the procbodytest package
          319  + *  was provided.  Places a boolean in the interp result indicating the
          320  + *  test outcome.
          321  + *
          322  + * Results:
          323  + *  Returns a standard Tcl code.
          324  + *
          325  + *----------------------------------------------------------------------
          326  + */
          327  +
          328  +static int
          329  +ProcBodyTestCheckObjCmd(
          330  +    ClientData dummy,		/* context; not used */
          331  +    Tcl_Interp *interp,		/* the current interpreter */
          332  +    int objc,			/* argument count */
          333  +    Tcl_Obj *const objv[])	/* arguments */
          334  +{
          335  +    const char *version;
          336  +
          337  +    if (objc != 1) {
          338  +	Tcl_WrongNumArgs(interp, 1, objv, "");
          339  +	return TCL_ERROR;
          340  +    }
          341  +
          342  +    version = Tcl_PkgPresent(interp, packageName, packageVersion, 1);
          343  +    Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
          344  +	    strcmp(version, packageVersion) == 0));
          345  +    return TCL_OK;
          346  +}
   302    347   
   303    348   /*
   304    349    * Local Variables:
   305    350    * mode: c
   306    351    * c-basic-offset: 4
   307    352    * fill-column: 78
   308    353    * End:
   309    354    */

Changes to tests-perf/timer-event.perf.tcl.

    72     72       setup {set le $i; incr i; list $le .. 1; # cancel up to $howmuch events}
    73     73       {after cancel $ev([incr i -1]); if {$i <= 1} break}
    74     74       cleanup {update; unset -nocomplain ev}
    75     75   
    76     76       # cancel forwards "after 0" / $howmuch timer-events in queue:
    77     77       setup {set i 0; timerate {set ev([incr i]) [after 0 {set foo bar}]} {*}$reptime}
    78     78       setup {set le $i; set i 0; list 1 .. $le; # cancel up to $howmuch events}
    79         -    {after cancel $ev([incr i]); if {$i >= $howmuch} break}
           79  +    {after cancel $ev([incr i]); if {$i >= $le} break}
    80     80       cleanup {update; unset -nocomplain ev}
    81     81       # cancel backwards "after 0" / $howmuch timer-events in queue:
    82     82       setup {set i 0; timerate {set ev([incr i]) [after 0 {set foo bar}]} {*}$reptime}
    83     83       setup {set le $i; incr i; list $le .. 1; # cancel up to $howmuch events}
    84     84       {after cancel $ev([incr i -1]); if {$i <= 1} break}
    85     85       cleanup {update; unset -nocomplain ev}
    86     86       

Changes to tests/proc.test.

   317    317   	set end [getbytes]
   318    318       }
   319    319       set leakedBytes [expr {$end - $tmp}]
   320    320   } -cleanup {
   321    321       rename getbytes {}
   322    322       unset -nocomplain end i tmp leakedBytes
   323    323   } -result 0
          324  +test proc-4.9 {[39fed4dae5] Valid Tcl_PkgPresent return} procbodytest {
          325  +    procbodytest::check
          326  +} 1
   324    327   
   325    328   test proc-5.1 {Bytecompiling noop; test for correct argument substitution} -body {
   326    329       proc p args {} ; # this will be bytecompiled into t
   327    330       proc t {} {
   328    331   	set res {}
   329    332   	set a 0
   330    333   	set b 0

Changes to unix/tclUnixTime.c.

   244    244   }
   245    245   
   246    246   /*
   247    247    *----------------------------------------------------------------------
   248    248    *
   249    249    * TclpWideClickInMicrosec --
   250    250    *
   251         - *	This procedure return scale to convert click values from the 
          251  + *	This procedure return scale to convert click values from the
   252    252    *	TclpGetWideClicks native resolution to microsecond resolution
   253    253    *	and back.
   254    254    *
   255    255    * Results:
   256    256    * 	1 click in microseconds as double.
   257    257    *
   258    258    * Side effects:

Changes to win/makefile.vc.

   377    377   release:    setup $(TCLSH) $(TCLSTUBLIB) dlls pkgs
   378    378   core:	    setup $(TCLLIB) $(TCLSTUBLIB)
   379    379   shell:	    setup $(TCLSH)
   380    380   dlls:	    setup $(TCLREGLIB) $(TCLDDELIB)
   381    381   all:	    setup $(TCLSH) $(TCLSTUBLIB) dlls $(CAT32) pkgs
   382    382   tcltest:    setup $(TCLTEST) dlls $(CAT32)
   383    383   install:    install-binaries install-libraries install-docs install-pkgs
          384  +!if $(SYMBOLS)
          385  +install:    install-pdbs
          386  +!endif
   384    387   setup:      default-setup
   385    388   
   386    389   test: test-core test-pkgs
   387    390   test-core: setup $(TCLTEST) dlls $(CAT32)
   388    391   	set TCL_LIBRARY=$(ROOT:\=/)/library
   389    392   	$(DEBUGGER) $(TCLTEST) "$(ROOT:\=/)/tests/all.tcl" $(TESTFLAGS) -loadfile <<
   390    393   		package ifneeded dde 1.4.1 [list load "$(TCLDDELIB:\=/)" dde]
................................................................................
   911    914   
   912    915   install-msgs:
   913    916   	@echo Installing message catalogs
   914    917   	@set TCL_LIBRARY=$(ROOT:\=/)/library
   915    918   	@$(TCLSH_NATIVE) "$(ROOT:\=/)/tools/installData.tcl" \
   916    919   	    "$(ROOT:\=/)/library/msgs" "$(SCRIPT_INSTALL_DIR)/msgs"
   917    920   
          921  +install-pdbs:
          922  +	@echo Installing debug symbols
          923  +	@$(CPY) "$(OUT_DIR)\*.pdb" "$(BIN_INSTALL_DIR)\"
          924  +# "emacs font-lock highlighting fix
          925  +
   918    926   #---------------------------------------------------------------------
   919    927   # Clean up
   920    928   #---------------------------------------------------------------------
   921    929   
   922    930   tidy:
   923    931   !if "$(TCLLIB)" != "$(TCLIMPLIB)"
   924    932   	@echo Removing $(TCLLIB) ...

Changes to win/nmakehlp.c.

   682    682       fclose(fp);
   683    683       return 0;
   684    684   }
   685    685   
   686    686   BOOL FileExists(LPCTSTR szPath)
   687    687   {
   688    688   #ifndef INVALID_FILE_ATTRIBUTES
   689         -    #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) 
          689  +    #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
   690    690   #endif
   691    691       DWORD pathAttr = GetFileAttributes(szPath);
   692         -    return (pathAttr != INVALID_FILE_ATTRIBUTES && 
          692  +    return (pathAttr != INVALID_FILE_ATTRIBUTES &&
   693    693   	    !(pathAttr & FILE_ATTRIBUTE_DIRECTORY));
   694    694   }
   695    695   
   696    696   
   697    697   /*
   698    698    * QualifyPath --
   699    699    *
................................................................................
   736    736       strncpy(path, dir, dirlen);
   737    737       strncpy(path+dirlen, "\\*", 3);	/* Including terminating \0 */
   738    738       keylen = strlen(keypath);
   739    739   
   740    740   #if 0 /* This function is not available in Visual C++ 6 */
   741    741       /*
   742    742        * Use numerics 0 -> FindExInfoStandard,
   743         -     * 1 -> FindExSearchLimitToDirectories, 
          743  +     * 1 -> FindExSearchLimitToDirectories,
   744    744        * as these are not defined in Visual C++ 6
   745    745        */
   746    746       hSearch = FindFirstFileEx(path, 0, &finfo, 1, NULL, 0);
   747    747   #else
   748    748       hSearch = FindFirstFile(path, &finfo);
   749    749   #endif
   750    750       if (hSearch == INVALID_HANDLE_VALUE)
................................................................................
   751    751   	return 1; /* Not found */
   752    752   
   753    753       /* Loop through all subdirs checking if the keypath is under there */
   754    754       ret = 1; /* Assume not found */
   755    755       do {
   756    756   	int sublen;
   757    757   	/*
   758         -	 * We need to check it is a directory despite the 
          758  +	 * We need to check it is a directory despite the
   759    759   	 * FindExSearchLimitToDirectories in the above call. See SDK docs
   760    760   	 */
   761    761   	if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
   762    762   	    continue;
   763    763   	sublen = strlen(finfo.cFileName);
   764    764   	if ((dirlen+1+sublen+1+keylen+1) > sizeof(path))
   765    765   	    continue;		/* Path does not fit, assume not matched */
................................................................................
   782    782    * LocateDependency --
   783    783    *
   784    784    *	Locates a dependency for a package.
   785    785    *        keypath - a relative path within the package directory
   786    786    *          that is used to confirm it is the correct directory.
   787    787    *	The search path for the package directory is currently only
   788    788    *      the parent and grandparent of the current working directory.
   789         - *      If found, the command prints 
          789  + *      If found, the command prints
   790    790    *         name_DIRPATH=<full path of located directory>
   791    791    *      and returns 0. If not found, does not print anything and returns 1.
   792    792    */
   793    793   static int LocateDependency(const char *keypath)
   794    794   {
   795    795       int i, ret;
   796         -    static char *paths[] = {"..", "..\\..", "..\\..\\.."};
   797         -    
          796  +    static const char *paths[] = {"..", "..\\..", "..\\..\\.."};
          797  +
   798    798       for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) {
   799    799   	ret = LocateDependencyHelper(paths[i], keypath);
   800    800   	if (ret == 0)
   801    801   	    return ret;
   802    802       }
   803    803       return ret;
   804    804   }

Changes to win/rules.vc.

    20     20   !ifndef _RULES_VC
    21     21   _RULES_VC = 1
    22     22   
    23     23   # The following macros define the version of the rules.vc nmake build system
    24     24   # For modifications that are not backward-compatible, you *must* change
    25     25   # the major version.
    26     26   RULES_VERSION_MAJOR = 1
    27         -RULES_VERSION_MINOR = 2
           27  +RULES_VERSION_MINOR = 3
    28     28   
    29     29   # The PROJECT macro must be defined by parent makefile.
    30     30   !if "$(PROJECT)" == ""
    31     31   !error *** Error: Macro PROJECT not defined! Please define it before including rules.vc
    32     32   !endif
    33     33   
    34     34   !if "$(PRJ_PACKAGE_TCLNAME)" == ""
................................................................................
   470    470   !endif
   471    471   !if "$(MACHINE)" != "$(ARCH)"
   472    472   !error Specified MACHINE macro $(MACHINE) does not match detected target architecture $(ARCH).
   473    473   !endif
   474    474   !else
   475    475   MACHINE=$(ARCH)
   476    476   !endif
          477  +
          478  +#---------------------------------------------------------------
          479  +# The PLATFORM_IDENTIFY macro matches the values returned by
          480  +# the Tcl platform::identify command
          481  +!if "$(MACHINE)" == "AMD64"
          482  +PLATFORM_IDENTIFY = win32-x86_64
          483  +!else
          484  +PLATFORM_IDENTIFY = win32-ix86
          485  +!endif
          486  +
          487  +# The MULTIPLATFORM macro controls whether binary extensions are installed
          488  +# in platform-specific directories. Intended to be set/used by extensions.
          489  +!ifndef MULTIPLATFORM_INSTALL
          490  +MULTIPLATFORM_INSTALL = 0
          491  +!endif
   477    492   
   478    493   #------------------------------------------------------------
   479    494   # Figure out the *host* architecture by reading the registry
   480    495   
   481    496   !if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86]
   482    497   NATIVE_ARCH=IX86
   483    498   !else
................................................................................
   735    750   TCL_THREADS	= 0
   736    751   USE_THREAD_ALLOC= 0
   737    752   !else
   738    753   TCL_THREADS	= 1
   739    754   USE_THREAD_ALLOC= 1
   740    755   !endif
   741    756   
          757  +# Yes, it's weird that the "symbols" option controls DEBUG and
          758  +# the "pdbs" option controls SYMBOLS. That's historical.
   742    759   !if [nmakehlp -f $(OPTS) "symbols"]
   743    760   !message *** Doing symbols
   744    761   DEBUG		= 1
   745    762   !else
   746    763   DEBUG		= 0
   747    764   !endif
   748    765   
................................................................................
  1222   1239   !endif
  1223   1240   DEMO_INSTALL_DIR	= $(SCRIPT_INSTALL_DIR)\demos
  1224   1241   INCLUDE_INSTALL_DIR	= $(_INSTALLDIR)\include
  1225   1242   
  1226   1243   !else # extension other than Tk
  1227   1244   
  1228   1245   PRJ_INSTALL_DIR         = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
         1246  +!if $(MULTIPLATFORM_INSTALL)
         1247  +LIB_INSTALL_DIR		= $(PRJ_INSTALL_DIR)\$(PLATFORM_IDENTIFY)
         1248  +BIN_INSTALL_DIR		= $(PRJ_INSTALL_DIR)\$(PLATFORM_IDENTIFY)
         1249  +!else
  1229   1250   LIB_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
  1230   1251   BIN_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
         1252  +!endif
  1231   1253   DOC_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
  1232   1254   SCRIPT_INSTALL_DIR	= $(PRJ_INSTALL_DIR)
  1233   1255   DEMO_INSTALL_DIR	= $(PRJ_INSTALL_DIR)\demos
  1234   1256   INCLUDE_INSTALL_DIR	= $(_INSTALLDIR)\..\include
  1235   1257   
  1236   1258   !endif
  1237   1259   
................................................................................
  1509   1531   
  1510   1532   !ifndef DEFAULT_BUILD_TARGET
  1511   1533   DEFAULT_BUILD_TARGET = $(PROJECT)
  1512   1534   !endif
  1513   1535   
  1514   1536   default-target: $(DEFAULT_BUILD_TARGET)
  1515   1537   
         1538  +!if $(MULTIPLATFORM_INSTALL)
         1539  +default-pkgindex:
         1540  +	@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
         1541  +	    [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
         1542  +!else
  1516   1543   default-pkgindex:
  1517   1544   	@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
  1518   1545   	    [list load [file join $$dir $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
         1546  +!endif
  1519   1547   
  1520   1548   default-pkgindex-tea:
  1521   1549   	@if exist $(ROOT)\pkgIndex.tcl.in nmakehlp -s << $(ROOT)\pkgIndex.tcl.in > $(OUT_DIR)\pkgIndex.tcl
  1522   1550   @PACKAGE_VERSION@    $(DOTVERSION)
  1523   1551   @PACKAGE_NAME@       $(PRJ_PACKAGE_TCLNAME)
  1524   1552   @PACKAGE_TCLNAME@    $(PRJ_PACKAGE_TCLNAME)
  1525   1553   @PKG_LIB_FILE@       $(PRJLIBNAME)
  1526   1554   <<
  1527   1555   
  1528         -
  1529   1556   default-install: default-install-binaries default-install-libraries
         1557  +!if $(SYMBOLS)
         1558  +default-install: default-install-pdbs
         1559  +!endif
  1530   1560   
         1561  +# Again to deal with historical brokenness, there is some confusion
         1562  +# in terminlogy. For extensions, the "install-binaries" was used to
         1563  +# locate target directory for *binary shared libraries* and thus
         1564  +# the appropriate macro is LIB_INSTALL_DIR since BIN_INSTALL_DIR is
         1565  +# for executables (exes). On the other hand the "install-libraries"
         1566  +# target is for *scripts* and should have been called "install-scripts".
  1531   1567   default-install-binaries: $(PRJLIB)
  1532         -	@echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
  1533         -	@if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
  1534         -	@$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
         1568  +	@echo Installing binaries to '$(LIB_INSTALL_DIR)'
         1569  +	@if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)"
         1570  +	@$(CPY) $(PRJLIB) "$(LIB_INSTALL_DIR)" >NUL
  1535   1571   
  1536         -default-install-libraries: $(OUT_DIR)\pkgIndex.tcl
         1572  +# Alias for default-install-scripts
         1573  +default-install-libraries: default-install-scripts
         1574  +
         1575  +default-install-scripts: $(OUT_DIR)\pkgIndex.tcl
  1537   1576   	@echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
  1538   1577   	@if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
  1539   1578   	@echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
  1540   1579   	@$(CPY) $(OUT_DIR)\pkgIndex.tcl $(SCRIPT_INSTALL_DIR)
  1541   1580   
  1542   1581   default-install-stubs:
  1543   1582   	@echo Installing stubs library to '$(SCRIPT_INSTALL_DIR)'
  1544   1583   	@if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
  1545   1584   	@$(CPY) $(PRJSTUBLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
  1546   1585   
         1586  +default-install-pdbs:
         1587  +	@echo Installing PDBs to '$(LIB_INSTALL_DIR)'
         1588  +	@if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)"
         1589  +	@$(CPY) "$(OUT_DIR)\*.pdb" "$(LIB_INSTALL_DIR)\"
         1590  +
  1547   1591   default-install-docs-html:
  1548   1592   	@echo Installing documentation files to '$(DOC_INSTALL_DIR)'
  1549   1593   	@if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)"
  1550   1594   	@if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css" "$(DOCDIR)\*.png") do @$(COPY) %f "$(DOC_INSTALL_DIR)"
  1551   1595   
  1552   1596   default-install-docs-n:
  1553   1597   	@echo Installing documentation files to '$(DOC_INSTALL_DIR)'

Changes to win/tclWinFile.c.

  1456   1456   
  1457   1457       Tcl_DStringInit(bufferPtr);
  1458   1458   
  1459   1459       wDomain = NULL;
  1460   1460       domain = Tcl_UtfFindFirst(name, '@');
  1461   1461       if (domain == NULL) {
  1462   1462   	const char *ptr;
  1463         -	
         1463  +
  1464   1464   	/* no domain - firstly check it's the current user */
  1465         -	if ( (ptr = TclpGetUserName(&ds)) != NULL 
         1465  +	if ( (ptr = TclpGetUserName(&ds)) != NULL
  1466   1466   	  && strcasecmp(name, ptr) == 0
  1467   1467   	) {
  1468   1468   	    /* try safest and fastest way to get current user home */
  1469   1469   	    ptr = TclGetEnv("HOME", &ds);
  1470   1470   	    if (ptr != NULL) {
  1471   1471   		Tcl_JoinPath(1, &ptr, bufferPtr);
  1472   1472   		rc = 1;
................................................................................
  1481   1481   	Tcl_DStringFree(&ds);
  1482   1482   	nameLen = domain - name;
  1483   1483       }
  1484   1484       if (rc == 0) {
  1485   1485   	Tcl_DStringInit(&ds);
  1486   1486   	wName = Tcl_UtfToUniCharDString(name, nameLen, &ds);
  1487   1487   	while (NetUserGetInfo(wDomain, wName, 1, (LPBYTE *) &uiPtr) != 0) {
  1488         -	    /* 
         1488  +	    /*
  1489   1489   	     * user does not exists - if domain was not specified,
  1490   1490   	     * try again using current domain.
  1491   1491   	     */
  1492   1492   	    rc = 1;
  1493   1493   	    if (domain != NULL) break;
  1494   1494   	    /* get current domain */
  1495   1495   	    rc = NetGetDCName(NULL, NULL, (LPBYTE *) &wDomain);
................................................................................
  1596   1596   	/*
  1597   1597   	 * File exists, nothing else to check.
  1598   1598   	 */
  1599   1599   
  1600   1600   	return 0;
  1601   1601       }
  1602   1602   
  1603         -    /* 
         1603  +    /*
  1604   1604        * If it's not a directory (assume file), do several fast checks:
  1605   1605        */
  1606   1606       if (!(attr & FILE_ATTRIBUTE_DIRECTORY)) {
  1607   1607   	/*
  1608   1608   	 * If the attributes say this is not writable at all.  The file is a
  1609   1609   	 * regular file (i.e., not a directory), then the file is not
  1610   1610   	 * writable, full stop.	 For directories, the read-only bit is
................................................................................
  2027   2027        * in wish by default). However the subsequent GetFileInformationByHandle
  2028   2028        * will fail. We do a WinIsReserved to see if it is one of the special
  2029   2029        * names, and if successful, mock up a BY_HANDLE_FILE_INFORMATION
  2030   2030        * structure.
  2031   2031        */
  2032   2032   
  2033   2033       fileHandle = CreateFile(nativePath, GENERIC_READ,
  2034         -	    FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 
         2034  +	    FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
  2035   2035   	    NULL, OPEN_EXISTING,
  2036   2036   	    FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
  2037   2037   
  2038   2038       if (fileHandle != INVALID_HANDLE_VALUE) {
  2039   2039   	BY_HANDLE_FILE_INFORMATION data;
  2040   2040   
  2041   2041   	if (GetFileInformationByHandle(fileHandle,&data) != TRUE) {

Changes to win/tclWinLoad.c.

    84     84   	 * Let the OS loader examine the binary search path for whatever
    85     85   	 * string the user gave us which hopefully refers to a file on the
    86     86   	 * binary path.
    87     87   	 */
    88     88   
    89     89   	Tcl_DString ds;
    90     90   
    91         -        /* 
           91  +        /*
    92     92            * Remember the first error on load attempt to be used if the
    93     93            * second load attempt below also fails.
    94     94           */
    95     95           firstError = (nativeName == NULL) ?
    96     96   		ERROR_MOD_NOT_FOUND : GetLastError();
    97     97   
    98     98   	nativeName = Tcl_WinUtfToTChar(Tcl_GetString(pathPtr), -1, &ds);

Changes to win/tclWinTest.c.

   568    568   
   569    569       /*
   570    570        * Apply the new ACL. Note PROTECTED_DACL_SECURITY_INFORMATION can be used
   571    571        * to remove inherited ACL (we need to overwrite the default ACL's in this case)
   572    572        */
   573    573   
   574    574       if (set_readOnly == acl_readOnly_found || SetNamedSecurityInfoA(
   575         -	    (LPSTR) nativePath, SE_FILE_OBJECT, 
          575  +	    (LPSTR) nativePath, SE_FILE_OBJECT,
   576    576   	    DACL_SECURITY_INFORMATION /*| PROTECTED_DACL_SECURITY_INFORMATION*/,
   577    577   	    NULL, NULL, newAcl, NULL) == ERROR_SUCCESS) {
   578    578   	res = 0;
   579    579       }
   580    580   
   581    581     done:
   582    582       if (secDesc) {

Changes to win/tclWinTime.c.

   253    253       LARGE_INTEGER curCounter;
   254    254   
   255    255       if (!wideClick.initialized) {
   256    256   	LARGE_INTEGER perfCounterFreq;
   257    257   
   258    258   	/*
   259    259   	 * The frequency of the performance counter is fixed at system boot and
   260         -	 * is consistent across all processors. Therefore, the frequency need 
          260  +	 * is consistent across all processors. Therefore, the frequency need
   261    261   	 * only be queried upon application initialization.
   262    262   	 */
   263    263   	if (QueryPerformanceFrequency(&perfCounterFreq)) {
   264    264   	    wideClick.perfCounter = 1;
   265    265   	    wideClick.microsecsScale = 1000000.0 / perfCounterFreq.QuadPart;
   266    266   	} else {
   267    267   	    /* fallback using microseconds */
   268    268   	    wideClick.perfCounter = 0;
   269    269   	    wideClick.microsecsScale = 1;
   270    270   	}
   271         -	
          271  +
   272    272   	wideClick.initialized = 1;
   273    273       }
   274    274       if (wideClick.perfCounter) {
   275    275   	if (QueryPerformanceCounter(&curCounter)) {
   276    276   	    return (Tcl_WideInt)curCounter.QuadPart;
   277    277   	}
   278    278   	/* fallback using microseconds */
................................................................................
   285    285   }
   286    286   
   287    287   /*
   288    288    *----------------------------------------------------------------------
   289    289    *
   290    290    * TclpWideClickInMicrosec --
   291    291    *
   292         - *	This procedure return scale to convert wide click values from the 
          292  + *	This procedure return scale to convert wide click values from the
   293    293    *	TclpGetWideClicks native resolution to microsecond resolution
   294    294    *	and back.
   295    295    *
   296    296    * Results:
   297    297    * 	1 click in microseconds as double.
   298    298    *
   299    299    * Side effects:
................................................................................
   324    324    *
   325    325    * Side effects:
   326    326    *	None.
   327    327    *
   328    328    *----------------------------------------------------------------------
   329    329    */
   330    330   
   331         -Tcl_WideInt 
          331  +Tcl_WideInt
   332    332   TclpGetMicroseconds(void)
   333    333   {
   334    334       Tcl_WideInt usecSincePosixEpoch;
   335    335   
   336    336       /* Try to use high resolution timer */
   337    337       if ( tclGetTimeProcPtr == NativeGetTime
   338    338         && (usecSincePosixEpoch = NativeGetMicroseconds())
................................................................................
   443    443   static inline Tcl_WideInt
   444    444   NativeCalc100NsTicks(
   445    445       ULONGLONG fileTimeLastCall,
   446    446       LONGLONG perfCounterLastCall,
   447    447       LONGLONG curCounterFreq,
   448    448       LONGLONG curCounter
   449    449   ) {
   450         -    return fileTimeLastCall + 
          450  +    return fileTimeLastCall +
   451    451   	((curCounter - perfCounterLastCall) * 10000000 / curCounterFreq);
   452    452   }
   453    453   
   454    454   static Tcl_WideInt
   455    455   NativeGetMicroseconds(void)
   456    456   {
   457    457       /*
................................................................................
  1061   1061         && curFileTime.QuadPart < lastFileTime.QuadPart +
  1062   1062         				    (timeInfo.calibrationInterv * 10000000)
  1063   1063       ) {
  1064   1064       	/* again in next one second */
  1065   1065   	return;
  1066   1066       }
  1067   1067       QueryPerformanceCounter(&curPerfCounter);
  1068         -    
         1068  +
  1069   1069       lastFileTime.QuadPart = curFileTime.QuadPart;
  1070   1070   
  1071   1071       /*
  1072   1072        * We devide by timeInfo.curCounterFreq.QuadPart in several places. That
  1073   1073        * value should always be positive on a correctly functioning system. But
  1074   1074        * it is good to be defensive about such matters. So if something goes
  1075   1075        * wrong and the value does goes to zero, we clear the
................................................................................
  1129   1129       if (tdiff > 10000000 || tdiff < -10000000) {
  1130   1130       	/* jump to current system time, use curent estimated frequency */
  1131   1131       	vt0 = curFileTime.QuadPart;
  1132   1132       } else {
  1133   1133       	/* calculate new frequency and estimate drift to the next second */
  1134   1134   	vt1 = 20000000 + curFileTime.QuadPart;
  1135   1135   	driftFreq = (estFreq * 20000000 / (vt1 - vt0));
  1136         -	/* 
         1136  +	/*
  1137   1137   	 * Avoid too large drifts (only half of the current difference),
  1138   1138   	 * that allows also be more accurate (aspire to the smallest tdiff),
  1139   1139   	 * so then we can prolong calibration interval by tdiff < 100000
  1140   1140   	 */
  1141   1141   	driftFreq = timeInfo.curCounterFreq.QuadPart +
  1142   1142   		(driftFreq - timeInfo.curCounterFreq.QuadPart) / 2;
  1143   1143   
  1144         -	/* 
         1144  +	/*
  1145   1145   	 * Average between estimated, 2 current and 5 drifted frequencies,
  1146   1146   	 * (do the soft drifting as possible)
  1147   1147   	 */
  1148   1148   	estFreq = (estFreq + 2 * timeInfo.curCounterFreq.QuadPart + 5 * driftFreq) / 8;
  1149   1149       }
  1150         -    
         1150  +
  1151   1151       /* Avoid too large discrepancy from nominal frequency */
  1152   1152       if (estFreq > 1003*timeInfo.nominalFreq.QuadPart/1000) {
  1153   1153   	estFreq = 1003*timeInfo.nominalFreq.QuadPart/1000;
  1154   1154   	vt0 = curFileTime.QuadPart;
  1155   1155       } else if (estFreq < 997*timeInfo.nominalFreq.QuadPart/1000) {
  1156   1156   	estFreq = 997*timeInfo.nominalFreq.QuadPart/1000;
  1157   1157   	vt0 = curFileTime.QuadPart;
  1158   1158       } else if (vt0 != curFileTime.QuadPart) {
  1159         -	/* 
         1159  +	/*
  1160   1160   	 * Be sure the clock ticks never backwards (avoid it by negative drifting)
  1161         -	 * just compare native time (in 100-ns) before and hereafter using 
         1161  +	 * just compare native time (in 100-ns) before and hereafter using
  1162   1162   	 * new calibrated values) and do a small adjustment (short time freeze)
  1163   1163   	 */
  1164   1164   	LARGE_INTEGER newPerfCounter;
  1165   1165   	Tcl_WideInt nt0, nt1;
  1166   1166   
  1167   1167   	QueryPerformanceCounter(&newPerfCounter);
  1168   1168   	nt0 = NativeCalc100NsTicks(timeInfo.fileTimeLastCall.QuadPart,