Tcl Source Code

Check-in [b81fc362ed]
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:Some fixes. Still broken on 64-bit systems
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-312-new
Files: files | file ages | folders
SHA3-256: b81fc362ed6f1f0d39d71a2f9301f8800cd09de05823c805d9425399f12a92f5
User & Date: dkf 2019-04-03 09:08:37
Context
2019-04-03
09:36
refactor; mark broken tests as broken check-in: b3ffd86e9b user: dkf tags: tip-312-new
09:08
Some fixes. Still broken on 64-bit systems check-in: b81fc362ed user: dkf tags: tip-312-new
07:58
Import of TIP 312 implementation check-in: 39413ccd4f user: dkf tags: tip-312-new
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to generic/tclLink.c.

    28     28       Tcl_Obj *varName;		/* Name of variable (must be global). This is
    29     29   				 * needed during trace callbacks, since the
    30     30   				 * actual variable may be aliased at that time
    31     31   				 * via upvar. */
    32     32       char *addr;			/* Location of C variable. */
    33     33       int bytes;			/* Size of C variable array. This is 0 when
    34     34   				 * single variables, and >0 used for array
    35         -				 * variables */
           35  +				 * variables. */
           36  +    int numElems;		/* Number of elements in C variable array.
           37  +				 * Zero for single variables. */
    36     38       int type;			/* Type of link (TCL_LINK_INT, etc.). */
    37     39       union {
    38     40   	char c;
    39     41   	unsigned char uc;
    40     42   	int i;
    41     43   	unsigned int ui;
    42     44   	short s;
................................................................................
    45     47   	long l;
    46     48   	unsigned long ul;
    47     49   #endif
    48     50   	Tcl_WideInt w;
    49     51   	Tcl_WideUInt uw;
    50     52   	float f;
    51     53   	double d;
    52         -	void *aryPtr;
           54  +	void *aryPtr;		/* Generic array. */
    53     55   	char *pc;
    54     56   	unsigned char *puc;
    55     57   	int *pi;
    56     58   	unsigned int *pui;
    57     59   	short *ps;
    58     60   	unsigned short *pus;
    59     61   	long *pl;
................................................................................
   168    170   #endif
   169    171       if (type & TCL_LINK_READ_ONLY) {
   170    172   	linkPtr->flags = LINK_READ_ONLY;
   171    173       } else {
   172    174   	linkPtr->flags = 0;
   173    175       }
   174    176       linkPtr->bytes = 0;
          177  +    linkPtr->numElems = 0;
   175    178       objPtr = ObjValue(linkPtr);
   176    179       if (Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, objPtr,
   177    180   	    TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
   178    181   	Tcl_DecrRefCount(linkPtr->varName);
   179    182   	LinkFree(linkPtr);
   180    183   	return TCL_ERROR;
   181    184       }
................................................................................
   230    233   	Tcl_SetObjResult(interp, Tcl_NewStringObj(
   231    234   		"wrong array size given", -1));
   232    235   	return TCL_ERROR;
   233    236       }
   234    237   
   235    238       linkPtr = ckalloc(sizeof(Link));
   236    239       linkPtr->type = type & ~TCL_LINK_READ_ONLY;
          240  +    linkPtr->numElems = size;
   237    241       if (type & TCL_LINK_READ_ONLY) {
   238    242   	linkPtr->flags = LINK_READ_ONLY;
   239    243       } else {
   240    244   	linkPtr->flags = 0;
   241    245       }
   242    246   
   243    247       switch (linkPtr->type) {
................................................................................
   561    565   	    /* single variables */
   562    566   	    switch (linkPtr->type) {
   563    567   	    case TCL_LINK_INT:
   564    568   	    case TCL_LINK_BOOLEAN:
   565    569   		changed = (LinkedVar(int) != linkPtr->lastValue.i);
   566    570   		break;
   567    571   	    case TCL_LINK_DOUBLE:
          572  +		/* FIXME: handle NaN */
   568    573   		changed = (LinkedVar(double) != linkPtr->lastValue.d);
   569    574   		break;
   570    575   	    case TCL_LINK_WIDE_INT:
   571    576   		changed = (LinkedVar(Tcl_WideInt) != linkPtr->lastValue.w);
   572    577   		break;
   573    578   	    case TCL_LINK_WIDE_UINT:
   574    579   		changed = (LinkedVar(Tcl_WideUInt) != linkPtr->lastValue.uw);
................................................................................
   593    598   		changed = (LinkedVar(long) != linkPtr->lastValue.l);
   594    599   		break;
   595    600   	    case TCL_LINK_ULONG:
   596    601   		changed = (LinkedVar(unsigned long) != linkPtr->lastValue.ul);
   597    602   		break;
   598    603   #endif
   599    604   	    case TCL_LINK_FLOAT:
          605  +		/* FIXME: handle NaN */
   600    606   		changed = (LinkedVar(float) != linkPtr->lastValue.f);
   601    607   		break;
   602    608   	    case TCL_LINK_STRING:
   603    609   	    case TCL_LINK_CHARS:
   604    610   	    case TCL_LINK_BINARY:
   605    611   		changed = 1;
   606    612   		break;
................................................................................
   641    647   
   642    648       /*
   643    649        * A couple of helper macros. 
   644    650        */
   645    651   
   646    652   #define CheckHaveList(valueObj, underlyingType)				\
   647    653       if (Tcl_ListObjGetElements(NULL, (valueObj), &objc, &objv) == TCL_ERROR \
   648         -	    || objc != linkPtr->bytes / sizeof(underlyingType)) { \
          654  +	    || objc != linkPtr->numElems) { \
   649    655   	return (char *) "wrong dimension";			  \
   650    656       }
   651    657   #define InRange(lowerLimit, value, upperLimit)	\
   652    658       ((value) >= (lowerLimit) && (value) <= (upperLimit))
   653    659   
   654    660       switch (linkPtr->type) {
   655    661       case TCL_LINK_INT:
................................................................................
  1048   1054    */
  1049   1055   
  1050   1056   static Tcl_Obj *
  1051   1057   ObjValue(
  1052   1058       Link *linkPtr)		/* Structure describing linked variable. */
  1053   1059   {
  1054   1060       char *p;
  1055         -    Tcl_Obj *resultObj;
  1056         -    int objc;
  1057         -    static Tcl_Obj **objv = NULL; // WTF?
         1061  +    Tcl_Obj *resultObj, **objv;
  1058   1062       int i;
  1059   1063   
  1060   1064       switch (linkPtr->type) {
  1061   1065       case TCL_LINK_INT:
  1062   1066   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1063   1067   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1064         -	    objc = linkPtr->bytes / sizeof(int);
  1065         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1066         -	    for (i=0; i < objc; i++) {
         1068  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1069  +	    for (i=0; i < linkPtr->numElems; i++) {
  1067   1070   		objv[i] = Tcl_NewIntObj(linkPtr->lastValue.pi[i]);
  1068   1071   	    }
  1069         -	    return Tcl_NewListObj(objc, objv);
         1072  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1073  +	    ckfree(objv);
         1074  +	    return resultObj;
  1070   1075   	}
  1071   1076   	linkPtr->lastValue.i = LinkedVar(int);
  1072   1077   	return Tcl_NewIntObj(linkPtr->lastValue.i);
  1073   1078       case TCL_LINK_WIDE_INT:
  1074   1079   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1075   1080   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1076         -	    objc = linkPtr->bytes / sizeof(Tcl_WideInt);
  1077         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1078         -	    for (i=0; i < objc; i++) {
         1081  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1082  +	    for (i=0; i < linkPtr->numElems; i++) {
  1079   1083   		objv[i] = Tcl_NewWideIntObj(linkPtr->lastValue.pw[i]);
  1080   1084   	    }
  1081         -	    return Tcl_NewListObj(objc, objv);
         1085  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1086  +	    ckfree(objv);
         1087  +	    return resultObj;
  1082   1088   	}
  1083   1089   	linkPtr->lastValue.w = LinkedVar(Tcl_WideInt);
  1084   1090   	return Tcl_NewWideIntObj(linkPtr->lastValue.w);
  1085   1091       case TCL_LINK_DOUBLE:
  1086   1092   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1087   1093   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1088         -	    objc = linkPtr->bytes / sizeof(double);
  1089         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1090         -	    for (i=0; i < objc; i++) {
         1094  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1095  +	    for (i=0; i < linkPtr->numElems; i++) {
  1091   1096   		objv[i] = Tcl_NewDoubleObj(linkPtr->lastValue.pd[i]);
  1092   1097   	    }
  1093         -	    return Tcl_NewListObj(objc, objv);
         1098  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1099  +	    ckfree(objv);
         1100  +	    return resultObj;
  1094   1101   	}
  1095   1102   	linkPtr->lastValue.d = LinkedVar(double);
  1096   1103   	return Tcl_NewDoubleObj(linkPtr->lastValue.d);
  1097   1104       case TCL_LINK_BOOLEAN:
  1098   1105   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1099   1106   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1100         -	    objc = linkPtr->bytes/sizeof(int);
  1101         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1102         -	    for (i=0; i < objc; i++) {
         1107  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1108  +	    for (i=0; i < linkPtr->numElems; i++) {
  1103   1109   		objv[i] = Tcl_NewBooleanObj(linkPtr->lastValue.pi[i] != 0);
  1104   1110   	    }
  1105         -	    return Tcl_NewListObj(objc, objv);
         1111  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1112  +	    ckfree(objv);
         1113  +	    return resultObj;
  1106   1114   	}
  1107   1115   	linkPtr->lastValue.i = LinkedVar(int);
  1108   1116   	return Tcl_NewBooleanObj(linkPtr->lastValue.i);
  1109   1117       case TCL_LINK_CHAR:
  1110   1118   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1111   1119   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1112         -	    objc = linkPtr->bytes / sizeof(char);
  1113         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1114         -	    for (i=0; i < objc; i++) {
         1120  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1121  +	    for (i=0; i < linkPtr->numElems; i++) {
  1115   1122   		objv[i] = Tcl_NewIntObj(linkPtr->lastValue.pc[i]);
  1116   1123   	    }
  1117         -	    return Tcl_NewListObj(objc, objv);
         1124  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1125  +	    ckfree(objv);
         1126  +	    return resultObj;
  1118   1127   	}
  1119   1128   	linkPtr->lastValue.c = LinkedVar(char);
  1120   1129   	return Tcl_NewIntObj(linkPtr->lastValue.c);
  1121   1130       case TCL_LINK_UCHAR:
  1122   1131   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1123   1132   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1124         -	    objc = linkPtr->bytes / sizeof(unsigned char);
  1125         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1126         -	    for (i=0; i < objc; i++) {
         1133  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1134  +	    for (i=0; i < linkPtr->numElems; i++) {
  1127   1135   		objv[i] = Tcl_NewIntObj(linkPtr->lastValue.puc[i]);
  1128   1136   	    }
  1129         -	    return Tcl_NewListObj(objc, objv);
         1137  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1138  +	    ckfree(objv);
         1139  +	    return resultObj;
  1130   1140   	}
  1131   1141   	linkPtr->lastValue.uc = LinkedVar(unsigned char);
  1132   1142   	return Tcl_NewIntObj(linkPtr->lastValue.uc);
  1133   1143       case TCL_LINK_SHORT:
  1134   1144   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1135   1145   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1136         -	    objc = linkPtr->bytes / sizeof(short);
  1137         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj*));
  1138         -	    for (i=0; i < objc; i++) {
         1146  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1147  +	    for (i=0; i < linkPtr->numElems; i++) {
  1139   1148   		objv[i] = Tcl_NewIntObj(linkPtr->lastValue.ps[i]);
  1140   1149   	    }
  1141         -	    return Tcl_NewListObj(objc, objv);
         1150  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1151  +	    ckfree(objv);
         1152  +	    return resultObj;
  1142   1153   	}
  1143   1154   	linkPtr->lastValue.s = LinkedVar(short);
  1144   1155   	return Tcl_NewIntObj(linkPtr->lastValue.s);
  1145   1156       case TCL_LINK_USHORT:
  1146   1157   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1147   1158   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1148         -	    objc = linkPtr->bytes / sizeof(unsigned short);
  1149         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj*));
  1150         -	    for (i=0; i < objc; i++) {
         1159  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1160  +	    for (i=0; i < linkPtr->numElems; i++) {
  1151   1161   		objv[i] = Tcl_NewIntObj(linkPtr->lastValue.pus[i]);
  1152   1162   	    }
  1153         -	    return Tcl_NewListObj(objc, objv);
         1163  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1164  +	    ckfree(objv);
         1165  +	    return resultObj;
  1154   1166   	}
  1155   1167   	linkPtr->lastValue.us = LinkedVar(unsigned short);
  1156   1168   	return Tcl_NewIntObj(linkPtr->lastValue.us);
  1157   1169       case TCL_LINK_UINT:
  1158   1170   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1159   1171   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1160         -	    objc = linkPtr->bytes / sizeof(unsigned int);
  1161         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1162         -	    for (i=0; i < objc; i++) {
         1172  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1173  +	    for (i=0; i < linkPtr->numElems; i++) {
  1163   1174   		objv[i] = Tcl_NewWideIntObj(linkPtr->lastValue.pui[i]);
  1164   1175   	    }
  1165         -	    return Tcl_NewListObj(objc, objv);
         1176  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1177  +	    ckfree(objv);
         1178  +	    return resultObj;
  1166   1179   	}
  1167   1180   	linkPtr->lastValue.ui = LinkedVar(unsigned int);
  1168   1181   	return Tcl_NewWideIntObj((Tcl_WideInt) linkPtr->lastValue.ui);
  1169   1182   #if !defined(TCL_WIDE_INT_IS_LONG) && !defined(_WIN32) && !defined(__CYGWIN__)
  1170   1183       case TCL_LINK_LONG:
  1171   1184   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1172   1185   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1173         -	    objc = linkPtr->bytes / sizeof(long);
  1174         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1175         -	    for (i=0; i < objc; i++) {
         1186  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1187  +	    for (i=0; i < linkPtr->numElems; i++) {
  1176   1188   		objv[i] = Tcl_NewWideIntObj(linkPtr->lastValue.pl[i]);
  1177   1189   	    }
  1178         -	    return Tcl_NewListObj(objc, objv);
         1190  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1191  +	    ckfree(objv);
         1192  +	    return resultObj;
  1179   1193   	}
  1180   1194   	linkPtr->lastValue.l = LinkedVar(long);
  1181   1195   	return Tcl_NewWideIntObj((Tcl_WideInt) linkPtr->lastValue.l);
  1182   1196       case TCL_LINK_ULONG:
  1183   1197   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1184   1198   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1185         -	    objc = linkPtr->bytes / sizeof(unsigned long);
  1186         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1187         -	    for (i=0; i < objc; i++) {
         1199  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1200  +	    for (i=0; i < linkPtr->numElems; i++) {
  1188   1201   		objv[i] = Tcl_NewWideIntObj(linkPtr->lastValue.pul[i]);
  1189   1202   	    }
  1190         -	    return Tcl_NewListObj(objc, objv);
         1203  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1204  +	    ckfree(objv);
         1205  +	    return resultObj;
  1191   1206   	}
  1192   1207   	linkPtr->lastValue.ul = LinkedVar(unsigned long);
  1193   1208   	return Tcl_NewWideIntObj((Tcl_WideInt) linkPtr->lastValue.ul);
  1194   1209   #endif
  1195   1210       case TCL_LINK_FLOAT:
  1196   1211   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1197   1212   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1198         -	    objc = linkPtr->bytes / sizeof(float);
  1199         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1200         -	    for (i=0; i < objc; i++) {
         1213  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1214  +	    for (i=0; i < linkPtr->numElems; i++) {
  1201   1215   		objv[i] = Tcl_NewDoubleObj(linkPtr->lastValue.pf[i]);
  1202   1216   	    }
  1203         -	    return Tcl_NewListObj(objc, objv);
         1217  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1218  +	    ckfree(objv);
         1219  +	    return resultObj;
  1204   1220   	}
  1205   1221   	linkPtr->lastValue.f = LinkedVar(float);
  1206   1222   	return Tcl_NewDoubleObj(linkPtr->lastValue.f);
  1207   1223       case TCL_LINK_WIDE_UINT:
  1208   1224   	/*
  1209   1225   	 * FIXME: represent as a bignum.
  1210   1226   	 */
  1211   1227   	if (linkPtr->flags & LINK_ALLOC_LAST) {
  1212   1228   	    memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes);
  1213         -	    objc = linkPtr->bytes / sizeof(Tcl_WideUInt);
  1214         -	    objv = ckrealloc(objv, objc * sizeof(Tcl_Obj *));
  1215         -	    for (i=0; i < objc; i++) {
         1229  +	    objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *));
         1230  +	    for (i=0; i < linkPtr->numElems; i++) {
  1216   1231   		objv[i] = Tcl_NewWideIntObj((Tcl_WideInt)
  1217   1232   			linkPtr->lastValue.puw[i]);
  1218   1233   	    }
  1219         -	    return Tcl_NewListObj(objc, objv);
         1234  +	    resultObj = Tcl_NewListObj(linkPtr->numElems, objv);
         1235  +	    ckfree(objv);
         1236  +	    return resultObj;
  1220   1237   	}
  1221   1238   	linkPtr->lastValue.uw = LinkedVar(Tcl_WideUInt);
  1222   1239   	return Tcl_NewWideIntObj((Tcl_WideInt) linkPtr->lastValue.uw);
         1240  +
  1223   1241       case TCL_LINK_STRING:
  1224   1242   	p = LinkedVar(char *);
  1225   1243   	if (p == NULL) {
  1226   1244   	    TclNewLiteralStringObj(resultObj, "NULL");
  1227   1245   	    return resultObj;
  1228   1246   	}
  1229   1247   	return Tcl_NewStringObj(p, -1);

Changes to tests/link.test.

   396    396   test link-8.3 {Tcl_UpdateLinkedVar procedure, read-only variable} {testlink} {
   397    397       testlink create 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   398    398       list [catch {
   399    399   	testlink update 47 {} {} {} {} {} {} {} {} {} {} {} {} {}
   400    400       } msg] $msg $int
   401    401   } {0 {} 47}
   402    402   
   403         -test link-9.1 {linkarray usage messages} {
   404         -    set mylist [list]
   405         -    catch {testlinkarray} my(msg)
   406         -    lappend mylist $my(msg)
   407         -    unset my(msg)
   408         -    catch {testlinkarray x} my(msg)
   409         -    lappend mylist $my(msg)
   410         -    unset my(msg)
   411         -    catch {testlinkarray update} my(msg)
   412         -    lappend mylist $my(msg)
   413         -    unset my(msg)
   414         -    catch {testlinkarray remove} my(msg)
   415         -    lappend mylist $my(msg)
   416         -    unset my(msg)
   417         -    catch {testlinkarray create} my(msg)
   418         -    lappend mylist $my(msg)
   419         -    unset my(msg)
   420         -    catch {testlinkarray create xx 1 my} my(msg)
   421         -    lappend mylist $my(msg)
   422         -    unset my(msg)
   423         -    catch {testlinkarray create char* 0 my} my(msg)
   424         -    lappend mylist $my(msg)
   425         -    unset my(msg)
   426         -    join $mylist "\n"
   427         -} {wrong # args: should be "testlinkarray option args"
          403  +test link-9.1 {linkarray usage messages} -setup {
          404  +    set mylist [list]
          405  +} -body {
          406  +    catch {testlinkarray} msg
          407  +    lappend mylist $msg
          408  +    catch {testlinkarray x} msg
          409  +    lappend mylist $msg
          410  +    catch {testlinkarray update} msg
          411  +    lappend mylist $msg
          412  +    catch {testlinkarray remove} msg
          413  +    lappend mylist $msg
          414  +    catch {testlinkarray create} msg
          415  +    lappend mylist $msg
          416  +    catch {testlinkarray create xx 1 my} msg
          417  +    lappend mylist $msg
          418  +    catch {testlinkarray create char* 0 my} msg
          419  +    lappend mylist $msg
          420  +    join $mylist "\n"
          421  +} -cleanup {
          422  +    unset -nocomplain my
          423  +} -result {wrong # args: should be "testlinkarray option args"
   428    424   bad option "x": must be update, remove, or create
   429    425   
   430    426   
   431    427   wrong # args: should be "testlinkarray create ?-readonly? type size name ?address?"
   432    428   bad type "xx": must be char, uchar, short, ushort, int, uint, long, ulong, wide, uwide, float, double, string, char*, or binary
   433    429   wrong array size given}
   434    430   
   435         -test link-10.1 {linkarray char*} {
          431  +test link-10.1 {linkarray char*} -setup {
   436    432       set mylist [list]
          433  +} -body {
   437    434       testlinkarray create char* 1 ::my(var)
   438    435       lappend mylist [set ::my(var) ""]
   439         -    catch {set ::my(var) x} my(msg)
   440         -    lappend mylist $my(msg)
   441         -    unset my(msg)
          436  +    catch {set ::my(var) x} msg
          437  +    lappend mylist $msg
   442    438       testlinkarray remove ::my(var)
   443    439       testlinkarray create char* 4 ::my(var)
   444    440       set ::my(var) x
   445         -    catch {set ::my(var) xyzz} my(msg)
   446         -    lappend mylist $my(msg)
   447         -    unset my(msg)
          441  +    catch {set ::my(var) xyzz} msg
          442  +    lappend mylist $msg
   448    443       testlinkarray remove ::my(var)
   449    444       testlinkarray create -r char* 4 ::my(var)
   450         -    catch {set ::my(var) x} my(msg)
   451         -    lappend mylist $my(msg)
   452         -    unset my(msg)
          445  +    catch {set ::my(var) x} msg
          446  +    lappend mylist $msg
   453    447       testlinkarray remove ::my(var)
   454         -    unset my
   455    448       join $mylist "\n"
   456         -} {
          449  +} -cleanup {
          450  +    unset -nocomplain my
          451  +} -result {
   457    452   can't set "::my(var)": wrong size of char* value
   458    453   can't set "::my(var)": wrong size of char* value
   459    454   can't set "::my(var)": linked variable is read-only}
   460    455   
   461         -test link-11.1 {linkarray char} {
          456  +test link-11.1 {linkarray char} -setup {
   462    457       set mylist [list]
          458  +} -body {
   463    459       testlinkarray create char 1 ::my(var)
   464         -    catch {set ::my(var) x} my(msg)
   465         -    lappend mylist $my(msg)
   466         -    unset my(msg)
          460  +    catch {set ::my(var) x} msg
          461  +    lappend mylist $msg
   467    462       lappend mylist [set ::my(var) 120]
   468         -    catch {set ::my(var) 1234} my(msg)
   469         -    lappend mylist $my(msg)
   470         -    unset my(msg)
          463  +    catch {set ::my(var) 1234} msg
          464  +    lappend mylist $msg
   471    465       testlinkarray remove ::my(var)
   472    466       testlinkarray create char 4 ::my(var)
   473         -    catch {set ::my(var) {1 2 3}} my(msg)
   474         -    lappend mylist $my(msg)
   475         -    unset my(msg)
          467  +    catch {set ::my(var) {1 2 3}} msg
          468  +    lappend mylist $msg
   476    469       set ::my(var) {1 2 3 4}
   477    470       lappend mylist $my(var)
   478    471       testlinkarray remove ::my(var)
   479    472       testlinkarray create -r char 2 ::my(var)
   480         -    catch {set ::my(var) {1 2}} my(msg)
   481         -    lappend mylist $my(msg)
   482         -    unset my(msg)
          473  +    catch {set ::my(var) {1 2}} msg
          474  +    lappend mylist $msg
   483    475       testlinkarray remove ::my(var)
   484         -    unset my
   485    476       join $mylist "\n"
   486         -} {can't set "::my(var)": variable must have char value
          477  +} -cleanup {
          478  +    unset -nocomplain my
          479  +} -result {can't set "::my(var)": variable must have char value
   487    480   120
   488    481   can't set "::my(var)": variable must have char value
   489    482   can't set "::my(var)": wrong dimension
   490    483   1 2 3 4
   491    484   can't set "::my(var)": linked variable is read-only}
   492    485   
   493         -test link-12.1 {linkarray unsigned char} {
          486  +test link-12.1 {linkarray unsigned char} -setup {
   494    487       set mylist [list]
          488  +} -body {
   495    489       testlinkarray create uchar 1 ::my(var)
   496         -    catch {set ::my(var) x} my(msg)
   497         -    lappend mylist $my(msg)
   498         -    unset my(msg)
          490  +    catch {set ::my(var) x} msg
          491  +    lappend mylist $msg
   499    492       lappend mylist [set ::my(var) 120]
   500         -    catch {set ::my(var) 1234} my(msg)
   501         -    lappend mylist $my(msg)
   502         -    unset my(msg)
   503         -    catch {set ::my(var) -1} my(msg)
   504         -    lappend mylist $my(msg)
   505         -    unset my(msg)
          493  +    catch {set ::my(var) 1234} msg
          494  +    lappend mylist $msg
          495  +    catch {set ::my(var) -1} msg
          496  +    lappend mylist $msg
   506    497       testlinkarray remove ::my(var)
   507    498       testlinkarray create uchar 4 ::my(var)
   508         -    catch {set ::my(var) {1 2 3}} my(msg)
   509         -    lappend mylist $my(msg)
   510         -    unset my(msg)
          499  +    catch {set ::my(var) {1 2 3}} msg
          500  +    lappend mylist $msg
   511    501       set ::my(var) {1 2 3 4}
   512    502       lappend mylist $my(var)
   513    503       testlinkarray remove ::my(var)
   514    504       testlinkarray create -r uchar 2 ::my(var)
   515         -    catch {set ::my(var) {1 2}} my(msg)
   516         -    lappend mylist $my(msg)
   517         -    unset my(msg)
          505  +    catch {set ::my(var) {1 2}} msg
          506  +    lappend mylist $msg
   518    507       testlinkarray remove ::my(var)
   519         -    unset my
   520    508       join $mylist "\n"
   521         -} {can't set "::my(var)": variable must have unsigned char value
          509  +} -cleanup {
          510  +    unset -nocomplain my
          511  +} -result {can't set "::my(var)": variable must have unsigned char value
   522    512   120
   523    513   can't set "::my(var)": variable must have unsigned char value
   524    514   can't set "::my(var)": variable must have unsigned char value
   525    515   can't set "::my(var)": wrong dimension
   526    516   1 2 3 4
   527    517   can't set "::my(var)": linked variable is read-only}
   528    518   
   529         -test link-13.1 {linkarray short} {
          519  +test link-13.1 {linkarray short} -setup {
   530    520       set mylist [list]
          521  +} -body {
   531    522       testlinkarray create short 1 ::my(var)
   532         -    catch {set ::my(var) x} my(msg)
   533         -    lappend mylist $my(msg)
   534         -    unset my(msg)
          523  +    catch {set ::my(var) x} msg
          524  +    lappend mylist $msg
   535    525       lappend mylist [set ::my(var) 120]
   536         -    catch {set ::my(var) 123456} my(msg)
   537         -    lappend mylist $my(msg)
   538         -    unset my(msg)
          526  +    catch {set ::my(var) 123456} msg
          527  +    lappend mylist $msg
   539    528       testlinkarray remove ::my(var)
   540    529       testlinkarray create short 4 ::my(var)
   541         -    catch {set ::my(var) {1 2 3}} my(msg)
   542         -    lappend mylist $my(msg)
   543         -    unset my(msg)
          530  +    catch {set ::my(var) {1 2 3}} msg
          531  +    lappend mylist $msg
   544    532       set ::my(var) {1 2 3 4}
   545    533       lappend mylist $my(var)
   546    534       testlinkarray remove ::my(var)
   547    535       testlinkarray create -r short 2 ::my(var)
   548         -    catch {set ::my(var) {1 2}} my(msg)
   549         -    lappend mylist $my(msg)
   550         -    unset my(msg)
          536  +    catch {set ::my(var) {1 2}} msg
          537  +    lappend mylist $msg
   551    538       testlinkarray remove ::my(var)
   552         -    unset my
   553    539       join $mylist "\n"
   554         -} {can't set "::my(var)": variable must have short value
          540  +} -cleanup {
          541  +    unset -nocomplain my
          542  +} -result {can't set "::my(var)": variable must have short value
   555    543   120
   556    544   can't set "::my(var)": variable must have short value
   557    545   can't set "::my(var)": wrong dimension
   558    546   1 2 3 4
   559    547   can't set "::my(var)": linked variable is read-only}
   560    548   
   561         -test link-14.1 {linkarray unsigned short} {
          549  +test link-14.1 {linkarray unsigned short} -setup {
   562    550       set mylist [list]
          551  +} -body {
   563    552       testlinkarray create ushort 1 ::my(var)
   564         -    catch {set ::my(var) x} my(msg)
   565         -    lappend mylist $my(msg)
   566         -    unset my(msg)
          553  +    catch {set ::my(var) x} msg
          554  +    lappend mylist $msg
   567    555       lappend mylist [set ::my(var) 120]
   568         -    catch {set ::my(var) 123456} my(msg)
   569         -    lappend mylist $my(msg)
   570         -    unset my(msg)
   571         -    catch {set ::my(var) -1} my(msg)
   572         -    lappend mylist $my(msg)
   573         -    unset my(msg)
          556  +    catch {set ::my(var) 123456} msg
          557  +    lappend mylist $msg
          558  +    catch {set ::my(var) -1} msg
          559  +    lappend mylist $msg
   574    560       testlinkarray remove ::my(var)
   575    561       testlinkarray create ushort 4 ::my(var)
   576         -    catch {set ::my(var) {1 2 3}} my(msg)
   577         -    lappend mylist $my(msg)
   578         -    unset my(msg)
          562  +    catch {set ::my(var) {1 2 3}} msg
          563  +    lappend mylist $msg
   579    564       set ::my(var) {1 2 3 4}
   580    565       lappend mylist $my(var)
   581    566       testlinkarray remove ::my(var)
   582    567       testlinkarray create -r ushort 2 ::my(var)
   583         -    catch {set ::my(var) {1 2}} my(msg)
   584         -    lappend mylist $my(msg)
   585         -    unset my(msg)
          568  +    catch {set ::my(var) {1 2}} msg
          569  +    lappend mylist $msg
   586    570       testlinkarray remove ::my(var)
   587         -    unset my
   588    571       join $mylist "\n"
   589         -} {can't set "::my(var)": variable must have unsigned short value
          572  +} -cleanup {
          573  +    unset -nocomplain my
          574  +} -result {can't set "::my(var)": variable must have unsigned short value
   590    575   120
   591    576   can't set "::my(var)": variable must have unsigned short value
   592    577   can't set "::my(var)": variable must have unsigned short value
   593    578   can't set "::my(var)": wrong dimension
   594    579   1 2 3 4
   595    580   can't set "::my(var)": linked variable is read-only}
   596    581   
   597         -test link-15.1 {linkarray int} {
          582  +test link-15.1 {linkarray int} -setup {
   598    583       set mylist [list]
          584  +} -body {
   599    585       testlinkarray create int 1 ::my(var)
   600         -    catch {set ::my(var) x} my(msg)
   601         -    lappend mylist $my(msg)
   602         -    unset my(msg)
          586  +    catch {set ::my(var) x} msg
          587  +    lappend mylist $msg
   603    588       lappend mylist [set ::my(var) 120]
   604         -    catch {set ::my(var) 1e3} my(msg)
   605         -    lappend mylist $my(msg)
   606         -    unset my(msg)
          589  +    catch {set ::my(var) 1e3} msg
          590  +    lappend mylist $msg
   607    591       testlinkarray remove ::my(var)
   608    592       testlinkarray create int 4 ::my(var)
   609         -    catch {set ::my(var) {1 2 3}} my(msg)
   610         -    lappend mylist $my(msg)
   611         -    unset my(msg)
          593  +    catch {set ::my(var) {1 2 3}} msg
          594  +    lappend mylist $msg
   612    595       set ::my(var) {1 2 3 4}
   613    596       lappend mylist $my(var)
   614    597       testlinkarray remove ::my(var)
   615    598       testlinkarray create -r int 2 ::my(var)
   616         -    catch {set ::my(var) {1 2}} my(msg)
   617         -    lappend mylist $my(msg)
   618         -    unset my(msg)
          599  +    catch {set ::my(var) {1 2}} msg
          600  +    lappend mylist $msg
   619    601       testlinkarray remove ::my(var)
   620         -    unset my
   621    602       join $mylist "\n"
   622         -} {can't set "::my(var)": variable must have integer value
          603  +} -cleanup {
          604  +    unset -nocomplain my
          605  +} -result {can't set "::my(var)": variable must have integer value
   623    606   120
   624    607   can't set "::my(var)": variable must have integer value
   625    608   can't set "::my(var)": wrong dimension
   626    609   1 2 3 4
   627    610   can't set "::my(var)": linked variable is read-only}
   628    611   
   629         -test link-16.1 {linkarray unsigned int} {
          612  +test link-16.1 {linkarray unsigned int} -setup {
   630    613       set mylist [list]
          614  +} -body {
   631    615       testlinkarray create uint 1 ::my(var)
   632         -    catch {set ::my(var) x} my(msg)
   633         -    lappend mylist $my(msg)
   634         -    unset my(msg)
          616  +    catch {set ::my(var) x} msg
          617  +    lappend mylist $msg
   635    618       lappend mylist [set ::my(var) 120]
   636         -    catch {set ::my(var) 1e33} my(msg)
   637         -    lappend mylist $my(msg)
   638         -    unset my(msg)
   639         -    catch {set ::my(var) -1} my(msg)
   640         -    lappend mylist $my(msg)
   641         -    unset my(msg)
          619  +    catch {set ::my(var) 1e33} msg
          620  +    lappend mylist $msg
          621  +    catch {set ::my(var) -1} msg
          622  +    lappend mylist $msg
   642    623       testlinkarray remove ::my(var)
   643    624       testlinkarray create uint 4 ::my(var)
   644         -    catch {set ::my(var) {1 2 3}} my(msg)
   645         -    lappend mylist $my(msg)
   646         -    unset my(msg)
          625  +    catch {set ::my(var) {1 2 3}} msg
          626  +    lappend mylist $msg
   647    627       set ::my(var) {1 2 3 4}
   648    628       lappend mylist $my(var)
   649    629       testlinkarray remove ::my(var)
   650    630       testlinkarray create -r uint 2 ::my(var)
   651         -    catch {set ::my(var) {1 2}} my(msg)
   652         -    lappend mylist $my(msg)
   653         -    unset my(msg)
          631  +    catch {set ::my(var) {1 2}} msg
          632  +    lappend mylist $msg
   654    633       testlinkarray remove ::my(var)
   655         -    unset my
   656    634       join $mylist "\n"
   657         -} {can't set "::my(var)": variable must have unsigned int value
          635  +} -cleanup {
          636  +    unset -nocomplain my
          637  +} -result {can't set "::my(var)": variable must have unsigned int value
   658    638   120
   659    639   can't set "::my(var)": variable must have unsigned int value
   660    640   can't set "::my(var)": variable must have unsigned int value
   661    641   can't set "::my(var)": wrong dimension
   662    642   1 2 3 4
   663    643   can't set "::my(var)": linked variable is read-only}
   664    644   
   665         -test link-17.1 {linkarray long} {
          645  +test link-17.1 {linkarray long} -setup {
   666    646       set mylist [list]
          647  +} -body {
   667    648       testlinkarray create long 1 ::my(var)
   668         -    catch {set ::my(var) x} my(msg)
   669         -    lappend mylist $my(msg)
   670         -    unset my(msg)
          649  +    catch {set ::my(var) x} msg
          650  +    lappend mylist $msg
   671    651       lappend mylist [set ::my(var) 120]
   672         -    catch {set ::my(var) 1e33} my(msg)
   673         -    lappend mylist $my(msg)
   674         -    unset my(msg)
          652  +    catch {set ::my(var) 1e33} msg
          653  +    lappend mylist $msg
   675    654       testlinkarray remove ::my(var)
   676    655       testlinkarray create long 4 ::my(var)
   677         -    catch {set ::my(var) {1 2 3}} my(msg)
   678         -    lappend mylist $my(msg)
   679         -    unset my(msg)
          656  +    catch {set ::my(var) {1 2 3}} msg
          657  +    lappend mylist $msg
   680    658       set ::my(var) {1 2 3 4}
   681    659       lappend mylist $my(var)
   682    660       testlinkarray remove ::my(var)
   683    661       testlinkarray create -r long 2 ::my(var)
   684         -    catch {set ::my(var) {1 2}} my(msg)
   685         -    lappend mylist $my(msg)
   686         -    unset my(msg)
          662  +    catch {set ::my(var) {1 2}} msg
          663  +    lappend mylist $msg
   687    664       testlinkarray remove ::my(var)
   688         -    unset my
   689    665       join $mylist "\n"
   690         -} {can't set "::my(var)": variable must have long value
          666  +} -cleanup {
          667  +    unset -nocomplain my
          668  +} -match glob -result {can't set "::my(var)": variable must have * value
   691    669   120
   692         -can't set "::my(var)": variable must have long value
          670  +can't set "::my(var)": variable must have * value
   693    671   can't set "::my(var)": wrong dimension
   694    672   1 2 3 4
   695    673   can't set "::my(var)": linked variable is read-only}
   696    674   
   697         -test link-18.1 {linkarray unsigned long} {
          675  +test link-18.1 {linkarray unsigned long} -setup {
   698    676       set mylist [list]
          677  +} -body {
   699    678       testlinkarray create ulong 1 ::my(var)
   700         -    catch {set ::my(var) x} my(msg)
   701         -    lappend mylist $my(msg)
   702         -    unset my(msg)
          679  +    catch {set ::my(var) x} msg
          680  +    lappend mylist $msg
   703    681       lappend mylist [set ::my(var) 120]
   704         -    catch {set ::my(var) 1e33} my(msg)
   705         -    lappend mylist $my(msg)
   706         -    unset my(msg)
   707         -    catch {set ::my(var) -1} my(msg)
   708         -    lappend mylist $my(msg)
   709         -    unset my(msg)
          682  +    catch {set ::my(var) 1e33} msg
          683  +    lappend mylist $msg
          684  +    catch {set ::my(var) -1} msg
          685  +    lappend mylist $msg
   710    686       testlinkarray remove ::my(var)
   711    687       testlinkarray create ulong 4 ::my(var)
   712         -    catch {set ::my(var) {1 2 3}} my(msg)
   713         -    lappend mylist $my(msg)
   714         -    unset my(msg)
          688  +    catch {set ::my(var) {1 2 3}} msg
          689  +    lappend mylist $msg
   715    690       set ::my(var) {1 2 3 4}
   716    691       lappend mylist $my(var)
   717    692       testlinkarray remove ::my(var)
   718    693       testlinkarray create -r ulong 2 ::my(var)
   719         -    catch {set ::my(var) {1 2}} my(msg)
   720         -    lappend mylist $my(msg)
   721         -    unset my(msg)
          694  +    catch {set ::my(var) {1 2}} msg
          695  +    lappend mylist $msg
   722    696       testlinkarray remove ::my(var)
   723         -    unset my
   724    697       join $mylist "\n"
   725         -} {can't set "::my(var)": variable must have unsigned long value
          698  +} -cleanup {
          699  +    unset -nocomplain my
          700  +} -match glob -result {can't set "::my(var)": variable must have unsigned * value
   726    701   120
   727         -can't set "::my(var)": variable must have unsigned long value
   728         -can't set "::my(var)": variable must have unsigned long value
          702  +can't set "::my(var)": variable must have unsigned * value
          703  +can't set "::my(var)": variable must have unsigned * value
   729    704   can't set "::my(var)": wrong dimension
   730    705   1 2 3 4
   731    706   can't set "::my(var)": linked variable is read-only}
   732    707   
   733         -test link-19.1 {linkarray wide} {
          708  +test link-19.1 {linkarray wide} -setup {
   734    709       set mylist [list]
          710  +} -body {
   735    711       testlinkarray create wide 1 ::my(var)
   736         -    catch {set ::my(var) x} my(msg)
   737         -    lappend mylist $my(msg)
   738         -    unset my(msg)
          712  +    catch {set ::my(var) x} msg
          713  +    lappend mylist $msg
   739    714       lappend mylist [set ::my(var) 120]
   740         -    catch {set ::my(var) 1e33} my(msg)
   741         -    lappend mylist $my(msg)
   742         -    unset my(msg)
          715  +    catch {set ::my(var) 1e33} msg
          716  +    lappend mylist $msg
   743    717       testlinkarray remove ::my(var)
   744    718       testlinkarray create wide 4 ::my(var)
   745         -    catch {set ::my(var) {1 2 3}} my(msg)
   746         -    lappend mylist $my(msg)
   747         -    unset my(msg)
          719  +    catch {set ::my(var) {1 2 3}} msg
          720  +    lappend mylist $msg
   748    721       set ::my(var) {1 2 3 4}
   749    722       lappend mylist $my(var)
   750    723       testlinkarray remove ::my(var)
   751    724       testlinkarray create -r wide 2 ::my(var)
   752         -    catch {set ::my(var) {1 2}} my(msg)
   753         -    lappend mylist $my(msg)
   754         -    unset my(msg)
          725  +    catch {set ::my(var) {1 2}} msg
          726  +    lappend mylist $msg
   755    727       testlinkarray remove ::my(var)
   756         -    unset my
   757    728       join $mylist "\n"
   758         -} {can't set "::my(var)": variable must have wide integer value
          729  +} -cleanup {
          730  +    unset -nocomplain my
          731  +} -result {can't set "::my(var)": variable must have wide integer value
   759    732   120
   760    733   can't set "::my(var)": variable must have wide integer value
   761    734   can't set "::my(var)": wrong dimension
   762    735   1 2 3 4
   763    736   can't set "::my(var)": linked variable is read-only}
   764    737   
   765         -test link-20.1 {linkarray unsigned wide} {
          738  +test link-20.1 {linkarray unsigned wide} -setup {
   766    739       set mylist [list]
          740  +} -body {
   767    741       testlinkarray create uwide 1 ::my(var)
   768         -    catch {set ::my(var) x} my(msg)
   769         -    lappend mylist $my(msg)
   770         -    unset my(msg)
          742  +    catch {set ::my(var) x} msg
          743  +    lappend mylist $msg
   771    744       lappend mylist [set ::my(var) 120]
   772         -    catch {set ::my(var) 1e33} my(msg)
   773         -    lappend mylist $my(msg)
   774         -    unset my(msg)
   775         -    catch {set ::my(var) -1} my(msg)
   776         -    lappend mylist $my(msg)
   777         -    unset my(msg)
          745  +    catch {set ::my(var) 1e33} msg
          746  +    lappend mylist $msg
          747  +    catch {set ::my(var) -1} msg
          748  +    lappend mylist $msg
   778    749       testlinkarray remove ::my(var)
   779    750       testlinkarray create uwide 4 ::my(var)
   780         -    catch {set ::my(var) {1 2 3}} my(msg)
   781         -    lappend mylist $my(msg)
   782         -    unset my(msg)
          751  +    catch {set ::my(var) {1 2 3}} msg
          752  +    lappend mylist $msg
   783    753       set ::my(var) {1 2 3 4}
   784    754       lappend mylist $my(var)
   785    755       testlinkarray remove ::my(var)
   786    756       testlinkarray create -r uwide 2 ::my(var)
   787         -    catch {set ::my(var) {1 2}} my(msg)
   788         -    lappend mylist $my(msg)
   789         -    unset my(msg)
          757  +    catch {set ::my(var) {1 2}} msg
          758  +    lappend mylist $msg
   790    759       testlinkarray remove ::my(var)
   791         -    unset my
   792    760       join $mylist "\n"
   793         -} {can't set "::my(var)": variable must have unsigned wide int value
          761  +} -cleanup {
          762  +    unset -nocomplain my
          763  +} -result {can't set "::my(var)": variable must have unsigned wide int value
   794    764   120
   795    765   can't set "::my(var)": variable must have unsigned wide int value
   796    766   can't set "::my(var)": variable must have unsigned wide int value
   797    767   can't set "::my(var)": wrong dimension
   798    768   1 2 3 4
   799    769   can't set "::my(var)": linked variable is read-only}
   800    770   
   801         -test link-21.1 {linkarray string} {
          771  +test link-21.1 {linkarray string} -setup {
   802    772       set mylist [list]
          773  +} -body {
   803    774       testlinkarray create string 1 ::my(var)
   804    775       lappend mylist [set ::my(var) ""]
   805    776       lappend mylist [set ::my(var) "xyz"]
   806    777       lappend mylist $::my(var)
   807    778       testlinkarray remove ::my(var)
   808    779       testlinkarray create -r string 4 ::my(var)
   809         -    catch {set ::my(var) x} my(msg)
   810         -    lappend mylist $my(msg)
   811         -    unset my(msg)
          780  +    catch {set ::my(var) x} msg
          781  +    lappend mylist $msg
   812    782       testlinkarray remove ::my(var)
   813         -    unset my
   814    783       join $mylist "\n"
   815         -} {
          784  +} -cleanup {
          785  +    unset -nocomplain my
          786  +} -result {
   816    787   xyz
   817    788   xyz
   818    789   can't set "::my(var)": linked variable is read-only}
   819    790   
   820         -test link-22.1 {linkarray binary} {
          791  +test link-22.1 {linkarray binary} -setup {
   821    792       set mylist [list]
          793  +} -body {
   822    794       testlinkarray create binary 1 ::my(var)
   823    795       set ::my(var) x
   824         -    catch {set ::my(var) xy} my(msg)
   825         -    lappend mylist $my(msg)
   826         -    unset my(msg)
          796  +    catch {set ::my(var) xy} msg
          797  +    lappend mylist $msg
   827    798       lappend mylist $::my(var)
   828    799       testlinkarray remove ::my(var)
   829    800       testlinkarray create binary 4 ::my(var)
   830         -    catch {set ::my(var) abc} my(msg)
   831         -    lappend mylist $my(msg)
   832         -    unset my(msg)
   833         -    catch {set ::my(var) abcde} my(msg)
   834         -    lappend mylist $my(msg)
   835         -    unset my(msg)
          801  +    catch {set ::my(var) abc} msg
          802  +    lappend mylist $msg
          803  +    catch {set ::my(var) abcde} msg
          804  +    lappend mylist $msg
   836    805       set ::my(var) abcd
   837    806       lappend mylist $::my(var)
   838    807       testlinkarray remove ::my(var)
   839    808       testlinkarray create -r binary 4 ::my(var)
   840         -    catch {set ::my(var) xyzv} my(msg)
   841         -    lappend mylist $my(msg)
   842         -    unset my(msg)
          809  +    catch {set ::my(var) xyzv} msg
          810  +    lappend mylist $msg
   843    811       testlinkarray remove ::my(var)
   844         -    unset my
   845    812       join $mylist "\n"
   846         -} {can't set "::my(var)": wrong size of binary value
          813  +} -cleanup {
          814  +    unset -nocomplain my
          815  +} -result {can't set "::my(var)": wrong size of binary value
   847    816   x
   848    817   can't set "::my(var)": wrong size of binary value
   849    818   can't set "::my(var)": wrong size of binary value
   850    819   abcd
   851    820   can't set "::my(var)": linked variable is read-only}
   852    821   
   853    822   catch {testlink set 0 0 0 - 0 0 0 0 0 0 0 0 0 0}