• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Plugin] Sscanf problem
#1
Code:
if(sscanf(inputtext, "{s[32]'@'s[32]'.'s[16]}"))


Always positive, even if I enter something like [email protected]

I'm using sscanf 2.10.2
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#2
I think it's nearly impossible using only sscanf, you should replace '@' and '.' to space and check it like this:



PHP Code:
if (sscanf(inputtext"{sss}")) 



Or you can just see my code below:

https://gist.github.com/se8870/ca137f685...bb861f2202
???? ???? ????? ?? ???????? ???? ?????, ?? ???? ???? ?? ?????? ?? ??? ???? ???? ???? ?? ??? ???? ??? ???? ??? ?? ?? ?????? ??????





  Reply
#3
(2020-08-27, 09:10 PM)Tama Wrote: I think it's nearly impossible using only sscanf, you should replace '@' and '.' to space and check it like this:



PHP Code:
if (sscanf(inputtext"{sss}")) 



Or you can just see my code below:

https://gist.github.com/se8870/ca137f685...bb861f2202

Nope, you cannot use s without length.

I already fixed this but this is an sscanf bug I think



idk why is search ' ' broken smh
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#4
(2020-08-27, 09:41 PM)Pinch Wrote: Nope, you cannot use s without length.

Still work but you're get an error.
That code it's just example for older version.
???? ???? ????? ?? ???????? ???? ?????, ?? ???? ???? ?? ?????? ?? ??? ???? ???? ???? ?? ??? ???? ??? ???? ??? ?? ?? ?????? ??????





  Reply
#5
I'm using sscanf 2.10.2 which turns warnings into errors...
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#6
Search works fine, but you don't want search. `s` can contain `@`, so if you type `[email protected]` sscanf will do the following:



`s[32]` - Gathers everything until the first separator (whitespace by default), so `[email protected]`.

`'@'` - Looks for another `@`, but there isn't one, so the check fails.



You are missing up searches and delimiters. sscanf doesn't have look-ahead/look-behind, so while it is reading a string it doesn't know that the NEXT instruction is to look for an `@`. You've not told sscanf to stop reading strings at `@`, so it doesn't. You want:



"p<@>s[32]s[32] "



(you also don't want to check for a `.`, as valid e-mail addresses don't have to have one. Really all you want is `strfind(input, "@") != -1` - that's the simplest way to look for a valid e-mail address. Of course the only truly correct way is to send an e-mail it it.
  Reply


Forum Jump: