[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bug: Literal strings in long format are not quite literal.
- From: Peter Cawley <lua@...>
- Date: Fri, 2 Nov 2012 14:49:38 +0000
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.