cvsuser 04/01/08 02:44:45
Modified: src string.c
Log:
Change string_transcode to use iterator for source string
Revision Changes Path
1.166 +7 -13 parrot/src/string.c
Index: string.c
===================================================================
RCS file: /cvs/public/parrot/src/string.c,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -w -r1.165 -r1.166
--- string.c 8 Jan 2004 09:12:30 -0000 1.165
+++ string.c 8 Jan 2004 10:44:45 -0000 1.166
@@ -1,7 +1,7 @@
/* string.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: string.c,v 1.165 2004/01/08 09:12:30 petergibbs Exp $
+ * $Id: string.c,v 1.166 2004/01/08 10:44:45 petergibbs Exp $
* Overview:
* This is the api definitions for the string subsystem
* Data Structure and Algorithms:
@@ -523,10 +523,8 @@
STRING *dest;
CHARTYPE_TRANSCODER transcoder1 = (CHARTYPE_TRANSCODER)NULLfunc;
CHARTYPE_TRANSCODER transcoder2 = (CHARTYPE_TRANSCODER)NULLfunc;
- const char *srcstart;
- const char *srcend;
- char *deststart;
char *destend;
+ struct string_iterator_t it;
if (!encoding) {
if (type)
@@ -564,13 +562,11 @@
}
}
- srcstart = (void *)src->strstart;
- srcend = srcstart + src->bufused;
- deststart = dest->strstart;
- destend = deststart;
+ destend = dest->strstart;
+ string_iterator_init(&it, src);
- while (srcstart < srcend) {
- UINTVAL c = src->encoding->decode(srcstart);
+ while (it.charpos < src->strlen) {
+ UINTVAL c = it.decode_and_advance(&it);
if (transcoder1)
c = transcoder1(src->type, dest->type, c);
@@ -578,11 +574,9 @@
c = transcoder2(src->type, dest->type, c);
destend = dest->encoding->encode(destend, c);
-
- srcstart = src->encoding->skip_forward(srcstart, 1);
}
- dest->bufused = destend - deststart;
+ dest->bufused = destend - (char *)dest->strstart;
dest->strlen = src->strlen;
if (dest_ptr) {