]> git.sesse.net Git - vlc/commitdiff
config: on OS X, don't use required_argument for getopt_long, but optional_argument.
authorDerk-Jan Hartman <hartman@videolan.org>
Tue, 12 Aug 2008 11:06:39 +0000 (13:06 +0200)
committerDerk-Jan Hartman <hartman@videolan.org>
Tue, 12 Aug 2008 11:06:39 +0000 (13:06 +0200)
required_argument is not implemented (behaves like optional_argument), and actually crashes in some instances.
This fixes a crash as detailed in #1681.
The problem is filed with Apple as Radar ticket 6113829

src/config/cmdline.c

index 4899129088da9d81ebc40fc33b1c3af1e1ae9c0e..4ea2e6a149f2ac3437f2529704db700d39764e15 100644 (file)
@@ -165,8 +165,14 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
             p_longopts[i_index].name = strdup( p_item->psz_name );
             if( p_longopts[i_index].name == NULL ) continue;
             p_longopts[i_index].has_arg =
-                (p_item->i_type == CONFIG_ITEM_BOOL)?
-                                               no_argument : required_argument;
+                (p_item->i_type == CONFIG_ITEM_BOOL) ? no_argument : 
+#ifndef __APPLE__
+                                                       required_argument;
+#else
+/* It seems that required_argument is broken on Darwin.
+ * Radar ticket #6113829 */
+                                                       optional_argument;
+#endif
             p_longopts[i_index].flag = &flag;
             p_longopts[i_index].val = 0;
             i_index++;