agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
[PATCH 2/5] Add va_header field to the varattrib_4b union.
144+ messages / 2 participants
[nested] [flat]

* [PATCH 2/5] Add va_header field to the varattrib_4b union.
@ 2026-03-11 13:53 Antonin Houska <ah@cybertec.at>
  0 siblings, 0 replies; 144+ messages in thread

From: Antonin Houska @ 2026-03-11 13:53 UTC (permalink / raw)

Since VARSIZE_ANY() may call VARSIZE_4B(), it's possible that the compiler
(when invoked with -Warray-bounds) complains if the argument of VARSIZE_ANY()
is actually smaller than what VARSIZE_4B() expects. With the new field,
VARSIZE_4B() can check the size w/o dereferencing varattrib_4b pointer.

The problem does not exist in the tree at the moment since the current users
of VARSIZE_ANY() pass a pointer to a dynamically allocated memory, so the
compiler has no idea about the memory available. However, in an upcoming
patch, it makes sense to pass a pointer to a local variable of "varlena"
type. In such a case, the compiler warning might appear because
sizeof(varlena) is lower than sizeof(varattrib_4b).
---
 src/include/varatt.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/include/varatt.h b/src/include/varatt.h
index 000bdf33b92..c54d5160c22 100644
--- a/src/include/varatt.h
+++ b/src/include/varatt.h
@@ -137,6 +137,10 @@ typedef union
 								 * compression method; see va_extinfo */
 		char		va_data[FLEXIBLE_ARRAY_MEMBER]; /* Compressed data */
 	}			va_compressed;
+	uint32		va_header;		/* Without this, compiler might raise warning
+								 * (-Warray-bounds) if the argument of
+								 * VARSIZE_ANY() is smaller than
+								 * varattrib_4b */
 } varattrib_4b;
 
 typedef struct
@@ -207,7 +211,7 @@ typedef struct
 
 /* VARSIZE_4B() should only be used on known-aligned data */
 #define VARSIZE_4B(PTR) \
-	(((const varattrib_4b *) (PTR))->va_4byte.va_header & 0x3FFFFFFF)
+	(*((const uint32 *) (PTR)) & 0x3FFFFFFF)
 #define VARSIZE_1B(PTR) \
 	(((const varattrib_1b *) (PTR))->va_header & 0x7F)
 #define VARTAG_1B_E(PTR) \
@@ -240,7 +244,7 @@ typedef struct
 
 /* VARSIZE_4B() should only be used on known-aligned data */
 #define VARSIZE_4B(PTR) \
-	((((const varattrib_4b *) (PTR))->va_4byte.va_header >> 2) & 0x3FFFFFFF)
+	((*((const uint32 *) (PTR)) >> 2) & 0x3FFFFFFF)
 #define VARSIZE_1B(PTR) \
 	((((const varattrib_1b *) (PTR))->va_header >> 1) & 0x7F)
 #define VARTAG_1B_E(PTR) \
-- 
2.47.3


--=-=-=
Content-Type: text/plain
Content-Disposition: attachment;
 filename=v41-0003-Add-CONCURRENTLY-option-to-REPACK-command.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread

* [PATCH v2 1/2] Add a binary to test getopt_long()
@ 2026-07-22 03:55 Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 144+ messages in thread

From: Japin Li @ 2026-07-22 03:55 UTC (permalink / raw)

---
 src/bin/Makefile                            |  1 +
 src/bin/getopt_long_test/Makefile           | 26 +++++++++++++++++++++
 src/bin/getopt_long_test/getopt_long_test.c | 25 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 src/bin/getopt_long_test/Makefile
 create mode 100644 src/bin/getopt_long_test/getopt_long_test.c

diff --git a/src/bin/Makefile b/src/bin/Makefile
index 538af88a523..b25305f9db5 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -14,6 +14,7 @@ top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
+	getopt_long_test \
 	initdb \
 	pg_amcheck \
 	pg_archivecleanup \
diff --git a/src/bin/getopt_long_test/Makefile b/src/bin/getopt_long_test/Makefile
new file mode 100644
index 00000000000..f7de6ef872c
--- /dev/null
+++ b/src/bin/getopt_long_test/Makefile
@@ -0,0 +1,26 @@
+PGFILEDESC = "getopt_long_test - test PostgreSQL getopt_long() function"
+PGAPPICON = win32
+
+subdir = src/bin/getopt_long_test
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS += -I$(top_srcdir)/src/port
+
+OBJS = \
+	$(WIN32RES) \
+	getopt_long.o \
+	getopt_long_test.o
+
+all: getopt_long_test
+
+getopt_long_test: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+getopt_long_test.o: getopt_long_test.c $(top_builddir)/src/Makefile.global
+
+getopt_long.c:
+	ln -s $(top_srcdir)/src/port/getopt_long.c .
+
+clean distclean:
+	rm -f getopt_long_test$(X) $(OBJS) getopt_long.c
diff --git a/src/bin/getopt_long_test/getopt_long_test.c b/src/bin/getopt_long_test/getopt_long_test.c
new file mode 100644
index 00000000000..4abd042bbaa
--- /dev/null
+++ b/src/bin/getopt_long_test/getopt_long_test.c
@@ -0,0 +1,25 @@
+
+#include "postgres.h"
+
+#include "getopt_long.h"
+
+int
+main(int argc, char **argv)
+{
+	int c;
+	const char		*shortopts = ":f:";
+	struct option	 longopts[] = {
+		{"log-filename", required_argument, NULL, 'f'},
+		{NULL, 0, NULL, 0},
+	};
+
+	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
+	{
+		if (c == ':')
+			fprintf(stderr, "option '%s' requires an argument\n", argv[optind - 1]);
+		else if (c == '?')
+			fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+	}
+
+	return 0;
+}
-- 
2.53.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0002-Fix-optind-handling-inconsistency-in-getopt_long-.patch



^ permalink  raw  reply  [nested|flat] 144+ messages in thread


end of thread, other threads:[~2026-07-22 03:55 UTC | newest]

Thread overview: 144+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-11 13:53 [PATCH 2/5] Add va_header field to the varattrib_4b union. Antonin Houska <ah@cybertec.at>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>
2026-07-22 03:55 [PATCH v2 1/2] Add a binary to test getopt_long() Japin Li <japinli@hotmail.com>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox