Thanks for your answer,
I've parallelly looked for a solution:
First, some comments on my post.
In first place:
My code in the post was not really the one I was testing, and it affects the result. The thing is that, according to [http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.12.html#scanf], any whitespace char (like space) is considered a separator when you do a scanf on "%s", so it will never be taken into "%s"
The solution has been, as you suggest, parsing the string in a different way. Instead of using strtok (which has a pretty weird output), i've parsed the string myself (yes, I know it won't be as optimal as using asm-coded string.a files, but maybe more clear to me). I paste here the function I wrote, tested working OK, just if becomes useful to anybody:
- T_s32
-
getStringFromCsvLine( T_u8 *csvLine, T_u8 *outputString, T_u32 fieldNo, T_u8 separator )
-
{
-
T_u32 lineLength;
-
T_u32 i_u32, j_u32, k_u32;
-
T_u32 fieldFound;
-
-
lineLength = strlen( csvLine );
-
-
// reset field counter
-
j_u32 = 0;
-
-
// reset current char in output string being filled
-
k_u32 = 0;
-
-
fieldFound = 0;
-
-
for( i_u32 = 0;
-
i_u32 < lineLength;
-
i_u32++ )
-
{
-
if( csvLine[ i_u32 ] == separator )
-
{
-
j_u32++;
-
continue;
-
}
-
-
if( j_u32 == fieldNo )
-
{
-
fieldFound = 1;
-
-
outputString[ k_u32 ] = csvLine[ i_u32 ];
-
-
k_u32++;
-
}
-
}
-
-
if( fieldFound )
-
{
-
outputString[ k_u32 ] = '\0';
-
return 0;
-
}
-
-
return 1;
-
}
Of course any comments or suggestions on this code are welcome.
Thanks again.-