----- Original Message -----
From: "David & Lisa Jacobs" <[EMAIL PROTECTED]>


> * Add transcoding ops (this might be a specific case of the previous e.g.,
> set S0, S1, "unicode", "utf-16")

Note that there is still a bug in string_transcode as of string.c 1.35; I
have repeated a patch below. I tested this with a separate opcode, but I
like your idea of using set.

> * Add size of string termination to encodings (i.e., how many 0 bytes)

Should string termination be required? If strings are assumed to be
terminated, it seems to me that precludes buffer re-use (copy-on-write) for
substrings. On the other hand, passing strings to native C library routines
requires the termination. One compromise would be for 'unique' strings to be
terminated, and do 'copy-on-read' if a non-unique string (i.e. one borrowing
a buffer) is passed to an external function.

Peter Gibbs
EmKel Systems


Index: string.c
===================================================================
RCS file: /home/perlcvs/parrot/string.c,v
retrieving revision 1.35
diff -c -r1.35 string.c
*** string.c 1 Jan 2002 17:53:50 -0000 1.35
--- string.c 2 Jan 2002 07:27:16 -0000
***************
*** 179,185 ****
      srcstart = (void*)src->bufstart;
      srcend = srcstart + src->bufused;
      deststart = dest->bufstart;
!     destend = deststart + dest->buflen;

      while (srcstart < srcend) {
          INTVAL c = src->encoding->decode(srcstart);
--- 179,185 ----
      srcstart = (void*)src->bufstart;
      srcend = srcstart + src->bufused;
      deststart = dest->bufstart;
!     destend = deststart;

      while (srcstart < srcend) {
          INTVAL c = src->encoding->decode(srcstart);
***************
*** 187,193 ****
          if (transcoder1) c = transcoder1(c);
          if (transcoder2) c = transcoder2(c);

!         deststart = dest->encoding->encode(deststart, c);

          srcstart = src->encoding->skip_forward(srcstart, 1);
      }
--- 187,193 ----
          if (transcoder1) c = transcoder1(c);
          if (transcoder2) c = transcoder2(c);

!         destend = dest->encoding->encode(destend, c);

          srcstart = src->encoding->skip_forward(srcstart, 1);
      }


Reply via email to