# NO_REGEX defaults on obscure platforms

6 messages from 2010-09-08 to 2010-09-10. Participants: Ævar Arnfjörð Bjarmason, Brandon Casey, Jakub Narebski, Junio C Hamano.
Thread: https://gitlist.dev/t/25038

## Ævar Arnfjörð Bjarmason, 2010-09-08 15:12

Subject: NO_REGEX defaults on obscure platforms
Message-ID: <AANLkTimYY_KHwqWWXTxFqW67FHYtJJkLuA-6WVc6wzO5@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimYY_KHwqWWXTxFqW67FHYtJJkLuA-6WVc6wzO5%40mail.gmail.com

```
On Mon, Sep 6, 2010 at 07:41, Junio C Hamano <gitster@pobox.com> wrote:

> There are a few leftover bits in 'next' that need to be merged to 'master'
> before we declare a real -rc cycle, so tonight's pushout is -rc0.

One thing that's almost certainly wrong in v1.7.3-rc0 is the NO_REGEX
defaults. It's a non-issue for people who run the configure script,
but the Makefile probably has the wrong defaults on some obscure
platforms.

I've CC'd people involved in Tru64, UnixWare, SCO, HP/UX, IRIX etc. It
would be really useful if you could:

  1. Get v1.7.3-rc0
  2. Compile with the defaults, and NO_REGEX=YesPlease
  3. Run `cd t && ./t7008-grep-binary.sh` and report the results.

That test is probably failing on some of these platforms.

Alternatively, just check for REG_STARTEND in regex.h (or the includes
it pulls in):

    $ grep REG_STARTEND /usr/include/regex.h
    #define REG_STARTEND (1 << 2)

```

## Brandon Casey, 2010-09-08 15:31

Subject: Re: NO_REGEX defaults on obscure platforms
Message-ID: <HYj6Cf-QUJiUlQ7fPRq5qJw3IurvsqhLa1qIg9c6ajPY6g_B2-OehA@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/HYj6Cf-QUJiUlQ7fPRq5qJw3IurvsqhLa1qIg9c6ajPY6g_B2-OehA%40cipher.nrlssc.navy.mil
In-Reply-To: <AANLkTimYY_KHwqWWXTxFqW67FHYtJJkLuA-6WVc6wzO5@mail.gmail.com>

```
On 09/08/2010 10:12 AM, Ævar Arnfjörð Bjarmason wrote:
> On Mon, Sep 6, 2010 at 07:41, Junio C Hamano <gitster@pobox.com> wrote:
> 
>> There are a few leftover bits in 'next' that need to be merged to 'master'
>> before we declare a real -rc cycle, so tonight's pushout is -rc0.
> 
> One thing that's almost certainly wrong in v1.7.3-rc0 is the NO_REGEX
> defaults. It's a non-issue for people who run the configure script,
> but the Makefile probably has the wrong defaults on some obscure
> platforms.
> 
> I've CC'd people involved in Tru64, UnixWare, SCO, HP/UX, IRIX etc. It
> would be really useful if you could:
> 
>   1. Get v1.7.3-rc0
>   2. Compile with the defaults, and NO_REGEX=YesPlease
>   3. Run `cd t && ./t7008-grep-binary.sh` and report the results.
> 
> That test is probably failing on some of these platforms.

Yes, I've already tested and IRIX does indeed need to use the compat
regex, i.e. IRIX needs NO_REGEX=YesPlease.

> Alternatively, just check for REG_STARTEND in regex.h (or the includes
> it pulls in):
> 
>     $ grep REG_STARTEND /usr/include/regex.h
>     #define REG_STARTEND (1 << 2)

Unfortunately, IRIX actually defines REG_STARTEND in its regex.h, but
the feature does not seem to work.  This also means the configure script
will give a false negative and indicate that NO_REGEX should _not_ be
set, when it actually should be.

I have a few other patches, in addition to this NO_REGEX setting, that
I haven't found time to submit, but my feelings won't be hurt if someone
else beats me to it. (hint, hint :)

-Brandon

```

## Jakub Narebski, 2010-09-08 17:20

Subject: Re: NO_REGEX defaults on obscure platforms
Message-ID: <m3hbi0m9uw.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3hbi0m9uw.fsf%40localhost.localdomain
In-Reply-To: <HYj6Cf-QUJiUlQ7fPRq5qJw3IurvsqhLa1qIg9c6ajPY6g_B2-OehA@cipher.nrlssc.navy.mil>

```
Brandon Casey <brandon.casey.ctr@nrlssc.navy.mil> writes:
> On 09/08/2010 10:12 AM, Ævar Arnfjörð Bjarmason wrote:
>> On Mon, Sep 6, 2010 at 07:41, Junio C Hamano <gitster@pobox.com> wrote:
>> 
>>> There are a few leftover bits in 'next' that need to be merged to 'master'
>>> before we declare a real -rc cycle, so tonight's pushout is -rc0.
>> 
>> One thing that's almost certainly wrong in v1.7.3-rc0 is the NO_REGEX
>> defaults. It's a non-issue for people who run the configure script,
>> but the Makefile probably has the wrong defaults on some obscure
>> platforms.
[...]

>> Alternatively, just check for REG_STARTEND in regex.h (or the includes
>> it pulls in):
>> 
>>     $ grep REG_STARTEND /usr/include/regex.h
>>     #define REG_STARTEND (1 << 2)
> 
> Unfortunately, IRIX actually defines REG_STARTEND in its regex.h, but
> the feature does not seem to work.  This also means the configure script
> will give a false negative and indicate that NO_REGEX should _not_ be
> set, when it actually should be.

Well, that just means that the test for NO_REGEX in configure.ac
should be more involved than just checking if REG_STARTEND is defined:
it should test if regex can truly handle null bytes.  There are some
examples of such test programs: see e.g. check for NO_C99_FORMAT
above.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Brandon Casey, 2010-09-09 19:15

Subject: [PATCH 1/2] t/t7008: workaround broken handling of \000 by printf on IRIX
Message-ID: <aIkKF4vjSeghwDQ63eyGAtU7mB-u0vNW0EzVfr5b9bck9XbQlHqCr65xFtnqEeEN20sMaBebsFc@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/aIkKF4vjSeghwDQ63eyGAtU7mB-u0vNW0EzVfr5b9bck9XbQlHqCr65xFtnqEeEN20sMaBebsFc%40cipher.nrlssc.navy.mil
In-Reply-To: <HYj6Cf-QUJiUlQ7fPRq5qJw3IurvsqhLa1qIg9c6ajPY6g_B2-OehA@cipher.nrlssc.navy.mil>

```
From: Brandon Casey <drafnel@gmail.com>

On IRIX 6.5, the printf utility in /usr/bin does not appear to handle the
\ddd notation according to POSIX.  This printf appears to halt processing
of the string argument and ignore any additional characters in the string.
Work around this flaw by replacing the \000's with 'Q' and using the
q_to_nul helper function provided by test-lib.sh

This problem with printf is not apparent when using the Bash shell since
Bash implements a POSIX compatible printf function internally.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t7008-grep-binary.sh |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh
index c0f9f3f..e058d18 100755
--- a/t/t7008-grep-binary.sh
+++ b/t/t7008-grep-binary.sh
@@ -5,7 +5,7 @@ test_description='git grep in binary files'
 . ./test-lib.sh
 
 test_expect_success 'setup' "
-	printf 'binary\000file\n' >a &&
+	echo 'binaryQfile' | q_to_nul >a &&
 	git add a &&
 	git commit -m.
 "
@@ -70,32 +70,32 @@ test_expect_failure 'git grep .fi a' '
 '
 
 test_expect_success 'git grep -F y<NUL>f a' "
-	printf 'y\000f' >f &&
+	printf 'yQf' | q_to_nul >f &&
 	git grep -f f -F a
 "
 
 test_expect_success 'git grep -F y<NUL>x a' "
-	printf 'y\000x' >f &&
+	printf 'yQx' | q_to_nul >f &&
 	test_must_fail git grep -f f -F a
 "
 
 test_expect_success 'git grep -Fi Y<NUL>f a' "
-	printf 'Y\000f' >f &&
+	printf 'YQf' | q_to_nul >f &&
 	git grep -f f -Fi a
 "
 
 test_expect_failure 'git grep -Fi Y<NUL>x a' "
-	printf 'Y\000x' >f &&
+	printf 'YQx' | q_to_nul >f &&
 	test_must_fail git grep -f f -Fi a
 "
 
 test_expect_success 'git grep y<NUL>f a' "
-	printf 'y\000f' >f &&
+	printf 'yQf' | q_to_nul >f &&
 	git grep -f f a
 "
 
 test_expect_failure 'git grep y<NUL>x a' "
-	printf 'y\000x' >f &&
+	printf 'yQx' | q_to_nul >f &&
 	test_must_fail git grep -f f a
 "
 
-- 
1.7.2.1

```

## Brandon Casey, 2010-09-09 19:15

Subject: [PATCH 2/2] Makefile: use compat regex on IRIX 6.5
Message-ID: <aIkKF4vjSeghwDQ63eyGAvzoq81HvE3fJPXM0HchsiJm2ahDUH-dO4jBA6nOEoyKGFpRKLAY7_A@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/aIkKF4vjSeghwDQ63eyGAvzoq81HvE3fJPXM0HchsiJm2ahDUH-dO4jBA6nOEoyKGFpRKLAY7_A%40cipher.nrlssc.navy.mil
In-Reply-To: <HYj6Cf-QUJiUlQ7fPRq5qJw3IurvsqhLa1qIg9c6ajPY6g_B2-OehA@cipher.nrlssc.navy.mil>

```
From: Brandon Casey <drafnel@gmail.com>

The IRIX 6.5 regex.h header file defines REG_STARTEND, but the feature does
not appear to work.  Since REG_STARTEND is required for proper functioning
of git-grep, set NO_REGEX and use the alternative regex libraries in compat/

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index 8b7c243..c27e8bc 100644
--- a/Makefile
+++ b/Makefile
@@ -982,6 +982,7 @@ ifeq ($(uname_S),IRIX)
 	# NO_MMAP.  If you suspect that your compiler is not affected by this
 	# issue, comment out the NO_MMAP statement.
 	NO_MMAP = YesPlease
+	NO_REGEX = YesPlease
 	SNPRINTF_RETURNS_BOGUS = YesPlease
 	SHELL_PATH = /usr/gnu/bin/bash
 	NEEDS_LIBGEN = YesPlease
@@ -1000,6 +1001,7 @@ ifeq ($(uname_S),IRIX64)
 	# NO_MMAP.  If you suspect that your compiler is not affected by this
 	# issue, comment out the NO_MMAP statement.
 	NO_MMAP = YesPlease
+	NO_REGEX = YesPlease
 	SNPRINTF_RETURNS_BOGUS = YesPlease
 	SHELL_PATH=/usr/gnu/bin/bash
 	NEEDS_LIBGEN = YesPlease
-- 
1.7.2.1

```

## Junio C Hamano, 2010-09-10 00:10

Subject: Re: [PATCH 2/2] Makefile: use compat regex on IRIX 6.5
Message-ID: <7v39tilapj.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v39tilapj.fsf%40alter.siamese.dyndns.org
In-Reply-To: <aIkKF4vjSeghwDQ63eyGAvzoq81HvE3fJPXM0HchsiJm2ahDUH-dO4jBA6nOEoyKGFpRKLAY7_A@cipher.nrlssc.navy.mil>

```
Thanks, as always.

```
