lua-users home
lua-l archive

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


It was thus said that the Great djczaski once stated:
> > On Feb 21, 2014, at 5:59 PM, Sean Conner <sean@conman.org> wrote:
> >
> > It was thus said that the Great René Rebe once stated:
> >>
> >> Instead of doing it right, look for others who do it worse?
> >
> >  I think it's more an investigation of "how do other languages handle
> > this?" than trying to look for worse.
> >
> >  C, using fgets(), would print:
> >
> > hellohellohellohellohello
> 
> That's exactly what I was wondering. How do other languages handle
> this situation? I tried Python, Perl, Ruby, and TCL. They all seem to
> support his expectation and what I would have imagined would be
> returned:
> 
>     $ python io.py
>     12 helloworld
>     12 helloworld
>     12 helloworld
> 
>     $ ruby io.rb
>     12 helloworld
>     12 helloworld
>     12 helloworld
> 
>     $ tclsh io.tcl
>     11 helloworld
>     11 helloworld
>     11 helloworld
> 
>     $ perl io.pl
>     helloworld
>     helloworld
>     helloworld
> 
>     $ lua io.lua
>     15  hellohellohello

  If the leading number is the number of characters in the string, then it
looks like TCL is stripping out the NUL byte entirely, which, depending on
how you look at it, is on par with the Lua version (wrong input) or worse
(corrupted data).

  -spc