Project

General

Profile

Actions

Bug #5707

open

While loop breaks when using $regex()

Added by westor (GR) about 1 year ago. Updated about 1 year ago.

Status:
New
Priority:
Normal
Assignee:
Category:
Scripting
Target version:
Start date:
04/10/2023
Due date:
% Done:

0%

Estimated time:
Operative System:
All
Regression:
No

Description

Hello,

I was trying to use that code, it seems the loop stops and breaks after 2nd iteration.

Try to use: /test_nicks test1 test2

alias test_nicks {
  ; /test_nicks de]bian de^bian de-bian de`bian dgdgd-de[b]ian_hdhdfh de[b]ian de}bian|legen de}bian d{e}bian

  if (!$1) { echo -a Error: Enter nicks! | return }

  var -s %nicks = $1-
  var %total = $numtok(%nicks,32)
  var %index = 1
  while (%index <= %total) {
    var -s %nick = $gettok(%nicks,%index,32)

    if (!$chkbadnick2(debian,%nick)) { echo -at Nick NOT matching! -> %nick | return }

    inc %index
  }

  echo -at Ok all nick(s) matching.
}

alias chkbadnick2 { 
  var %s = [-a-z_`|{}^\[\]\d]*

  if ($regex($2,/^(?! $+ \Q $+ $replacecs($1,\E,\E\\E\Q) $+ \E $+) $+ %s $+ \Q $+ $replacecs($basenicktoregex($1,%s),\E,\E\\E\Q) $+ \E $+ %s $+ $/i)) { return 1 }
}

alias basenicktoregex { 
  var %name $2

  return $regsubex($replace($1,o,[0o],e,[e3],etc,[etc]),/(\[[^\]]+\]|.)/g,\1+ $+ %name) 
}


- Thanks!
Actions #1

Updated by westor (GR) about 1 year ago

Also the adiirc doesn't print any errors anywhere (active window or rawlog->debug) at all to see where is the error.

EDIT :

If i add u modifier in the $regex call it works.

Actions #2

Updated by Per Amundsen about 1 year ago

It's because of the $/i which is not a valid identifier. try $ $+ /i instead, it's the same in mirc.

Actions #3

Updated by westor (GR) about 1 year ago

Indeed, you're right.

The issue here is that loop breaks without any error, it's just stop progressing without anything, in mirc it continues working and not breaking.

Actions #4

Updated by Per Amundsen about 1 year ago

I'm not sure why exactly, it's the same in mirc. Looking closer, it's likely trying thinking "$/i))" is an identifier and since the parentheses gets eaten, there are unbalanced parentheses and it will never actually try to evaluate it and assumes it's a invalid /if or something.

Actions #5

Updated by Per Amundsen about 1 year ago

mirc does not seem to perform the if statement for me and I am not seeing any errors in mirc with this example, so either the identifier exists and there is something else going on, or it doesn't show a identifier warning for whatever reason.

Actions #6

Updated by westor (GR) about 1 year ago

Ok i apologize , you're right the fault here is mine.

You can close this issue, is invalid.

Actions #7

Updated by Per Amundsen about 1 year ago

Keeping it open for now as a reminder, need to do more testing in both clients to understand what's going on.

Actions #8

Updated by Oui Ouims about 1 year ago

Hey, what's going on is that westor had the default alias in adiirc called 'i', which is called with $/i here. That alias has $$1 which is not filled so the script is stopped, that's what is going on.

But something to note if adiirc is not behaving as exactly as mIRC is that there is an incorrect "$+)" in this script line in case you didn't notice, which may be fluking out adiirc's () count.
I had reported to maroon and westor before that the syntax highlighting of the script editor, and therefore (I believe was tested but unsure) the scripting engine was not working the way mIRC is when dealing with (), where mIRC can accept as many literal ( and ) inside string as the balance counts allow it to, meaning that
if (%v(ar == $ide)nt) is totaly valid in mIRC, but should fail on adiirc, maybe this is related.

Actions

Also available in: Atom PDF