[openssh-commits] [openssh] 01/01: avoid clash between for getopt's struct option

git+noreply at mindrot.org git+noreply at mindrot.org
Mon Feb 27 17:10:26 AEDT 2023


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 01dbeb3084d714bbd001ff9d03b9de542e8cdf58
Author: Damien Miller <djm at mindrot.org>
Date:   Mon Feb 27 17:07:52 2023 +1100

    avoid clash between for getopt's struct option
    
    Since we don't use getopt_long() nothing outside the getopt()
    implementation itself uses this structure, so move it into the
    source to remove it from visibility and clashes with libc's
    
    ok dtucker@
---
 openbsd-compat/getopt.h      |  3 +++
 openbsd-compat/getopt_long.c | 14 ++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/openbsd-compat/getopt.h b/openbsd-compat/getopt.h
index 8eb12447..65c8bc7f 100644
--- a/openbsd-compat/getopt.h
+++ b/openbsd-compat/getopt.h
@@ -40,6 +40,7 @@
 #define required_argument  1
 #define optional_argument  2
 
+#if 0
 struct option {
 	/* name of long option */
 	const char *name;
@@ -58,6 +59,8 @@ int	 getopt_long(int, char * const *, const char *,
 	    const struct option *, int *);
 int	 getopt_long_only(int, char * const *, const char *,
 	    const struct option *, int *);
+#endif
+
 #ifndef _GETOPT_DEFINED_
 #define _GETOPT_DEFINED_
 int	 getopt(int, char * const *, const char *);
diff --git a/openbsd-compat/getopt_long.c b/openbsd-compat/getopt_long.c
index 1a5001f7..c2863a78 100644
--- a/openbsd-compat/getopt_long.c
+++ b/openbsd-compat/getopt_long.c
@@ -72,6 +72,20 @@
 
 #include "log.h"
 
+struct option {
+	/* name of long option */
+	const char *name;
+	/*
+	 * one of no_argument, required_argument, and optional_argument:
+	 * whether option takes an argument
+	 */
+	int has_arg;
+	/* if not NULL, set *flag to val when option found */
+	int *flag;
+	/* if flag not NULL, value to set *flag to; else return value */
+	int val;
+};
+
 int	opterr = 1;		/* if error message should be printed */
 int	optind = 1;		/* index into parent argv vector */
 int	optopt = '?';		/* character checked for validity */

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list