lua-users home
lua-l archive

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

I believe the Debug library and API both have facilities for reporting code fragments in the case of errors, but I'll address the problem at hand. When you load up the strings of a file, typically the strings don't carry the newlines. These would need to be placed in. In the case of C code, that probably looks like this,

char * lineptr = 0, * linetosave;
size_t len = 0;
getline( &lineptr, &len, infile );
linetosave = (char *) malloc(len+2);
strcpy(linetosave, lineptr)
strcat(linetosave, "\n");

Within Lua, this is much easier (and a good reason why we like to use it).
linetosave = file:read("*l");
linetosave = linetosave .. "\n";