v33-0006-Moving-handle_help_version_opts.patch
application/octet-stream
Filename: v33-0006-Moving-handle_help_version_opts.patch
Type: application/octet-stream
Part: 5
Message:
Re: new heapcheck contrib module
Patch
Format: format-patch
Series: patch v33-0006
Subject: Moving handle_help_version_opts
| File | + | − |
|---|---|---|
| src/bin/scripts/clusterdb.c | 1 | 0 |
| src/bin/scripts/common.c | 0 | 24 |
| src/bin/scripts/common.h | 0 | 6 |
| src/bin/scripts/createdb.c | 1 | 0 |
| src/bin/scripts/createuser.c | 1 | 0 |
| src/bin/scripts/dropdb.c | 1 | 0 |
| src/bin/scripts/dropuser.c | 1 | 0 |
| src/bin/scripts/pg_isready.c | 1 | 0 |
| src/bin/scripts/reindexdb.c | 1 | 0 |
| src/bin/scripts/vacuumdb.c | 1 | 0 |
| src/fe_utils/Makefile | 1 | 0 |
| src/fe_utils/option_utils.c | 38 | 0 |
| src/include/fe_utils/option_utils.h | 23 | 0 |
| src/tools/msvc/Mkvcbuild.pm | 1 | 1 |
From 25cd1302bda0f0a74e93e76472631361d5612266 Mon Sep 17 00:00:00 2001
From: Mark Dilger <mark.dilger@enterprisedb.com>
Date: Sun, 24 Jan 2021 09:17:08 -0800
Subject: [PATCH v33 6/8] Moving handle_help_version_opts
Moving handle_help_version_opts from src/bin/scripts/common.[ch] to
new files fe_utils/option_utils.[ch] in anticipation of pg_amcheck
needing to use it.
---
src/bin/scripts/clusterdb.c | 1 +
src/bin/scripts/common.c | 24 ------------------
src/bin/scripts/common.h | 6 -----
src/bin/scripts/createdb.c | 1 +
src/bin/scripts/createuser.c | 1 +
src/bin/scripts/dropdb.c | 1 +
src/bin/scripts/dropuser.c | 1 +
src/bin/scripts/pg_isready.c | 1 +
src/bin/scripts/reindexdb.c | 1 +
src/bin/scripts/vacuumdb.c | 1 +
src/fe_utils/Makefile | 1 +
src/fe_utils/option_utils.c | 38 +++++++++++++++++++++++++++++
src/include/fe_utils/option_utils.h | 23 +++++++++++++++++
src/tools/msvc/Mkvcbuild.pm | 2 +-
14 files changed, 71 insertions(+), 31 deletions(-)
create mode 100644 src/fe_utils/option_utils.c
create mode 100644 src/include/fe_utils/option_utils.h
diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c
index 24a5a549b4..fc771eed77 100644
--- a/src/bin/scripts/clusterdb.c
+++ b/src/bin/scripts/clusterdb.c
@@ -13,6 +13,7 @@
#include "common.h"
#include "common/logging.h"
#include "fe_utils/cancel.h"
+#include "fe_utils/option_utils.h"
#include "fe_utils/query_utils.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index c7fdd3adcb..c86c19eae2 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -25,30 +25,6 @@
#include "fe_utils/query_utils.h"
#include "fe_utils/string_utils.h"
-/*
- * Provide strictly harmonized handling of --help and --version
- * options.
- */
-void
-handle_help_version_opts(int argc, char *argv[],
- const char *fixed_progname, help_handler hlp)
-{
- if (argc > 1)
- {
- if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
- {
- hlp(get_progname(argv[0]));
- exit(0);
- }
- if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
- {
- printf("%s (PostgreSQL) " PG_VERSION "\n", fixed_progname);
- exit(0);
- }
- }
-}
-
-
/*
* Split TABLE[(COLUMNS)] into TABLE and [(COLUMNS)] portions. When you
* finish using them, pg_free(*table). *columns is a pointer into "spec",
diff --git a/src/bin/scripts/common.h b/src/bin/scripts/common.h
index 54e6575a7b..ddd8f35274 100644
--- a/src/bin/scripts/common.h
+++ b/src/bin/scripts/common.h
@@ -15,12 +15,6 @@
#include "libpq-fe.h"
#include "pqexpbuffer.h" /* pgrminclude ignore */
-typedef void (*help_handler) (const char *progname);
-
-extern void handle_help_version_opts(int argc, char *argv[],
- const char *fixed_progname,
- help_handler hlp);
-
extern void splitTableColumnsSpec(const char *spec, int encoding,
char **table, const char **columns);
diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c
index abf21d4942..041454f075 100644
--- a/src/bin/scripts/createdb.c
+++ b/src/bin/scripts/createdb.c
@@ -13,6 +13,7 @@
#include "common.h"
#include "common/logging.h"
+#include "fe_utils/option_utils.h"
#include "fe_utils/string_utils.h"
diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c
index 47b0e28bc6..ef7e0e549f 100644
--- a/src/bin/scripts/createuser.c
+++ b/src/bin/scripts/createuser.c
@@ -14,6 +14,7 @@
#include "common.h"
#include "common/logging.h"
#include "common/string.h"
+#include "fe_utils/option_utils.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
diff --git a/src/bin/scripts/dropdb.c b/src/bin/scripts/dropdb.c
index ba0dcdecb9..b154ed1bb6 100644
--- a/src/bin/scripts/dropdb.c
+++ b/src/bin/scripts/dropdb.c
@@ -13,6 +13,7 @@
#include "postgres_fe.h"
#include "common.h"
#include "common/logging.h"
+#include "fe_utils/option_utils.h"
#include "fe_utils/string_utils.h"
diff --git a/src/bin/scripts/dropuser.c b/src/bin/scripts/dropuser.c
index ff5b455ae5..61b8557bc7 100644
--- a/src/bin/scripts/dropuser.c
+++ b/src/bin/scripts/dropuser.c
@@ -14,6 +14,7 @@
#include "common.h"
#include "common/logging.h"
#include "common/string.h"
+#include "fe_utils/option_utils.h"
#include "fe_utils/string_utils.h"
diff --git a/src/bin/scripts/pg_isready.c b/src/bin/scripts/pg_isready.c
index ceb8a09b4c..fc6f7b0a93 100644
--- a/src/bin/scripts/pg_isready.c
+++ b/src/bin/scripts/pg_isready.c
@@ -12,6 +12,7 @@
#include "postgres_fe.h"
#include "common.h"
#include "common/logging.h"
+#include "fe_utils/option_utils.h"
#define DEFAULT_CONNECT_TIMEOUT "3"
diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c
index af0cc2bb00..a0f9592ee9 100644
--- a/src/bin/scripts/reindexdb.c
+++ b/src/bin/scripts/reindexdb.c
@@ -16,6 +16,7 @@
#include "common/connect.h"
#include "common/logging.h"
#include "fe_utils/cancel.h"
+#include "fe_utils/option_utils.h"
#include "fe_utils/parallel_slot.h"
#include "fe_utils/query_utils.h"
#include "fe_utils/simple_list.h"
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index 10ab894f10..b7634a1ecd 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -18,6 +18,7 @@
#include "common/connect.h"
#include "common/logging.h"
#include "fe_utils/cancel.h"
+#include "fe_utils/option_utils.h"
#include "fe_utils/parallel_slot.h"
#include "fe_utils/query_utils.h"
#include "fe_utils/simple_list.h"
diff --git a/src/fe_utils/Makefile b/src/fe_utils/Makefile
index bd499e6045..8167adb225 100644
--- a/src/fe_utils/Makefile
+++ b/src/fe_utils/Makefile
@@ -26,6 +26,7 @@ OBJS = \
connect_utils.o \
exit_utils.o \
mbprint.o \
+ option_utils.o \
parallel_slot.o \
pgreshandler.o \
print.o \
diff --git a/src/fe_utils/option_utils.c b/src/fe_utils/option_utils.c
new file mode 100644
index 0000000000..97aca1f02b
--- /dev/null
+++ b/src/fe_utils/option_utils.c
@@ -0,0 +1,38 @@
+/*-------------------------------------------------------------------------
+ *
+ * Command line option processing facilities for frontend code
+ *
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/fe_utils/option_utils.c
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres_fe.h"
+
+#include "fe_utils/option_utils.h"
+
+/*
+ * Provide strictly harmonized handling of --help and --version
+ * options.
+ */
+void
+handle_help_version_opts(int argc, char *argv[],
+ const char *fixed_progname, help_handler hlp)
+{
+ if (argc > 1)
+ {
+ if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
+ {
+ hlp(get_progname(argv[0]));
+ exit(0);
+ }
+ if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
+ {
+ printf("%s (PostgreSQL) " PG_VERSION "\n", fixed_progname);
+ exit(0);
+ }
+ }
+}
diff --git a/src/include/fe_utils/option_utils.h b/src/include/fe_utils/option_utils.h
new file mode 100644
index 0000000000..ef6eb24ae0
--- /dev/null
+++ b/src/include/fe_utils/option_utils.h
@@ -0,0 +1,23 @@
+/*-------------------------------------------------------------------------
+ *
+ * Command line option processing facilities for frontend code
+ *
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/fe_utils/option_utils.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef OPTION_UTILS_H
+#define OPTION_UTILS_H
+
+#include "postgres_fe.h"
+
+typedef void (*help_handler) (const char *progname);
+
+extern void handle_help_version_opts(int argc, char *argv[],
+ const char *fixed_progname,
+ help_handler hlp);
+
+#endif /* OPTION_UTILS_H */
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 4385962c7c..f3d8c1faf4 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -147,7 +147,7 @@ sub mkvcbuild
our @pgcommonbkndfiles = @pgcommonallfiles;
our @pgfeutilsfiles = qw(
- archive.c cancel.c conditional.c exit_utils.c mbprint.c pgreshandler.c print.c psqlscan.l
+ archive.c cancel.c conditional.c exit_utils.c mbprint.c option_utils.c pgreshandler.c print.c psqlscan.l
psqlscan.c simple_list.c string_utils.c recovery_gen.c);
$libpgport = $solution->AddProject('libpgport', 'lib', 'misc');
--
2.21.1 (Apple Git-122.3)