Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Nov 2025 11:06:02 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 291172] regexp.h routines behave differently for my program and in the base grep
Message-ID:  <bug-291172-227@https.bugs.freebsd.org/bugzilla/>

index | next in thread | raw e-mail

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=291172

            Bug ID: 291172
           Summary: regexp.h routines behave differently for my program
                    and in the base grep
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: arrowd@FreeBSD.org

Created attachment 265589
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=265589&action=edit
Test program

I have a little program that tries to match the "domain/foo" string against the
"^domain/[a-z]\+$" regexp. For some reason it prints "regex doesn't match:
domain/foo" for me.

The strange thing is that the same regex works in grep:

# cat input
domain/foo
# dtrace -q -n 'pid$target::regcomp:entry { printf("%s(m,\"%s\",%d)\n",
probefunc, copyinstr(arg1), arg2); }' -c 'grep ^domain/[a-z]\+$ input'
domain/foo
regcomp(m,"^domain/[a-z]\+$",12)

We can see that regcomp() gets called with exactly the same arguments as in my
program, but for some reason the consecutive regexec() returns REG_NOMATCH in
my case and 0 for grep.

I should be missing something obvious, but I can't figure it.

-- 
You are receiving this mail because:
You are the assignee for the bug.

home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-291172-227>