Re: Complier warnings on mingw gcc 4.5.0

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: Complier warnings on mingw gcc 4.5.0
Дата
Msg-id 4D093106.1020508@dunslane.net
обсуждение исходный текст
Ответ на Re: Complier warnings on mingw gcc 4.5.0  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Complier warnings on mingw gcc 4.5.0  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers

On 12/15/2010 03:52 PM, Tom Lane wrote:
> Andrew Dunstan<andrew@dunslane.net>  writes:
>> And here is where it changed:
>> <http://sourceforge.net/project/shownotes.php?release_id=24832>
>>      * A replacement implementation for the getopt() family of functions,
>>         adding support for the GNU getopt_long_only() function.  Users
>>         should note that this intentionally *removes* support for the BSD
>>         or Mac OS-X specific, and non-standard, `optreset' global variable;
>>         to reset the getopt() scanner, use `optind = 0;' instead of relying
>>         on this non-standard, non-portable and now-unsupported feature.
> Great.  So instead of a nonstandard but pretty portable API, they
> decided on a nonstandard interpretation of optind ... which absolutely
> will not work for our usage, because we need to be able to tell getopt
> to skip over --single, even if we were willing to figure out whether
> getopt behaves this way or the more usual way.  Dolts.
>
> While I don't mind forcing use of our getopt() on mingw, I'm a mite
> concerned by the idea that this might represent an upstream change we'll
> soon see elsewhere, rather than just mingw-specific brain damage.
> Anybody know?
>
>             

On my Fedora box, man 3 getopt says this:
   A program that scans multiple argument vectors, or rescans the same   vector more than once, and wants to make use
ofGNU extensions such   as '+'  and '-'  at  the start of optstring, or changes the value of   POSIXLY_CORRECT between
scans,must reinitialize getopt() by   resetting optind to 0, rather than the traditional value of 1.    (Resetting to 0
forcesthe invocation of an internal initialization   routine that rechecks POSIXLY_CORRECT and checks for GNU
extensions  in optstring.)
 

Modulo the --single issue, we don't have to force use of our getopt on 
Mingw. This patch seems to work, at least to get regression working:
   diff --git a/src/backend/postmaster/postmaster.c   b/src/backend/postmaster/postmaster.c   index 90854f4..9ae3767
100644  --- a/src/backend/postmaster/postmaster.c   +++ b/src/backend/postmaster/postmaster.c   @@ -753,6 +753,8 @@
PostmasterMain(intargc, char *argv[])         optind = 1;     #ifdef HAVE_INT_OPTRESET         optreset = 1;
   /* some systems need this too */   +#elsif defined (WIN32) &&  !defined(_MSC_VER)   +    optind = 0;
/*modern Mingw needs this instead */     #endif
 
         /* For debugging: display postmaster environment */   diff --git a/src/backend/tcop/postgres.c
b/src/backend/tcop/postgres.c  index ff2e9bd..ea4ae79 100644   --- a/src/backend/tcop/postgres.c   +++
b/src/backend/tcop/postgres.c  @@ -3444,6 +3444,8 @@ process_postgres_switches(int argc, char   *argv[], GucContext
ctx)        optind = 1;     #ifdef HAVE_INT_OPTRESET         optreset = 1;                /* some systems need this too
*/  +#elsif defined (WIN32) &&  !defined(_MSC_VER)   +        optind = 0;                             /* modern Mingw
needsthis instead */     #endif
 

cheers

andrew




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Complier warnings on mingw gcc 4.5.0
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Complier warnings on mingw gcc 4.5.0