Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Create a narrowing procedure to make the operation explicit when needed. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dgp-properbytearray |
Files: | files | file ages | folders |
SHA1: |
ba8e57d76c81d32fa83ebcc1395c3bb1 |
User & Date: | dgp 2016-12-07 18:57:34 |
Context
2016-12-07
| ||
19:22 | Make explicit the implicit byte-narrowing function of [binary format]. check-in: 56ac0f8998 user: dgp tags: dgp-properbytearray | |
18:57 | Create a narrowing procedure to make the operation explicit when needed. check-in: ba8e57d76c user: dgp tags: dgp-properbytearray | |
2016-12-06
| ||
20:09 | Purge the old and broken Tcl_ObjType. check-in: ea03de5a23 user: dgp tags: dgp-properbytearray | |
Changes
Changes to generic/tclBinary.c.
︙ | ︙ | |||
447 448 449 450 451 452 453 454 455 | * The return value is always TCL_OK. * * Side effects: * A ByteArray object is stored as the internal rep of objPtr. * *---------------------------------------------------------------------- */ static int | | < | > > | < > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < < < | | | < < < < < | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | * The return value is always TCL_OK. * * Side effects: * A ByteArray object is stored as the internal rep of objPtr. * *---------------------------------------------------------------------- */ static int MakeByteArray( Tcl_Obj *objPtr, int earlyOut, ByteArray **byteArrayPtrPtr) { int length, proper = 1; unsigned char *dst; const char *src = TclGetStringFromObj(objPtr, &length); ByteArray *byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length)); const char *srcEnd = src + length; for (dst = byteArrayPtr->bytes; src < srcEnd; ) { Tcl_UniChar ch; src += Tcl_UtfToUniChar(src, &ch); if (ch > 255) { proper = 0; if (earlyOut) { ckfree(byteArrayPtr); *byteArrayPtrPtr = NULL; return proper; } } *dst++ = UCHAR(ch); } byteArrayPtr->used = dst - byteArrayPtr->bytes; byteArrayPtr->allocated = length; *byteArrayPtrPtr = byteArrayPtr; return proper; } Tcl_Obj * TclNarrowToBytes( Tcl_Obj *objPtr) { ByteArray *byteArrayPtr; if (0 == MakeByteArray(objPtr, 0, &byteArrayPtr)) { objPtr = Tcl_NewObj(); TclInvalidateStringRep(objPtr); } TclFreeIntRep(objPtr); objPtr->typePtr = &properByteArrayType; SET_BYTEARRAY(objPtr, byteArrayPtr); Tcl_IncrRefCount(objPtr); return objPtr; } static int SetByteArrayFromAny( Tcl_Interp *interp, /* Not used. */ Tcl_Obj *objPtr) /* The object to convert to type ByteArray. */ { ByteArray *byteArrayPtr; if (objPtr->typePtr == &properByteArrayType) { return TCL_OK; } if (0 == MakeByteArray(objPtr, 1, &byteArrayPtr)) { return TCL_ERROR; } TclFreeIntRep(objPtr); objPtr->typePtr = &properByteArrayType; SET_BYTEARRAY(objPtr, byteArrayPtr); return TCL_OK; } |
︙ | ︙ |
Changes to generic/tclDictObj.c.
︙ | ︙ | |||
488 489 490 491 492 493 494 | Tcl_Obj *dictPtr) { #define LOCAL_SIZE 64 char localFlags[LOCAL_SIZE], *flagPtr = NULL; Dict *dict = DICT(dictPtr); ChainEntry *cPtr; Tcl_Obj *keyPtr, *valuePtr; | | > | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | Tcl_Obj *dictPtr) { #define LOCAL_SIZE 64 char localFlags[LOCAL_SIZE], *flagPtr = NULL; Dict *dict = DICT(dictPtr); ChainEntry *cPtr; Tcl_Obj *keyPtr, *valuePtr; size_t i, length; int bytesNeeded = 0; const char *elem; char *dst; /* * This field is the most useful one in the whole hash structure, and it * is not exposed by any API function... */ |
︙ | ︙ |
Changes to generic/tclInt.h.
︙ | ︙ | |||
2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 | MODULE_SCOPE Tcl_Command TclMakeEnsemble(Tcl_Interp *interp, const char *name, const EnsembleImplMap map[]); MODULE_SCOPE int TclMaxListLength(const char *bytes, int numBytes, const char **endPtr); MODULE_SCOPE int TclMergeReturnOptions(Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], Tcl_Obj **optionsPtrPtr, int *codePtr, int *levelPtr); MODULE_SCOPE Tcl_Obj * TclNoErrorStack(Tcl_Interp *interp, Tcl_Obj *options); MODULE_SCOPE int TclNokia770Doubles(void); MODULE_SCOPE void TclNsDecrRefCount(Namespace *nsPtr); MODULE_SCOPE void TclObjVarErrMsg(Tcl_Interp *interp, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, const char *operation, const char *reason, int index); MODULE_SCOPE int TclObjInvokeNamespace(Tcl_Interp *interp, | > | 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 | MODULE_SCOPE Tcl_Command TclMakeEnsemble(Tcl_Interp *interp, const char *name, const EnsembleImplMap map[]); MODULE_SCOPE int TclMaxListLength(const char *bytes, int numBytes, const char **endPtr); MODULE_SCOPE int TclMergeReturnOptions(Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], Tcl_Obj **optionsPtrPtr, int *codePtr, int *levelPtr); MODULE_SCOPE Tcl_Obj * TclNarrowToBytes(Tcl_Obj *objPtr); MODULE_SCOPE Tcl_Obj * TclNoErrorStack(Tcl_Interp *interp, Tcl_Obj *options); MODULE_SCOPE int TclNokia770Doubles(void); MODULE_SCOPE void TclNsDecrRefCount(Namespace *nsPtr); MODULE_SCOPE void TclObjVarErrMsg(Tcl_Interp *interp, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, const char *operation, const char *reason, int index); MODULE_SCOPE int TclObjInvokeNamespace(Tcl_Interp *interp, |
︙ | ︙ |