lib: improve synopsis and doc of many libs
[nit.git] / lib / binary / binary.nit
index 263ad95..b6909cd 100644 (file)
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# Add reading and writing binary services
+# Read and write binary data with any `Reader` and `Writer`
 #
 # ~~~
 # var w = new FileWriter.open("/tmp/data.bin")
@@ -178,11 +178,13 @@ redef abstract class Reader
        # Returns a truncated string when an error is pending (`last_error != null`).
        fun read_string: String
        do
-               var buf = new FlatBuffer
+               var buf = new Bytes.empty
                loop
                        var byte = read_byte
-                       if byte == null or byte == 0x00u8 then return buf.to_s
-                       buf.bytes.add byte
+                       if byte == null or byte == 0u8 then
+                               return buf.to_s
+                       end
+                       buf.add byte
                end
        end