Dne 31.03.09 04:55, Tom Lane napsal(a):
> Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:
>> I attached a fix. Only problem what I see there is getopt_long.h which
>> contains
>
> I'm more concerned about the "static int optreset", which is 100%
> guaranteed to break things.
Yeah correct, I overlooked that optreset is also defined as a extern.
There is updated patch.
Thanks Zdenek
*** pgsql.c598eae30145/src/port/getopt.c 2009-03-31 13:31:56.896353577 +0200
--- pgsql/src/port/getopt.c 2009-03-31 12:22:04.619485958 +0200
***************
*** 36,47 ****
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
!
! int opterr = 1, /* if error message should be printed */
! optind = 1, /* index into parent argv vector */
! optopt, /* character checked for validity */
! optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
--- 36,54 ----
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
! /* In situation when we use getopt_long from libc, we needs to use libc variable,
! * else it causes symbol overriding and optind contains nonsens.
! */
! #ifndef HAVE_GETOPT_LONG
! int opterr = 1; /* if error message should be printed */
! int optind = 1; /* index into parent argv vector */
! int optopt; /* character checked for validity */
char *optarg; /* argument associated with option */
+ #endif
+
+ #ifndef HAVE_INT_OPTRESET
+ int optreset; /* reset getopt */
+ #endif
#define BADCH (int)'?'
#define BADARG (int)':'