bugGNU nano - Bugs: bug #47325, regex anchors \< and \> do...

 
 

bug #47325: regex anchors \< and \> do not work on Mac OS X

Submitted by:  None
Submitted on:  Wed 02 Mar 2016 11:46:42 PM UTC  
 
Severity: 3 - NormalStatus: Fixed
Assigned to: Benno Schulenberg <bens>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Tue 22 Mar 2016 10:43:06 AM UTC, comment #13:

Fixed in SVN, r5759.

Thanks for the patch.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 21 Mar 2016 07:21:54 AM UTC, comment #12:

Another version of the patch, as discussed in the mailing list

(file #36707)

Thomas Rosenau <thomas_r>
Sun 13 Mar 2016 09:41:52 PM UTC, comment #11:

Yes. And here's the patch against trunk (rev.5734).

Again, not only does the REG_ENHANCED flag avoid unnecessary fixbounds() calls, but also unlocks a ton of other features like \b, \w, \d, and many more. Those are only available in enhanced mode on Mac OS.

Actually, the bug report title falls short on that fact.

(file #36625)

Thomas Rosenau <thomas_r>
Sun 13 Mar 2016 07:48:00 PM UTC, comment #10:

The partial fix was applied to SVN, r5731.

So... if I understand, you want ./configure on a Mac to detect that GNU word bounds are supported, so that fixbounds() becomes a no-op instead of a somewhat expensive and unnecessary substitution function?

If so, I will need an updated version of your patch, because things have changed a bit in SVN (something that I planned to do for a while).

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sat 12 Mar 2016 07:41:02 PM UTC, comment #9:

Yes, I am the original poster. Comment #2 is from someone else, but I agree with him ;)

The reason that I moved the detection to the autoconf file is that the GNU_WORDBOUNDS detection (line 604/624 in configure.ac before/after patching) relies on extended regular expressions.
For things to work as intended, NANO_REG_EXTENDED must be used there too, instead of REG_EXTENDED. In order to avoid duplicate code there, I decided to store the correct flag to a SH variable.

Thomas Rosenau <thomas_r>
Sat 12 Mar 2016 04:34:39 PM UTC, comment #8:

@Thomas

Okay, so the one-line patch would fix the issue with \< and \> not working in Search on non-GNU machines. Then I will apply that as a separate patch, as a clear bug fix.

The second part of this bug is that you request REG_ENHANCED support on Macs. :) Okay. But... why isn't the #ifdef that was proposed in the beginning not enough? Why must things be detected through ./configure?

BTW, you are the original poster of this bug, Thomas?

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sat 12 Mar 2016 11:51:48 AM UTC, comment #7:

> if REG_EXTENDED is used

That should be "if REG_ENHANCED is used"

Thomas Rosenau <thomas_r>
Sat 12 Mar 2016 11:39:45 AM UTC, comment #6:

@Benno

Your patch works, but it does not really fix the issue. The point is, Mac supports \< and \> just fine if REG_EXTENDED is used. Additionally, that flag provides features like lazy matching etc.

However, your fix is fine for other systems (not GNU, not Mac).

The reason why my first fix didn't work is I forgot to include regex.h before the check. How embarassing.

Please see the improved patch, which now works fine on my machine.

(file #36609)

Anonymous
Sun 06 Mar 2016 12:56:46 PM UTC, comment #5:

Aaah. You cannot use \< and \> on a Mac. You would have to use [[:<:]] and [[:>:]] instead. (Yes, I know, untypable.) That's why fixbounds() translates the first two to the latter two in the defined syntaxes. But when you type regexes at the search prompt, you will have to type the complicated expressions yourself.

Maybe nano should call fixbounds() on those typed strings too? Please try the attached patch. Then you should be able to use \< and \> (after turning regexes on with M-R).

(file #36558)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 06 Mar 2016 08:06:31 AM UTC, comment #4:

The search is still broken. Actually, syntax highlighting works just fine, even without the patch, when nano is compiled on the Mac.

Apparently this has something to do with fixbounds() in utils.c, which depends on GNU_WORDBOUNDS, set in configure.ac.
Not sure if I fully understand what exactly is going on there, but it looks some sort of feature detection.

Anonymous
Fri 04 Mar 2016 12:19:06 PM UTC, comment #3:

Can you try attached patch (against nano-2.5.3)?

(file #36547)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 04 Mar 2016 03:59:06 AM UTC, comment #2:

Benno: Yes that's right, the syntax colorings do not work on Mac and \< and \> are interpreted as the literals < and >.

Anonymous
Thu 03 Mar 2016 08:28:56 PM UTC, comment #1:

(For \< not working properly anyhow, see bug #45630.)

Adding the proposed #ifdef should be possible, but... if OS X needs REG_ENHANCED to see \< and \> as word boundaries, doesn't that mean that several of the syntax colorings aren't working on Macs? As what does OS X interpret a \> when REG_ENHANCED is not given? As a literal >?

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Wed 02 Mar 2016 11:46:42 PM UTC, original submission:

I know that nano uses the OS's regex engine with the REG_EXTENDED flag passed. Mac OS X additionally requires the REG_ENHANCED flag to provide all features.

In addition to \< and \>, those features include \b,\B,\d,\D,\s,\S,\w,\W, +?, *?, and more.

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man7/re_format.7.html

Since grep uses REG_ENHANCED, it is a pain to write regexes for nano, because there's a lot of trial and error involved

Would it be possible to include this flag? Something like
#if defined REG_ENHANCED
REG_EXTENDED | REG_ENHANCED
#else
REG_EXTENDED
#endif

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #36707:  nano-47325-r5756.patch added by thomas_r (4KiB - text/x-diff)
file #36625:  nano-47325-r5734.patch added by thomas_r (4KiB - text/x-diff)
file #36609:  nano-47325.patch added by None (5KiB - text/x-diff)
file #36558:  morf-the-regex.patch added by bens (398B - text/x-diff)
file #36547:  reg-enhanced.patch added by bens (3KiB - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by thomas_r (Posted a comment)
  • -unavailable- added by bens (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 15 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 20 Jun 2016 09:46:10 AM UTCbensOpen/ClosedOpen=>Closed
    Tue 22 Mar 2016 10:43:06 AM UTCbensStatusIn Progress=>Fixed
      Summaryregex anchors \\< and \\> do not work on Mac OS X=>regex anchors \< and \> do not work on Mac OS X
    Mon 21 Mar 2016 07:21:54 AM UTCthomas_rAttached File-=>Added nano-47325-r5756.patch, #36707
    Sun 13 Mar 2016 09:41:52 PM UTCthomas_rAttached File-=>Added nano-47325-r5734.patch, #36625
    Sun 13 Mar 2016 07:48:00 PM UTCbensStatusNone=>In Progress
      SummaryRegex: \\< and \\> do not work on Mac OS X=>regex anchors \< and \> do not work on Mac OS X
    Sat 12 Mar 2016 04:34:39 PM UTCbensAssigned toNone=>bens
      SummaryRegex: \\< and \\> do not work on Mac OS X=>Regex: \< and \> do not work on Mac OS X
    Sat 12 Mar 2016 11:39:45 AM UTCNoneAttached File-=>Added nano-47325.patch, #36609
    Sun 06 Mar 2016 12:56:46 PM UTCbensAttached File-=>Added morf-the-regex.patch, #36558
      SummaryRegex: \\< and \\> do not work on Mac OS X=>Regex: \< and \> do not work on Mac OS X
    Fri 04 Mar 2016 12:19:06 PM UTCbensAttached File-=>Added reg-enhanced.patch, #36547
      SummaryRegex: \\< and \\> do not work on Mac OS X=>Regex: \< and \> do not work on Mac OS X
    Thu 03 Mar 2016 08:28:56 PM UTCbensSummaryRegex: \\< and \\> do not work on Mac OS X=>Regex: \< and \> do not work on Mac OS X

    Back to the top


    Powered by Savane 3.1-cleanup1