Makarius, > On 20 Sep 2016, at 16:42, Makarius <[email protected]> wrote: > > On 20/09/16 16:50, Rob Arthan wrote: >> >> I think this patch fixes it: >> >> diff --git a/libpolyml/pexport.cpp b/libpolyml/pexport.cpp >> index b03b1da..a9ebd2e 100644 >> --- a/libpolyml/pexport.cpp >> +++ b/libpolyml/pexport.cpp >> @@ -158,7 +158,7 @@ void PExport::printObject(PolyObject *p) >> for (unsigned i = 0; i < ps->length; i++) >> { >> char ch = ps->chars[i]; >> - fprintf(exportFile, "%02x", ch); >> + fprintf(exportFile, "%02x", ch & 0xff); >> } >> } >> else > > It seems to work, but it is unclear to me why. > > A few lines before there is the following text: > > /* See if the first word is a possible length. The length > cannot be one because single character strings are > represented by the character. */ > /* This is not infallible but it seems to be good enough > to detect the strings. */ > POLYUNSIGNED bytes = length * sizeof(PolyWord); > if (length >= 2 && ...) > > It looks like it requires further update. >
I think length is the length of the PolyObject representing the string while ps->length is the length of the string and will have been 1 in the call that caused the problem. I suspect the comments and possibly the test on length are redundant. Regards, Rob. _______________________________________________ polyml mailing list [email protected] http://lists.inf.ed.ac.uk/mailman/listinfo/polyml
