[Johannes.Hofmann@gmx.de: [Johannes.Hofmann@gmx.de: Re: [Dillo-dev] Dillo FLTK2 alpha release for developers]]
Hi, I compiled dillo-fltk2 on NetBSD-3.1, implementing strndup was the only change needed. However, strndup needs to null-terminate its return value, and strncpy does not do this if the source string is longer than the destination, so: * Johannes Hofmann:
* I added a own version of strndup() as it does not exist for DragonFly:
char* strndup(const char *s, size_t size) { char *r = (char*) calloc(size + 1, 1);
if (r) { strncpy(r, s, size);
r[size] = '\0'; /* null-terminate return value */
}
return r; }
Also, strndup is found in <string.h> only if _GNU_SOURCE was #define'd. This should probably be done in configure, with something like HAVE_STRNDUP, but I have no experience with autoconf. Regards, Alexander -- PGP key available
Hi Alexander, On Wed, Oct 03, 2007 at 02:11:56PM +0200, Alexander Becher wrote:
Hi,
I compiled dillo-fltk2 on NetBSD-3.1, implementing strndup was the only change needed. However, strndup needs to null-terminate its return value, and strncpy does not do this if the source string is longer than the destination, so:
As calloc() initializes the allocated buffer with 0, this is not needed, I think. Johannes
* Johannes Hofmann:
* I added a own version of strndup() as it does not exist for DragonFly:
char* strndup(const char *s, size_t size) { char *r = (char*) calloc(size + 1, 1);
if (r) { strncpy(r, s, size);
r[size] = '\0'; /* null-terminate return value */
}
return r; }
Also, strndup is found in <string.h> only if _GNU_SOURCE was #define'd. This should probably be done in configure, with something like HAVE_STRNDUP, but I have no experience with autoconf.
Regards, Alexander -- PGP key available
_______________________________________________ Dillo-dev mailing list Dillo-dev@dillo.org http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
* Johannes Hofmann:
On Wed, Oct 03, 2007 at 02:11:56PM +0200, Alexander Becher wrote:
I compiled dillo-fltk2 on NetBSD-3.1, implementing strndup was the only change needed. However, strndup needs to null-terminate its return value, and strncpy does not do this if the source string is longer than the destination, so:
As calloc() initializes the allocated buffer with 0, this is not needed, I think.
Hm, right. I had used malloc() in my replacement function, but with calloc() it is indeed unnecessary. I have wrapped this in autoconf, see attached patch. I also made autoconf in dillo and dw-testbed check for the path to the perl binary and substitute it in dpidc and Doxyfile, respectively, see other patch. Actually, these patches can't simply be applied: first, dillo-f15/dpid/dpidc and dw-testbed-0.0.43j/Doxyfile have to be moved to *.in. Regards, Alexander -- PGP key available citator@jabber.ccc.de
participants (3)
-
Alexander Becher
-
Johannes Hofmann
-
Jorge Arellano Cid