[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: dostring(...) on the Mac
- From: kleiser@... (Jon Kleiser)
- Date: Tue, 20 Jan 1998 00:36:23 +0100
I'd like to describe some Lua problems I've had (and finally solved) on the
Macintosh. To some of you it might be just trivial, but to me it was a
pain.
On the Macintosh I've been building small Lua (3.0) test projects (both 68K
and PPC) based on two different frameworks/libraries, MacZoop and Tools
Plus, using CodeWarrior 10. When I started to use lua_linehook and $debug,
the ones based on MacZoop (C++) did well, but the others, based on Tools
Plus (C), failed quite consistently. Most of all it seemed to be the $debug
pragma, not the presence of my lua_linehook, that was causing the problems.
Fortunately I have a friend who's a real MacsBug specialist, so when I'd
had enough errors, I brought my projects over to his place. He was
observing registers and hex codes for a while, but then he got suspicious
by a fact that I hadn't payed too much attention to: My nice projects only
made use of lua_dofile's, while my problem projects only made use of
lua_dostring's. After a few more minutes it was clear: When you use
lua_dofile's, the Carriage Returns in the Mac files get translated into
Linefeeds; when you use lua_dostring's, they don't. For some reason Lua
thinks Returns are quite OK as long as they don't enclose pragmas like
$debug. We wrote a quick CR-to-LF translator to be used prior to the
lua_dostring calls, and that was it.
A few experiments in the interactive (terminal) Lua, show it quite clearly
(if the backslashes survive the mailing):
dostring("print(1)\nprint(2)")
1
2
dostring("print(1)\rprint(2)")
1
2
dostring("print(1)\n$debug\nprint(2)")
1
2
dostring("print(1)\r$debug\rprint(2)")
prin syntax error;$d
Active Stack:
function dostring [in file (C)]
main of (dostring) >> dostring("print(1)\r at line 1
It think a few words on this LF/CR/separator subject would be fine in the
Lua documentation ;)
I'm looking forward to exploring 3.1 (alpha), both on the Mac and the BeBox.
Sincerely,
Jon Kleiser