Ok, I feel dumb.
I noticed that I tell it the script length when I was reviewing it. However, in my defense, I copied that code from the Angelscript documentation to calculate the script length, and that code doesn't work. So it's not Angelscript at fault, it's the Angelscript documentation. Either way, it resulted in a few hours of needless debugging to figure out that the problem was with the line endings in the first place.
char* script; FILE *f = fopen(szFile, "r"); // Determine the size of the file fseek(f, 0, SEEK_END); int len = ftell(f); fseek(f, 0, SEEK_SET); // Load the entire file in one call script = new char[len]; fread(&script[0], len, 1, f); fclose(f);
That adds 2 characters for each line ending, and the parser only reads back 1 character per line ending. Still would be simpler to have a setting in the parser, because I can't think of a better way to fix this than to read through the whole file and count the number of newlines. Or I guess I could just google something.
edit:
Ok simpler than I thought. Just had to change it to read binary instead of text, now both read 2 chars per line ending. This is the change:
FILE *f = fopen(szFile, "rb");
Well, I just wasted a whole day changing one character in my game. What will tomorrow bring? =P
[Edited by - polaris2013 on January 3, 2009 11:32:38 AM]