On Tue, Oct 20, 2009 at 17:58:58 -0400, Peter Harris wrote: > Jeremy Huddleston wrote: > > And if strnlen isn't available? ... > > I must have misread the docs. I thought autoconf was supposed to > generate strnlen when it isn't available. > > Could somebody with better knowledge of auto* than I have please take a > look at this? > afaict configure just adds strnlen.o to LIBOBJS if the system doesn't provide strnlen. So how about something like this (untested):
From: Julien Cristau <[email protected]> Date: Wed, 21 Oct 2009 00:27:20 +0200 Subject: [PATCH] Fix for systems without strnlen Provide a replacement and use it if the system doesn't have strnlen --- Makefile.am | 2 +- strnlen.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletions(-) create mode 100644 strnlen.c diff --git a/Makefile.am b/Makefile.am index 59887e2..94f3111 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,7 @@ bin_PROGRAMS = xlsclients AM_CFLAGS = $(CWARNFLAGS) $(XLSCLIENTS_CFLAGS) -xlsclients_LDADD = $(XLSCLIENTS_LIBS) +xlsclients_LDADD = $(XLSCLIENTS_LIBS) $(LIBOBJS) xlsclients_SOURCES = \ xlsclients.c diff --git a/strnlen.c b/strnlen.c new file mode 100644 index 0000000..6503be3 --- /dev/null +++ b/strnlen.c @@ -0,0 +1,10 @@ +#include "config.h" + +size_t +strnlen(const char *s, size_t maxlen) +{ + char *end = memchr(s, '\0', maxlen); + if (!end) + return maxlen; + return end - s; +} -- 1.6.5 _______________________________________________ xorg-devel mailing list [email protected] http://lists.x.org/mailman/listinfo/xorg-devel
