Diff
Not logged in

Differences From Artifact [37caa0ada4]:

To Artifact [b4c1f49656]:


430
431
432
433
434
435
436


437
438
439
440
441
442
443
				 * array of bytes in the ByteArray object. */
{
    ByteArray *baPtr;
    const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &properByteArrayType);

    if (irPtr == NULL) {
	if (TCL_ERROR == SetByteArrayFromAny(NULL, objPtr)) {


	    if (lengthPtr != NULL) {
		*lengthPtr = 0;
	    }
	    return NULL;
	}
	irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
    }







>
>







430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
				 * array of bytes in the ByteArray object. */
{
    ByteArray *baPtr;
    const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &properByteArrayType);

    if (irPtr == NULL) {
	if (TCL_ERROR == SetByteArrayFromAny(NULL, objPtr)) {

	    /* TODO: Reconsider claiming a length for failed conversion. */
	    if (lengthPtr != NULL) {
		*lengthPtr = 0;
	    }
	    return NULL;
	}
	irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
    }
484
485
486
487
488
489
490


491
492
493
494
495
496
497
    }

    irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
    if (irPtr == NULL) {
	if (length == 0) {
	    Tcl_SetByteArrayObj(objPtr, NULL, 0);
	} else if (TCL_ERROR == SetByteArrayFromAny(NULL, objPtr)) {


	    return NULL;
	}
	irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
    }

    byteArrayPtr = GET_BYTEARRAY(irPtr);
    if (length > byteArrayPtr->allocated) {







>
>







486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
    }

    irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
    if (irPtr == NULL) {
	if (length == 0) {
	    Tcl_SetByteArrayObj(objPtr, NULL, 0);
	} else if (TCL_ERROR == SetByteArrayFromAny(NULL, objPtr)) {

	    /* TODO: Consider a length limit on conversion attempt. */
	    return NULL;
	}
	irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
    }

    byteArrayPtr = GET_BYTEARRAY(irPtr);
    if (length > byteArrayPtr->allocated) {
506
507
508
509
510
511
512


513
514
515
516
517
518
519

/*
 *----------------------------------------------------------------------
 *
 * SetByteArrayFromAny --
 *
 *	Generate the ByteArray internal rep from the string rep.


 *
 * Results:
 *	The return value is always TCL_OK.
 *
 * Side effects:
 *	A ByteArray object is stored as the internal rep of objPtr.
 *







>
>







510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525

/*
 *----------------------------------------------------------------------
 *
 * SetByteArrayFromAny --
 *
 *	Generate the ByteArray internal rep from the string rep.
 *
 *	TODO: Consider length limit on conversion.
 *
 * Results:
 *	The return value is always TCL_OK.
 *
 * Side effects:
 *	A ByteArray object is stored as the internal rep of objPtr.
 *
576
577
578
579
580
581
582

583
584
585
586
587
588
589
    Tcl_Interp *dummy,		/* Not used. */
    Tcl_Obj *objPtr)		/* The object to convert to type ByteArray. */
{
    ByteArray *byteArrayPtr;
    Tcl_ObjIntRep ir;
    (void)dummy;


    if (TclHasIntRep(objPtr, &properByteArrayType)) {
	return TCL_OK;
    }

    if (0 == MakeByteArray(objPtr, 1, &byteArrayPtr)) {
	return TCL_ERROR;
    }







>







582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
    Tcl_Interp *dummy,		/* Not used. */
    Tcl_Obj *objPtr)		/* The object to convert to type ByteArray. */
{
    ByteArray *byteArrayPtr;
    Tcl_ObjIntRep ir;
    (void)dummy;

    /* TODO: Consider imposing this check on callers. */
    if (TclHasIntRep(objPtr, &properByteArrayType)) {
	return TCL_OK;
    }

    if (0 == MakeByteArray(objPtr, 1, &byteArrayPtr)) {
	return TCL_ERROR;
    }