8 static int strs(Tcl_Interp *ip, int strc, Tcl_Obj *const *strv, int *l_r) {
12 for (i=1; i<strc; i++) {
13 rc= Tcl_ConvertToType(ip,strv[i],&hbytes_type);
15 l += HBYTES_LEN(HBYTES(strv[i]));
16 fprintf(stderr,"strs #%d %d %02x\n",i,l,
17 HBYTES(strv[i]).start ? HBYTES(strv[i]).start[0] : 0xff);
23 int app_pre(ClientData cd, Tcl_Interp *ip, int begin,
24 HBytes_Var v, int strc, Tcl_Obj *const *strv) {
25 int ol, rc, al, i, tl;
27 rc= strs(ip,strc,strv,&al); if (rc) return rc;
29 ol= HBYTES_LEN(*v.hb);
30 v.hb->start= v.hb->end= Tcl_Realloc(v.hb->start, ol + al);
32 if (begin) v.hb->end += ol;
33 else memmove(v.hb->start + al, v.hb->start, ol);
35 for (i=1; i<strc; i++) {
36 tl= HBYTES_LEN(HBYTES(strv[i]));
37 memcpy(v.hb->end, HBYTES(strv[i]).start, tl);
43 int do_hbytes_append(ClientData cd, Tcl_Interp *ip,
44 HBytes_Var v, int strc, Tcl_Obj *const *strv) {
45 return app_pre(cd,ip,0,v,strc,strv);
48 int do_hbytes_prepend(ClientData cd, Tcl_Interp *ip,
49 HBytes_Var v, int strc, Tcl_Obj *const *strv) {
50 return app_pre(cd,ip,1,v,strc,strv);
53 int do_hbytes_concat(ClientData cd, Tcl_Interp *ip,
54 int strc, Tcl_Obj *const *strv, HBytes_Value *result) {
57 result->start= result->end= 0;
59 return app_pre(cd,ip,1,fake,strc,strv);