Skip to content

Commit 7abbd36

Browse files
committed
Fix C syntactic errors for the Plan 9 C compiler
Signed-off-by: lufia <[email protected]>
1 parent 63e7e77 commit 7abbd36

File tree

6 files changed

+44
-11
lines changed

6 files changed

+44
-11
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
@@ -26,6 +26,9 @@
2626
#include <stdlib.h>
2727
#include <string.h>
2828

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

config.c

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

24642464
if (cf->subsection_case_sensitive)
2465-
cmpfn = strncasecmp;
2465+
/* Plan 9's strncasecmp is typed (char*, char*, int) */
2466+
cmpfn = (int (*)(const char*, const char*, size_t))strncasecmp;
24662467
else
24672468
cmpfn = strncmp;
24682469

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 & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ enum parse_opt_option_flags {
4646
PARSE_OPT_COMP_ARG = 1024
4747
};
4848

49+
enum parse_opt_result {
50+
PARSE_OPT_COMPLETE = -3,
51+
PARSE_OPT_HELP = -2,
52+
PARSE_OPT_ERROR = -1, /* must be the same as error() */
53+
PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */
54+
PARSE_OPT_NON_OPTION,
55+
PARSE_OPT_UNKNOWN
56+
};
57+
4958
struct option;
5059
typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
5160

@@ -241,15 +250,6 @@ const char *optname(const struct option *opt, int flags);
241250

242251
/*----- incremental advanced APIs -----*/
243252

244-
enum parse_opt_result {
245-
PARSE_OPT_COMPLETE = -3,
246-
PARSE_OPT_HELP = -2,
247-
PARSE_OPT_ERROR = -1, /* must be the same as error() */
248-
PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */
249-
PARSE_OPT_NON_OPTION,
250-
PARSE_OPT_UNKNOWN
251-
};
252-
253253
/*
254254
* It's okay for the caller to consume argv/argc in the usual way.
255255
* Other fields of that structure are private to parse-options and should not

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)