diff options
author | sopwith <sopwith> | 1999-04-07 18:57:23 +0000 |
---|---|---|
committer | sopwith <sopwith> | 1999-04-07 18:57:23 +0000 |
commit | a29ab6b3d587c5afac791e4148497ca77601268b (patch) | |
tree | 9c380b6682ad0ed62f332a34414c564b709b5db4 /poptparse.c | |
parent | dc4f62fe874e7734def1ca71034d1fbab19990a8 (diff) | |
download | libpopt-a29ab6b3d587c5afac791e4148497ca77601268b.tar.gz |
Merge (most) changes from the GNOME version of popt. The remaining changesPOST_GNOME_MERGE
are GNOME-specific.
Diffstat (limited to 'poptparse.c')
-rw-r--r-- | poptparse.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/poptparse.c b/poptparse.c index 181ec1a..ebad66a 100644 --- a/poptparse.c +++ b/poptparse.c @@ -10,19 +10,32 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_ALLOCA_H -#include <alloca.h> +/* AIX requires this to be the first thing in the file. */ +#ifndef __GNUC__ +# if HAVE_ALLOCA_H +# include <alloca.h> +# else +# ifdef _AIX +#pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +#elif defined(__GNUC__) && defined(__STRICT_ANSI__) +#define alloca __builtin_alloca #endif #include "popt.h" -static const int poptArgvArrayGrowDelta = 5; +#define POPT_ARGV_ARRAY_GROW_DELTA 5 int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) { char * buf, * bufStart, * dst; const char * src; char quote = '\0'; - int argvAlloced = poptArgvArrayGrowDelta; + int argvAlloced = POPT_ARGV_ARRAY_GROW_DELTA; char ** argv = malloc(sizeof(*argv) * argvAlloced); char ** argv2; int argc = 0; @@ -52,7 +65,7 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) { if (*argv[argc]) { buf++, argc++; if (argc == argvAlloced) { - argvAlloced += poptArgvArrayGrowDelta; + argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA; argv = realloc(argv, sizeof(*argv) * argvAlloced); } argv[argc] = buf; |