summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9af0cd9)
raw | patch | inline | side by side (parent: 9af0cd9)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 11 May 2009 21:25:57 +0000 (21:25 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 11 May 2009 21:25:57 +0000 (21:25 +0000) |
prominently is kills a segfault when using rrdtool perl bindings on
solaris ... thanks to Ihsan Dogan for helping with tracking this down and providing
access to sparc solaris boxes.
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3@1799 a5681a0c-68f1-0310-ab6d-d61299d08faa
solaris ... thanks to Ihsan Dogan for helping with tracking this down and providing
access to sparc solaris boxes.
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3@1799 a5681a0c-68f1-0310-ab6d-d61299d08faa
program/configure.ac | patch | blob | history | |
program/src/rrd_getopt.c | patch | blob | history |
diff --git a/program/configure.ac b/program/configure.ac
index 496841f07eef3aa1aaa0fcb29474e675490f1492..5a54d33d91298ffe1d68949b258143f294741d1c 100644 (file)
--- a/program/configure.ac
+++ b/program/configure.ac
dnl Do we need getopt_long
+dnl even when including our own getopt implementation
+dnl we may want to make sure we use the external
+dnl defined by libc to not run into linker resolve trouble
+
+AC_CACHE_CHECK([for opterr], rd_cv_var_int_opterr,
+[AC_TRY_LINK([#include <unistd.h>],
+ [extern int opterr; opterr = 1;],
+ [rd_cv_var_int_opterr=yes],
+ [rd_cv_var_int_opterr=no])])
+if test x"$rd_cv_var_int_opterr" = x"yes"; then
+ AC_DEFINE(HAVE_INT_OPTERR, 1, [Define to 1 if you have the global variable 'int opterr'.])
+fi
+
build_getopt=no
RRD_GETOPT_LONG="LIBC_HAS_GETOPT_LONG"
AC_CHECK_FUNC(getopt_long,[],[
index 57266302db8ac849b9826836e9b3bfdbc2dac511..d206af0bf62e84242099dedaf2c14c925525606a 100644 (file)
--- a/program/src/rrd_getopt.c
+++ b/program/src/rrd_getopt.c
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
+/*
+ * On some versions of Solaris, opterr and friends are defined in core libc
+ * rather than in a separate getopt module. Define these variables only
+ * if configure found they aren't there by default. (We assume that testing
+ * opterr is sufficient for all of these except optreset.)
+ */
+#ifndef HAVE_INT_OPTERR
+
char *optarg = NULL;
/* Index in ARGV of the next element to be scanned.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
+/* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+ This must be initialized on some systems to avoid linking in the
+ system's own getopt implementation. */
+
+int optopt = '?';
+
/* 1003.2 says this must be 1 before any call. */
int optind = 1;
+#else
+ extern int opterr;
+ extern int optind;
+ extern int optopt;
+ extern char *optarg;
+#endif
+
+
/* Formerly, initialization of getopt depended on optind==0, which
causes problems with re-calling getopt as programs generally don't
know that. */
static char *nextchar;
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-int optopt = '?';
/* Describe how to deal with options that follow non-option ARGV-elements.