]> git.sesse.net Git - vlc/blobdiff - src/input/stream.c
Fix quoted values containing # in VLM shell.
[vlc] / src / input / stream.c
index 7714114eaaf554ec67115521342d95ec040b7ebf..aaf7f94169673cea50f9584475718935214fa1e7 100644 (file)
@@ -31,7 +31,6 @@
 #include <vlc_common.h>
 #include <vlc_strings.h>
 #include <vlc_osd.h>
-#include <vlc_charset.h>
 #include <vlc_memory.h>
 
 #include <libvlc.h>
@@ -243,10 +242,11 @@ void stream_CommonDelete( stream_t *s )
     vlc_object_release( s );
 }
 
+#undef stream_UrlNew
 /****************************************************************************
  * stream_UrlNew: create a stream from a access
  ****************************************************************************/
-stream_t *__stream_UrlNew( vlc_object_t *p_parent, const char *psz_url )
+stream_t *stream_UrlNew( vlc_object_t *p_parent, const char *psz_url )
 {
     const char *psz_access, *psz_demux;
     char *psz_path;
@@ -461,7 +461,6 @@ error:
         free( p_sys->list[--(p_sys->i_list)] );
     free( p_sys->list );
     free( s->p_sys );
-    vlc_object_detach( s );
     stream_CommonDelete( s );
     return NULL;
 }
@@ -473,8 +472,6 @@ static void AStreamDestroy( stream_t *s )
 {
     stream_sys_t *p_sys = s->p_sys;
 
-    vlc_object_detach( s );
-
     if( p_sys->method == STREAM_METHOD_BLOCK )
         block_ChainRelease( p_sys->block.p_first );
     else
@@ -688,7 +685,7 @@ static void AStreamPrebufferBlock( stream_t *s )
                          (p_sys->stat.i_read_time + 1);
 
             msg_Dbg( s, "prebuffering done %"PRId64" bytes in %"PRId64"s - "
-                     "%"PRId64" kbytes/s",
+                     "%"PRId64" KiB/s",
                      p_sys->stat.i_bytes,
                      p_sys->stat.i_read_time / INT64_C(1000000),
                      i_byterate / 1024 );
@@ -1443,7 +1440,7 @@ static void AStreamPrebufferStream( stream_t *s )
                          (p_sys->stat.i_read_time+1);
 
             msg_Dbg( s, "pre-buffering done %"PRId64" bytes in %"PRId64"s - "
-                     "%"PRId64" kbytes/s",
+                     "%"PRId64" KiB/s",
                      p_sys->stat.i_bytes,
                      p_sys->stat.i_read_time / INT64_C(1000000),
                      i_byterate / 1024 );
@@ -1570,35 +1567,38 @@ char *stream_ReadLine( stream_t *s )
         {
             /* UTF-8: 0A <LF> */
             psz_eol = memchr( p_data, '\n', i_data );
+            if( psz_eol == NULL )
+                /* UTF-8: 0D <CR> */
+                psz_eol = memchr( p_data, '\r', i_data );
         }
         else
         {
-            const uint8_t *p = p_data;
-            const uint8_t *p_last = p + i_data - s->p_text->i_char_width;
+            const uint8_t *p_last = p_data + i_data - s->p_text->i_char_width;
+            uint16_t eol = s->p_text->b_little_endian ? 0x0A00 : 0x00A0;
 
-            if( s->p_text->i_char_width == 2 )
+            assert( s->p_text->i_char_width == 2 );
+            psz_eol = NULL;
+            /* UTF-16: 000A <LF> */
+            for( const uint8_t *p = p_data; p <= p_last; p += 2 )
             {
-                if( s->p_text->b_little_endian == true)
-                {
-                    /* UTF-16LE: 0A 00 <LF> */
-                    while( p <= p_last && ( p[0] != 0x0A || p[1] != 0x00 ) )
-                        p += 2;
-                }
-                else
+                if( U16_AT( p ) == eol )
                 {
-                    /* UTF-16BE: 00 0A <LF> */
-                    while( p <= p_last && ( p[1] != 0x0A || p[0] != 0x00 ) )
-                        p += 2;
+                     psz_eol = (char *)p + 1;
+                     break;
                 }
             }
 
-            if( p > p_last )
-            {
-                psz_eol = NULL;
-            }
-            else
-            {
-                psz_eol = (char *)p + ( s->p_text->i_char_width - 1 );
+            if( psz_eol == NULL )
+            {   /* UTF-16: 000D <CR> */
+                eol = s->p_text->b_little_endian ? 0x0D00 : 0x00D0;
+                for( const uint8_t *p = p_data; p <= p_last; p += 2 )
+                {
+                    if( U16_AT( p ) == eol )
+                    {
+                        psz_eol = (char *)p + 1;
+                        break;
+                    }
+                }
             }
         }