Tcl Source Code

Check-in [059ed80454]
Login

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

Overview
Comment:
* generic/tclPreserve.c: In Result and Preserve'd routines, do not * generic/tclUtil.c: assume that ckfree == free, as that is not * generic/tclResult.c: always true. [Bug 756791] (fuller)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 059ed80454ac05b274a92999be4abc888dbeacd6
User & Date: hobbs 2003-07-16 21:24:12.000
Context
2003-07-16
21:34
Tcl_MakeSafe is a nasty function; document it as such. [Bug 655300] check-in: d9a41d63e9 user: dkf tags: trunk
21:24
* generic/tclPreserve.c: In Result and Preserve'd routines, do not * generic/tclUtil.c: assume...
check-in: 059ed80454 user: hobbs tags: trunk
15:29
* generic/tclFileName.c (Tcl_GlobObjCmd): [Bug 771840] * generic/tclPathObj.c ...
check-in: 31e59a0126 user: dgp tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to ChangeLog.
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
2003-07-16  Don Porter  <[email protected]>

	* generic/tclFileName.c (Tcl_GlobObjCmd):       [Bug 771840]
	* generic/tclPathObj.c (Tcl_FSConvertToPathType):[Bug 771947]
	* unix/tclUnixFCmd.c (GetModeFromPermString):   [Bug 771949]
	Silence compiler warnings about unreached lines.

        * library/tcltest/tcltest.tcl (ProcessFlags):   Corrected broken call
        * library/tcltest/pkgIndex.tcl:                 to [lrange].  Bumped
        to version 2.2.4. [Bug 772333]

2003-07-15  Mo DeJong  <[email protected]>

	* unix/dltest/pkga.c (Pkga_EqObjCmd): Fix typo
	that was causing a crash in load.test.

2003-07-15  Donal K. Fellows  <[email protected]>

	* doc/array.n: Make sure docs are synched with the 8.4 release.

2003-07-15  Don Porter  <[email protected]>

	* doc/http.n:  Updated SYNOPSIS to match actual syntax of
	commands.  [Bug 756112]

        * unix/dltest/pkga.c:   Updated to not use Tcl_UtfNcmp and counted
        strings instead of strcmp (not defined in any #include'd header)
        and presumed NULL-terminated strings.

	* generic/tclCompCmds.c (TclCompileIfCmd):  Prior fix of Bug 711371
	on 2003-04-07 introduced a buffer overflow.  Corrected.  [Bug 771613]

2003-07-15  Kevin B. Kenny  <[email protected]>

	* win/rules.vc: Added a missing $(OPTDEFINES) which broke the


|

|


|
|
|















|
|
|







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
2003-07-16  Don Porter  <[email protected]>

	* generic/tclFileName.c (Tcl_GlobObjCmd):	[Bug 771840]
	* generic/tclPathObj.c (Tcl_FSConvertToPathType):[Bug 771947]
	* unix/tclUnixFCmd.c (GetModeFromPermString):	[Bug 771949]
	Silence compiler warnings about unreached lines.

	* library/tcltest/tcltest.tcl (ProcessFlags):	Corrected broken call
	* library/tcltest/pkgIndex.tcl:			to [lrange].  Bumped
	to version 2.2.4. [Bug 772333]

2003-07-15  Mo DeJong  <[email protected]>

	* unix/dltest/pkga.c (Pkga_EqObjCmd): Fix typo
	that was causing a crash in load.test.

2003-07-15  Donal K. Fellows  <[email protected]>

	* doc/array.n: Make sure docs are synched with the 8.4 release.

2003-07-15  Don Porter  <[email protected]>

	* doc/http.n:  Updated SYNOPSIS to match actual syntax of
	commands.  [Bug 756112]

	* unix/dltest/pkga.c:	Updated to not use Tcl_UtfNcmp and counted
	strings instead of strcmp (not defined in any #include'd header)
	and presumed NULL-terminated strings.

	* generic/tclCompCmds.c (TclCompileIfCmd):  Prior fix of Bug 711371
	on 2003-04-07 introduced a buffer overflow.  Corrected.  [Bug 771613]

2003-07-15  Kevin B. Kenny  <[email protected]>

	* win/rules.vc: Added a missing $(OPTDEFINES) which broke the
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

2003-06-23  Vince Darley  <[email protected]>

	* generic/tclTrace.c: fix to Window debug build compilation error.

2003-06-27  Don Porter  <[email protected]>

	* tests/init.test:	Added [cleanupTests] to report results of tests
	* tests/pkg.test:	that run in slave interps.  [Bugs 761334,761344]

	* tests/http.test:	Used more reliable path to find httpd script.

2003-06-25  Don Porter  <[email protected]>

	* tests/init.test:  Added tests init-4.6.* to illustrate [Bug 760872]

2003-06-25  Donal K. Fellows  <[email protected]>








|
|

|







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

2003-06-23  Vince Darley  <[email protected]>

	* generic/tclTrace.c: fix to Window debug build compilation error.

2003-06-27  Don Porter  <[email protected]>

	* tests/init.test: Added [cleanupTests] to report results of tests
	* tests/pkg.test:  that run in slave interps.  [Bugs 761334,761344]

	* tests/http.test: Used more reliable path to find httpd script.

2003-06-25  Don Porter  <[email protected]>

	* tests/init.test:  Added tests init-4.6.* to illustrate [Bug 760872]

2003-06-25  Donal K. Fellows  <[email protected]>

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255

	* string.test (string-4.15): Added test for [string first] bug
	reported in Tcl 8.3, where test for all-single-byte-encoded strings
	was not reliable.

2003-06-04  Joe Mistachkin  <[email protected]>

        * tools/man2help.tcl: Added duplicate help section checking
        * tools/index.tcl:    and corrected a comment typo for the 
        getTopics proc in index.tcl [Bug #748700].

2003-06-02  Vince Darley  <[email protected]>

	* win/tclWinFCmd.c:
        * tests/fCmd.test: fix to [Bug #747575] in which a bad error
        message is given when trying to rename a busy directory to
        one with the same prefix, but not the same name.  Added three
        new tests.
        
2003-05-23  D. Richard Hipp <[email protected]>

	* win/tclWinTime.c: Add tests to detect and avoid a division by zero
	in the windows precision timer calibration logic.

2003-05-23  Don Porter  <[email protected]>

        * generic/tclObj.c (tclCmdNameType):  Converted internal rep
        management of the cmdName Tcl_ObjType the opposite way, to always
        use the twoPtrValue instead of always using the otherValuePtr.
        Previous fix on 2003-05-12 broke several extensions that wanted
        to poke around with the twoPtrValue.ptr2 value of a cmdName
        Tcl_Obj, like TclBlend and e4graph.  [Bug 726018]
        Thanks to George Petasis for the bug report and Jacob Levy for
        testing assistance.

2003-05-23  Mo DeJong  <[email protected]>

	* unix/mkLinks: Set the var S to "" at the top
	of the file to avoid error when user has set S
	to something.
	[Tk Bug #739833]







|
|
|
















|
|
|
|
|
|
|
|







215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255

	* string.test (string-4.15): Added test for [string first] bug
	reported in Tcl 8.3, where test for all-single-byte-encoded strings
	was not reliable.

2003-06-04  Joe Mistachkin  <[email protected]>

	* tools/man2help.tcl: Added duplicate help section checking
	* tools/index.tcl:    and corrected a comment typo for the 
	getTopics proc in index.tcl [Bug #748700].

2003-06-02  Vince Darley  <[email protected]>

	* win/tclWinFCmd.c:
        * tests/fCmd.test: fix to [Bug #747575] in which a bad error
        message is given when trying to rename a busy directory to
        one with the same prefix, but not the same name.  Added three
        new tests.
        
2003-05-23  D. Richard Hipp <[email protected]>

	* win/tclWinTime.c: Add tests to detect and avoid a division by zero
	in the windows precision timer calibration logic.

2003-05-23  Don Porter  <[email protected]>

	* generic/tclObj.c (tclCmdNameType):  Converted internal rep
	management of the cmdName Tcl_ObjType the opposite way, to always
	use the twoPtrValue instead of always using the otherValuePtr.
	Previous fix on 2003-05-12 broke several extensions that wanted
	to poke around with the twoPtrValue.ptr2 value of a cmdName
	Tcl_Obj, like TclBlend and e4graph.  [Bug 726018]
	Thanks to George Petasis for the bug report and Jacob Levy for
	testing assistance.

2003-05-23  Mo DeJong  <[email protected]>

	* unix/mkLinks: Set the var S to "" at the top
	of the file to avoid error when user has set S
	to something.
	[Tk Bug #739833]
Changes to generic/tclPreserve.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-1998 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: tclPreserve.c,v 1.3 1999/04/16 00:46:52 stanton Exp $
 */

#include "tclInt.h"

/*
 * The following data structure is used to keep track of all the
 * Tcl_Preserve calls that are still in effect.  It grows as needed







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-1998 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: tclPreserve.c,v 1.4 2003/07/16 21:24:12 hobbs Exp $
 */

#include "tclInt.h"

/*
 * The following data structure is used to keep track of all the
 * Tcl_Preserve calls that are still in effect.  It grows as needed
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
            freeProc = refPtr->freeProc;
            mustFree = refPtr->mustFree;
	    inUse--;
	    if (i < inUse) {
		refArray[i] = refArray[inUse];
	    }
	    if (mustFree) {
		if ((freeProc == TCL_DYNAMIC) ||
                        (freeProc == (Tcl_FreeProc *) free)) {
		    ckfree((char *) clientData);
		} else {
		    Tcl_MutexUnlock(&preserveMutex);
		    (*freeProc)((char *) clientData);
		    return;
		}
	    }







|
<







229
230
231
232
233
234
235
236

237
238
239
240
241
242
243
            freeProc = refPtr->freeProc;
            mustFree = refPtr->mustFree;
	    inUse--;
	    if (i < inUse) {
		refArray[i] = refArray[inUse];
	    }
	    if (mustFree) {
		if (freeProc == TCL_DYNAMIC) {

		    ckfree((char *) clientData);
		} else {
		    Tcl_MutexUnlock(&preserveMutex);
		    (*freeProc)((char *) clientData);
		    return;
		}
	    }
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
    }
    Tcl_MutexUnlock(&preserveMutex);

    /*
     * No reference for this block.  Free it now.
     */

    if ((freeProc == TCL_DYNAMIC)
	    || (freeProc == (Tcl_FreeProc *) free)) {
	ckfree((char *) clientData);
    } else {
	(*freeProc)((char *)clientData);
    }
}

/*







|
<







301
302
303
304
305
306
307
308

309
310
311
312
313
314
315
    }
    Tcl_MutexUnlock(&preserveMutex);

    /*
     * No reference for this block.  Free it now.
     */

    if (freeProc == TCL_DYNAMIC) {

	ckfree((char *) clientData);
    } else {
	(*freeProc)((char *)clientData);
    }
}

/*
Changes to generic/tclResult.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* 
 * tclResult.c --
 *
 *	This file contains code to manage the interpreter result.
 *
 * Copyright (c) 1997 by 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: tclResult.c,v 1.6 2003/05/05 20:54:40 dgp Exp $
 */

#include "tclInt.h"

/*
 * Function prototypes for local procedures in this file:
 */










|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* 
 * tclResult.c --
 *
 *	This file contains code to manage the interpreter result.
 *
 * Copyright (c) 1997 by 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: tclResult.c,v 1.7 2003/07/16 21:24:12 hobbs Exp $
 */

#include "tclInt.h"

/*
 * Function prototypes for local procedures in this file:
 */
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
    Tcl_SavedResult *statePtr;	/* State returned by Tcl_SaveResult. */
{
    TclDecrRefCount(statePtr->objResultPtr);

    if (statePtr->result == statePtr->appendResult) {
	ckfree(statePtr->appendResult);
    } else if (statePtr->freeProc) {
	if ((statePtr->freeProc == TCL_DYNAMIC)
	        || (statePtr->freeProc == (Tcl_FreeProc *) free)) {
	    ckfree(statePtr->result);
	} else {
	    (*statePtr->freeProc)(statePtr->result);
	}
    }
}








|
<







194
195
196
197
198
199
200
201

202
203
204
205
206
207
208
    Tcl_SavedResult *statePtr;	/* State returned by Tcl_SaveResult. */
{
    TclDecrRefCount(statePtr->objResultPtr);

    if (statePtr->result == statePtr->appendResult) {
	ckfree(statePtr->appendResult);
    } else if (statePtr->freeProc) {
	if (statePtr->freeProc == TCL_DYNAMIC) {

	    ckfree(statePtr->result);
	} else {
	    (*statePtr->freeProc)(statePtr->result);
	}
    }
}

261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
    /*
     * If the old result was dynamically-allocated, free it up.  Do it
     * here, rather than at the beginning, in case the new result value
     * was part of the old result value.
     */

    if (oldFreeProc != 0) {
	if ((oldFreeProc == TCL_DYNAMIC)
		|| (oldFreeProc == (Tcl_FreeProc *) free)) {
	    ckfree(oldResult);
	} else {
	    (*oldFreeProc)(oldResult);
	}
    }

    /*







|
<







260
261
262
263
264
265
266
267

268
269
270
271
272
273
274
    /*
     * If the old result was dynamically-allocated, free it up.  Do it
     * here, rather than at the beginning, in case the new result value
     * was part of the old result value.
     */

    if (oldFreeProc != 0) {
	if (oldFreeProc == TCL_DYNAMIC) {

	    ckfree(oldResult);
	} else {
	    (*oldFreeProc)(oldResult);
	}
    }

    /*
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
    TclDecrRefCount(oldObjResult);

    /*
     * Reset the string result since we just set the result object.
     */

    if (iPtr->freeProc != NULL) {
	if ((iPtr->freeProc == TCL_DYNAMIC)
	        || (iPtr->freeProc == (Tcl_FreeProc *) free)) {
	    ckfree(iPtr->result);
	} else {
	    (*iPtr->freeProc)(iPtr->result);
	}
	iPtr->freeProc = 0;
    }
    iPtr->result = iPtr->resultSpace;







|
<







353
354
355
356
357
358
359
360

361
362
363
364
365
366
367
    TclDecrRefCount(oldObjResult);

    /*
     * Reset the string result since we just set the result object.
     */

    if (iPtr->freeProc != NULL) {
	if (iPtr->freeProc == TCL_DYNAMIC) {

	    ckfree(iPtr->result);
	} else {
	    (*iPtr->freeProc)(iPtr->result);
	}
	iPtr->freeProc = 0;
    }
    iPtr->result = iPtr->resultSpace;
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
	ResetObjResult(iPtr);
	
	objResultPtr = iPtr->objResultPtr;
	length = strlen(iPtr->result);
	TclInitStringRep(objResultPtr, iPtr->result, length);
	
	if (iPtr->freeProc != NULL) {
	    if ((iPtr->freeProc == TCL_DYNAMIC)
	            || (iPtr->freeProc == (Tcl_FreeProc *) free)) {
		ckfree(iPtr->result);
	    } else {
		(*iPtr->freeProc)(iPtr->result);
	    }
	    iPtr->freeProc = 0;
	}
	iPtr->result = iPtr->resultSpace;







|
<







406
407
408
409
410
411
412
413

414
415
416
417
418
419
420
	ResetObjResult(iPtr);
	
	objResultPtr = iPtr->objResultPtr;
	length = strlen(iPtr->result);
	TclInitStringRep(objResultPtr, iPtr->result, length);
	
	if (iPtr->freeProc != NULL) {
	    if (iPtr->freeProc == TCL_DYNAMIC) {

		ckfree(iPtr->result);
	    } else {
		(*iPtr->freeProc)(iPtr->result);
	    }
	    iPtr->freeProc = 0;
	}
	iPtr->result = iPtr->resultSpace;
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
void
Tcl_FreeResult(interp)
    register Tcl_Interp *interp; /* Interpreter for which to free result. */
{
    register Interp *iPtr = (Interp *) interp;
    
    if (iPtr->freeProc != NULL) {
	if ((iPtr->freeProc == TCL_DYNAMIC)
	        || (iPtr->freeProc == (Tcl_FreeProc *) free)) {
	    ckfree(iPtr->result);
	} else {
	    (*iPtr->freeProc)(iPtr->result);
	}
	iPtr->freeProc = 0;
    }
    







|
<







743
744
745
746
747
748
749
750

751
752
753
754
755
756
757
void
Tcl_FreeResult(interp)
    register Tcl_Interp *interp; /* Interpreter for which to free result. */
{
    register Interp *iPtr = (Interp *) interp;
    
    if (iPtr->freeProc != NULL) {
	if (iPtr->freeProc == TCL_DYNAMIC) {

	    ckfree(iPtr->result);
	} else {
	    (*iPtr->freeProc)(iPtr->result);
	}
	iPtr->freeProc = 0;
    }
    
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
Tcl_ResetResult(interp)
    register Tcl_Interp *interp; /* Interpreter for which to clear result. */
{
    register Interp *iPtr = (Interp *) interp;

    ResetObjResult(iPtr);
    if (iPtr->freeProc != NULL) {
	if ((iPtr->freeProc == TCL_DYNAMIC)
	        || (iPtr->freeProc == (Tcl_FreeProc *) free)) {
	    ckfree(iPtr->result);
	} else {
	    (*iPtr->freeProc)(iPtr->result);
	}
	iPtr->freeProc = 0;
    }
    iPtr->result = iPtr->resultSpace;







|
<







782
783
784
785
786
787
788
789

790
791
792
793
794
795
796
Tcl_ResetResult(interp)
    register Tcl_Interp *interp; /* Interpreter for which to clear result. */
{
    register Interp *iPtr = (Interp *) interp;

    ResetObjResult(iPtr);
    if (iPtr->freeProc != NULL) {
	if (iPtr->freeProc == TCL_DYNAMIC) {

	    ckfree(iPtr->result);
	} else {
	    (*iPtr->freeProc)(iPtr->result);
	}
	iPtr->freeProc = 0;
    }
    iPtr->result = iPtr->resultSpace;
Changes to generic/tclUtil.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* 
 * tclUtil.c --
 *
 *	This file contains utility procedures that are used by many Tcl
 *	commands.
 *
 * Copyright (c) 1987-1993 The Regents of the University of California.
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
 * Copyright (c) 2001 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: tclUtil.c,v 1.37 2003/04/16 23:33:44 dgp Exp $
 */

#include "tclInt.h"
#include "tclPort.h"

/*
 * The following variable holds the full path name of the binary













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* 
 * tclUtil.c --
 *
 *	This file contains utility procedures that are used by many Tcl
 *	commands.
 *
 * Copyright (c) 1987-1993 The Regents of the University of California.
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
 * Copyright (c) 2001 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: tclUtil.c,v 1.38 2003/07/16 21:24:12 hobbs Exp $
 */

#include "tclInt.h"
#include "tclPort.h"

/*
 * The following variable holds the full path name of the binary
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
    if (*(iPtr->result) == 0) {
	Tcl_SetResult(interp, TclGetString(Tcl_GetObjResult(interp)),
	        TCL_VOLATILE);
    }

    dsPtr->length = strlen(iPtr->result);
    if (iPtr->freeProc != NULL) {
	if ((iPtr->freeProc == TCL_DYNAMIC)
		|| (iPtr->freeProc == (Tcl_FreeProc *) free)) {
	    dsPtr->string = iPtr->result;
	    dsPtr->spaceAvl = dsPtr->length+1;
	} else {
	    dsPtr->string = (char *) ckalloc((unsigned) (dsPtr->length+1));
	    strcpy(dsPtr->string, iPtr->result);
	    (*iPtr->freeProc)(iPtr->result);
	}







|
<







1740
1741
1742
1743
1744
1745
1746
1747

1748
1749
1750
1751
1752
1753
1754
    if (*(iPtr->result) == 0) {
	Tcl_SetResult(interp, TclGetString(Tcl_GetObjResult(interp)),
	        TCL_VOLATILE);
    }

    dsPtr->length = strlen(iPtr->result);
    if (iPtr->freeProc != NULL) {
	if (iPtr->freeProc == TCL_DYNAMIC) {

	    dsPtr->string = iPtr->result;
	    dsPtr->spaceAvl = dsPtr->length+1;
	} else {
	    dsPtr->string = (char *) ckalloc((unsigned) (dsPtr->length+1));
	    strcpy(dsPtr->string, iPtr->result);
	    (*iPtr->freeProc)(iPtr->result);
	}