The result of getopt() should be compared to -1, not EOF, per
authorTom Lane <[email protected]>
Thu, 10 Jan 2002 01:11:45 +0000 (01:11 +0000)
committerTom Lane <[email protected]>
Thu, 10 Jan 2002 01:11:45 +0000 (01:11 +0000)
pgsql-hackers discussion of this date.

contrib/dbase/dbf2pg.c
contrib/oid2name/oid2name.c
contrib/pgbench/pgbench.c
src/backend/bootstrap/bootstrap.c
src/backend/postmaster/postmaster.c
src/backend/tcop/postgres.c
src/bin/pg_dump/pg_restore.c
src/interfaces/ecpg/preproc/ecpg.c

index 8b7d989a072767a14aced6d59f6517ea7001126d..5f5e9d2823f403c4b8138b9a763b9fcf6d4e571f 100644 (file)
@@ -16,6 +16,9 @@
 #ifdef HAVE_ICONV_H
 #include <iconv.h>
 #endif
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
 
 #include "libpq-fe.h"
 #include "dbf.h"
@@ -673,7 +676,7 @@ main(int argc, char **argv)
        char       *query;
        dbhead     *dbh;
 
-       while ((i = getopt(argc, argv, "DWflucvh:b:e:d:t:s:B:U:F:T:")) != EOF)
+       while ((i = getopt(argc, argv, "DWflucvh:b:e:d:t:s:B:U:F:T:")) != -1)
        {
                switch (i)
                {
index 2d4e2b8d0f8e2c45a9f6c406c50aacddd8c529e3..dfd261240ac1d55b1dbcc8bfb4d1dee51343c7b3 100644 (file)
@@ -67,7 +67,7 @@ get_opts(int argc, char **argv, struct options * my_opts)
        my_opts->remotepass = 0;
 
        /* get opts */
-       while ((c = getopt(argc, argv, "H:p:U:P:d:t:o:xh?")) != EOF)
+       while ((c = getopt(argc, argv, "H:p:U:P:d:t:o:xh?")) != -1)
        {
                switch (c)
                {
index 1b92fd4acd9ce3a638f77b857014003080c80115..e95bbd7dddc7c6bf81ff9111fc6fc9d34967d1e5 100644 (file)
@@ -641,7 +641,7 @@ main(int argc, char **argv)
        PGconn     *con;
        PGresult   *res;
 
-       while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CS")) != EOF)
+       while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CS")) != -1)
        {
                switch (c)
                {
index 8c658cc62dafa19df754bc6e7f0670a6ce5c42a1..bce393a3c79460d500372cf821983854f487d1a0 100644 (file)
@@ -250,7 +250,7 @@ BootstrapMain(int argc, char *argv[])
                                                                                                 * variable */
        }
 
-       while ((flag = getopt(argc, argv, "B:dD:Fo:px:")) != EOF)
+       while ((flag = getopt(argc, argv, "B:dD:Fo:px:")) != -1)
        {
                switch (flag)
                {
index 83ef060f593f181f014ef9c421e8055b1fe141c5..1991c5e1c95476db2d32fb6c5fcead324bc4d31a 100644 (file)
@@ -420,7 +420,7 @@ PostmasterMain(int argc, char *argv[])
         * with the wrong argument. Death and destruction will occur.
         */
        opterr = 1;
-       while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF)
+       while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != -1)
        {
                switch (opt)
                {
@@ -458,7 +458,7 @@ PostmasterMain(int argc, char *argv[])
        optreset = 1;                           /* some systems need this too */
 #endif
 
-       while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF)
+       while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != -1)
        {
                switch (opt)
                {
index a2b097052c43243e9f29b7888f14be4af3e373f6..66fdaacf902a6c64460b8bd9131b479d1e6618b4 100644 (file)
@@ -1165,7 +1165,7 @@ PostgresMain(int argc, char *argv[], const char *username)
        secure = true;
        ctx = PGC_POSTMASTER;
 
-       while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiNOPo:p:S:st:v:W:x:-:")) != EOF)
+       while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiNOPo:p:S:st:v:W:x:-:")) != -1)
                switch (flag)
                {
                        case 'A':
@@ -1626,7 +1626,7 @@ PostgresMain(int argc, char *argv[], const char *username)
        if (!IsUnderPostmaster)
        {
                puts("\nPOSTGRES backend interactive interface ");
-               puts("$Revision: 1.244 $ $Date: 2002/01/01 23:16:22 $\n");
+               puts("$Revision: 1.245 $ $Date: 2002/01/10 01:11:45 $\n");
        }
 
        /*
index 5197a3e04da5bf8265d3019f1e004226a2ffd14b..ece6c85d4482345e5825a0e3ffdd6ca89cea8a2a 100644 (file)
@@ -67,7 +67,6 @@
 #include <termios.h>
 #endif
 
-/* FreeBSD 4.3 seems to put getopt in unistd.h */
 #include <unistd.h>
 
 #ifdef HAVE_GETOPT_H
@@ -164,7 +163,7 @@ main(int argc, char **argv)
        }
 
 #ifdef HAVE_GETOPT_LONG
-       while ((c = getopt_long(argc, argv, "acCd:f:F:h:i:lL:NoOp:P:rRsS:t:T:uU:vWxX:", cmdopts, NULL)) != EOF)
+       while ((c = getopt_long(argc, argv, "acCd:f:F:h:i:lL:NoOp:P:rRsS:t:T:uU:vWxX:", cmdopts, NULL)) != -1)
 #else
        while ((c = getopt(argc, argv, "acCd:f:F:h:i:lL:NoOp:P:rRsS:t:T:uU:vWxX:")) != -1)
 #endif
index 2c2c30e9381eed17942a2b6e717f57aaa9d9c434..2e6f85ece2f0714785b0db1e01e4e84867294fe9 100644 (file)
@@ -7,9 +7,8 @@
 #include "postgres_fe.h"
 
 #include <unistd.h>
-
 #ifdef HAVE_GETOPT_H
-#include "getopt.h"
+#include <getopt.h>
 #endif
 
 extern int     optind;
@@ -108,7 +107,7 @@ main(int argc, char *const argv[])
        add_include_path("/usr/local/include");
        add_include_path(".");
 
-       while ((c = getopt(argc, argv, "vo:I:tD:d")) != EOF)
+       while ((c = getopt(argc, argv, "vo:I:tD:d")) != -1)
        {
                switch (c)
                {