Tcl Source Code

Check-in [aed31dfc6d]
Login

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

Overview
Comment:Make Tcl_GetIntForIndex() do reasonable things when endValue < -1 and when indexPtr == NULL.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-branch
Files: files | file ages | folders
SHA3-256: aed31dfc6d8f62fda5b6ab2c07db1bc7c8416dd5f4f130dcf07412d2379ebceb
User & Date: jan.nijtmans 2020-06-16 12:24:25
Context
2020-06-19
09:34
Make tclStringClassTable a little bit smaller, and save a pointer access when accessing the name of ... check-in: 1ceb0885f4 user: jan.nijtmans tags: core-8-branch
2020-06-16
16:41
Merge 8.7 check-in: 04bb16f1d9 user: jan.nijtmans tags: strict-index-experiment
12:43
Merge 8.7 check-in: 6deef9f426 user: jan.nijtmans tags: trunk
12:24
Make Tcl_GetIntForIndex() do reasonable things when endValue < -1 and when indexPtr == NULL. check-in: aed31dfc6d user: jan.nijtmans tags: core-8-branch
2020-06-12
14:49
Merge 8.6 check-in: 162c548406 user: jan.nijtmans tags: core-8-branch
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclUtil.c.
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998

void
Tcl_DStringGetResult(
    Tcl_Interp *interp,		/* Interpreter whose result is to be reset. */
    Tcl_DString *dsPtr)		/* Dynamic string that is to become the result
				 * of interp. */
{
#ifdef TCL_NO_DEPRECATED
    Tcl_Obj *obj = Tcl_GetObjResult(interp);
    const char *bytes = TclGetString(obj);

    Tcl_DStringFree(dsPtr);
    Tcl_DStringAppend(dsPtr, bytes, obj->length);
    Tcl_ResetResult(interp);
#else







|







2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998

void
Tcl_DStringGetResult(
    Tcl_Interp *interp,		/* Interpreter whose result is to be reset. */
    Tcl_DString *dsPtr)		/* Dynamic string that is to become the result
				 * of interp. */
{
#if defined(TCL_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8
    Tcl_Obj *obj = Tcl_GetObjResult(interp);
    const char *bytes = TclGetString(obj);

    Tcl_DStringFree(dsPtr);
    Tcl_DStringAppend(dsPtr, bytes, obj->length);
    Tcl_ResetResult(interp);
#else
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697

3698
3699
3700
3701


3702
3703

3704
3705
3706
3707
3708
3709
3710
				 * NULL, then no error message is left after
				 * errors. */
    Tcl_Obj *objPtr,		/* Points to an object containing either "end"
				 * or an integer. */
    int endValue,		/* The value to be stored at "indexPtr" if
				 * "objPtr" holds "end". */
    int *indexPtr)		/* Location filled in with an integer
				 * representing an index. */
{
    Tcl_WideInt wide;

    if (GetWideForIndex(interp, objPtr, endValue, &wide) == TCL_ERROR) {
	return TCL_ERROR;
    }

    if (wide < 0) {
	*indexPtr = -1;
    } else if (wide > INT_MAX) {
	*indexPtr = INT_MAX;


    } else {
	*indexPtr = (int) wide;

    }
    return TCL_OK;
}
/*
 *----------------------------------------------------------------------
 *
 * GetEndOffsetFromObj --







|



|


>
|
|
|
|
>
>
|
|
>







3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
				 * NULL, then no error message is left after
				 * errors. */
    Tcl_Obj *objPtr,		/* Points to an object containing either "end"
				 * or an integer. */
    int endValue,		/* The value to be stored at "indexPtr" if
				 * "objPtr" holds "end". */
    int *indexPtr)		/* Location filled in with an integer
				 * representing an index. May be NULL.*/
{
    Tcl_WideInt wide;

    if (GetWideForIndex(interp, objPtr, (size_t)(endValue + 1) - 1, &wide) == TCL_ERROR) {
	return TCL_ERROR;
    }
    if (indexPtr != NULL) {
	if ((wide < 0) && (endValue > TCL_INDEX_END)) {
	    *indexPtr = -1;
	} else if (wide > INT_MAX) {
	    *indexPtr = INT_MAX;
	} else if (wide < INT_MIN) {
	    *indexPtr = INT_MIN;
	} else {
	    *indexPtr = (int) wide;
	}
    }
    return TCL_OK;
}
/*
 *----------------------------------------------------------------------
 *
 * GetEndOffsetFromObj --