]> git.sesse.net Git - vlc/blobdiff - src/extras/libc.c
Fix another series of HAVE_ dependencies (string replacement functions mostly).
[vlc] / src / extras / libc.c
index 03423804f9ad0bd87ec650bb15ccd3152e44be2e..826cc578549e7cc190c545a4b531e4e49ee2274f 100644 (file)
  * 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 <vlc/vlc.h>
 
-#include <string.h>                                              /* strdup() */
-#include <stdlib.h>
 #include <ctype.h>
 
 
 #   include <dirent.h>
 #endif
 
+#ifdef HAVE_SIGNAL_H
+#   include <signal.h>
+#endif
+
 #ifdef HAVE_FORK
 #   include <sys/time.h>
 #   include <unistd.h>
@@ -113,13 +119,13 @@ char *vlc_strndup( const char *string, size_t n )
 #endif
 
 /*****************************************************************************
- * strnlen: 
+ * strnlen:
  *****************************************************************************/
 #if !defined( HAVE_STRNLEN )
 size_t vlc_strnlen( const char *psz, size_t n )
 {
     const char *psz_end = memchr( psz, 0, n );
-    return psz_end ? ( psz_end - psz ) : n;
+    return psz_end ? (size_t)( psz_end - psz ) : n;
 }
 #endif
 
@@ -180,7 +186,7 @@ char * vlc_strcasestr( const char *psz_big, const char *psz_little )
 
     if( !psz_big || !psz_little || !*psz_little ) return p_pos;
  
-    while( *p_pos ) 
+    while( *p_pos )
     {
         if( toupper( *p_pos ) == toupper( *psz_little ) )
         {
@@ -369,8 +375,7 @@ int64_t vlc_atoll( const char *nptr )
 /*****************************************************************************
  * lldiv: returns quotient and remainder
  *****************************************************************************/
-#if defined(SYS_BEOS) \
- || (defined (__FreeBSD__) && (__FreeBSD__ < 5))
+#if !defined( HAVE_LLDIV )
 lldiv_t vlc_lldiv( long long numer, long long denom )
 {
     lldiv_t d;
@@ -949,12 +954,17 @@ int __vlc_execve( vlc_object_t *p_object, int i_argc, char *const *ppsz_argv,
     switch (pid)
     {
         case -1:
-            msg_Err (p_object, "unable to fork (%s)", strerror (errno));
+            msg_Err (p_object, "unable to fork (%m)");
             close (fds[0]);
             close (fds[1]);
             return -1;
 
         case 0:
+        {
+            sigset_t set;
+            sigemptyset (&set);
+            pthread_sigmask (SIG_SETMASK, &set, NULL);
+
             /* NOTE:
              * Like it or not, close can fail (and not only with EBADF)
              */
@@ -964,7 +974,8 @@ int __vlc_execve( vlc_object_t *p_object, int i_argc, char *const *ppsz_argv,
              && ((psz_cwd == NULL) || (chdir (psz_cwd) == 0)))
                 execve (ppsz_argv[0], ppsz_argv, ppsz_env);
 
-            exit (1);
+            exit (EXIT_FAILURE);
+        }
     }
 
     close (fds[1]);