lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I was curious how Python would handle this evil and non portable mess:

    $ cat io.py
    from string import printable

    f = open('foo', 'w')
    for i in range(0, 5):
        f.write("hello\0world\n")

    f = open('foo', 'r')
    for l in f.readlines():
        print ''.join(c if c in printable else '.' for c in l),

    $ python io.py
    hello.world
    hello.world
    hello.world
    hello.world
    hello.world

On Feb 17, 2014, at 10:51 AM, René Rebe <rene@exactcode.de> wrote:

Hi all,

I just noticed that io:lines() does not cope with \0 in the lines, and thus just returns truncated lines (lua-5.2.3, but legacy 5.1 likewise).

May I suggest replacing the call to fgets in src/liolib.c so that we can read lines with \0 data?

René

-- 
 ExactCODE GmbH, Jaegerstr. 67, DE-10117 Berlin
 http://exactcode.com | http://exactscan.com | http://ocrkit.com | http://t2-project.org | http://rene.rebe.de