15.04.2015, 12:52
Thanks Emmet for this!
Glad to see this Emmet_. One thing that really disappoints me about this thread (not in particular, just sscanf) is that he never released 3.0 (which I think I remember him saying was stable but he was cleaning).
|
sscanf 2.8.2
While 3.0 is not ready yet, I have released a small update which fixes a bug where the "u" specifier wasn't working correctly after a server restart. Link with the .dll, .so and source: https://dl.dropboxusercontent.com/u/...canf-2.8.2.zip |
He deleted all of his topics because he left SA-MP.
https://sampforum.blast.hk/showthread.php?pid=3431155#pid3431155 |
objectid, "text", 0, 50, "text2", 0, 0, 0xFFFFFFFF, 0xFFFFFFFF, 0
Can someone help me parse this correctly? I've been having a hard time without a string buffer overflow warning.
pawn Код:
|
enum Parse_Detail { E_obj, E_text[32], E_dat1, E_dat2, E_text[32], E_dat3, E_dat4, E_hex1, E_hex2, E_dat5, } main { new var[Parse_Detail]; sscanf(string, "p<,\">e<is[32]iis[32]iixxi>", var); //If the quote is not escaped just remove the escape and remove the quotes afterwards... }
You escape any character by doing \c (replace c with the character of your choice).
Also "p<,\">is[32]iis[32]iixxi" Can't work. 1. It's P if your using 2 specifiers. 2. '"text", 50' Check this, it's gonna try to get the string for the first ", which is why the first " should be ignored, then its gonna try to get a param between " and , because they are right next to each other and thats gonna throw a warning. |
sscanf(funcargs, "P<,\">e<s[32]iis[32]iixxi>", matTextParseData);
printf(" DEBUG: [eventLoadMap] Object Text: '%s', %d, %d, '%s', %d, %d, %x, %x, %d",
matTextParseData[tmpObjText], matTextParseData[tmpObjIdx], matTextParseData[tmpObjMatSize], matTextParseData[tmpObjFont], matTextParseData[tmpObjFontSize], matTextParseData[tmpObjBold], matTextParseData[tmpObjFontCol], matTextParseData[tmpObjBackCol], matTextParseData[tmpObjAlign]);