]> git.sesse.net Git - vlc/commitdiff
Start moving replacement functions to a static import library
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 10 Apr 2009 17:14:10 +0000 (20:14 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 10 Apr 2009 17:14:10 +0000 (20:14 +0300)
21 files changed:
Makefile.am
compat/Makefile.am [new file with mode: 0644]
compat/asprintf.c [new file with mode: 0644]
compat/atof.c [new file with mode: 0644]
compat/atoll.c [new file with mode: 0644]
compat/lldiv.c [new file with mode: 0644]
compat/strdup.c [new file with mode: 0644]
compat/strlcpy.c [new file with mode: 0644]
compat/strndup.c [new file with mode: 0644]
compat/strnlen.c [new file with mode: 0644]
compat/strsep.c [new file with mode: 0644]
compat/strtof.c [new file with mode: 0644]
compat/strtoll.c [new file with mode: 0644]
compat/vasprintf.c [new file with mode: 0644]
configure.ac
include/vlc_common.h
include/vlc_fixups.h
modules/common.am
src/Makefile.am
src/extras/libc.c
src/libvlccore.sym

index 26df232f388d6d8d1fa09ea9a09cc4bee41759ef..4224ba7a2ada87592c26685ccca7a959eeff288f 100644 (file)
@@ -7,13 +7,13 @@
 # which have makefiles with distribution information.
 #  - src (libvlc) is nedeed by modules, mozilla and bindings
 #  - libs/* are needed by modules
-BASE_SUBDIRS = po src bin modules share doc test
+BASE_SUBDIRS = po compat src bin modules share doc test
 EXTRA_SUBDIRS = m4 extras/package/ipkg \
        libs/loader libs/srtp libs/unzip \
        projects/mozilla projects/activex
 DIST_SUBDIRS = $(BASE_SUBDIRS) $(EXTRA_SUBDIRS)
 
-SUBDIRS = po src
+SUBDIRS = po compat src
 if LOADER
 SUBDIRS += libs/loader
 endif
diff --git a/compat/Makefile.am b/compat/Makefile.am
new file mode 100644 (file)
index 0000000..225ce39
--- /dev/null
@@ -0,0 +1,4 @@
+noinst_LTLIBRARIES = libcompat.la
+libcompat_la_SOURCES =
+libcompat_la_LIBADD = $(LTLIBOBJS)
+libcompat_la_LDFLAGS = -no-undefined
diff --git a/compat/asprintf.c b/compat/asprintf.c
new file mode 100644 (file)
index 0000000..e3b319d
--- /dev/null
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * asprintf.c: asprintf() replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+
+int asprintf (char **strp, const char *fmt, ...)
+{
+    va_list ap;
+    int ret;
+
+    va_start (ap, fmt);
+    ret = vasprintf (strp, fmt, ap);
+    va_end (ap);
+    return ret;
+}
diff --git a/compat/atof.c b/compat/atof.c
new file mode 100644 (file)
index 0000000..c658dc6
--- /dev/null
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * atof.c: atof replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+
+double atof (const char *str)
+{
+    return strtod (str, NULL);
+}
diff --git a/compat/atoll.c b/compat/atoll.c
new file mode 100644 (file)
index 0000000..6c6a347
--- /dev/null
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * atoll.c: atoll replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+
+long long atoll (const char *str)
+{
+    return strtoll (str, NULL, 10);
+}
diff --git a/compat/lldiv.c b/compat/lldiv.c
new file mode 100644 (file)
index 0000000..25f4abc
--- /dev/null
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * lldiv.c: lldiv replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+lldiv_t lldiv (long long num, long long denom)
+{
+    lldiv_t d = { num / denom, num % demon, };
+    return d;
+}
diff --git a/compat/strdup.c b/compat/strdup.c
new file mode 100644 (file)
index 0000000..7e3765c
--- /dev/null
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * strdup.c: strdup replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+
+char *strdup (const char *str)
+{
+    size_t len = strlen (str) + 1;
+    char *res = malloc (len);
+    if (res)
+        memcpy (res, str, len);
+    return res;
+}
diff --git a/compat/strlcpy.c b/compat/strlcpy.c
new file mode 100644 (file)
index 0000000..bc815ea
--- /dev/null
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * strlcpy.c: BSD strlcpy replacement
+ *****************************************************************************
+ * Copyright © 2006 Rémi Denis-Courmont
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stddef.h>
+
+/**
+ * Copy a string to a sized buffer. The result is always nul-terminated
+ * (contrary to strncpy()).
+ *
+ * @param dest destination buffer
+ * @param src string to be copied
+ * @param len maximum number of characters to be copied plus one for the
+ * terminating nul.
+ *
+ * @return strlen(src)
+ */
+size_t strlcpy (char *tgt, const char *src, size_t bufsize)
+{
+    size_t length;
+
+    for (length = 1; (length < bufsize) && *src; length++)
+        *tgt++ = *src++;
+
+    if (bufsize)
+        *tgt = '\0';
+
+    while (*src++)
+        length++;
+
+    return length - 1;
+}
diff --git a/compat/strndup.c b/compat/strndup.c
new file mode 100644 (file)
index 0000000..863b075
--- /dev/null
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * strndup.c: strndup replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+
+char *strndup (const char *str, size_t max)
+{
+    size_t len = strnlen (str, max);
+    char *res = malloc (len + 1);
+    if (res)
+    {
+        memcpy (res, str, len);
+        res[len] = '\0';
+    }
+    return res;
+}
diff --git a/compat/strnlen.c b/compat/strnlen.c
new file mode 100644 (file)
index 0000000..96be3d2
--- /dev/null
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * strnlen.c: strnlen replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+
+size_t strnlen (const char *str, size_t max)
+{
+    const char *end = memchr (str, 0, max);
+    return end ? (size_t)(end - str) : max;
+}
diff --git a/compat/strsep.c b/compat/strsep.c
new file mode 100644 (file)
index 0000000..1163f46
--- /dev/null
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * strsep.c: BSD strsep replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+
+char *strsep( char **ppsz_string, const char *psz_delimiters )
+{
+    char *psz_string = *ppsz_string;
+    if( !psz_string )
+        return NULL;
+
+    char *p = strpbrk( psz_string, psz_delimiters );
+    if( !p )
+    {
+        *ppsz_string = NULL;
+        return psz_string;
+    }
+    *p++ = '\0';
+
+    *ppsz_string = p;
+    return psz_string;
+}
diff --git a/compat/strtof.c b/compat/strtof.c
new file mode 100644 (file)
index 0000000..807db0e
--- /dev/null
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * strtof.c: strtof replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+
+float strtof (const char *str, char **end)
+{
+    return strtod (str, end);
+}
diff --git a/compat/strtoll.c b/compat/strtoll.c
new file mode 100644 (file)
index 0000000..1f0a71d
--- /dev/null
@@ -0,0 +1,92 @@
+/*****************************************************************************
+ * strtoll.c: strtoll replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+long long int strtof( const char *nptr, char **endptr, int base )
+{
+    long long i_value = 0;
+    int sign = 1, newbase = base ? base : 10;
+
+    nptr += strspn( nptr, "\t " );
+    if( *nptr == '-' )
+    {
+        sign = -1;
+        nptr++;
+    }
+
+    /* Try to detect base */
+    if( *nptr == '0' )
+    {
+        newbase = 8;
+        nptr++;
+
+        if( *nptr == 'x' )
+        {
+            newbase = 16;
+            nptr++;
+        }
+    }
+
+    if( base && newbase != base )
+    {
+        if( endptr ) *endptr = (char *)nptr;
+        return i_value;
+    }
+
+    switch( newbase )
+    {
+        case 10:
+            while( *nptr >= '0' && *nptr <= '9' )
+            {
+                i_value *= 10;
+                i_value += ( *nptr++ - '0' );
+            }
+            if( endptr ) *endptr = (char *)nptr;
+            break;
+
+        case 16:
+            while( (*nptr >= '0' && *nptr <= '9') ||
+                   (*nptr >= 'a' && *nptr <= 'f') ||
+                   (*nptr >= 'A' && *nptr <= 'F') )
+            {
+                int i_valc = 0;
+                if(*nptr >= '0' && *nptr <= '9') i_valc = *nptr - '0';
+                else if(*nptr >= 'a' && *nptr <= 'f') i_valc = *nptr - 'a' +10;
+                else if(*nptr >= 'A' && *nptr <= 'F') i_valc = *nptr - 'A' +10;
+                i_value *= 16;
+                i_value += i_valc;
+                nptr++;
+            }
+            if( endptr ) *endptr = (char *)nptr;
+            break;
+
+        default:
+            i_value = strtol( nptr, endptr, newbase );
+            break;
+    }
+
+    return i_value * sign;
+}
diff --git a/compat/vasprintf.c b/compat/vasprintf.c
new file mode 100644 (file)
index 0000000..98d7e72
--- /dev/null
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * vasprintf.c: vasprintf replacement
+ *****************************************************************************
+ * Copyright © 1998-2008 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+int vasprintf (char **strp, const char *fmt, va_list ap)
+{
+    ssize_t len = vsnprintf (NULL, 0, fmt, ap) + 1;
+    char *res = malloc (len);
+    if (res == NULL)
+        return -1;
+    *strp = res;
+    return vsnprintf (res, len, fmt, ap);
+}
index 8795978746a87a4cbe422474e1389c50d675ef2e..3dc383eadbe7b4f22744fc88e6f0eb7cd1ae7c61 100644 (file)
@@ -18,6 +18,7 @@ AC_PREREQ(2.59c)
 AC_CONFIG_SRCDIR(src/libvlc.c)
 AC_CONFIG_AUX_DIR(autotools)
 AC_CONFIG_MACRO_DIR(m4)
+AC_CONFIG_LIBOBJ_DIR(compat)
 AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
 
@@ -550,12 +551,13 @@ dnl Check for system libs needed
 need_libc=false
 
 dnl Check for usual libc functions
-AC_CHECK_FUNCS([gettimeofday strtod strtol strtof strtoll strtoull strsep isatty vasprintf asprintf swab sigrelse getpwuid_r memalign posix_memalign if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon fork bsearch lstat strlcpy strdup strndup strnlen atof lldiv posix_fadvise posix_madvise uselocale])
+AC_CHECK_FUNCS([gettimeofday isatty swab sigrelse getpwuid_r memalign posix_memalign if_nametoindex getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon fork bsearch lstat posix_fadvise posix_madvise uselocale])
 AC_CHECK_FUNCS(strcasecmp,,[AC_CHECK_FUNCS(stricmp)])
 AC_CHECK_FUNCS(strncasecmp,,[AC_CHECK_FUNCS(strnicmp)])
 AC_CHECK_FUNCS(strcasestr,,[AC_CHECK_FUNCS(stristr)])
 AC_FUNC_ALLOCA
 AC_CHECK_FUNCS(fcntl)
+AC_REPLACE_FUNCS([asprintf atof atoll lldiv strdup strlcpy strndup strnlen strsep strtof strtoll vasprintf])
 
 dnl Check for Linux system calls
 AC_CHECK_FUNCS([vmsplice])
@@ -5964,6 +5966,7 @@ AC_CONFIG_FILES([
   share/Makefile
   share/vlc_win32_rc.rc
   share/libvlc_win32_rc.rc
+  compat/Makefile
   src/Makefile
   src/test/Makefile
   bin/Makefile
index 77881158cfc4f34f64154d7a9f840960e0513ad6..2c7ef61967909e434ca351fd61b15ac61f447690 100644 (file)
@@ -731,9 +731,6 @@ static inline uint64_t ntoh64 (uint64_t ll)
 #define VLC_UNUSED(x) (void)(x)
 
 /* Stuff defined in src/extras/libc.c */
-VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) );
-VLC_EXPORT( long long, vlc_strtoll, ( const char *nptr, char **endptr, int base ) LIBVLC_USED );
-
 VLC_EXPORT( char *, vlc_strcasestr, ( const char *s1, const char *s2 ) LIBVLC_USED );
 
 #if defined(WIN32) || defined(UNDER_CE)
index d9872d7b6c84e1a7dbdf913672965bac2d2b07c1..25d5f10d349c91f8c32b16aacdcab65ad9d26288 100644 (file)
 #endif
 
 #ifndef HAVE_STRDUP
-# include <string.h>
-# include <stdlib.h>
-static inline char *strdup (const char *str)
-{
-    size_t len = strlen (str) + 1;
-    char *res = (char *)malloc (len);
-    if (res) memcpy (res, str, len);
-    return res;
-}
+char *strdup (const char *);
 #endif
 
 #ifndef HAVE_VASPRINTF
-# include <stdio.h>
-# include <stdlib.h>
 # include <stdarg.h>
-static inline int vasprintf (char **strp, const char *fmt, va_list ap)
-{
-    int len = vsnprintf (NULL, 0, fmt, ap) + 1;
-    char *res = (char *)malloc (len);
-    if (res == NULL)
-        return -1;
-    *strp = res;
-    return vsnprintf (res, len, fmt, ap);
-}
+int vasprintf (char **, const char *, va_list);
 #endif
 
 #ifndef HAVE_ASPRINTF
-# include <stdio.h>
-# include <stdarg.h>
-static inline int asprintf (char **strp, const char *fmt, ...)
-{
-    va_list ap;
-    int ret;
-    va_start (ap, fmt);
-    ret = vasprintf (strp, fmt, ap);
-    va_end (ap);
-    return ret;
-}
+int asprintf (char **, const char *, ...);
 #endif
 
 #ifndef HAVE_STRNLEN
-# include <string.h>
-static inline size_t strnlen (const char *str, size_t max)
-{
-    const char *end = (const char *) memchr (str, 0, max);
-    return end ? (size_t)(end - str) : max;
-}
+# include <stddef.h>
+size_t strnlen (const char *, size_t);
 #endif
 
 #ifndef HAVE_STRNDUP
-# include <string.h>
-# include <stdlib.h>
-static inline char *strndup (const char *str, size_t max)
-{
-    size_t len = strnlen (str, max);
-    char *res = (char *) malloc (len + 1);
-    if (res)
-    {
-        memcpy (res, str, len);
-        res[len] = '\0';
-    }
-    return res;
-}
+# include <stddef.h>
+char *strndup (const char *, size_t);
 #endif
 
 #ifndef HAVE_STRLCPY
-# define strlcpy vlc_strlcpy
+# include <stddef.h>
+size_t strlcpy (char *, const char *, size_t);
 #endif
 
 #ifndef HAVE_STRTOF
-# define strtof( a, b ) ((float)strtod (a, b))
+float strtof (const char *, char **);
 #endif
 
 #ifndef HAVE_ATOF
-# define atof( str ) (strtod ((str), (char **)NULL, 10))
+double atof (const char *);
 #endif
 
 #ifndef HAVE_STRTOLL
-# define strtoll vlc_strtoll
+long long int strtoll (const char *, char **, int);
 #endif
 
 #ifndef HAVE_STRSEP
-static inline char *strsep( char **ppsz_string, const char *psz_delimiters )
-{
-    char *psz_string = *ppsz_string;
-    if( !psz_string )
-        return NULL;
-
-    char *p = strpbrk( psz_string, psz_delimiters );
-    if( !p )
-    {
-        *ppsz_string = NULL;
-        return psz_string;
-    }
-    *p++ = '\0';
-
-    *ppsz_string = p;
-    return psz_string;
-}
+char *strsep (char **, const char *);
 #endif
 
 #ifndef HAVE_ATOLL
-# define atoll( str ) (strtoll ((str), (char **)NULL, 10))
+long long atoll (const char *);
 #endif
 
 #ifndef HAVE_LLDIV
@@ -151,11 +93,7 @@ typedef struct {
     long long rem;  /* Remainder. */
 } lldiv_t;
 
-static inline lldiv_t lldiv (long long numer, long long denom)
-{
-    lldiv_t d = { .quot = numer / denom, .rem = numer % denom };
-    return d;
-}
+lldiv_t lldiv (long long, long long);
 #endif
 
 #ifndef HAVE_GETENV
index caa56590622b3a28647d73703a9bcf8cac7c8e20..7fbf430c520f08ebbbcec625ba6b83fdd85ca783 100644 (file)
@@ -23,7 +23,8 @@ AM_LDFLAGS = -rpath '$(libvlcdir)' \
        -shrext $(LIBEXT) \
        -no-undefined \
         `$(VLC_CONFIG) --ldflags plugin $@`
-AM_LIBADD = `$(VLC_CONFIG) -libs plugin $@` $(LTLIBVLCCORE)
+AM_LIBADD = `$(VLC_CONFIG) -libs plugin $@` \
+       $(LTLIBVLCCORE) $(top_builddir)/compat/libcompat.la
 
 include $(srcdir)/Modules.am
 
index eabdb6c90945e2388c2a8ffc8ff4fa11b24f8358..84f79d094f831c7d058480b310fb104378e2b634 100644 (file)
@@ -157,9 +157,11 @@ libvlccore_la_CFLAGS = `$(VLC_CONFIG) --cflags libvlc` \
        -DLIBDIR=\"$(libdir)\" \
        -DPLUGIN_PATH=\"$(vlclibdir)\"
 libvlccore_la_LDFLAGS = `$(VLC_CONFIG) --ldflags libvlc` $(AM_LDFLAGS) \
+       -no-undefined \
        -export-symbols $(srcdir)/libvlccore.sym \
        -version-info 2:0:0
-libvlccore_la_LIBADD = `$(VLC_CONFIG) -libs libvlc` $(AM_LIBADD) $(LTLIBINTL)
+libvlccore_la_LIBADD = `$(VLC_CONFIG) -libs libvlc` $(AM_LIBADD) \
+       $(LTLIBINTL) ../compat/libcompat.la
 libvlccore_la_DEPENDENCIES = libvlccore.sym
 if HAVE_WIN32
 libvlccore_la_DEPENDENCIES += libvlc_win32_rc.$(OBJEXT)
index acd0924027a8d833a52e12e8af9e330cbaaa9370..6dc1dd137e9576097bbe41616d39f64000686e39 100644 (file)
@@ -101,111 +101,6 @@ char * vlc_strcasestr( const char *psz_big, const char *psz_little )
 #endif
 }
 
-/*****************************************************************************
- * strtoll: convert a string to a 64 bits int.
- *****************************************************************************/
-long long vlc_strtoll( const char *nptr, char **endptr, int base )
-{
-#if defined( HAVE_STRTOLL )
-    return strtoll( nptr, endptr, base );
-#else
-    long long i_value = 0;
-    int sign = 1, newbase = base ? base : 10;
-
-    while( isspace(*nptr) ) nptr++;
-
-    if( *nptr == '-' )
-    {
-        sign = -1;
-        nptr++;
-    }
-
-    /* Try to detect base */
-    if( *nptr == '0' )
-    {
-        newbase = 8;
-        nptr++;
-
-        if( *nptr == 'x' )
-        {
-            newbase = 16;
-            nptr++;
-        }
-    }
-
-    if( base && newbase != base )
-    {
-        if( endptr ) *endptr = (char *)nptr;
-        return i_value;
-    }
-
-    switch( newbase )
-    {
-        case 10:
-            while( *nptr >= '0' && *nptr <= '9' )
-            {
-                i_value *= 10;
-                i_value += ( *nptr++ - '0' );
-            }
-            if( endptr ) *endptr = (char *)nptr;
-            break;
-
-        case 16:
-            while( (*nptr >= '0' && *nptr <= '9') ||
-                   (*nptr >= 'a' && *nptr <= 'f') ||
-                   (*nptr >= 'A' && *nptr <= 'F') )
-            {
-                int i_valc = 0;
-                if(*nptr >= '0' && *nptr <= '9') i_valc = *nptr - '0';
-                else if(*nptr >= 'a' && *nptr <= 'f') i_valc = *nptr - 'a' +10;
-                else if(*nptr >= 'A' && *nptr <= 'F') i_valc = *nptr - 'A' +10;
-                i_value *= 16;
-                i_value += i_valc;
-                nptr++;
-            }
-            if( endptr ) *endptr = (char *)nptr;
-            break;
-
-        default:
-            i_value = strtol( nptr, endptr, newbase );
-            break;
-    }
-
-    return i_value * sign;
-#endif
-}
-
-/**
- * Copy a string to a sized buffer. The result is always nul-terminated
- * (contrary to strncpy()).
- *
- * @param dest destination buffer
- * @param src string to be copied
- * @param len maximum number of characters to be copied plus one for the
- * terminating nul.
- *
- * @return strlen(src)
- */
-extern size_t vlc_strlcpy (char *tgt, const char *src, size_t bufsize)
-{
-#ifdef HAVE_STRLCPY
-    return strlcpy (tgt, src, bufsize);
-#else
-    size_t length;
-
-    for (length = 1; (length < bufsize) && *src; length++)
-        *tgt++ = *src++;
-
-    if (bufsize)
-        *tgt = '\0';
-
-    while (*src++)
-        length++;
-
-    return length - 1;
-#endif
-}
-
 /*****************************************************************************
  * vlc_*dir_wrapper: wrapper under Windows to return the list of drive letters
  * when called with an empty argument or just '\'
index 1ef453b27d0fa1efd0ce99aaef5dfafcdea944f3..6773ac349acfff3202b43a1834bc416ff48d7f9e 100644 (file)
@@ -486,8 +486,6 @@ vlc_sd_Start
 vlc_sd_Stop
 vlc_sendmsg
 vlc_strcasestr
-vlc_strlcpy
-vlc_strtoll
 vlc_testcancel
 vlc_thread_create
 __vlc_thread_join