This is a patch to popt-1.7 that allows it to compile correctly under SCO's UNIXWare 8 system. Their compiler gets calls to the alloca() intrinsic when used from within another function call: char *dst = strcpy(alloca(strlen(src) + 1), src); The compiler pushes the pointer "origOptString" AND THEN performs the alloca(): this *mucks with the stack* during parameter setup, and strcpy() sees the wrong thing for the parameters, and other stack housekeeping is messed up badly. It makes the code go *BOOM*. The SCO compiler is clearly in the wrong, but alloca() has long been troublesome and this seems to be in the "asking for trouble" category. So the workaround is to call alloca() by itself: char *dst = alloca(strlen(src) + 1); strcpy(dst, src); I've filed a bug report with SCO: http://www.unixwiz.net/blogmisc/sco-alloca-bug.txt I found this while building rsync, and the nice folks on the rsync list suggested that I feed these changes back to you. Happy holidays, Steve Patch created: Wed Dec 25 12:15:56 PST 2002 Working dir..: /user/source/popt-1.7 Patch created with: ======================================================= { cat ../popt-patch-header echo "" echo "Patch created: " `date` echo "Working dir..: " `pwd` echo "" echo "Patch created with:" echo "=======================================================" cat ../make-popt-patch echo "=======================================================" echo "" LC_ALL=C TZ=UTC0 diff -Naur popt.c.orig popt.c LC_ALL=C TZ=UTC0 diff -Naur popthelp.c.orig popthelp.c LC_ALL=C TZ=UTC0 diff -Naur poptparse.c.orig poptparse.c } ======================================================= --- popt.c.orig 2002-12-25 18:44:44.626457001 +0000 +++ popt.c 2002-12-25 18:45:44.205577003 +0000 @@ -737,8 +737,8 @@ } /* Make a copy we can hack at */ - localOptString = optString = - strcpy(alloca(strlen(origOptString) + 1), origOptString); + localOptString = optString = alloca(strlen(origOptString) + 1); + strcpy(optString, origOptString); if (optString[0] == '\0') return POPT_ERROR_BADOPT; @@ -927,6 +927,7 @@ if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_DOUBLE) { *((double *) opt->arg) = aDouble; } else { +#undef _ABS #define _ABS(a) ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a)) if ((_ABS(aDouble) - FLT_MAX) > DBL_EPSILON) return POPT_ERROR_OVERFLOW; --- popthelp.c.orig 2002-12-25 18:58:17.675257001 +0000 +++ popthelp.c 2002-12-25 18:59:39.144217004 +0000 @@ -708,14 +708,17 @@ void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags) { - poptDone done = memset(alloca(sizeof(*done)), 0, sizeof(*done)); int cursor; + poptDone done = alloca(sizeof(*done)); + memset(done, 0, sizeof(*done)); done->nopts = 0; done->maxopts = 64; cursor = done->maxopts * sizeof(*done->opts); /*@-boundswrite@*/ - done->opts = memset(alloca(cursor), 0, cursor); + done->opts = alloca(cursor); + memset(done->opts, 0, cursor); + done->opts[done->nopts++] = (const void *) con->options; /*@=boundswrite@*/ --- poptparse.c.orig 2002-12-25 18:59:57.483977001 +0000 +++ poptparse.c 2002-12-25 19:00:22.263737000 +0000 @@ -62,8 +62,10 @@ const char ** argv = malloc(sizeof(*argv) * argvAlloced); int argc = 0; int buflen = strlen(s) + 1; - char * buf = memset(alloca(buflen), 0, buflen); int rc = POPT_ERROR_MALLOC; + char * buf = alloca(buflen); + + memset(buf, 0, buflen); if (argv == NULL) return rc; argv[argc] = buf;