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

Commit939a59f

Browse files
committed
Use our own version of getopt_long() if the OS doesn't have one.
1 parent6e90803 commit939a59f

File tree

14 files changed

+280
-200
lines changed

14 files changed

+280
-200
lines changed

‎configure

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9819,8 +9819,7 @@ test $ac_cv_func_memcmp_working = no && LIBOBJS="$LIBOBJS memcmp.$ac_objext"
98199819
98209820
98219821
9822-
9823-
forac_funcin cbrt fcvt getopt_long getpeereid memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen fdatasync
9822+
forac_funcin cbrt fcvt getpeereid memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen fdatasync
98249823
do
98259824
as_ac_var=`echo"ac_cv_func_$ac_func"|$as_tr_sh`
98269825
echo"$as_me:$LINENO: checking for$ac_func">&5
@@ -10644,7 +10643,8 @@ fi
1064410643
1064510644
1064610645
10647-
forac_funcin fseeko gethostname getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul
10646+
10647+
forac_funcin fseeko gethostname getopt_long getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul
1064810648
do
1064910649
as_ac_var=`echo"ac_cv_func_$ac_func"|$as_tr_sh`
1065010650
echo"$as_me:$LINENO: checking for$ac_func">&5

‎configure.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $Header: /cvsroot/pgsql/configure.in,v 1.227 2003/01/0606:06:04 momjian Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.228 2003/01/0618:53:22 petere Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -782,7 +782,7 @@ PGAC_FUNC_GETTIMEOFDAY_1ARG
782782
# SunOS doesn't handle negative byte comparisons properly with +/- return
783783
AC_FUNC_MEMCMP
784784

785-
AC_CHECK_FUNCS([cbrt fcvtgetopt_longgetpeereid memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen fdatasync])
785+
AC_CHECK_FUNCS([cbrt fcvt getpeereid memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen fdatasync])
786786

787787
AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
788788

@@ -842,7 +842,7 @@ else
842842
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
843843
fi
844844

845-
AC_REPLACE_FUNCS([fseeko gethostname getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul])
845+
AC_REPLACE_FUNCS([fseeko gethostnamegetopt_longgetrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul])
846846

847847
# BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos
848848
# We override the previous test that said fseeko/ftello didn't exist

‎doc/src/sgml/ref/pg_dump.sgml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.53 2002/11/15 03:11:18 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.54 2003/01/06 18:53:24 petere Exp $
33
PostgreSQL documentation
44
-->
55

@@ -537,10 +537,6 @@ PostgreSQL documentation
537537
</varlistentry>
538538
</variablelist>
539539
</para>
540-
541-
<para>
542-
Long option forms are only available on some platforms.
543-
</para>
544540
</refsect1>
545541

546542
<refsect1>

‎doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.35 2002/11/15 03:11:18 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.36 2003/01/06 18:53:24 petere Exp $
33
PostgreSQL documentation
44
-->
55

@@ -223,10 +223,6 @@ PostgreSQL documentation
223223
</varlistentry>
224224
</variablelist>
225225
</para>
226-
227-
<para>
228-
Long options are only available on some platforms.
229-
</para>
230226
</refsect1>
231227

232228

‎doc/src/sgml/ref/pg_restore.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.33 2002/11/21 23:34:43 petere Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.34 2003/01/06 18:53:24 petere Exp $ -->
22

33
<refentry id="APP-PGRESTORE">
44
<docinfo>
@@ -74,7 +74,7 @@
7474

7575
<para>
7676
<command>pg_restore</command> accepts the following command
77-
line arguments. (Long option forms are only available on some platforms.)
77+
line arguments.
7878

7979
<variablelist>
8080
<varlistentry>

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.81 2002/12/12 21:02:19 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.82 2003/01/06 18:53:24 petere Exp $
33
PostgreSQL documentation
44
-->
55

@@ -446,10 +446,6 @@ PostgreSQL documentation
446446
</listitem>
447447
</varlistentry>
448448
</variablelist>
449-
450-
<para>
451-
Long options are not available on all platforms.
452-
</para>
453449
</refsect1>
454450

455451

‎doc/src/sgml/release.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.174 2002/12/30 19:45:11 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.175 2003/01/06 18:53:23 petere Exp $
33
-->
44

55
<appendix id="release">
@@ -34,6 +34,7 @@ Statement-level triggers
3434
System can use either hash- or sort-based strategy for grouped aggregation
3535
ON COMMIT options for temp tables
3636
extra_float_digits option allows pg_dump to dump float data accurately
37+
Long options for psql and pg_dump are now available on all platforms
3738
]]></literallayout>
3839

3940
</sect1>

‎src/bin/pg_dump/pg_dump.c

Lines changed: 11 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.313 2002/12/27 17:10:45 tgl Exp $
15+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.314 2003/01/06 18:53:24 petere Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -40,6 +40,11 @@
4040
#include"strdup.h"
4141
#endif
4242

43+
#ifndefHAVE_GETOPT_LONG
44+
#include"getopt_long.h"
45+
intoptreset;
46+
#endif
47+
4348
#include"access/attnum.h"
4449
#include"access/htup.h"
4550
#include"catalog/pg_class.h"
@@ -179,7 +184,6 @@ main(int argc, char **argv)
179184

180185
RestoreOptions*ropt;
181186

182-
#ifdefHAVE_GETOPT_LONG
183187
staticstructoptionlong_options[]= {
184188
{"data-only",no_argument,NULL,'a'},
185189
{"blobs",no_argument,NULL,'b'},
@@ -218,7 +222,6 @@ main(int argc, char **argv)
218222
{NULL,0,NULL,0}
219223
};
220224
intoptindex;
221-
#endif
222225

223226
#ifdefENABLE_NLS
224227
setlocale(LC_ALL,"");
@@ -260,12 +263,8 @@ main(int argc, char **argv)
260263
}
261264
}
262265

263-
#ifdefHAVE_GETOPT_LONG
264-
while ((c=getopt_long(argc,argv,"abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:",long_options,&optindex))!=-1)
265-
#else
266-
while ((c=getopt(argc,argv,"abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:-"))!=-1)
267-
#endif
268-
266+
while ((c=getopt_long(argc,argv,"abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:",
267+
long_options,&optindex))!=-1)
269268
{
270269
switch (c)
271270
{
@@ -415,23 +414,15 @@ main(int argc, char **argv)
415414
exit(1);
416415
}
417416
break;
417+
418418
case'Z':/* Compression Level */
419419
compressLevel=atoi(optarg);
420420
break;
421-
422-
#ifndefHAVE_GETOPT_LONG
423-
case'-':
424-
fprintf(stderr,
425-
_("%s was compiled without support for long options.\n"
426-
"Use --help for help on invocation options.\n"),
427-
progname);
428-
exit(1);
429-
break;
430-
#else
431421
/* This covers the long options equivalent to -X xxx. */
422+
432423
case0:
433424
break;
434-
#endif
425+
435426
default:
436427
fprintf(stderr,_("Try '%s --help' for more information.\n"),progname);
437428
exit(1);
@@ -658,26 +649,16 @@ help(const char *progname)
658649
printf(_(" %s [OPTION]... [DBNAME]\n"),progname);
659650

660651
printf(_("\nGeneral options:\n"));
661-
#ifdefHAVE_GETOPT_LONG
662652
printf(_(" -f, --file=FILENAME output file name\n"));
663653
printf(_(" -F, --format=c|t|p output file format (custom, tar, plain text)\n"));
664654
printf(_(" -i, --ignore-version proceed even when server version mismatches\n"
665655
" pg_dump version\n"));
666656
printf(_(" -v, --verbose verbose mode\n"));
667657
printf(_(" -Z, --compress=0-9 compression level for compressed formats\n"));
668-
#else/* not HAVE_GETOPT_LONG */
669-
printf(_(" -f FILENAME output file name\n"));
670-
printf(_(" -F c|t|p output file format (custom, tar, plain text)\n"));
671-
printf(_(" -i proceed even when server version mismatches\n"
672-
" pg_dump version\n"));
673-
printf(_(" -v verbose mode\n"));
674-
printf(_(" -Z 0-9 compression level for compressed formats\n"));
675-
#endif/* not HAVE_GETOPT_LONG */
676658
printf(_(" --help show this help, then exit\n"));
677659
printf(_(" --version output version information, then exit\n"));
678660

679661
printf(_("\nOptions controlling the output content:\n"));
680-
#ifdefHAVE_GETOPT_LONG
681662
printf(_(" -a, --data-only dump only the data, not the schema\n"));
682663
printf(_(" -b, --blobs include large objects in dump\n"));
683664
printf(_(" -c, --clean clean (drop) schema prior to create\n"));
@@ -699,41 +680,12 @@ help(const char *progname)
699680
" than \\connect commands\n"));
700681
printf(_(" -X disable-triggers, --disable-triggers\n"
701682
" disable triggers during data-only restore\n"));
702-
#else/* not HAVE_GETOPT_LONG */
703-
printf(_(" -a dump only the data, not the schema\n"));
704-
printf(_(" -b include large objects in dump\n"));
705-
printf(_(" -c clean (drop) schema prior to create\n"));
706-
printf(_(" -C include commands to create database in dump\n"));
707-
printf(_(" -d dump data as INSERT, rather than COPY, commands\n"));
708-
printf(_(" -D dump data as INSERT commands with column names\n"));
709-
printf(_(" -o include OIDs in dump\n"));
710-
printf(_(" -O do not output \\connect commands in plain\n"
711-
" text format\n"));
712-
printf(_(" -R disable ALL reconnections to the database in\n"
713-
" plain text format\n"));
714-
printf(_(" -s dump only the schema, no data\n"));
715-
printf(_(" -S NAME specify the superuser user name to use in\n"
716-
" plain text format\n"));
717-
printf(_(" -t TABLE dump this table only (* for all)\n"));
718-
printf(_(" -x do not dump privileges (grant/revoke)\n"));
719-
printf(_(" -X use-set-session-authorization\n"
720-
" output SET SESSION AUTHORIZATION commands rather\n"
721-
" than \\connect commands\n"));
722-
printf(_(" -X disable-triggers disable triggers during data-only restore\n"));
723-
#endif/* not HAVE_GETOPT_LONG */
724683

725684
printf(_("\nConnection options:\n"));
726-
#ifdefHAVE_GETOPT_LONG
727685
printf(_(" -h, --host=HOSTNAME database server host name\n"));
728686
printf(_(" -p, --port=PORT database server port number\n"));
729687
printf(_(" -U, --username=NAME connect as specified database user\n"));
730688
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
731-
#else/* not HAVE_GETOPT_LONG */
732-
printf(_(" -h HOSTNAME database server host name\n"));
733-
printf(_(" -p PORT database server port number\n"));
734-
printf(_(" -U NAME connect as specified database user\n"));
735-
printf(_(" -W force password prompt (should happen automatically)\n"));
736-
#endif/* not HAVE_GETOPT_LONG */
737689

738690
printf(_("\nIf no database name is not supplied, then the PGDATABASE environment\n"
739691
"variable value is used.\n\n"));

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.11 2002/11/29 16:38:42 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.12 2003/01/06 18:53:25 petere Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -25,6 +25,11 @@
2525
#endif
2626
#include<errno.h>
2727

28+
#ifndefHAVE_GETOPT_LONG
29+
#include"getopt_long.h"
30+
intoptreset;
31+
#endif
32+
2833
#include"dumputils.h"
2934
#include"libpq-fe.h"
3035
#include"pg_backup.h"
@@ -71,7 +76,6 @@ main(int argc, char *argv[])
7176
PGconn*conn;
7277
intc;
7378

74-
#ifdefHAVE_GETOPT_LONG
7579
staticstructoptionlong_options[]= {
7680
{"clean",no_argument,NULL,'c'},
7781
{"inserts",no_argument,NULL,'d'},
@@ -88,7 +92,6 @@ main(int argc, char *argv[])
8892
};
8993

9094
intoptindex;
91-
#endif
9295

9396
#ifdefENABLE_NLS
9497
setlocale(LC_ALL,"");
@@ -118,11 +121,7 @@ main(int argc, char *argv[])
118121
pgdumploc=findPgDump(argv[0]);
119122
pgdumpopts=createPQExpBuffer();
120123

121-
#ifdefHAVE_GETOPT_LONG
122124
while ((c=getopt_long(argc,argv,"cdDgh:iop:U:vW",long_options,&optindex))!=-1)
123-
#else
124-
while ((c=getopt(argc,argv,"cdDgh:iop:U:vW"))!=-1)
125-
#endif
126125
{
127126
switch (c)
128127
{
@@ -216,7 +215,6 @@ help(void)
216215
printf(_(" %s [OPTION]...\n"),progname);
217216

218217
printf(_("\nOptions:\n"));
219-
#ifdefHAVE_GETOPT_LONG
220218
printf(_(" -c, --clean clean (drop) databases prior to create\n"));
221219
printf(_(" -d, --inserts dump data as INSERT, rather than COPY, commands\n"));
222220
printf(_(" -D, --column-inserts dump data as INSERT commands with column names\n"));
@@ -225,31 +223,14 @@ help(void)
225223
" pg_dumpall version\n"));
226224
printf(_(" -o, --oids include OIDs in dump\n"));
227225
printf(_(" -v, --verbose verbose mode\n"));
228-
#else/* not HAVE_GETOPT_LONG */
229-
printf(_(" -c clean (drop) databases prior to create\n"));
230-
printf(_(" -d dump data as INSERT, rather than COPY, commands\n"));
231-
printf(_(" -D dump data as INSERT commands with column names\n"));
232-
printf(_(" -g dump only global objects, no databases\n"));
233-
printf(_(" -i proceed even when server version mismatches\n"
234-
" pg_dumpall version\n"));
235-
printf(_(" -o include OIDs in dump\n"));
236-
printf(_(" -v verbose mode\n"));
237-
#endif/* not HAVE_GETOPT_LONG */
238226
printf(_(" --help show this help, then exit\n"));
239227
printf(_(" --version output version information, then exit\n"));
240228

241229
printf(_("\nConnection options:\n"));
242-
#ifdefHAVE_GETOPT_LONG
243230
printf(_(" -h, --host=HOSTNAME database server host name\n"));
244231
printf(_(" -p, --port=PORT database server port number\n"));
245232
printf(_(" -U, --username=NAME connect as specified database user\n"));
246233
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
247-
#else/* not HAVE_GETOPT_LONG */
248-
printf(_(" -h HOSTNAME database server host name\n"));
249-
printf(_(" -p PORT database server port number\n"));
250-
printf(_(" -U NAME connect as specified database user\n"));
251-
printf(_(" -W force password prompt (should happen automatically)\n"));
252-
#endif/* not HAVE_GETOPT_LONG */
253234

254235
printf(_("\nThe SQL script will be written to the standard output.\n\n"));
255236
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp