mingwex/getopt.c vs POSIXLY_CORRECT

Danny Smith danny_r_smith_2001@yahoo.co.nz
Sun Feb 1 04:13:00 GMT 2004


Hello

This is a mingw issue, but effects cygwin -mno-cygwin apps (probably
setup) too so I cross-post to see what antipathy (a new word: as in
"antipathy rules, OK") I raise.

The cygwin implementation of getopt and getopt_long effectively defaults
to POSIXLY_CORRECTness by virtue of: 
#define IS_POSIXLY_CORRECT (getenv("POSIXLY_INCORRECT_GETOPT") == NULL)

Now, that environmental variable is bit strange to me, particularly in a
native environment such as mingw that doesn't have a clue about PC, I
propose this patch, for mingw subdir, so that the default implementation
of mingw's getopt matches the documentation in NetBSD man page. In
effect this means that the permute and in_order BSD extensions (the
latter also a default GNUC extension) are enabled for mingw.

Unless I hear reasonable arguments against this, I will commit the patch
after 48 hours.

Danny

mingw/ChangeLog

2004-02-02  Danny Smith  <dannysmith@users.sourceforge.net>

	* mingwex/getopt.c: Define IS_POSIXLY_CORRECT as per
	NetBSD getopt_long.c

retrieving revision 1.2
diff -c -3 -p -r1.2 getopt.c
*** mingwex/getopt.c	3 Mar 2003 10:27:57 -0000	1.2
--- mingwex/getopt.c	1 Feb 2004 03:00:07 -0000
*************** extern char __declspec(dllimport) *__pro
*** 73,79 ****
  #define PRINT_ERROR	((opterr) && ((*options != ':') \
  				      || (IGNORE_FIRST && options[1] != ':')))
  
! #define IS_POSIXLY_CORRECT (getenv("POSIXLY_INCORRECT_GETOPT") == NULL)
  
  #define PERMUTE         (!IS_POSIXLY_CORRECT && !IGNORE_FIRST)
  /* XXX: GNU ignores PC if *options == '-' */
--- 73,83 ----
  #define PRINT_ERROR	((opterr) && ((*options != ':') \
  				      || (IGNORE_FIRST && options[1] != ':')))
  
! /* This differs from the cygwin implementation, which effectively defaults to
!    PC, but is consistent with the NetBSD implementation and doc's.  */
! #ifndef IS_POSIXLY_CORRECT
! #define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL)
! #endif
  
  #define PERMUTE         (!IS_POSIXLY_CORRECT && !IGNORE_FIRST)
  /* XXX: GNU ignores PC if *options == '-' */

http://greetings.yahoo.com.au - Yahoo! Greetings
Send your love online with Yahoo! Greetings - FREE!



More information about the Cygwin-apps mailing list