Question about the following code.

+INTVAL
+string_compare(STRING* s1, STRING* s2) {
+    if (s1->encoding != s2->encoding) {
+        if (s1->encoding->which != enc_utf32) {
+            s1 = Parrot_transcode_table[s1->encoding->which][enc_utf32](s1,
NULL);
+        }
+        if (s2->encoding->which != enc_utf32) {
+            s2 = Parrot_transcode_table[s2->encoding->which][enc_utf32](s2,
NULL);
+        }
+    }
+
+    return (ENC_VTABLE(s1)->compare)(s1, s2);
+}

Does the call to the transcode function create a new string or change the
string in place.  I don't think we want to pass in a native string only to
find out it is unicode after we get done comparing it.
 

-----Original Message-----
From: Tom Hughes
To: [EMAIL PROTECTED]
Sent: 10/9/2001 6:49 PM
Subject: String comparison ops

Attached is a patch to add string comparison ops, along with the
necessary infrastructure in the string code.

The current behaviour is that if the two strings do not have the
same encoding then both are promoted to UTF-32 before comparison
as that should generally preserve information.

Tom

-- 
Tom Hughes ([EMAIL PROTECTED])
http://www.compton.nu/
 <<strcmp.patch>> 

Reply via email to