Kevin I made a fast compare on code disassembly, and I found no differences between the two. So the issue isn't in the code generation (attache the 2 disassembly).
Then I changed the fopen to binary mode, and it seems to work well:
FILE *fp = fopen("test.txt", "rb");
Could you try to change the function Final_Transforms () as follow:
void Final_Transforms (void)
{
char Source[BCXSTRSIZE];
char Dll_Orig[BCXSTRSIZE];
strcpy(Dll_Orig,vchr(30,67,95,69,88,80,79,82,84,32,105,110,116,32,95,95,115,116,100,99,97,108,108,32,68,108,108,77,97,105,110));
char Dll_Repl[BCXSTRSIZE];
....
// If compiling for PellesC open file in binary mode.
#ifdef __POCC__
if((FP1=fopen(FileOut, "rb"))==0)
#else
if((FP1=fopen(FileOut, "r"))==0)
#endif
{
fprintf(stderr, "Error: Cannot Access File or File Not Found. %s\n", FileOut); exit(1);
}
if((FP2=fopen("$Bcx$Temp$File$", "w"))==0)
{
fprintf(stderr, "Error: Cannot Access File or File Not Found. %s\n", "$Bcx$Temp$File$"); exit(1);
}
while(!EoF(FP1)){
Source[0]=0;
fgets(Source, 2048, FP1);
if(feof(FP1) || (Source[strlen(Source)-1]==10))
{
Source[strcspn(Source,"\r\n")] = 0;
}
else
{
printf("%s%d while reading file: %s\n","Error! - LINE INPUT truncation detected at PROGRAM line: ",__LINE__-7, NamePathFromFP(FP1));
printf("%s\n","The actual truncated line of text:");
printf("%s",Source);
exit(1);
}
if(strcmp(ltrim(Source),"")==0 && strcmp(ltrim(LookAhead(FP1)),"")==0){
continue;
}
if(strcmp(ltrim(Source),"")==0 && strcmp(ltrim(LookAhead(FP1)),"#endif")==0){
continue;
}
strcpy(Source,replace(Source,chr(15),":"));
strcpy(Source,replace(Source,QQF,QQR));
strcpy(Source,replace(Source,Dll_Orig,Dll_Repl));
...
}
You can also try changing _ftell64() to ftell() as suggested by John (you already use ftell() when compiling for LCC-Win32).
You can check on the sample I posted before, you can change the file opening to binary and check results.
At this point the issue is in the PellesC I/O library. Probably the cr/lf translation sometime fails, maybe when the cr and the lf are on a sector boundary (adding something in the file shift them and remove the problem).