This function was unable to parse the format string properly when there are 2 consecutive "%%". This was because "%%" should be replaced by "%" but, this function passes "%%" to the default case where it is appended to "s", without any change.

So I added a special case to handle %%.