]> git.sesse.net Git - vlc/commitdiff
Move remaining replacement to static import library
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 10 Apr 2009 19:17:13 +0000 (22:17 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 10 Apr 2009 19:17:13 +0000 (22:17 +0300)
12 files changed:
compat/gmtime_r.c [new file with mode: 0644]
compat/localtime_r.c [new file with mode: 0644]
compat/rewind.c [new file with mode: 0644]
compat/strcasecmp.c [new file with mode: 0644]
compat/strcasestr.c [new file with mode: 0644]
compat/strncasecmp.c [new file with mode: 0644]
configure.ac
include/vlc_common.h
include/vlc_fixups.h
modules/demux/mkv/matroska_segment_parse.cpp
src/extras/libc.c
src/libvlccore.sym

diff --git a/compat/gmtime_r.c b/compat/gmtime_r.c
new file mode 100644 (file)
index 0000000..94d3123
--- /dev/null
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * gmtime_r.c: POSIX gmtime_r() 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 <time.h>
+
+struct tm *gmtime_r (const time_t *timep, struct tm *result)
+{
+    struct tm *s = gmtime (timep);
+    if (s == NULL)
+        return NULL;
+
+    *result = *s;
+    return result;
+}
diff --git a/compat/localtime_r.c b/compat/localtime_r.c
new file mode 100644 (file)
index 0000000..f3e2811
--- /dev/null
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * localtime_r.c: POSIX localtime_r() 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 <time.h>
+
+/* If localtime_r() is not provided, we assume localtime() uses
+ * thread-specific storage. */
+struct tm *localtime_r (const time_t *timep, struct tm *result)
+{
+    struct tm *s = localtime (timep);
+    if (s == NULL)
+        return NULL;
+
+    *result = *s;
+    return result;
+}
diff --git a/compat/rewind.c b/compat/rewind.c
new file mode 100644 (file)
index 0000000..c27323a
--- /dev/null
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * rewind.c: C rewind 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>
+
+void rewind (FILE *stream)
+{
+    fseek (stream, 0L, SEEK_SET);
+    clearerr (stream);
+}
diff --git a/compat/strcasecmp.c b/compat/strcasecmp.c
new file mode 100644 (file)
index 0000000..7ef670c
--- /dev/null
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * strcasecmp.c: POSIX strcasecmp() 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 <ctype.h>
+#include <assert.h>
+
+int strcasecmp (const char *s1, const char *s2)
+{
+#ifdef HAVE_STRICMP
+    return stricmp (s1, s2);
+#else
+    for (size_t i = 0;; i++)
+    {
+        int d = tolower (s1[i]) - tolower (s2[i]);
+        if (d || !s1[i])
+            return d;
+        assert (s2[i]);
+    }
+#endif
+}
diff --git a/compat/strcasestr.c b/compat/strcasestr.c
new file mode 100644 (file)
index 0000000..45b8830
--- /dev/null
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * strcasestr.c: GNU strcasestr() replacement
+ *****************************************************************************
+ * Copyright © 2002-2006 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 <ctype.h>
+#include <assert.h>
+
+int strcasecmp (const char *psz_big, const char *psz_little)
+{
+    char *p_pos = (char *)psz_big;
+
+    if( !*psz_little ) return p_pos;
+
+    while( *p_pos )
+    {
+        if( toupper( *p_pos ) == toupper( *psz_little ) )
+        {
+            char * psz_cur1 = p_pos + 1;
+            char * psz_cur2 = (char *)psz_little + 1;
+            while( *psz_cur1 && *psz_cur2 &&
+                   toupper( *psz_cur1 ) == toupper( *psz_cur2 ) )
+            {
+                psz_cur1++;
+                psz_cur2++;
+            }
+            if( !*psz_cur2 ) return p_pos;
+        }
+        p_pos++;
+    }
+    return NULL;
+}
diff --git a/compat/strncasecmp.c b/compat/strncasecmp.c
new file mode 100644 (file)
index 0000000..b834b48
--- /dev/null
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * strncasecmp.c: POSIX strncasecmp() 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 <ctype.h>
+#include <assert.h>
+
+int strncasecmp (const char *s1, const char *s2)
+{
+#ifdef HAVE_STRNICMP
+    return strnicmp (s1, s2);
+#else
+    for (size_t i = 0; i < n; i++)
+    {
+        int d = tolower (s1[i]) - tolower (s2[i]);
+        if (d || !s1[i])
+            return d;
+        assert (s2[i]);
+    }
+    return 0;
+#endif
+}
index 85fe3ebce20150232560e5fc48c7db72675698ef..d0fe51fc81a3e86385140e49d8d4f4e5faadf245 100644 (file)
@@ -551,13 +551,11 @@ dnl Check for system libs needed
 need_libc=false
 
 dnl Check for usual libc functions
-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 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_CHECK_FUNCS([gettimeofday isatty swab sigrelse getpwuid_r memalign posix_memalign if_nametoindex getenv putenv setenv ctime_r lrintf daemon fork lstat posix_fadvise posix_madvise uselocale])
 AC_FUNC_ALLOCA
 AC_CHECK_FUNCS(fcntl)
-AC_REPLACE_FUNCS([asprintf atof atoll lldiv strdup strlcpy strndup strnlen strsep strtof strtoll vasprintf])
+AC_REPLACE_FUNCS([asprintf atof atoll gmtime_r lldiv localtime_r rewind strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtoll vasprintf])
+AC_CHECK_FUNCS([stricmp strnicmp])
 
 dnl Check for Linux system calls
 AC_CHECK_FUNCS([vmsplice])
index 2c7ef61967909e434ca351fd61b15ac61f447690..2ca14508c001caf60fb04252e033cdb9609e3d5d 100644 (file)
@@ -731,7 +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( char *, vlc_strcasestr, ( const char *s1, const char *s2 ) LIBVLC_USED );
 
 #if defined(WIN32) || defined(UNDER_CE)
 /* win32, cl and icl support */
index 25d5f10d349c91f8c32b16aacdcab65ad9d26288..b433834bbfefa6d5dc3936ae6574c463c5b85de3 100644 (file)
@@ -105,69 +105,30 @@ static inline char *getenv (const char *name)
 #endif
 
 #ifndef HAVE_STRCASECMP
-# ifndef HAVE_STRICMP
-#  include <ctype.h>
-static inline int strcasecmp (const char *s1, const char *s2)
-{
-    for (size_t i = 0;; i++)
-    {
-        int d = tolower (s1[i]) - tolower (s2[i]);
-        if (d || !s1[i]) return d;
-    }
-    return 0;
-}
-# else
-#  define strcasecmp stricmp
-# endif
+int strcasecmp (const char *, const char *);
 #endif
 
 #ifndef HAVE_STRNCASECMP
-# ifndef HAVE_STRNICMP
-#  include <ctype.h>
-static inline int strncasecmp (const char *s1, const char *s2, size_t n)
-{
-    for (size_t i = 0; i < n; i++)
-    {
-        int d = tolower (s1[i]) - tolower (s2[i]);
-        if (d || !s1[i]) return d;
-    }
-    return 0;
-}
-# else
-#  define strncasecmp strnicmp
-# endif
+int strncasecmp (const char *, const char *, size_t);
 #endif
 
 #ifndef HAVE_STRCASESTR
-# ifndef HAVE_STRISTR
-#  define strcasestr vlc_strcasestr
-# else
-#  define strcasestr stristr
-# endif
+char *strcasestr (const char *, const char *
 #endif
 
-#ifndef HAVE_LOCALTIME_R
-/* If localtime_r() is not provided, we assume localtime() uses
- * thread-specific storage. */
+#ifndef HAVE_GMTIME_R
 # include <time.h>
-static inline struct tm *localtime_r (const time_t *timep, struct tm *result)
-{
-    struct tm *s = localtime (timep);
-    if (s == NULL)
-        return NULL;
+struct tm *gmtime_r (const time_t *, struct tm *);
+#endif
 
-    *result = *s;
-    return result;
-}
-static inline struct tm *gmtime_r (const time_t *timep, struct tm *result)
-{
-    struct tm *s = gmtime (timep);
-    if (s == NULL)
-        return NULL;
+#ifndef HAVE_LOCALTIME_R
+# include <time.h>
+struct tm *localtime_r (const time_t *, struct tm *);
+#endif
 
-    *result = *s;
-    return result;
-}
+#ifndef HAVE_REWIND
+# include <stdio.h>
+void rewind (FILE *);
 #endif
 
 /* Alignment of critical static data structures */
@@ -201,12 +162,4 @@ typedef void *locale_t;
 #define N_(str) gettext_noop (str)
 #define gettext_noop(str) (str)
 
-#ifdef UNDER_CE
-static inline void rewind ( FILE *stream )
-{
-    fseek(stream, 0L, SEEK_SET);
-    clearerr(stream);
-}
-#endif
-
 #endif /* !LIBVLC_FIXUPS_H */
index fb1b23376ab0f2d603c8686ebeb68e3da177713a..db889db1db95df8e1baabc1805aed82521ff3c73 100644 (file)
@@ -767,7 +767,6 @@ void matroska_segment_c::ParseInfo( KaxInfo *info )
 
             msg_Dbg( &sys.demuxer, "|   |   + family=%d", *(uint32*)uid->GetBuffer() );
         }
-#if defined( HAVE_GMTIME_R )
         else if( MKV_IS_ID( l, KaxDateUTC ) )
         {
             KaxDateUTC &date = *(KaxDateUTC*)l;
@@ -785,7 +784,6 @@ void matroska_segment_c::ParseInfo( KaxInfo *info )
                 msg_Dbg( &sys.demuxer, "|   |   + Date=%s", psz_date_utc );
             }
         }
-#endif
         else if( MKV_IS_ID( l, KaxChapterTranslate ) )
         {
             KaxChapterTranslate *p_trans = static_cast<KaxChapterTranslate*>( l );
index 6dc1dd137e9576097bbe41616d39f64000686e39..3bb0b5654b27f8ede3258ba74b04e5c48ba167ef 100644 (file)
 #   include <windows.h>
 #endif
 
-/******************************************************************************
- * strcasestr: find a substring (little) in another substring (big)
- * Case sensitive. Return NULL if not found, return big if little == null
- *****************************************************************************/
-char * vlc_strcasestr( const char *psz_big, const char *psz_little )
-{
-#if defined (HAVE_STRCASESTR) || defined (HAVE_STRISTR)
-    return strcasestr (psz_big, psz_little);
-#else
-    char *p_pos = (char *)psz_big;
-
-    if( !psz_big || !psz_little || !*psz_little ) return p_pos;
-    while( *p_pos )
-    {
-        if( toupper( *p_pos ) == toupper( *psz_little ) )
-        {
-            char * psz_cur1 = p_pos + 1;
-            char * psz_cur2 = (char *)psz_little + 1;
-            while( *psz_cur1 && *psz_cur2 &&
-                   toupper( *psz_cur1 ) == toupper( *psz_cur2 ) )
-            {
-                psz_cur1++;
-                psz_cur2++;
-            }
-            if( !*psz_cur2 ) return p_pos;
-        }
-        p_pos++;
-    }
-    return NULL;
-#endif
-}
-
 /*****************************************************************************
  * vlc_*dir_wrapper: wrapper under Windows to return the list of drive letters
  * when called with an empty argument or just '\'
index 6773ac349acfff3202b43a1834bc416ff48d7f9e..b14b8d48f9c30a8f2afc1de3d945583021012de7 100644 (file)
@@ -485,7 +485,6 @@ vlc_sdp_Start
 vlc_sd_Start
 vlc_sd_Stop
 vlc_sendmsg
-vlc_strcasestr
 vlc_testcancel
 vlc_thread_create
 __vlc_thread_join