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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

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

Submitter:  None
Submitted:  Wed 02 Mar 2016 11:46:42 PM UTC
   
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

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>
Group administrator
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>
Group administrator
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>
Group administrator
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>
Group administrator
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>
Group administrator
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>
Group administrator
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.)

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
  • -email is unavailable- added by thomas_r (Posted a comment)
  • -email is unavailable- added by bens (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 15 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-06-20 bens Open/ClosedOpen Closed
    2016-03-22 bens StatusIn Progress Fixed
        Summaryregex anchors \\&lt; and \\&gt; do not work on Mac OS X regex anchors \< and \> do not work on Mac OS X
    2016-03-21 thomas_r Attached File- Added nano-47325-r5756.patch, #36707
    2016-03-13 thomas_r Attached File- Added nano-47325-r5734.patch, #36625
    2016-03-13 bens StatusNone In Progress
        SummaryRegex: \\&lt; and \\&gt; do not work on Mac OS X regex anchors \< and \> do not work on Mac OS X
    2016-03-12 bens Assigned toNone bens
        SummaryRegex: \\&lt; and \\&gt; do not work on Mac OS X Regex: \< and \> do not work on Mac OS X
    2016-03-12 None Attached File- Added nano-47325.patch, #36609
    2016-03-06 bens Attached File- Added morf-the-regex.patch, #36558
        SummaryRegex: \\&lt; and \\&gt; do not work on Mac OS X Regex: \< and \> do not work on Mac OS X
    2016-03-04 bens Attached File- Added reg-enhanced.patch, #36547
        SummaryRegex: \\&lt; and \\&gt; do not work on Mac OS X Regex: \< and \> do not work on Mac OS X
    2016-03-03 bens SummaryRegex: \\&lt; and \\&gt; do not work on Mac OS X Regex: \< and \> do not work on Mac OS X

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code