lua-users home
lua-l archive

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


As a Windows user where files flutter between having carriage returns
and not, depending on which editor was last used, I am quite happy
with this behaviour. As such, I'd prefer to see the manual changed
rather than the behaviour changed.

On Fri, Nov 2, 2012 at 2:46 PM, Jim Studt <jim@studt.net> wrote:
> In Lua 5.1.5, and from looking at the source, it appears 5.2, a literal string in long format will drop a carriage return when followed by a linefeed.
>
> The manual suggests they should not do this...
>
>   "Literals in this bracketed form can run for several lines, do not interpret any escape sequences,
>    and ignore long brackets of any other level. They can contain anything except a closing bracket
>    of the proper level."
>
> You can see it happen in this test program, which unfortunately you have to make yourself because it has to contain literal carriage return characters.  The "^M" sequences represent carriage return characters, in emacs you can insert them with C-q C-m.
>
>
> print( #[=[A^MB]=])
>
> print( #[=[A^M
> B]=])
>
> When run, you will see that both strings have a length of 3, where the second one should actually be 4. The carriage return gets dropped and only the newline passes to the string.