git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: "lufia via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, lufia <lufia@lufia.org>
Subject: [PATCH v2 2/3] Fix C syntactic errors for the Plan 9 C compiler
Date: Tue, 27 Aug 2019 06:46:18 -0700 (PDT)	[thread overview]
Message-ID: <7abbd36e1ddc2037925c3ff148f62f0352a8954b.1566913575.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.305.v2.git.gitgitgadget@gmail.com>

From: lufia <lufia@lufia.org>

Signed-off-by: lufia <lufia@lufia.org>
---
 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.sh           | 17 +++++++++++++++++
 6 files changed, 44 insertions(+), 11 deletions(-)
 create mode 100644 compat/plan9/openssl/crypto.h
 create mode 100755 remove-bitfields.sh

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 <openssl/crypto.h>
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 <stdlib.h>
 #include <string.h>
 
+#ifdef NEEDS_SYS_PARAM_H
+#include <sys/param.h>
+#endif
 #if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC
 # include <langinfo.h>
 #endif
diff --git a/config.c b/config.c
index 14de96ee6d..0024b767e5 100644
--- a/config.c
+++ b/config.c
@@ -2462,7 +2462,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 <sys/types.h>
 #include <unistd.h>
+#ifdef __PLAN9__
+#include <libv.h>
+#endif
 #include <stdio.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -180,7 +184,6 @@
 #ifdef NEEDS_SYS_PARAM_H
 #include <sys/param.h>
 #endif
-#include <sys/types.h>
 #include <dirent.h>
 #include <sys/time.h>
 #include <time.h>
@@ -282,6 +285,10 @@ char *gitbasename(char *);
 char *gitdirname(char *);
 #endif
 
+#ifdef __PLAN9__
+#include <machine/endian.h>
+#endif
+
 #ifndef NO_ICONV
 #include <iconv.h>
 #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.sh b/remove-bitfields.sh
new file mode 100755
index 0000000000..952bd34f12
--- /dev/null
+++ b/remove-bitfields.sh
@@ -0,0 +1,17 @@
+#!/bin/ape/sh
+# Plan 9 C compiler rejects initialization a structure including bit field.
+# usage: remove-bitfields.sh [dir ...]
+
+if ! echo abc | sed 's/(ab)c/\1/' >/dev/null 2>&1
+then
+	alias sed='sed -E'
+fi
+
+trap 'rm -f /tmp/remove-bitfields.$pid; exit 1' 1 2 3 15 EXIT
+
+files=$(du -a $* | awk '/\.[ch]$/ { print $2 }')
+for i in $files
+do
+	sed '/(^[ 	]*\*|\?)/!s/([a-z]+[a-z0-9]*) *: *[0-9]+([,;])/\1\2/g' $i >/tmp/remove-bitfields.$pid
+	cp /tmp/remove-bitfields.$pid $i
+done
-- 
gitgitgadget


  parent reply	other threads:[~2019-08-27 13:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-03 23:52 [PATCH 0/6] Port git to Plan 9 KADOTA, Kyohei via GitGitGadget
2019-08-03 23:52 ` [PATCH 1/6] Change HOME, PATH, and .gitconfig paths to be customizable lufia via GitGitGadget
2019-08-03 23:52 ` [PATCH 2/6] Fix C syntactic errors for the Plan 9 C compiler lufia via GitGitGadget
2019-08-03 23:52 ` [PATCH 3/6] GIT-VERSION-GEN: Use sed instead of expr lufia via GitGitGadget
2019-08-05 22:37   ` Junio C Hamano
2019-08-03 23:52 ` [PATCH 5/6] Add plan9/wrap.c lufia via GitGitGadget
2019-08-04  0:03   ` brian m. carlson
2019-08-04  1:26     ` Kyohei Kadota
2019-08-03 23:52 ` [PATCH 4/6] Port generate-cmdline.sh to rc lufia via GitGitGadget
2019-08-03 23:52 ` [PATCH 6/6] Add mkfile to build git and subcommands for Plan 9 lufia via GitGitGadget
2019-08-04  0:38 ` [PATCH 0/6] Port git to " brian m. carlson
2019-08-04  2:22   ` Kyohei Kadota
2019-08-04 20:22     ` Jonathan Nieder
2019-08-27 13:46 ` [PATCH v2 0/3] " KADOTA, Kyohei via GitGitGadget
2019-08-27 13:46   ` [PATCH v2 1/3] Change HOME, PATH, and .gitconfig paths to be customizable lufia via GitGitGadget
2019-08-27 13:46   ` lufia via GitGitGadget [this message]
2019-08-27 13:46   ` [PATCH v2 3/3] Support Plan 9 dialect lufia via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7abbd36e1ddc2037925c3ff148f62f0352a8954b.1566913575.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lufia@lufia.org \
    --subject='Re: [PATCH v2 2/3] Fix C syntactic errors for the Plan 9 C compiler' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).