lua-users home
lua-l archive

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


On Jan 18, 2008 10:04 AM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
> > Looks logical (for me) that source files are normalized before being
> > processed. I suppose you can add a \r if needed on some lines only, or
> > replace all \n by \r\n otherwise, which can be done at initialization time.
>
> I think the point of the original poster is that you cannot add escape
> sequences to long strings. On the other hand, life is much easier when
> end-of-lines are normalized in text files.

I understand the convenience of normalizing end-of-lines for
file:read("*l") and for Lua source code, and just to make it clear I
was not talking about escape sequences, but the actual characters. In
my particular situation, I needed the contents of the long strings to
be preserved as-is, like file contents are preserved as-is with
file:read("*a"). (The particular application was to embed patch files
as long strings in LuaRocks spec files, which are Lua files; the
end-of-line characters need to be preserved or the patch will not
apply).

Since the manual says that long strings "may contain anything except a
closing bracket of the proper level" and observing that even embedded
NUL characters are preserved, I expected embedded CRs to be as well,
which they are, except if they're followed by a LF. So, should I
interpret this that long strings may indeed contain anything other
than its closing bracket, but that CR-LF sequences, while allowed, are
lost? If so, perhaps this limitation should be stated in the manual?

-- Hisham