diff --git a/doc/src/sgml/ref/ecpg-ref.sgml b/doc/src/sgml/ref/ecpg-ref.sgml
index 8bfb47c4d79..3953972ee1d 100644
--- a/doc/src/sgml/ref/ecpg-ref.sgml
+++ b/doc/src/sgml/ref/ecpg-ref.sgml
@@ -41,14 +41,21 @@ PostgreSQL documentation
ecpg will convert each input file given on the
- command line to the corresponding C output file. Input files
- preferably have the extension .pgc.
- The extension will be replaced by .c to
- determine the output file name.
- The output file name can also be overridden using the
+ command line to the corresponding C output file. If an input file
+ name does not have any extension, .pgc is
+ assumed. The file's extension will be replaced
+ by .c to construct the output file name.
+ But the output file name can be overridden using the
option.
+
+ If an input file name is just -,
+ ecpg reads the program from standard input
+ (and writes to standard output, unless that is overridden
+ with ).
+
+
This reference page does not describe the embedded SQL language.
See for more information on that topic.
@@ -94,6 +101,19 @@ PostgreSQL documentation
+
+
+
+
+ Process header files. When this option is specified, the output file
+ extension becomes .h not .c,
+ and the default input file extension is .pgh
+ not .pgc. Also, the option is
+ forced on.
+
+
+
+
@@ -125,6 +145,7 @@ PostgreSQL documentation
Specifies that ecpg should write all
its output to the given filename.
+ Write -o - to send all output to standard output.
diff --git a/src/port/getopt_long.c b/src/port/getopt_long.c
index ff379db29b0..c9892769883 100644
--- a/src/port/getopt_long.c
+++ b/src/port/getopt_long.c
@@ -79,14 +79,22 @@ getopt_long(int argc, char *const argv[],
place++;
- if (place[0] && place[0] == '-' && place[1] == '\0')
- { /* found "--" */
+ if (!*place)
+ {
+ /* treat "-" as not being an option */
+ place = EMSG;
+ return -1;
+ }
+
+ if (place[0] == '-' && place[1] == '\0')
+ {
+ /* found "--", treat it as end of options */
++optind;
place = EMSG;
return -1;
}
- if (place[0] && place[0] == '-' && place[1])
+ if (place[0] == '-' && place[1])
{
/* long option */
size_t namelen;