Does somebody know what is happening here? This piece of code should skip leading spaces (and others).
If isspace encounters a non space character, it doesn't return false.
If we analyze the " isspace(*cs_str);" in the debugger, it returns 0. If we check the value in b_space after assigning the value, the value is <> 0. We are using an UTF-8 encoded string. Could that have anything to do with it? It confuses the hell out of us.
We had it like that, but then we saw that the code was doing strange things. (It was not leaving the if loop the first time, so that we would lose our first character).
To see what the isspace returned, we put the value in a variable.
Well the code looks ok to me. I downloaded it and wrote a little wrapper. It works with both c and c++.
The only way that I can see this happening is a 64 bit/32 bit mismatch. Under that scenario, isspace would be returning a 32 bit integer. But b_space would want a 64 bit integer. So it grabs the correct 2 bytes (which are zero) and it grabs two more bytes which are not zero.