Skip to content

Commit 8aadd64

Browse files
committed
Fix C syntactic errors for the Plan 9 C compiler
Signed-off-by: lufia <[email protected]>
1 parent 30cea48 commit 8aadd64

File tree

6 files changed

+44
-2
lines changed

6 files changed

+44
-2
lines changed

compat/plan9/openssl/crypto.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifndef __attribute__
2+
#define __attribute__(x)
3+
#endif
4+
5+
#include_next <openssl/crypto.h>

compat/regex/regex_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#include <stdio.h>
2626
#include <string.h>
2727

28+
#ifdef NEEDS_SYS_PARAM_H
29+
#include <sys/param.h>
30+
#endif
2831
#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC
2932
# include <langinfo.h>
3033
#endif

config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,8 @@ static int store_aux_event(enum config_event_t type,
24572457
return error(_("invalid section name '%s'"), cf->var.buf);
24582458

24592459
if (cf->subsection_case_sensitive)
2460-
cmpfn = strncasecmp;
2460+
/* Plan 9's strncasecmp is typed (char*, char*, int) */
2461+
cmpfn = (int (*)(const char*, const char*, size_t))strncasecmp;
24612462
else
24622463
cmpfn = strncmp;
24632464

git-compat-util.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@
164164
#define GIT_WINDOWS_NATIVE
165165
#endif
166166

167+
#include <sys/types.h>
167168
#include <unistd.h>
169+
#ifdef __PLAN9__
170+
#include <libv.h>
171+
#endif
168172
#include <stdio.h>
169173
#include <sys/stat.h>
170174
#include <fcntl.h>
@@ -180,7 +184,6 @@
180184
#ifdef NEEDS_SYS_PARAM_H
181185
#include <sys/param.h>
182186
#endif
183-
#include <sys/types.h>
184187
#include <dirent.h>
185188
#include <sys/time.h>
186189
#include <time.h>
@@ -282,6 +285,10 @@ char *gitbasename(char *);
282285
char *gitdirname(char *);
283286
#endif
284287

288+
#ifdef __PLAN9__
289+
#include <machine/endian.h>
290+
#endif
291+
285292
#ifndef NO_ICONV
286293
#include <iconv.h>
287294
#endif

parse-options.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ enum parse_opt_result {
5959
PARSE_OPT_UNKNOWN
6060
};
6161

62+
enum parse_opt_result {
63+
PARSE_OPT_COMPLETE = -3,
64+
PARSE_OPT_HELP = -2,
65+
PARSE_OPT_ERROR = -1, /* must be the same as error() */
66+
PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */
67+
PARSE_OPT_NON_OPTION,
68+
PARSE_OPT_UNKNOWN
69+
};
70+
6271
struct option;
6372
typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
6473

remove-bitfields.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/ape/sh
2+
# Plan 9 C compiler rejects initialization a structure including bit field.
3+
# usage: remove-bitfields.sh [dir ...]
4+
5+
if ! echo abc | sed 's/(ab)c/\1/' >/dev/null 2>&1
6+
then
7+
alias sed='sed -E'
8+
fi
9+
10+
trap 'rm -f /tmp/remove-bitfields.$pid; exit 1' 1 2 3 15 EXIT
11+
12+
files=$(du -a $* | awk '/\.[ch]$/ { print $2 }')
13+
for i in $files
14+
do
15+
sed '/(^[ ]*\*|\?)/!s/([a-z]+[a-z0-9]*) *: *[0-9]+([,;])/\1\2/g' $i >/tmp/remove-bitfields.$pid
16+
cp /tmp/remove-bitfields.$pid $i
17+
done

0 commit comments

Comments
 (0)