From: lufia via GitGitGadget Date: Sat, 03 Aug 2019 23:52:10 GMT Subject: [PATCH 2/6] Fix C syntactic errors for the Plan 9 C compiler Message-ID: <301a796de9e853f9b0e398bc0d0c54a737a2f2c0.1564876327.git.gitgitgadget@gmail.com> In-Reply-To: From: lufia Signed-off-by: lufia --- compat/plan9/openssl/crypto.h | 5 +++++ compat/regex/regex_internal.h | 3 +++ config.c | 3 ++- git-compat-util.h | 9 ++++++++- parse-options.h | 18 +++++++++--------- remove-bitfields.rc | 14 ++++++++++++++ 6 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 compat/plan9/openssl/crypto.h create mode 100644 remove-bitfields.rc diff --git a/compat/plan9/openssl/crypto.h b/compat/plan9/openssl/crypto.h new file mode 100644 index 0000000000..9d1ef43422 --- /dev/null +++ b/compat/plan9/openssl/crypto.h @@ -0,0 +1,5 @@ +#ifndef __attribute__ +#define __attribute__(x) +#endif + +#include_next diff --git a/compat/regex/regex_internal.h b/compat/regex/regex_internal.h index 3ee8aae59d..7313c747a6 100644 --- a/compat/regex/regex_internal.h +++ b/compat/regex/regex_internal.h @@ -26,6 +26,9 @@ #include #include +#ifdef NEEDS_SYS_PARAM_H +#include +#endif #if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC # include #endif diff --git a/config.c b/config.c index f67cef5cf8..993f9f57be 100644 --- a/config.c +++ b/config.c @@ -2461,7 +2461,8 @@ static int store_aux_event(enum config_event_t type, return error(_("invalid section name '%s'"), cf->var.buf); if (cf->subsection_case_sensitive) - cmpfn = strncasecmp; + /* Plan 9's strncasecmp is typed (char*, char*, int) */ + cmpfn = (int (*)(const char*, const char*, size_t))strncasecmp; else cmpfn = strncmp; diff --git a/git-compat-util.h b/git-compat-util.h index f8fdd79591..1aa7877af4 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -164,7 +164,11 @@ #define GIT_WINDOWS_NATIVE #endif +#include #include +#ifdef __PLAN9__ +#include +#endif #include #include #include @@ -180,7 +184,6 @@ #ifdef NEEDS_SYS_PARAM_H #include #endif -#include #include #include #include @@ -282,6 +285,10 @@ char *gitbasename(char *); char *gitdirname(char *); #endif +#ifdef __PLAN9__ +#include +#endif + #ifndef NO_ICONV #include #endif diff --git a/parse-options.h b/parse-options.h index a4bd40bb6a..38a33a087e 100644 --- a/parse-options.h +++ b/parse-options.h @@ -46,6 +46,15 @@ enum parse_opt_option_flags { PARSE_OPT_COMP_ARG = 1024 }; +enum parse_opt_result { + PARSE_OPT_COMPLETE = -3, + PARSE_OPT_HELP = -2, + PARSE_OPT_ERROR = -1, /* must be the same as error() */ + PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */ + PARSE_OPT_NON_OPTION, + PARSE_OPT_UNKNOWN +}; + struct option; typedef int parse_opt_cb(const struct option *, const char *arg, int unset); @@ -241,15 +250,6 @@ const char *optname(const struct option *opt, int flags); /*----- incremental advanced APIs -----*/ -enum parse_opt_result { - PARSE_OPT_COMPLETE = -3, - PARSE_OPT_HELP = -2, - PARSE_OPT_ERROR = -1, /* must be the same as error() */ - PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */ - PARSE_OPT_NON_OPTION, - PARSE_OPT_UNKNOWN -}; - /* * It's okay for the caller to consume argv/argc in the usual way. * Other fields of that structure are private to parse-options and should not diff --git a/remove-bitfields.rc b/remove-bitfields.rc new file mode 100644 index 0000000000..897f98da10 --- /dev/null +++ b/remove-bitfields.rc @@ -0,0 +1,14 @@ +#!/bin/rc +# Plan 9 C compiler rejects initialization a structure including bit field. +# usage: remove-bitfields.rc [dir ...] + +fn sigexit sighup sigint sigquit sigterm { + rm -f /tmp/remove-bitfields.$pid + exit +} + +files=`{du -a $* | awk '/\.[ch]$/ { print $2 }'} +for(i in $files){ + sed '/(^[ ]*\*|\?)/!s/([a-z]+[a-z0-9]*) *: *[0-9]+([,;])/\1\2/g' $i >/tmp/remove-bitfields.$pid + cp /tmp/remove-bitfields.$pid $i +} -- gitgitgadget