On Thu, Aug 22, 2024 at 08:44:08PM -0400, Thomas Dickey wrote:
> On Thu, Aug 22, 2024 at 08:12:59PM -0400, Thomas Dickey wrote:
> > On Fri, Aug 23, 2024 at 01:53:51AM +0200, Marek Rusinowski wrote:
> > > In the newest version of mawk, the following invocation returns invalid
> > > result:
> > > 
> > > $ mawk 'BEGIN { x = "asd "; sub(/ .*$/, "", x); print("|"x"|"); }'
> > > |asd |
> > 
> > thanks - I can reproduce this
> > (though puzzled how added and existing tests didn't show this regression)
> > 
> > I'll see how to fix (and add this case...)
> 
> fwiw, the regression came in the set of changes for this bug-fix:
> 
> https://github.com/ThomasDickey/original-mawk/issues/76
> 
> ...which is about 100 lines modified.
> 
> I'll pick that apart and see how to fix both :-)

This fixes the reported problem (and doesn't interfere with other testcases).

diff -u -r1.61 rexp3.c
--- rexp3.c     2024/07/28 23:04:24     1.61
+++ rexp3.c     2024/08/23 23:09:39
@@ -431,7 +431,9 @@
 
     case M_END + U_ON:
        if (s >= str_end) {
-           RE_FILL();
+           if (cb_ss && current_best(s)) {
+               RE_FILL();
+           }
        } else if (!ss) {
            if (cb_ss) {
                RE_FILL();

-- 
Thomas E. Dickey <dic...@invisible-island.net>
https://invisible-island.net

Attachment: signature.asc
Description: PGP signature

Reply via email to