Qball's Weblog

Puzzled

Tags Grind My Gears 

Why is my code broken because vala developers decided that the string.str is something you don’t need and is deprecated.

Instead you need to use index_of function.

So now if I want to get a pointer (c) to substring b in string a, this is done (merged the c code inserted by vala):

?View Code C
1
2
3
4
5
6
7
8
9
10
11
12
char *temp = strstr(a,b);
 
int index;
char *c = NULL;
 
if(temp == NULL) index = -1;
 
else index = (temp-a);
if(index >= ) {
c = &a[index];
 
}

(p.s. I removed the extra function call this also causes)

instead of the old way:

?View Code C
1
char*c = strstr(a,b);

Is this realy worth