Tcl Source Code

Check-in [0f923b5cc0]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:
[kennykb-numerics-branch]
* generic/tclExecute.c: Updated TclIncrObj() to more efficiently add native long integers.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | kennykb-numerics-branch
Files: files | file ages | folders
SHA1: 0f923b5cc09f12cafc638a33929e22eadbf1ed13
User & Date: dgp 2005-10-04 16:00:12
Context
2005-10-04
18:33
[kennykb-numerics-branch]
* generic/tclExecute.c: Updated TclIncrObj() to more effi...
check-in: 53add32158 user: dgp tags: kennykb-numerics-branch
16:00
[kennykb-numerics-branch]
* generic/tclExecute.c: Updated TclIncrObj() to more effi...
check-in: 0f923b5cc0 user: dgp tags: kennykb-numerics-branch
13:49
[kennykb-numerics-branch]
* generic/tclBasic.c: Updated more callers to make use ...
check-in: 215aa64c5c user: dgp tags: kennykb-numerics-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.

1
2
3



4
5
6
7
8
9
10
2005-10-04  Don Porter  <[email protected]>

	[kennykb-numerics-branch]




	* generic/tclBasic.c:	Updated more callers to make use of
	TclGetNumberFromObj.  Removed some dead code.

2005-10-03  Don Porter  <[email protected]>

	[kennykb-numerics-branch]


>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
2005-10-04  Don Porter  <[email protected]>

	[kennykb-numerics-branch]

	* generic/tclExecute.c:	Updated TclIncrObj() to more efficiently
	add native long integers.

	* generic/tclBasic.c:	Updated more callers to make use of
	TclGetNumberFromObj.  Removed some dead code.

2005-10-03  Don Porter  <[email protected]>

	[kennykb-numerics-branch]

Changes to generic/tclExecute.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1031
1032
1033
1034
1035
1036
1037


1038
1039
1040
1041
1042
1043


















1044
1045
1046
1047
1048
1049
1050
 * Copyright (c) 2001 by Kevin B. Kenny.  All rights reserved.
 * Copyright (c) 2002-2005 by Miguel Sofer.
 * Copyright (c) 2005 by Donal K. Fellows.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclExecute.c,v 1.167.2.42 2005/09/20 14:11:51 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"
#include "tommath.h"

#include <math.h>
................................................................................

int
TclIncrObj(interp, valuePtr, incrPtr)
    Tcl_Interp *interp;
    Tcl_Obj *valuePtr;
    Tcl_Obj *incrPtr;
{


    mp_int value, incr;

    if (Tcl_IsShared(valuePtr)) {
	Tcl_Panic("shared object passed to TclIncrObj");
    }



















    if (Tcl_GetBignumAndClearObj(interp, valuePtr, &value) != TCL_OK) {
	return TCL_ERROR;
    }
    if (Tcl_GetBignumFromObj(interp, incrPtr, &incr) != TCL_OK) {
	Tcl_AddErrorInfo(interp, "\n    (reading increment)");
	return TCL_ERROR;
    }






|







 







>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
 * Copyright (c) 2001 by Kevin B. Kenny.  All rights reserved.
 * Copyright (c) 2002-2005 by Miguel Sofer.
 * Copyright (c) 2005 by Donal K. Fellows.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclExecute.c,v 1.167.2.43 2005/10/04 16:00:13 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"
#include "tommath.h"

#include <math.h>
................................................................................

int
TclIncrObj(interp, valuePtr, incrPtr)
    Tcl_Interp *interp;
    Tcl_Obj *valuePtr;
    Tcl_Obj *incrPtr;
{
    ClientData ptr1, ptr2;
    int type1, type2;
    mp_int value, incr;

    if (Tcl_IsShared(valuePtr)) {
	Tcl_Panic("shared object passed to TclIncrObj");
    }

    if ((TclGetNumberFromObj(interp, valuePtr, &ptr1, &type1) == TCL_OK)
	    && (TclGetNumberFromObj(interp, incrPtr, &ptr2, &type2) == TCL_OK)
	    && (type1 == TCL_NUMBER_LONG) && (type2 == TCL_NUMBER_LONG)) {
	Tcl_WideInt w1 = (Tcl_WideInt)(*(CONST long *)ptr1);
	Tcl_WideInt w2 = (Tcl_WideInt)(*(CONST long *)ptr2);
	Tcl_WideInt sum = w1 + w2;
#ifdef TCL_WIDE_INT_IS_LONG
	/* Must check for overflow */
	if (((w1 < 0) && (w2 < 0) && (sum > 0))
		|| ((w1 > 0) && (w2 > 0) && (sum < 0))) {
	    goto overflow;
	}
#endif
	Tcl_SetWideIntObj(valuePtr, sum);
	return TCL_OK;
    }

    overflow:
    if (Tcl_GetBignumAndClearObj(interp, valuePtr, &value) != TCL_OK) {
	return TCL_ERROR;
    }
    if (Tcl_GetBignumFromObj(interp, incrPtr, &incr) != TCL_OK) {
	Tcl_AddErrorInfo(interp, "\n    (reading increment)");
	return TCL_ERROR;
    }