Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit60ff2fd

Browse files
committed
Centralize getopt-related declarations in a new header file pg_getopt.h.
We used to have externs for getopt() and its API variables scatteredall over the place. Now that we find we're going to need to tweak thevariable declarations for Cygwin, it seems like a good idea to havejust one place to tweak.In this commit, the variables are declared "#ifndef HAVE_GETOPT_H".That may or may not work everywhere, but we'll soon find out.Andres Freund
1 parent32be1c8 commit60ff2fd

File tree

19 files changed

+57
-130
lines changed

19 files changed

+57
-130
lines changed

‎contrib/oid2name/oid2name.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@
99
*/
1010
#include"postgres_fe.h"
1111

12-
#include<unistd.h>
13-
#ifdefHAVE_GETOPT_H
14-
#include<getopt.h>
15-
#endif
16-
17-
externchar*optarg;
18-
1912
#include"libpq-fe.h"
13+
#include"pg_getopt.h"
2014

2115
/* an extensible array to keep track of elements to show */
2216
typedefstruct

‎contrib/pg_archivecleanup/pg_archivecleanup.c‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,9 @@
1717
#include<sys/stat.h>
1818
#include<fcntl.h>
1919
#include<signal.h>
20-
21-
#ifndefWIN32
2220
#include<sys/time.h>
23-
#include<unistd.h>
24-
25-
#ifdefHAVE_GETOPT_H
26-
#include<getopt.h>
27-
#endif
28-
#else/* WIN32 */
29-
externintgetopt(intargc,char*constargv[],constchar*optstring);
30-
#endif/* ! WIN32 */
3121

32-
externchar*optarg;
33-
externintoptind;
22+
#include"pg_getopt.h"
3423

3524
constchar*progname;
3625

‎contrib/pg_standby/pg_standby.c‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,9 @@
2828
#include<sys/stat.h>
2929
#include<fcntl.h>
3030
#include<signal.h>
31-
32-
#ifdefWIN32
33-
intgetopt(intargc,char*constargv[],constchar*optstring);
34-
#else
3531
#include<sys/time.h>
36-
#include<unistd.h>
37-
38-
#ifdefHAVE_GETOPT_H
39-
#include<getopt.h>
40-
#endif
41-
#endif/* ! WIN32 */
4232

43-
externchar*optarg;
44-
externintoptind;
33+
#include"pg_getopt.h"
4534

4635
constchar*progname;
4736

‎contrib/pg_upgrade/option.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
#include"postgres_fe.h"
1111

1212
#include"miscadmin.h"
13+
#include"getopt_long.h"
1314

1415
#include"pg_upgrade.h"
1516

16-
#include<getopt_long.h>
1717
#include<time.h>
1818
#include<sys/types.h>
1919
#include<sys/stat.h>

‎contrib/pgbench/pgbench.c‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@
4040
#include<ctype.h>
4141
#include<math.h>
4242
#include<signal.h>
43-
44-
#ifndefWIN32
4543
#include<sys/time.h>
46-
#include<unistd.h>
47-
#endif/* ! WIN32 */
48-
4944
#ifdefHAVE_SYS_SELECT_H
5045
#include<sys/select.h>
5146
#endif
@@ -89,9 +84,6 @@ static intpthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start
8984
staticintpthread_join(pthread_tth,void**thread_return);
9085
#endif
9186

92-
externchar*optarg;
93-
externintoptind;
94-
9587

9688
/********************************************************************
9789
* some configurable parameters */

‎contrib/vacuumlo/vacuumlo.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@
2222
#endif
2323

2424
#include"libpq-fe.h"
25+
#include"pg_getopt.h"
2526

2627
#defineatooid(x) ((Oid) strtoul((x), NULL, 10))
2728

2829
#defineBUFSIZE1024
2930

30-
externchar*optarg;
31-
externintoptind,
32-
opterr;
33-
3431
enumtrivalue
3532
{
3633
TRI_DEFAULT,

‎src/backend/bootstrap/bootstrap.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
#include<time.h>
1818
#include<unistd.h>
1919
#include<signal.h>
20-
#ifdefHAVE_GETOPT_H
21-
#include<getopt.h>
22-
#endif
2320

2421
#include"access/htup_details.h"
2522
#include"bootstrap/bootstrap.h"
@@ -29,6 +26,7 @@
2926
#include"libpq/pqsignal.h"
3027
#include"miscadmin.h"
3128
#include"nodes/makefuncs.h"
29+
#include"pg_getopt.h"
3230
#include"postmaster/bgwriter.h"
3331
#include"postmaster/startup.h"
3432
#include"postmaster/walwriter.h"
@@ -46,9 +44,6 @@
4644
#include"utils/relmapper.h"
4745
#include"utils/tqual.h"
4846

49-
externintoptind;
50-
externchar*optarg;
51-
5247
uint32bootstrap_data_checksum_version=0;/* No checksum */
5348

5449

‎src/backend/postmaster/postmaster.c‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@
8383
#include<sys/select.h>
8484
#endif
8585

86-
#ifdefHAVE_GETOPT_H
87-
#include<getopt.h>
88-
#endif
89-
9086
#ifdefUSE_BONJOUR
9187
#include<dns_sd.h>
9288
#endif
@@ -101,6 +97,7 @@
10197
#include"libpq/libpq.h"
10298
#include"libpq/pqsignal.h"
10399
#include"miscadmin.h"
100+
#include"pg_getopt.h"
104101
#include"pgstat.h"
105102
#include"postmaster/autovacuum.h"
106103
#include"postmaster/bgworker_internals.h"
@@ -352,14 +349,6 @@ static volatile bool HaveCrashedWorker = false;
352349
staticunsignedintrandom_seed=0;
353350
staticstructtimevalrandom_start_time;
354351

355-
externchar*optarg;
356-
externintoptind,
357-
opterr;
358-
359-
#ifdefHAVE_INT_OPTRESET
360-
externintoptreset;/* might not be declared by system headers */
361-
#endif
362-
363352
#ifdefUSE_BONJOUR
364353
staticDNSServiceRefbonjour_sdref=NULL;
365354
#endif

‎src/backend/tcop/postgres.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
#include<sys/time.h>
3333
#include<sys/resource.h>
3434
#endif
35-
#ifdefHAVE_GETOPT_H
36-
#include<getopt.h>
37-
#endif
3835

3936
#ifndefHAVE_GETRUSAGE
4037
#include"rusagestub.h"
@@ -55,6 +52,7 @@
5552
#include"pg_trace.h"
5653
#include"parser/analyze.h"
5754
#include"parser/parser.h"
55+
#include"pg_getopt.h"
5856
#include"postmaster/autovacuum.h"
5957
#include"postmaster/postmaster.h"
6058
#include"replication/walsender.h"
@@ -77,14 +75,6 @@
7775
#include"mb/pg_wchar.h"
7876

7977

80-
externchar*optarg;
81-
externintoptind;
82-
83-
#ifdefHAVE_INT_OPTRESET
84-
externintoptreset;/* might not be declared by system headers */
85-
#endif
86-
87-
8878
/* ----------------
8979
*global variables
9080
* ----------------

‎src/bin/pg_dump/pg_dump.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@
6363
#include"dumputils.h"
6464
#include"parallel.h"
6565

66-
externchar*optarg;
67-
externintoptind,
68-
opterr;
69-
7066

7167
typedefstruct
7268
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp