I just became aware of a, imho, rather odd thing in sscanf().
If we have the following:
string x = "some text"; string y; sscanf(x, "%s,", y); werror("%O\n", y);
the string y will be empty. I think it's rather odd that the %s doesn't match the whole string in this case.
Compatibility issues aside, don't we want %s to match to next matcher or EOS?
to me "%s," says that there must me a ',' in the string, otherwise it's not valid.
greetings, martin.
(Note: string y will be uninitialized, not empty.)
As Martin says, that's as it should be. You scan for a string followed by a comma. None is found, so you get no result. It's not a regexp where you get partial results, and that is one of the things that makes it so useful.
You do get partial results;
sscanf("hej,hopp", "%s,%s,", string x, string y)
will give you "hej" in x and leave y uninitialized. I would say that is a partial result.
pike-devel@lists.lysator.liu.se