=== Applying patches on top of PostgreSQL commit ID 6857947db5bbec823226cd5234f088524f933caa === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Fri Mar 27 14:32:31 UTC 2026 On branch cf/5760 nothing to commit, working tree clean === using 'git am' to apply patch ./0001-Fix-latent-bug-in-get_stats_option_name.patch === Applying: Fix latent bug in get_stats_option_name() === using 'git am' to apply patch ./0002-Invent-custom-pg_getopt_ctx-that-is-thread-safe.patch === Applying: Invent custom pg_getopt_ctx that is thread-safe Using index info to reconstruct a base tree... M src/port/Makefile M src/port/getopt.c M src/port/meson.build M src/tools/pgindent/typedefs.list Falling back to patching base and 3-way merge... Auto-merging src/tools/pgindent/typedefs.list Auto-merging src/port/meson.build CONFLICT (content): Merge conflict in src/port/meson.build Auto-merging src/port/getopt.c CONFLICT (content): Merge conflict in src/port/getopt.c Auto-merging src/port/Makefile CONFLICT (content): Merge conflict in src/port/Makefile error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Invent custom pg_getopt_ctx that is thread-safe When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./0002-Invent-custom-pg_getopt_ctx-that-is-thread-safe.patch === patching file src/include/port/pg_getopt_ctx.h patching file src/port/Makefile Hunk #1 FAILED at 44. 1 out of 1 hunk FAILED -- saving rejects to file src/port/Makefile.rej patching file src/port/getopt.c Hunk #2 FAILED at 50. 1 out of 2 hunks FAILED -- saving rejects to file src/port/getopt.c.rej patching file src/port/meson.build Hunk #1 FAILED at 7. 1 out of 1 hunk FAILED -- saving rejects to file src/port/meson.build.rej patching file src/port/pg_getopt_ctx.c patching file src/tools/pgindent/typedefs.list Hunk #1 succeeded at 3976 (offset 146 lines). Unstaged changes after reset: M src/port/getopt.c M src/tools/pgindent/typedefs.list Removing src/include/port/pg_getopt_ctx.h Removing src/port/Makefile.rej Removing src/port/getopt.c.rej Removing src/port/meson.build.rej Removing src/port/pg_getopt_ctx.c === using 'git apply' to apply patch ./0002-Invent-custom-pg_getopt_ctx-that-is-thread-safe.patch === Falling back to direct application... Applied patch to 'src/port/Makefile' with conflicts. Applied patch to 'src/port/getopt.c' with conflicts. Applied patch to 'src/port/meson.build' with conflicts. Falling back to direct application... Applied patch to 'src/tools/pgindent/typedefs.list' cleanly. U src/port/Makefile U src/port/getopt.c U src/port/meson.build diff --cc src/port/Makefile index 47cfea1507d,5aa5867b5ea..00000000000 --- a/src/port/Makefile +++ b/src/port/Makefile @@@ -44,7 -44,7 +44,11 @@@ OBJS = noblock.o \ path.o \ pg_bitutils.o \ ++<<<<<<< ours + pg_cpu_x86.o \ ++======= + pg_getopt_ctx.o \ ++>>>>>>> theirs pg_localeconv_r.o \ pg_numa.o \ pg_popcount_aarch64.o \ diff --cc src/port/getopt.c index 2cca5a0673a,34a60d5f32d..00000000000 --- a/src/port/getopt.c +++ b/src/port/getopt.c @@@ -71,67 -66,23 +66,28 @@@ char *optarg; /* argument associa int getopt(int nargc, char *const *nargv, const char *ostr) { ++<<<<<<< ours + static char *place = EMSG; /* option letter processing */ + const char *oli; /* option letter list index */ ++======= + static bool active = false; + static pg_getopt_ctx ctx; + int result; ++>>>>>>> theirs - if (!*place) - { /* update scanning pointer */ - if (optind >= nargc || *(place = nargv[optind]) != '-') - { - place = EMSG; - return -1; - } - if (place[1] && *++place == '-' && place[1] == '\0') - { /* found "--" */ - ++optind; - place = EMSG; - return -1; - } - } /* option letter okay? */ - if ((optopt = (int) *place++) == (int) ':' || - !(oli = strchr(ostr, optopt))) + if (!active) { - /* - * if the user didn't specify '-' as an option, assume it means -1. - */ - if (optopt == (int) '-') - { - place = EMSG; - return -1; - } - if (!*place) - ++optind; - if (opterr && *ostr != ':') - (void) fprintf(stderr, - "illegal option -- %c\n", optopt); - return BADCH; + pg_getopt_start(&ctx, nargc, nargv, ostr); + ctx.opterr = opterr; + active = true; } - if (*++oli != ':') - { /* don't need argument */ - optarg = NULL; - if (!*place) - ++optind; - } - else - { /* need an argument */ - if (*place) /* no white space */ - optarg = place; - else if (nargc <= ++optind) - { /* no arg */ - place = EMSG; - if (*ostr == ':') - return BADARG; - if (opterr) - (void) fprintf(stderr, - "option requires an argument -- %c\n", - optopt); - return BADCH; - } - else - /* white space */ - optarg = nargv[optind]; - place = EMSG; - ++optind; - } - return optopt; /* dump back option letter */ + + result = pg_getopt_next(&ctx); + opterr = ctx.opterr; + optind = ctx.optind; + optopt = ctx.optopt; + optarg = ctx.optarg; + if (result == -1) + active = false; + return result; } diff --cc src/port/meson.build index 7296f8e3c03,a6ec9c82f3a..00000000000 --- a/src/port/meson.build +++ b/src/port/meson.build @@@ -7,7 -7,7 +7,11 @@@ pgport_sources = 'noblock.c', 'path.c', 'pg_bitutils.c', ++<<<<<<< ours + 'pg_cpu_x86.c', ++======= + 'pg_getopt_ctx.c', ++>>>>>>> theirs 'pg_localeconv_r.c', 'pg_numa.c', 'pg_popcount_aarch64.c',