summaryrefslogtreecommitdiff
path: root/poptparse.c
diff options
context:
space:
mode:
Diffstat (limited to 'poptparse.c')
-rw-r--r--poptparse.c23
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;