]> git.sesse.net Git - vlc/commitdiff
stream_ReadLine: bytes per char is either 1 or 2
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 17 Feb 2010 20:25:06 +0000 (22:25 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 17 Feb 2010 20:25:06 +0000 (22:25 +0200)
src/input/stream.c

index b36590bba577092e0bd55ac35e4137c2a22c2ce1..d068986298bedfa4e2118a605cba4e6692358d9f 100644 (file)
@@ -1573,20 +1573,18 @@ char *stream_ReadLine( stream_t *s )
             const uint8_t *p = p_data;
             const uint8_t *p_last = p + i_data - s->p_text->i_char_width;
 
-            if( s->p_text->i_char_width == 2 )
+            assert( s->p_text->i_char_width == 2 );
+            if( s->p_text->b_little_endian == true)
             {
-                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
-                {
-                    /* UTF-16BE: 00 0A <LF> */
-                    while( p <= p_last && ( p[1] != 0x0A || p[0] != 0x00 ) )
-                        p += 2;
-                }
+                /* UTF-16LE: 0A 00 <LF> */
+                while( p <= p_last && ( p[0] != 0x0A || p[1] != 0x00 ) )
+                    p += 2;
+            }
+            else
+            {
+                /* UTF-16BE: 00 0A <LF> */
+                while( p <= p_last && ( p[1] != 0x0A || p[0] != 0x00 ) )
+                    p += 2;
             }
 
             if( p > p_last )
@@ -1595,7 +1593,7 @@ char *stream_ReadLine( stream_t *s )
             }
             else
             {
-                psz_eol = (char *)p + ( s->p_text->i_char_width - 1 );
+                psz_eol = (char *)p + 1;
             }
         }