Check-in [f08e71ebd9]
Not logged in

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

Overview
Comment:Merge 8.7
Timelines: family | ancestors | descendants | both | trunk | main
Files: files | file ages | folders
SHA3-256: f08e71ebd9742f292595e5c023f192b9cf81a5edeaa118dcbfd5ad85f9750eda
User & Date: jan.nijtmans 2024-02-01 21:47:01.147
References
2024-08-25
08:33
Merge [f08e71ebd9742f29]: Fix [0d78177f20]: unsigned use of Tcl_ObjPrintf() doesn't work as expected... check-in: b826c4d1e8 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
Context
2024-08-25
08:33
Merge [f08e71ebd9742f29]: Fix [0d78177f20]: unsigned use of Tcl_ObjPrintf() doesn't work as expected... check-in: b826c4d1e8 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
2024-02-04
10:54
Merge 8.7 check-in: 6dafc212ae user: jan.nijtmans tags: trunk, main
2024-02-02
17:44
Merge 9.0 check-in: 4539cca84e user: jan.nijtmans tags: tip-626
2024-02-01
21:47
Merge 8.7 check-in: f08e71ebd9 user: jan.nijtmans tags: trunk, main
21:44
Fix [0d78177f20]: unsigned use of Tcl_ObjPrintf() doesn't work as expected. With testcases. check-in: 7abae71820 user: jan.nijtmans tags: core-8-branch
09:43
Merge 8.7 check-in: 32d3f61f23 user: jan.nijtmans tags: trunk, main
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclStringObj.c.
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
    objPtr->bytes[newLength] = 0;
    objPtr->length = newLength;
}

/*
 *----------------------------------------------------------------------
 *
 * TclAppendUtfToUtf -- 
 *
 *	This function appends "numBytes" bytes of "bytes" to the UTF string
 *	rep of "objPtr" (objPtr's internal rep converted to string on demand).
 *	numBytes must be non-negative.
 *
 * Results:
 *	None.







|







1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
    objPtr->bytes[newLength] = 0;
    objPtr->length = newLength;
}

/*
 *----------------------------------------------------------------------
 *
 * TclAppendUtfToUtf --
 *
 *	This function appends "numBytes" bytes of "bytes" to the UTF string
 *	rep of "objPtr" (objPtr's internal rep converted to string on demand).
 *	numBytes must be non-negative.
 *
 * Results:
 *	None.
2659
2660
2661
2662
2663
2664
2665






















2666
2667
2668
2669
2670
2671
2672
 *
 * Results:
 *
 * Side effects:
 *
 *---------------------------------------------------------------------------
 */























static void
AppendPrintfToObjVA(
    Tcl_Obj *objPtr,
    const char *format,
    va_list argList)
{







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







2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
 *
 * Results:
 *
 * Side effects:
 *
 *---------------------------------------------------------------------------
 */

static Tcl_Obj *
NewIntObj(
    char c,
    Tcl_WideUInt max,
	Tcl_WideInt value)
{
    if (!((max+1) & (Tcl_WideUInt)value)) {
	/* sign-bit is not set, so handle the positive value */
	return Tcl_NewWideIntObj(value & (Tcl_WideInt)max);
    }

    if (strchr("puoxX", c) && (max == WIDE_MAX)) {
	/* Value > WIDE_MAX, so we need to use bignum */
	mp_int bignumValue;
	if (mp_init_u64(&bignumValue, (uint64_t)value) != MP_OKAY) {
	    Tcl_Panic("%s: memory overflow", "AppendPrintfToObjVA");
	}
	return Tcl_NewBignumObj(&bignumValue);
    }
    return Tcl_NewWideIntObj(value | ~(Tcl_WideInt)max);
}

static void
AppendPrintfToObjVA(
    Tcl_Obj *objPtr,
    const char *format,
    va_list argList)
{
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
	    case 'o':
	    case 'x':
	    case 'X':
		seekingConversion = 0;
		switch (size) {
		case -1:
		case 0:
		    Tcl_ListObjAppendElement(NULL, list, Tcl_NewWideIntObj(
			    va_arg(argList, int)));
		    break;
		case 1:
		    Tcl_ListObjAppendElement(NULL, list, Tcl_NewWideIntObj(
			    va_arg(argList, long)));
		    break;
		case 2:
		    Tcl_ListObjAppendElement(NULL, list, Tcl_NewWideIntObj(
			    va_arg(argList, Tcl_WideInt)));
		    break;
		case 3:
		    Tcl_ListObjAppendElement(NULL, list, Tcl_NewBignumObj(
			    va_arg(argList, mp_int *)));
		    break;
		}







|



|



|







2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
	    case 'o':
	    case 'x':
	    case 'X':
		seekingConversion = 0;
		switch (size) {
		case -1:
		case 0:
		    Tcl_ListObjAppendElement(NULL, list, NewIntObj(*p, INT_MAX,
			    va_arg(argList, int)));
		    break;
		case 1:
		    Tcl_ListObjAppendElement(NULL, list, NewIntObj(*p, LONG_MAX,
			    va_arg(argList, long)));
		    break;
		case 2:
		    Tcl_ListObjAppendElement(NULL, list, NewIntObj(*p, WIDE_MAX,
			    va_arg(argList, Tcl_WideInt)));
		    break;
		case 3:
		    Tcl_ListObjAppendElement(NULL, list, Tcl_NewBignumObj(
			    va_arg(argList, mp_int *)));
		    break;
		}
Changes to generic/tclTest.c.
4430
4431
4432
4433
4434
4435
4436

4437
4438
4439

4440
4441
4442
4443
4444
4445

4446
4447
4448
4449
4450
4451
4452
4453
    TCL_UNUSED(void *),
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* The argument objects. */
{
    Tcl_WideInt argv1 = 0;
    size_t argv2;


    if (objc < 2 || objc > 3) {
	Tcl_WrongNumArgs(interp, 1, objv, "format wideint");

    }

    if (objc > 1) {
	Tcl_GetWideIntFromObj(interp, objv[2], &argv1);
    }
    argv2 = (size_t)argv1;

    Tcl_SetObjResult(interp, Tcl_ObjPrintf(Tcl_GetString(objv[1]), argv1, argv2, argv2));
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
 * TestregexpObjCmd --







>

|

>


<
|
<

>
|







4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443

4444

4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
    TCL_UNUSED(void *),
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* The argument objects. */
{
    Tcl_WideInt argv1 = 0;
    size_t argv2;
    long argv3;

    if (objc != 3) {
	Tcl_WrongNumArgs(interp, 1, objv, "format wideint");
	return TCL_OK;
    }


    Tcl_GetWideIntFromObj(interp, objv[2], &argv1);

    argv2 = (size_t)argv1;
    argv3 = (long)argv1;
    Tcl_SetObjResult(interp, Tcl_ObjPrintf(Tcl_GetString(objv[1]), argv1, argv2, argv3, argv3));
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
 * TestregexpObjCmd --
Changes to tests/util.test.
17
18
19
20
21
22
23

24
25
26
27
28
29
30

testConstraint controversialNaN 1
testConstraint testbytestring [llength [info commands testbytestring]]
testConstraint testdstring [llength [info commands testdstring]]
testConstraint testconcatobj [llength [info commands testconcatobj]]
testConstraint testdoubledigits [llength [info commands testdoubledigits]]
testConstraint testprint [llength [info commands testprint]]


# Big test for correct ordering of data in [expr]

proc testIEEE {} {
    variable ieeeValues
    binary scan [binary format dd -1.0 1.0] c* c
    switch -exact -- $c {







>







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

testConstraint controversialNaN 1
testConstraint testbytestring [llength [info commands testbytestring]]
testConstraint testdstring [llength [info commands testdstring]]
testConstraint testconcatobj [llength [info commands testconcatobj]]
testConstraint testdoubledigits [llength [info commands testdoubledigits]]
testConstraint testprint [llength [info commands testprint]]
testConstraint pointerIs64bit [expr {$tcl_platform(pointerSize) >= 8}]

# Big test for correct ordering of data in [expr]

proc testIEEE {} {
    variable ieeeValues
    binary scan [binary format dd -1.0 1.0] c* c
    switch -exact -- $c {
2226
2227
2228
2229
2230
2231
2232








2233
2234
2235
2236
2237
2238
2239
2240
test util-18.11 {Tcl_ObjPrintf} {testprint} {
    testprint "%I64d %td" 65536
} {65536 65536}

test util-18.12 {Tcl_ObjPrintf} {testprint} {
    testprint "%I64d %Id" 65537
} {65537 65537}









# cleanup
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End:







>
>
>
>
>
>
>
>








2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
test util-18.11 {Tcl_ObjPrintf} {testprint} {
    testprint "%I64d %td" 65536
} {65536 65536}

test util-18.12 {Tcl_ObjPrintf} {testprint} {
    testprint "%I64d %Id" 65537
} {65537 65537}

test util-18.13 {Tcl_ObjPrintf} -constraints {testprint pointerIs64bit} -body {
    testprint "%llu %ju %lu" -1
} -result {18446744073709551615 18446744073709551615 18446744073709551615}

test util-18.14 {Tcl_ObjPrintf} -constraints {testprint pointerIs64bit} -body {
    testprint "%llu %zu %lu" -1
} -result {18446744073709551615 18446744073709551615 18446744073709551615}

# cleanup
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End: