Skip to content

Commit 92a2598

Browse files
committed
The result of getopt() should be compared to -1, not EOF, per
pgsql-hackers discussion of this date.
1 parent 4d72af6 commit 92a2598

File tree

8 files changed

+20
-19
lines changed

8 files changed

+20
-19
lines changed

contrib/dbase/dbf2pg.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#ifdef HAVE_ICONV_H
1717
#include <iconv.h>
1818
#endif
19+
#ifdef HAVE_GETOPT_H
20+
#include <getopt.h>
21+
#endif
1922

2023
#include "libpq-fe.h"
2124
#include "dbf.h"
@@ -673,7 +676,7 @@ main(int argc, char **argv)
673676
char *query;
674677
dbhead *dbh;
675678

676-
while ((i = getopt(argc, argv, "DWflucvh:b:e:d:t:s:B:U:F:T:")) != EOF)
679+
while ((i = getopt(argc, argv, "DWflucvh:b:e:d:t:s:B:U:F:T:")) != -1)
677680
{
678681
switch (i)
679682
{

contrib/oid2name/oid2name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ get_opts(int argc, char **argv, struct options * my_opts)
6767
my_opts->remotepass = 0;
6868

6969
/* get opts */
70-
while ((c = getopt(argc, argv, "H:p:U:P:d:t:o:xh?")) != EOF)
70+
while ((c = getopt(argc, argv, "H:p:U:P:d:t:o:xh?")) != -1)
7171
{
7272
switch (c)
7373
{

contrib/pgbench/pgbench.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.13 2001/11/05 17:46:23 momjian Exp $
2+
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.14 2002/01/10 01:11:45 tgl Exp $
33
*
44
* pgbench: a simple TPC-B like benchmark program for PostgreSQL
55
* written by Tatsuo Ishii
@@ -641,7 +641,7 @@ main(int argc, char **argv)
641641
PGconn *con;
642642
PGresult *res;
643643

644-
while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CS")) != EOF)
644+
while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CS")) != -1)
645645
{
646646
switch (c)
647647
{

src/backend/bootstrap/bootstrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.119 2001/10/25 05:49:22 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.120 2002/01/10 01:11:45 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -250,7 +250,7 @@ BootstrapMain(int argc, char *argv[])
250250
* variable */
251251
}
252252

253-
while ((flag = getopt(argc, argv, "B:dD:Fo:px:")) != EOF)
253+
while ((flag = getopt(argc, argv, "B:dD:Fo:px:")) != -1)
254254
{
255255
switch (flag)
256256
{

src/backend/postmaster/postmaster.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.263 2002/01/06 21:40:02 tgl Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.264 2002/01/10 01:11:45 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -420,7 +420,7 @@ PostmasterMain(int argc, char *argv[])
420420
* with the wrong argument. Death and destruction will occur.
421421
*/
422422
opterr = 1;
423-
while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF)
423+
while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != -1)
424424
{
425425
switch (opt)
426426
{
@@ -458,7 +458,7 @@ PostmasterMain(int argc, char *argv[])
458458
optreset = 1; /* some systems need this too */
459459
#endif
460460

461-
while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF)
461+
while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != -1)
462462
{
463463
switch (opt)
464464
{

src/backend/tcop/postgres.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.244 2002/01/01 23:16:22 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.245 2002/01/10 01:11:45 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1165,7 +1165,7 @@ PostgresMain(int argc, char *argv[], const char *username)
11651165
secure = true;
11661166
ctx = PGC_POSTMASTER;
11671167

1168-
while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiNOPo:p:S:st:v:W:x:-:")) != EOF)
1168+
while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiNOPo:p:S:st:v:W:x:-:")) != -1)
11691169
switch (flag)
11701170
{
11711171
case 'A':
@@ -1626,7 +1626,7 @@ PostgresMain(int argc, char *argv[], const char *username)
16261626
if (!IsUnderPostmaster)
16271627
{
16281628
puts("\nPOSTGRES backend interactive interface ");
1629-
puts("$Revision: 1.244 $ $Date: 2002/01/01 23:16:22 $\n");
1629+
puts("$Revision: 1.245 $ $Date: 2002/01/10 01:11:45 $\n");
16301630
}
16311631

16321632
/*

src/bin/pg_dump/pg_restore.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*
3636
* IDENTIFICATION
37-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.31 2001/11/26 23:10:36 tgl Exp $
37+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.32 2002/01/10 01:11:45 tgl Exp $
3838
*
3939
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
4040
*
@@ -67,7 +67,6 @@
6767
#include <termios.h>
6868
#endif
6969

70-
/* FreeBSD 4.3 seems to put getopt in unistd.h */
7170
#include <unistd.h>
7271

7372
#ifdef HAVE_GETOPT_H
@@ -164,7 +163,7 @@ main(int argc, char **argv)
164163
}
165164

166165
#ifdef HAVE_GETOPT_LONG
167-
while ((c = getopt_long(argc, argv, "acCd:f:F:h:i:lL:NoOp:P:rRsS:t:T:uU:vWxX:", cmdopts, NULL)) != EOF)
166+
while ((c = getopt_long(argc, argv, "acCd:f:F:h:i:lL:NoOp:P:rRsS:t:T:uU:vWxX:", cmdopts, NULL)) != -1)
168167
#else
169168
while ((c = getopt(argc, argv, "acCd:f:F:h:i:lL:NoOp:P:rRsS:t:T:uU:vWxX:")) != -1)
170169
#endif

src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.51 2001/10/28 06:26:11 momjian Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.52 2002/01/10 01:11:45 tgl Exp $ */
22

33
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
44
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -7,9 +7,8 @@
77
#include "postgres_fe.h"
88

99
#include <unistd.h>
10-
1110
#ifdef HAVE_GETOPT_H
12-
#include "getopt.h"
11+
#include <getopt.h>
1312
#endif
1413

1514
extern int optind;
@@ -108,7 +107,7 @@ main(int argc, char *const argv[])
108107
add_include_path("/usr/local/include");
109108
add_include_path(".");
110109

111-
while ((c = getopt(argc, argv, "vo:I:tD:d")) != EOF)
110+
while ((c = getopt(argc, argv, "vo:I:tD:d")) != -1)
112111
{
113112
switch (c)
114113
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy