OSDN Git Service

libgo: Update to weekly.2011-11-01.
[pf3gnuchains/gcc-fork.git] / libgo / go / net / textproto / reader.go
index ece9a99..98b3927 100644 (file)
@@ -50,8 +50,22 @@ func (r *Reader) ReadLineBytes() ([]byte, os.Error) {
 
 func (r *Reader) readLineSlice() ([]byte, os.Error) {
        r.closeDot()
-       line, _, err := r.R.ReadLine()
-       return line, err
+       var line []byte
+       for {
+               l, more, err := r.R.ReadLine()
+               if err != nil {
+                       return nil, err
+               }
+               // Avoid the copy if the first call produced a full line.
+               if line == nil && !more {
+                       return l, nil
+               }
+               line = append(line, l...)
+               if !more {
+                       break
+               }
+       }
+       return line, nil
 }
 
 // ReadContinuedLine reads a possibly continued line from r,