Weird behavior of luadoc and files saved with CPM...

Normally I execute “luadoc f.lua” in a terminal window while in that file’s directory, and all works well: index.html and files/f.html get generated and all looks good in the browser.

If I edit that file with CPM, save, and regenerate the html with luadoc, I end up with an html file without the actual doc.

When I edit and save in TextMate, all is normal.

It seems very reproducible and took me a while to accept the fact as it’s so weird.

Does CPM do anything “special” with a file when it saves it?

Confusingly yours, Frank.
[import]uid: 8093 topic_id: 7066 reply_id: 307066[/import]

I didn’t think it did anything special, but to be honest, I didn’t write the save code for the editor. It’s part of the editor control I’m using and I’ve never seen anything weird happen before. I’ve opened CPM-saved files in both BBEdit and TextMate.

Okay, I just looked at the Save code and it’s a total of 16 lines long. Nothing weird is happening – it opens the file, truncates it, writes the data, and then closes it.

The only thing that’s “weird” to me is that it also sets the encoding to UTF8 – and that’s only weird because if ASCII was good enough when I first started coding, it ought to be good enough now! However, the world changes and Unicode marches on.

Is it possible that luadoc doesn’t like UTF8 encoded files?

Jay
[import]uid: 9440 topic_id: 7066 reply_id: 24774[/import]

It may be the line endings that get changed.

So I have two files that look identical in both CPM and TextMate, but the one saved by CPM doesn’t get rendered by luadoc.

If I compare them in kdiff3 (a very nice tool btw), then the CPM-saved one shows as a single line, while the original textmate one shows the 60+ lines of code.

Still not clear what the exact difference is on the line endings, but I have now 2 tools that show differences… so maybe I’m not losing it (yet).

-FS.
[import]uid: 8093 topic_id: 7066 reply_id: 24854[/import]

I think that I found the reason for all this weirdness…

CPM does translate the line endings from LF to CR.

CR (carrige returns) were the “old” Mac OS9 way of using line endings, and MacOSX has move to the unix-linefeed (LF).

Most editors recognize the line endings used and don’t care, but some tools and filters adhere more strictly to the unix-LF conventions and choke on CRs.

I can convert CPM-saved files with

tr “\r” “\n” <filecr.lua>newFileLF.lua

and all works well again.

Now… it would be nice if CPM could use the newer unix-LF convention…

… not just for me, but I believe you will run into this issue in the future more when others will use unix-filters and other tools that barf on CRs.

-FrankS. [import]uid: 8093 topic_id: 7066 reply_id: 24972[/import] </filecr.lua>

Hmm…my dev environment defines EOL for console-based apps as LF, but for GUI apps has it defined as CR.

But, it could very well be wrong. :slight_smile:

I’ll look up what Apple says (must be somewhere in their Dev site) and if LF is what it should be, I’ll switch – as long as I can do that without breaking everything already in CPM. Because that would stink. :slight_smile:

Thanks for doing the detective work.

Jay
[import]uid: 9440 topic_id: 7066 reply_id: 24999[/import]

There is some self-interest on my part to try to make you switch :wink:

So:

TextMate by default uses LF and lists in the prefs LF as recommended and CR (MacOS Classic).

TextWrangler also has LF by default and will even translate it to LF by default.

Wkipidia’s newline entry lists (http://en.wikipedia.org/wiki/Newline):
LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.)
CR: Commodore 8-bit machines, TRS-80, Apple II family, Mac OS up to version 9 and OS-9

and I cannot find anything useful on apple’s dev site…

-FS.

[import]uid: 8093 topic_id: 7066 reply_id: 25019[/import]

Yeah, I tested both BBEdit and TextMate and they insisted LF should be the default. *sigh*

Okay, I’ll see if I can’t switch that in the next version. :slight_smile:

I already do a ReplaceLineEndings() on the Windows side when I load source files, so I’ll make that happen on the Mac side, too, and convert to LF.

I just uploaded 2.2.1 to fix a bug in 2.2.0 (gulp) and unless something “bad” happens I don’t intend to put out another version for a week or two – I want to try and do some actual Corona SDK coding for at least a few days. :slight_smile:

But look for the change soon.

Thanks for prodding me – I like to code things “right” because it usually matters later on if not now.

Jay
[import]uid: 9440 topic_id: 7066 reply_id: 25027[/import]

Thanks - I knew you would do the right thing :wink:

I put that tr filter in front of my luadoc generation which is a small hack such that I can keep using your tool in the mean time.

Make sure to use CPM for your Corona SDK coding as we will all benefit if you eat your own dog food!

-FS. [import]uid: 8093 topic_id: 7066 reply_id: 25029[/import]

Make sure to use CPM for your Corona SDK coding as we will all benefit if you eat your own dog food!

Are you kidding? I use CPM when I write an email to my Mom!

Okay, maybe I’m not that bad, But yes, I do use it for ALL my Corona coding. That’s where I come up with most of the new features. And if they happen to match what someone else has requested, so much the better! :wink:

Jay
[import]uid: 9440 topic_id: 7066 reply_id: 25037[/import]