Mercurial > mxe-octave
comparison 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 |
comparison
equal
deleted
inserted
replaced
3060:cbdf4575016d | 3061:f8299bb6c872 |
---|---|
1 --- getopt.c 2010-01-14 21:38:46 +0000 | |
2 +++ getopt-new.c 2010-01-14 21:37:14 +0000 | |
3 @@ -47,6 +47,10 @@ | |
4 # define PROGNAME *argv | |
5 #endif | |
6 | |
7 +#ifdef _MSC_VER | |
8 +# define __inline__ __inline | |
9 +#endif | |
10 + | |
11 /* Initialise the public variables. */ | |
12 | |
13 int optind = 1; /* index for first non-option arg */ | |
14 @@ -463,7 +467,7 @@ | |
15 /* | |
16 * we use `this_arg' to store these temporarily. | |
17 */ | |
18 - CHAR *this_arg[optspan]; | |
19 + CHAR **this_arg = (CHAR**) malloc (sizeof(CHAR*) * optspan); | |
20 /* | |
21 * we cannot manipulate `argv' directly, since the `getopt' | |
22 * API prototypes it as `read-only'; this cast to `arglist' | |
23 @@ -493,6 +497,8 @@ | |
24 /* adjust `optbase', to account for the relocated option. | |
25 */ | |
26 optbase += optspan; | |
27 + | |
28 + free(this_arg); | |
29 } | |
30 | |
31 else | |
32 @@ -578,9 +584,12 @@ | |
33 * specified for the `getopt_long' APIs. | |
34 */ | |
35 va_list refptr; | |
36 + struct option *longopts; | |
37 + int *optindex; | |
38 + | |
39 va_start( refptr, optstring ); | |
40 - struct option *longopts = va_arg( refptr, struct option * ); | |
41 - int *optindex = va_arg( refptr, int * ); | |
42 + longopts = va_arg( refptr, struct option * ); | |
43 + optindex = va_arg( refptr, int * ); | |
44 va_end( refptr ); | |
45 | |
46 /* ensuring that `optarg' does not inherit any junk, from parsing |