Author Topic: ADD_PROJECTILE is messing with new lines (prevents $ regexp)  (Read 1620 times)

Offline K4thos

  • Planewalker
  • *****
  • Posts: 110
ADD_PROJECTILE is messing with new lines (prevents $ regexp)
« on: September 26, 2015, 11:54:08 AM »
Whenever I'm analyzing IDS files I first trim them and fix newlines via this code:
Code: [Select]
REPLACE_TEXTUALLY ~%WNL%~ ~%LNL%~
REPLACE_TEXTUALLY ~[%TAB% ]+~ ~ ~
REPLACE_TEXTUALLY ~^[%TAB% ]+~ ~~
REPLACE_TEXTUALLY ~[%TAB% ]+$~ ~~
btw. a new command called PRETY_PRINT_IDS would be useful here.

When using ADD_PROJECTILE I've noticed that above solution is not enough - each time you use ADD_PROJECTILE "$" regexp special character stops working, so you can no longer use for example FILE_CONTAINS_EVALUATED. In order to fix it you must once again make a COPY of the file and do REPLACE_TEXTUALLY ~%WNL%~ ~%LNL%~ before calling FILE_CONTAINS_EVALUATED or COUNT_REGEXP_INSTANCES that checks end of the line. Is this intended behaviour?
« Last Edit: September 26, 2015, 11:55:08 AM by K4thos »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: ADD_PROJECTILE is messing with new lines (prevents $ regexp)
« Reply #1 on: October 04, 2015, 05:10:37 AM »
Essentially, ADD_PROJECTILE converts the file into CRLF as a side-effect and $ apparently only matches against LF. I don't know if this has always been the case, or if it's something e.g., OCaml has changed at some point (what, exactly, is matched by $ is not entirely specified). It's not intended behaviour, but I am not yet certain how to resolve this.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: ADD_PROJECTILE is messing with new lines (prevents $ regexp)
« Reply #2 on: October 23, 2015, 04:48:01 PM »
OCaml's position is that this is not a bug. $ only matches against LF because you are not supposed to use CRLF in code (but WeiDU does; bad WeiDU!). I don't see any entirely backward-compatible solutions to this. More thought required, perhaps.

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: ADD_PROJECTILE is messing with new lines (prevents $ regexp)
« Reply #3 on: October 23, 2015, 06:37:07 PM »
Maybe we could add WeiDU commands to infer and modify the type of newlines used in a file.

Whenever an ADD_PROJECTILE is performed, the behind-the-scenes steps for appending to the .IDS could be:

Code: [Select]
1. infer newline type
2. convert to WNL
3. append line
4. convert back to original newline type
« Last Edit: October 23, 2015, 06:37:38 PM by Mike1072 »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: ADD_PROJECTILE is messing with new lines (prevents $ regexp)
« Reply #4 on: October 31, 2015, 11:56:05 AM »
Newline type isn't really inferable, since the same file may contain all kinds of newlines in no necessary order. This is especially likely for files which have been the target of appends or other edits. The most straightforward approach would probably be to just convert all newlines into the right kind at read-time and leave it at that.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: