#17216: cgilib port enhancement ----------------------------+----------------------------------------------- Reporter: mike@flyn.org | Owner: macports-tickets@lists.macosforge.org Type: enhancement | Status: new Priority: Normal | Milestone: Port Enhancements Component: ports | Version: 1.6.0 Resolution: | Keywords: Port: | ----------------------------+----------------------------------------------- Comment(by mike@flyn.org): cgilib-strndup.patch {{{ diff -u --recursive ../cgilib-0.6-vanilla/cgi.c ./cgi.c --- ../cgilib-0.6-vanilla/cgi.c 2008-11-12 18:42:35.000000000 -0500 +++ ./cgi.c 2008-11-12 19:03:45.000000000 -0500 @@ -841,6 +841,18 @@ } } +#ifndef HAVE_STRNDUP +char *strndup(const char *s, size_t n) { + char *fnval; + + if ((fnval = (char *)malloc (n + 1)) == NULL) + return NULL; + strncpy(fnval, s, n); + fnval[n] = '\0'; + return fnval; +} +#endif + /* * Local variables: * c-indent-level: 4 diff -u --recursive ../cgilib-0.6-vanilla/cgi.h ./cgi.h --- ../cgilib-0.6-vanilla/cgi.h 2008-11-12 18:42:35.000000000 -0500 +++ ./cgi.h 2008-11-12 18:58:03.000000000 -0500 @@ -142,6 +142,10 @@ */ char *cgiEscape (char *string); +#ifndef HAVE_STRNDUP +char *strndup(const char *s, size_t n); +#endif + #ifdef __cplusplus extern } #endif diff -u --recursive ../cgilib-0.6-vanilla/configure.ac ./configure.ac --- ../cgilib-0.6-vanilla/configure.ac 2008-11-12 19:04:09.000000000 -0500 +++ ./configure.ac 2008-11-12 18:57:10.000000000 -0500 @@ -6,4 +6,6 @@ AC_PROG_INSTALL AC_PROG_LIBTOOL +AC_CHECK_FUNCS(strndup) + AC_OUTPUT(Makefile) }}} -- Ticket URL: <http://trac.macports.org/ticket/17216#comment:4> MacPorts <http://www.macports.org/> Ports system for Mac OS