diff src/build-msvctools/getopt.diff @ 3061:f8299bb6c872

Initial support for native MSVC compilation. * add MSVC support files: compiler wrappers and support libraries * adapt libiconv to work with MSVC * adapt gettext to work with MSVC
author Michael Goffioul <michael.goffioul@gmail.com>
date Mon, 17 Jun 2013 22:43:11 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/build-msvctools/getopt.diff	Mon Jun 17 22:43:11 2013 -0400
@@ -0,0 +1,46 @@
+--- getopt.c	2010-01-14 21:38:46 +0000
++++ getopt-new.c	2010-01-14 21:37:14 +0000
+@@ -47,6 +47,10 @@
+ # define PROGNAME  *argv
+ #endif
+ 
++#ifdef _MSC_VER
++# define __inline__ __inline
++#endif
++
+ /* Initialise the public variables. */
+ 
+ int optind = 1;				/* index for first non-option arg     */
+@@ -463,7 +467,7 @@
+     /*
+      * we use `this_arg' to store these temporarily.
+      */
+-    CHAR *this_arg[optspan];
++    CHAR **this_arg = (CHAR**) malloc (sizeof(CHAR*) * optspan);
+     /*
+      * we cannot manipulate `argv' directly, since the `getopt'
+      * API prototypes it as `read-only'; this cast to `arglist'
+@@ -493,6 +497,8 @@
+     /* adjust `optbase', to account for the relocated option.
+      */
+     optbase += optspan;
++
++    free(this_arg);
+   }
+ 
+   else
+@@ -578,9 +584,12 @@
+ 	 * specified for the `getopt_long' APIs.
+ 	 */
+ 	va_list refptr;
++	struct option *longopts;
++	int *optindex;
++	
+ 	va_start( refptr, optstring );
+-	struct option *longopts = va_arg( refptr, struct option * );
+-	int *optindex = va_arg( refptr, int * );
++	longopts = va_arg( refptr, struct option * );
++	optindex = va_arg( refptr, int * );
+ 	va_end( refptr );
+ 
+ 	/* ensuring that `optarg' does not inherit any junk, from parsing