mIRC Homepage

$hfind can't find regex that matches $null

Posted By: Seb

$hfind can't find regex that matches $null - 24/05/18 09:27 PM

Code:
alias testcase {
  var %regex = /^$/
  echo -a -- $regex(%regex,$null) ; verify regex matches
  hadd -m testcase %regex 42
  echo -a -- $hfind(testcase,$null,0,R) ; <--- bug here; $hfind returns non-numeric value when it should return 1
}
Posted By: maroon

Re: $hfind can't find regex that matches $null - 24/05/18 10:36 PM

I'm guessing that $null is being treated as if a missing a required parameter, and is the same as $hfind(testcase,,0,R)
Posted By: Raccoon

Re: $hfind can't find regex that matches $null - 25/05/18 02:28 AM

> $regex(%regex,$null)

Incorrect $regex() syntax. Try $regex($null,%regex)
Posted By: Wims

Re: $hfind can't find regex that matches $null - 25/05/18 09:24 AM

Confirmed on 7.52 non beta

Raccoon: the first $regex test is meant to show the attempt of $hfind(,,,R)'s function
Posted By: Raccoon

Re: $hfind can't find regex that matches $null - 25/05/18 08:45 PM

It remains that the first $regex test is incorrect, and it incorrectly represents $hfind -R
Posted By: Wims

Re: $hfind can't find regex that matches $null - 25/05/18 09:49 PM

How is it incorrect? It's unusual but it's to illustrate the report, it does ask if the regular expression "" matches the string "/^$/", which is what $hfind's R is doing
Posted By: Raccoon

Re: $hfind can't find regex that matches $null - 25/05/18 10:03 PM

$hfind -R (reversed regex) is where regular expression patterns are stored in a hash table, and compared against the normal string passed in the $hfind parameter. $null is the normal string, not an 'unusual pattern'.

Just look at it. It's wrong, and you're wrong. :P

This isn't to say that $hfind() supports $null string parameters -- it doesn't -- but at least grasp the fundamentals of how mIRC works, Ouims!

$hfind() never works in any situation when $null is passed, whether -n -w -W -r -R are specified. This is a limitation of $hfind()

(The $regex qualitative test is still wrong.)
Posted By: Wims

Re: $hfind can't find regex that matches $null - 25/05/18 10:15 PM

Uh well you're right that pattern don't become test string, I mixed things up here, but the usage of $regex is still valid/correct, (even if it's pointless), and the issue on $hfind does exist.

I disagree it's a limitation, $hfind should not be limited on the input it can receive, if $hfind were limited with the $null usage here, it wouldn't return incorrect value, it would return 0 instead of a possible positive integer
Posted By: Raccoon

Re: $hfind can't find regex that matches $null - 25/05/18 10:22 PM

$hfind() gives no return value when '$null' is passed. This indicates that it does not work, as it does not work with many identifiers.

We would have a problem if $hfind() returned 0 or some other value that isn't nothing. Nothing means Error.

Should, or can, it be made to work? Sure, why not. I could see it useful in cases of $hfind(table,$null,0).data to discover table entries with null empty values. Or, whatever the original poster is trying to do as well.
Posted By: Wims

Re: $hfind can't find regex that matches $null - 25/05/18 10:39 PM

This parameter is a string parameter, I can't think of any identifier which takes a string parameter which won't work with $null. This is not an error, $hfind should return 1 here.
Posted By: Seb

Re: $hfind can't find regex that matches $null - 03/06/18 06:40 PM

Yes, my bad, I meant to reverse the $regex parameters... Corrected testcase:

Code:
alias testcase {
  var %regex = /^$/
  echo -a -- $regex($null,%regex) ; verify regex matches
  hadd -m testcase %regex 42
  echo -a -- $hfind(testcase,$null,0,R) ; <--- bug here; $hfind returns non-numeric value when it should return 1
}
Posted By: Khaled

Re: $hfind can't find regex that matches $null - 18/10/18 10:00 AM

Thanks this issue has been fixed for the next version.
© 2020 mIRC Discussion Forums