Skip to Content.
Sympa Menu

freetds - [freetds] [PATCH] make replacements more configurable

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Craig A. Berry" <craigberry AT mac.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] [PATCH] make replacements more configurable
  • Date: Sun, 26 Jan 2003 18:24:49 -0600

In porting FreeTDS to VMS (which is nearly finished) I hit a small snag
using the strtok_r function supplied in src/replacements/strtok_r.c. The
latest version of the C run-time has its own strtok_r, but the second
latest doesn't. If I build FreeTDS with the older version, then upgrade
the C run-time, then link against the TDS libraries, I'll get a multiply
defined symbol error because the home-made strtok_r collides with the
system-supplied one. Similar problems are latent for the other
replacement functions.

The easiest around this was to prefix all the function names with
"freetds_" and then locate them when and where needed via the HAVE_xxx
macros. Patch below. Does anyone have any objections or see any
potential problems with this?

This was taken against the nightly snapshot from about a week ago; let
me know if anything's changed that would make it need to be reformulated.


--- include/replacements.h;-0 Thu Nov 21 10:53:43 2002
+++ include/replacements.h Thu Jan 23 19:07:59 2003
@@ -35,18 +35,22 @@
#include "tds_sysdep_public.h"

#if !HAVE_ASPRINTF
+#define asprintf freetds_asprintf
int asprintf(char **ret, const char *fmt, ...);
#endif /* !HAVE_ASPRINTF */

#if !HAVE_VASPRINTF
+#define vasprintf freetds_vasprintf
int vasprintf(char **ret, const char *fmt, va_list ap);
#endif /* !HAVE_VASPRINTF */

#if !HAVE_ATOLL
+#define atoll freetds_atoll
tds_sysdep_int64_type atoll(const char *nptr);
#endif /* !HAVE_ATOLL */

#if !HAVE_STRTOK_R
+#define strtok_r freetds_strtok_r
char *strtok_r(char *str, const char *sep, char **lasts);
#endif /* !HAVE_STRTOK_R */

--- src/replacements/asprintf.c;-0 Sun Nov 17 05:28:12 2002
+++ src/replacements/asprintf.c Thu Jan 23 19:01:44 2003
@@ -16,7 +16,7 @@


int
-asprintf(char **ret, const char *fmt, ...)
+freetds_asprintf(char **ret, const char *fmt, ...)
{
int len;
va_list ap;
--- src/replacements/atoll.c;-0 Sun Nov 17 05:28:12 2002
+++ src/replacements/atoll.c Thu Jan 23 19:01:59 2003
@@ -30,7 +30,7 @@
static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };

tds_sysdep_int64_type
-atoll(const char *nptr)
+freetds_atoll(const char *nptr)
{
return atol(nptr);
}
--- src/replacements/strtok_r.c;-0 Sun Nov 17 05:28:12 2002
+++ src/replacements/strtok_r.c Thu Jan 23 19:02:16 2003
@@ -20,7 +20,7 @@
#include "replacements.h"

char *
-strtok_r(char *str, const char *sep, char **lasts)
+freetds_strtok_r(char *str, const char *sep, char **lasts)
{
char *p;

--- src/replacements/vasprintf.c;-0 Mon Dec 9 10:40:59 2002
+++ src/replacements/vasprintf.c Thu Jan 23 19:02:41 2003
@@ -40,7 +40,7 @@

#define CHUNKSIZE 512
int
-vasprintf(char **ret, const char *fmt, va_list ap)
+freetds_vasprintf(char **ret, const char *fmt, va_list ap)
{
#if HAVE_VSNPRINTF
int chunks;



Archive powered by MHonArc 2.6.24.

Top of Page