# fc046a75d539a78e6b2c16534c4078617a69a327 fails on OpenBSD 3.8

6 messages from 2006-06-30 to 2006-06-30. Participants: Randal L. Schwartz, Junio C Hamano, Jakub Narebski.
Thread: https://gitlist.dev/t/4721

## Randal L. Schwartz, 2006-06-30 16:57

Subject: fc046a75d539a78e6b2c16534c4078617a69a327 fails on OpenBSD 3.8
Message-ID: <86wtayy42o.fsf@blue.stonehenge.com>
URL: https://gitlist.dev/e/86wtayy42o.fsf%40blue.stonehenge.com

```

gcc -o upload-pack.o -c -g -O2 -Wall -I/usr/local/include -DSHA1_HEADER='<openssl/sha.h>' -DNO_STRCASESTR upload-pack.c
In file included from /usr/include/sys/poll.h:54,
                 from upload-pack.c:9:
/usr/include/ctype.h:67: error: syntax error before ']' token
/usr/include/ctype.h:68: error: syntax error before ']' token
/usr/include/ctype.h:70: error: syntax error before ']' token
/usr/include/ctype.h:75: error: syntax error before ']' token
/usr/include/ctype.h:78: error: syntax error before '(' token
/usr/include/ctype.h:79: error: syntax error before '(' token
/usr/include/ctype.h:93: error: syntax error before "c"
In file included from /usr/include/sys/poll.h:54,
                 from upload-pack.c:9:
/usr/include/ctype.h:91:1: unterminated #if
/usr/include/ctype.h:40:1: unterminated #ifndef
In file included from upload-pack.c:9:
/usr/include/sys/poll.h:53:1: unterminated #ifndef
/usr/include/sys/poll.h:28:1: unterminated #ifndef
gmake: *** [upload-pack.o] Error 1

The lines in ctype.h that are probably relevant are:

    #if defined(__GNUC__) || defined(_ANSI_LIBRARY) || defined(lint)
    int	isalnum(int);
    int	isalpha(int);
    int	iscntrl(int);
    int	isdigit(int);
    int	isgraph(int);
    int	islower(int);
    int	isprint(int);
    int	ispunct(int);
    int	isspace(int);
    int	isupper(int);
    int	isxdigit(int);
    int	tolower(int);
    int	toupper(int);

Line 67 is "int isalnum(int)"

Are you defining a macro when you shouldn't be in upload-pack?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

```

## Junio C Hamano, 2006-06-30 17:06

Subject: Re: fc046a75d539a78e6b2c16534c4078617a69a327 fails on OpenBSD 3.8
Message-ID: <7vy7veindn.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vy7veindn.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <86wtayy42o.fsf@blue.stonehenge.com>

```
merlyn@stonehenge.com (Randal L. Schwartz) writes:

> gcc -o upload-pack.o -c -g -O2 -Wall -I/usr/local/include -DSHA1_HEADER='<openssl/sha.h>' -DNO_STRCASESTR upload-pack.c
> In file included from /usr/include/sys/poll.h:54,
>                  from upload-pack.c:9:
> /usr/include/ctype.h:67: error: syntax error before ']' token
> /usr/include/ctype.h:68: error: syntax error before ']' token
> /usr/include/ctype.h:70: error: syntax error before ']' token
> /usr/include/ctype.h:75: error: syntax error before ']' token
> /usr/include/ctype.h:78: error: syntax error before '(' token
> /usr/include/ctype.h:79: error: syntax error before '(' token
> /usr/include/ctype.h:93: error: syntax error before "c"
> In file included from /usr/include/sys/poll.h:54,
>                  from upload-pack.c:9:
> /usr/include/ctype.h:91:1: unterminated #if
> /usr/include/ctype.h:40:1: unterminated #ifndef

Crap.  Including <sys/poll.h> pollutes your namespace with ctype
macros?

```

## Randal L. Schwartz, 2006-06-30 17:09

Subject: Re: fc046a75d539a78e6b2c16534c4078617a69a327 fails on OpenBSD 3.8
Message-ID: <86sllmy3ia.fsf@blue.stonehenge.com>
URL: https://gitlist.dev/e/86sllmy3ia.fsf%40blue.stonehenge.com
In-Reply-To: <7vy7veindn.fsf@assigned-by-dhcp.cox.net>

```
>>>>> "Junio" == Junio C Hamano <junkio@cox.net> writes:

Junio> merlyn@stonehenge.com (Randal L. Schwartz) writes:
>> gcc -o upload-pack.o -c -g -O2 -Wall -I/usr/local/include -DSHA1_HEADER='<openssl/sha.h>' -DNO_STRCASESTR upload-pack.c
>> In file included from /usr/include/sys/poll.h:54,
>> from upload-pack.c:9:
>> /usr/include/ctype.h:67: error: syntax error before ']' token
>> /usr/include/ctype.h:68: error: syntax error before ']' token
>> /usr/include/ctype.h:70: error: syntax error before ']' token
>> /usr/include/ctype.h:75: error: syntax error before ']' token
>> /usr/include/ctype.h:78: error: syntax error before '(' token
>> /usr/include/ctype.h:79: error: syntax error before '(' token
>> /usr/include/ctype.h:93: error: syntax error before "c"
>> In file included from /usr/include/sys/poll.h:54,
>> from upload-pack.c:9:
>> /usr/include/ctype.h:91:1: unterminated #if
>> /usr/include/ctype.h:40:1: unterminated #ifndef

Junio> Crap.  Including <sys/poll.h> pollutes your namespace with ctype
Junio> macros?

>From /usr/include/sys/poll.h:

    #ifndef _KERNEL
    #include <ctype.h>

So, I guess, it's ... Yes.

This sounds familiar.  Maybe the mailing list archive has me reporting
this bug last time too. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

```

## Junio C Hamano, 2006-06-30 17:38

Subject: Re: fc046a75d539a78e6b2c16534c4078617a69a327 fails on OpenBSD 3.8
Message-ID: <7vk66yilxd.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vk66yilxd.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <86sllmy3ia.fsf@blue.stonehenge.com>

```
merlyn@stonehenge.com (Randal L. Schwartz) writes:

>>>>>> "Junio" == Junio C Hamano <junkio@cox.net> writes:
>...
>>> In file included from /usr/include/sys/poll.h:54,
>>> from upload-pack.c:9:
>>> /usr/include/ctype.h:91:1: unterminated #if
>>> /usr/include/ctype.h:40:1: unterminated #ifndef
>
> Junio> Crap.  Including <sys/poll.h> pollutes your namespace with ctype
> Junio> macros?

I should stop imitating others -- not my style.  Sorry.
Would this work for you?

diff --git a/upload-pack.c b/upload-pack.c
index 2b70c3d..b18eb9b 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,3 +1,6 @@
+#include <signal.h>
+#include <sys/wait.h>
+#include <sys/poll.h>
 #include "cache.h"
 #include "refs.h"
 #include "pkt-line.h"
@@ -5,9 +8,6 @@ #include "tag.h"
 #include "object.h"
 #include "commit.h"
 #include "exec_cmd.h"
-#include <signal.h>
-#include <sys/poll.h>
-#include <sys/wait.h>
 
 static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>";
 

```

## Junio C Hamano, 2006-06-30 18:30

Subject: [PATCH/RFT] upload-pack.c: <sys/poll.h> includes <ctype.h> on OpenBSD 3.8
Message-ID: <7vr716h4xm.fsf_-_@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vr716h4xm.fsf_-_%40assigned-by-dhcp.cox.net
In-Reply-To: <7vk66yilxd.fsf@assigned-by-dhcp.cox.net>

```
Merlyn reports that <sys/poll.h> on OpenBSD 3.8 includes <ctype.h>
and having our custom ctype (done in git-compat-util.h which is
included via cache.h) makes upload-pack.c uncompilable.  Try to
work it around by including the system headers first.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 * Can somebody with OpenBSD who can reproduce the original
   problem confirm or reject this patch, so that the issue can
   be resolved before 1.4.1, please?

diff --git a/upload-pack.c b/upload-pack.c
index 2b70c3d..b18eb9b 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,3 +1,6 @@
+#include <signal.h>
+#include <sys/wait.h>
+#include <sys/poll.h>
 #include "cache.h"
 #include "refs.h"
 #include "pkt-line.h"
@@ -5,9 +8,6 @@ #include "tag.h"
 #include "object.h"
 #include "commit.h"
 #include "exec_cmd.h"
-#include <signal.h>
-#include <sys/poll.h>
-#include <sys/wait.h>
 
 static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>";
 

```

## Jakub Narebski, 2006-06-30 19:00

Subject: Re: [PATCH/RFT] upload-pack.c: <sys/poll.h> includes <ctype.h> on OpenBSD 3.8
Message-ID: <e83sbc$4s0$1@sea.gmane.org>
URL: https://gitlist.dev/e/e83sbc%244s0%241%40sea.gmane.org
In-Reply-To: <7vr716h4xm.fsf_-_@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:

> Try to work it around by including the system headers first.

Shouldn't it be always the case?

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```
