Hi Serg, Paul, all

I found another problem with owtcl's returning binary data. As soon the
result form owlib contains a 0xc8, the input is wrongly treated as
UTF-8. I made a patch similar to that of ow::put.

If you think it's ok I will commit it.

Kind regards

        Jan



Index: ow.c
===================================================================
RCS file: /cvsroot/owfs/owfs/module/owtcl/ow.c,v
retrieving revision 1.6
diff -u -r1.6 ow.c
--- ow.c        5 Jul 2013 18:53:23 -0000       1.6
+++ ow.c        12 Aug 2013 20:04:09 -0000
@@ -316,6 +316,8 @@
 {
        OwtclStateType *OwtclStatePtr = (OwtclStateType *) clientData;
        char *arg, *path, *buf = NULL, *d, *p;
+       Tcl_UniChar *uvalue;
+       int v;
        int tcl_return = TCL_OK, r, s, lst;
        size_t ss;
        Tcl_Obj *resultPtr;
@@ -378,7 +380,20 @@
                        resultPtr = Tcl_NewStringObj(buf, -1);
                }
        } else {
-               resultPtr = Tcl_NewStringObj(buf, s);
+               if ((s==1) && (buf[0]==0)) {
+                       tcl_return = TCL_OK;
+                       goto common_exit;
+               }
+
+               uvalue = malloc(2*s);
+               if (uvalue == NULL) {
+                       tcl_return = TCL_OK;
+                       goto common_exit;
+               }
+               for (v=0 ; v < s ; v++)
+                       uvalue[v]=(Tcl_UniChar)buf[v];
+               resultPtr = Tcl_NewUnicodeObj(uvalue, s);
+               free(uvalue);
        }
        Tcl_SetObjResult(interp, resultPtr);
        free(buf);

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to