Browse code

improve ff_get_line to return line length

Originally committed as revision 24400 to svn://svn.ffmpeg.org/ffmpeg/trunk

Aurelien Jacobs authored on 2010/07/22 06:40:10
Showing 2 changed files
... ...
@@ -554,18 +554,19 @@ char *get_strz(ByteIOContext *s, char *buf, int maxlen)
554 554
     return buf;
555 555
 }
556 556
 
557
-void ff_get_line(ByteIOContext *s, char *buf, int maxlen)
557
+int ff_get_line(ByteIOContext *s, char *buf, int maxlen)
558 558
 {
559 559
     int i = 0;
560 560
     char c;
561 561
 
562 562
     do {
563 563
         c = get_byte(s);
564
-        if (i < maxlen-1)
564
+        if (c && i < maxlen-1)
565 565
             buf[i++] = c;
566 566
     } while (c != '\n' && c);
567 567
 
568 568
     buf[i] = 0;
569
+    return i;
569 570
 }
570 571
 
571 572
 uint64_t get_be64(ByteIOContext *s)
... ...
@@ -167,7 +167,7 @@ int ff_get_v_length(uint64_t val);
167 167
  */
168 168
 void ff_put_v(ByteIOContext *bc, uint64_t val);
169 169
 
170
-void ff_get_line(ByteIOContext *s, char *buf, int maxlen);
170
+int ff_get_line(ByteIOContext *s, char *buf, int maxlen);
171 171
 
172 172
 #define SPACE_CHARS " \t\r\n"
173 173