[vlc-commits] commit: Lua: use config_StringEscape. ( Rémi Duraffort )

git at videolan.org git at videolan.org
Mon Apr 5 22:46:54 CEST 2010


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Mon Apr  5 22:46:36 2010 +0200| [d139be2b6d3f3ca2537ce4f110146a55fccf87bf] | committer: Rémi Duraffort 

Lua: use config_StringEscape.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d139be2b6d3f3ca2537ce4f110146a55fccf87bf
---

 modules/misc/lua/vlc.c |   35 ++---------------------------------
 1 files changed, 2 insertions(+), 33 deletions(-)

diff --git a/modules/misc/lua/vlc.c b/modules/misc/lua/vlc.c
index e3e2415..b5ee416 100644
--- a/modules/misc/lua/vlc.c
+++ b/modules/misc/lua/vlc.c
@@ -582,37 +582,6 @@ int __vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
     return i_count;
 }
 
-static char *escape( const char *psz )
-{
-    if( !psz )
-        return NULL;
-
-    /* Count the number of ' and \ in the string */
-    const char *it = psz;
-    int i_esc = 0;
-    while( *it != '\0')
-    {
-        if( *it == '\'' || *it == '\\' )
-            i_esc++;
-        it++;
-    }
-
-    if( i_esc == 0 )
-        return strdup( psz );
-
-    char *psz_esc = malloc( strlen( psz ) + i_esc + 1 );
-    char *it2 = psz_esc;
-    it = psz;
-    while( *it != '\0' )
-    {
-        if( *it == '\'' || *it == '\\' )
-            *it2++ = '\\';
-        *it2++ = *it++;
-    }
-    *it2 = '\0';
-
-    return psz_esc;
-}
 static int vlc_sd_probe_Open( vlc_object_t *obj )
 {
     vlc_probe_t *probe = (vlc_probe_t *)obj;
@@ -697,8 +666,8 @@ static int vlc_sd_probe_Open( vlc_object_t *obj )
                 }
             }
 
-            char *psz_file_esc = escape( *ppsz_file );
-            char *psz_longname_esc = escape( psz_longname );
+            char *psz_file_esc = config_StringEscape( *ppsz_file );
+            char *psz_longname_esc = config_StringEscape( psz_longname );
             if( asprintf( &psz_name, "lua{sd='%s',longname='%s'}",
                           psz_file_esc, psz_longname_esc ) < 0 )
             {



More information about the vlc-commits mailing list