[Vala] [REGRESSION vala 0.7.5] It's no longer possible to use GLib.IOStream.write_chars with st ring.



Hello,

With vala 0.7.5 it is no longer possible to use GLib.IOChannel.write_chars
with strings (and GLIb.IOStream has no other write method for strings to
replace it), because converting a string to char[] now produces a C compiler
error (undefined symbol <var>_length1).

I added this to tests:

Program: test

using GLib;

static int main(string[] args) {
        string s = "test-string";
        char[] a = (char[])s;
        return 0;
}

and using that traced the change to commit
edcd069d6b0b7b9e1ff2797d45ccbafe910a1357

Note however, that this test never succeeded, because the assignment causes
a segmentation fault at runtime because of trying to copy -1 byte!

So now the question is, what should be the correct way to handle this
problem.
(The real use-case is:
    GLib.IOChannel channel;
    string s;
    channel.write_chars(s, out n);
)
One option is to make the string -> array conversion work (by properly
calculating the length). The other is to add a method to string that will do
such conversion (which is what Java and C# do, because string is composed of
unicode codepoints, so it has to be encoded to a char[] -- thus the method
would in fact be called to_utf8()).

Further, given that GIOChannel supports encoding internally, it should
actually provide a string interface rather than char[] one. The problem there
would be that string in vala cannot contain NUL characters, but shouldn't
/that/ be changed?

Regards,
Jan





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]