mIRC Home    About    Download    Register    News    Help

Print Thread
$hfind seek distance limited #263932 12/10/18 04:32 PM
Joined: Jan 2004
Posts: 1,329
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,329
Somewhere between 6.35 and current, $hfind changed to no longer search past the 'line length limit'.

Results from different versions:

Quote:
1 vs 1 123456791 6.35 /hfind_test 123456789
1 vs 0 4151 7.52 /hfind_test 4149
1 vs 0 8293 7.52 1265 /hfind_test 8291


Code:
alias hfind_test {
  bset -t &var $1 abc
  noop because hfind won't search past 0x00: | breplace &var 0 $asc(a)
  hadd -bm table item &var
  echo 4 $hfind(table, *b*, 0, w).data vs $hfind(table, *c*, 0, w).data $bvar(&var,0) $version $beta /hfind_test $1
  hdel table item
}


Edit:

The above was for wildcard match. For regex match, 6.35 couldn't see past the line length limit like it could for wildcard match. (Thanks Wims) For the below, 6.35 matches at %len 4150 but not 4151. In the newest beta, regex's limit is %len 8292

Code:
//var %len 4151 | bset -t &var %len b | breplace &var 0 $asc(a) | hadd -bm table item &var | echo 4 $hfind(table, (a*b$), 0, r).data $bvar(&var,0)




Last edited by maroon; 12/10/18 06:40 PM.
Re: $hfind seek distance limited [Re: maroon] #263934 13/10/18 01:00 PM
Joined: Dec 2002
Posts: 4,738
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,738
Thanks for your bug report. I have been able to reproduce this issue. This is due to a change in the very first Unicode version of mIRC, which required introducing UTF-8/UTF-16 conversions throughout the code. I have updated the next beta so that the 'w' option will allow unlimited string length matching.

However, this cannot be easily changed for regex as the string length limit is something that is imposed throughout the regex routines. Allowing unlimited string lengths in the regex routines would require a significant rewrite. This has been added to my to-do list.

Re: $hfind seek distance limited [Re: Khaled] #263948 14/10/18 02:56 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
If this is fixed, how would $regml and $regmlex behave if the regex is capturing a string that is more than 8292 characters? Would they chop at 8292 or would they return a line too long error?


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $hfind seek distance limited [Re: Wims] #263949 14/10/18 03:58 PM
Joined: Dec 2002
Posts: 4,738
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,738
Quote:
If this is fixed, how would $regml and $regmlex behave if the regex is capturing a string that is more than 8292 characters? Would they chop at 8292 or would they return a line too long error?

String length checking is performed in all of the regex routines/identifers/etc. in numerous places. If evaluation reaches the stage of storing results in $regml(), they would be truncated. It may be that different routines will report a line too long error and halt the processing before it reaches that stage. Substitution would also be a problem. There would also be issues with calling commands to evaluate parameters during regex evaluation, where it would be necessary to truncate parameters since script commands and identifiers cannot exceed the maximum string length. And so on. So, while it might be possible to extend regex in some ways to handle matching against longer text, some regex features, such as alias call evaluation of parameters, will never be able to handle it.

Re: $hfind seek distance limited [Re: Khaled] #263950 14/10/18 04:25 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
Yes, I agree, I was going to say multiple things but only posted about $regml*.

First of all, I wanted to mention something about the limit, right now we have $maxlenl = 8192, which corresponds to the previous 4096, representing the 'safe' number of character allowed per 'line', shouldn't this number have been used as the limit for $regml* here (but this is also meaningful for others areas)? Which would leave room for handling $regml* value with for example an /echo or whatever, whereas right now, a $regml* value of 8292 characters is very hard to deal with.

I don't think $hfind should be handling match against longer string via hadd -b, because I don't think people expect it to, even the interested scripters: binvar support for regex has been asked in 2003 but nobody really thought of using $hfind to do a match on a binvar, at least I've never heard/seen such things.
For all the reasons you mention, even if it were fixed, it would be far from having binvar support for input of regex, this would just be knowing if there's a match. That's as good as it can be for wildcard though, so maybe just having wildcard not truncating makes sense.

Note that /filter works on long line with regex last time I tried it.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $hfind seek distance limited [Re: Wims] #263958 15/10/18 08:55 AM
Joined: Dec 2002
Posts: 4,738
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,738
Quote:
First of all, I wanted to mention something about the limit, right now we have $maxlenl = 8192, which corresponds to the previous 4096, representing the 'safe' number of character allowed per 'line', shouldn't this number have been used as the limit for $regml* here (but this is also meaningful for others areas)? Which would leave room for handling $regml* value with for example an /echo or whatever, whereas right now, a $regml* value of 8292 characters is very hard to deal with.

The same issue applied to $regml() with 4096, where the longest string could technically have been around 4150. Unfortunately, there is no way to limit all strings to 8192. The maximum string length, with leeway up to 8292, applies to all routine equally. If I did what you are requesting, I would have to arbitrarily choose some routines/identifiers/commands/features to only allow a maxumum of 8192 and others, such as /echo, to allow the leeway up to 8292. That is simply not possible. I would have to make this change, and add checks, in thousands of places for it to make sense.

Quote:
For all the reasons you mention, even if it were fixed, it would be far from having binvar support for input of regex, this would just be knowing if there's a match.

I think I have found a safe route through the regex code that allows unlimited string length regex matching. As you say, it will only let you know if there's a match. Results would still be truncated. I may include this change in the next beta.

Re: $hfind seek distance limited [Re: Khaled] #263966 15/10/18 01:43 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
Yeah, I wasn't asking for a change, but I was wondering if that was the intended plan. As I explained it would make more sense for us scripters to be able to deal with such a long value.

Quote:
I think I have found a safe route through the regex code that allows unlimited string length regex matching
Nice, but are there no plans for real binvar support in regex input?


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net