Begin forwarded message:
From: pancake <panc...@youterm.com>
Date: September 12, 2009 11:05:27 AM GMT+02:00
To: Arkadi Viner <arkash...@gmail.com>
Subject: Re: [Vala] Is this a bug in VALA ?
On Sep 6, 2009, at 4:12 PM, Arkadi Viner <arkash...@gmail.com> wrote:
Hello.
I am trying to split a string into two strings.
The string should be split-ed by locating a first space character
from the
left.
Please look at a simple code I made:
public class Main
{
public static int main (string[] args)
{
long index = 0;
string col1,col2;
string line = "happy doggy";
for(;index<=line.len();index++)
if(line[index] == ' ') break;
col1 = line.substring(0,index);
col2 = line.substring(index+1,line.len());
stdout.printf ("Line - %s\n", line);
stdout.printf ("index - %f ,Len() - f%\n" ,index,line.len());
stdout.printf ("Col1 - %s ,Col2 - s%\n" ,col1,col2);
return 0;
}
}
*When I compile this code I get:*
/home/arkadi/Bug/main.vala.c: In function ‘main_main’:
/home/arkadi/Bug/main.vala.c:113: warning: unknown conversion type
character
0xa in format
/home/arkadi/Bug/main.vala.c:114: warning: unknown conversion type
character
0xa in format
Hehe . I think that vala here should display the aliased character
instead of the hex value. ('\n') This way the error would be more
consistent.. But yeah this code is awful
<b>Process return 0 execution time: 0.674968 s</b>
*When I run this code I get:*
Line - happy doggy
<b>Process return 0 execution time: 0.008026 s</b>
index - 5.000000 ,Len() - f%
** (process:7502): CRITICAL **: string_substring: assertion `
(offset + len)
<= string_length' failed
Col1 - happy ,Col2 - s%
You can see that, It finds the place where to split the string very
well
(5.000000) and col1="happy"
,but for the second part, line.Len() = f% and col2 = s%...
I have tried to change line.len() to numbers, but it's not the
problem...
How to get col2="doggy" ???
Maybe some one know what is the problem with this code? or maybe it
is
really a bug?
_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list
_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list